using evolution = uint64;
Add a mechanism to give more descriptive names to primitive types.
Remove status as a built-in feature of the language. Introduce a zx
library to contain the primitive types from
Often developers want to assign more descriptive names to primitive
types. For example,
status is a more descriptive name for
status is built into the language and other types cannot be used
in the same way.
This proposal affects only the FIDL source language.
- Extend the
usingkeyword to be able to assign descriptive names to primitive types. Specifically, add the following production to the FIDL grammar:
using-list = ( using | using-declaration )* ; using-declaration = "using" , IDENTIFIER , "=" , primitive-type , ";" ;
statusprimitive type from the language. The
statusprimitive type can now be defined using the language itself instead of being a built-in feature.
statusreserved word. We no longer need to reserve the word
statusnow that we can define the name in the language. Add a
zxlibrary that contains declarations for the primitive types defined by the Zircon system interface. Ideally, this library would be generated from a future syscalls.abigen that contained this information. For example:
library zx; using status = int32; using time = uint64; using duration = uint64; [...]
Notice that these declarations must appear in the using-list and must refer directly to primitive types. This approach avoids complexity in the compiler because their use can be immediately translated into the underlying primitive type.
Further, notice that there are no proposed changes to the generated code in any target language. These types are represented in the target languages using the underlying primitive types.
Documentation and examples
1: AdvanceTime(zx.duration duration) -> (zx.status status);
This change is a non-backwards compatible change to the FIDL source
language because it removes the
status primitive type. However,
migrating existing clients of
status is trivial because they can
The proposed change has no impact on performance.
The proposed change has no impact on security.
The feature will be tested in the fidl-test suite in Zircon by adding
a FIDL file that uses each of the types from the
Drawbacks, alternatives, and unknowns
This proposal is straightforward to implement in the FIDL frontend and requires no changes to the language-specific backends.
An alternative is to not solve the problem and continue to use primitive types directly.
Prior art and references
This feature is very common in programming languages. The syntax is borrowed loosely from C++.