Can we rename the ‘type’ keyword to something else, maybe ‘typedef’? ‘type’ is such a useful word to use in variable and attribute names.
-Phil
Can we rename the ‘type’ keyword to something else, maybe ‘typedef’? ‘type’ is such a useful word to use in variable and attribute names.
-Phil
Else we could also reuse Python’s (I don’t know whether official) style for variables with keywords as name, by appending an underscore.
type -> type_
Yeah that’s what I currently do. libsyntax uses ‘ty’ I guess for the same reason. Feels like a bit of a sucky workaround for a keyword not used that often.
Feels like a bit of a sucky workaround for a keyword not used that often.
Note that it's going to be used considerably more often with associated types.
type
is used by many languages for defining type synonyms, for example, Scala and Haskell. It is clean and nice and, as @glaebhoerl said, it will be used much more often if (when?) associated types are accepted.
Also typedef
in C/C++ is different from type
in Rust and other languages; it does not create real type synonyms, it creates new types (consider variable definitions: struct S a = ...;
for struct S { ... };
and S a = ...
for typedef struct { ... } S
). Renaming type
into typedef
may be confusing for newcomers from C.
typedef
in C/C++ does define type aliases, just that struct
is part of all non-typedef
ed struct
names.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.