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

0 Likes

#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_

0 Likes

#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.

0 Likes

#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.

0 Likes

#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.

0 Likes

#6

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

0 Likes

closed #7

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

0 Likes