Rename 'type' to 'typedef' or something?


#1

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


#2

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_


#3

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.


#4

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.


#5

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.


#6

typedef in C/C++ does define type aliases, just that struct is part of all non-typedefed struct names.