tomtom
August 29, 2024, 2:36pm
1
basically the word “type” is used everywhere in docs and function names like typeof(). So, why use the keyword struct but not type in type definition??
What’s now mutable struct used to be type. And what is now struct used to be immutable.
opened 09:08PM - 29 Oct 16 UTC
closed 04:38PM - 10 Feb 17 UTC
needs decision
kind:breaking
Over time, this keyword has increasingly bothered me. There are several problems… :
- `type` is a very generic word and I'd just as soon leave it available for variable names (and keyword arguments!)
- There are now several kinds of types, so it seems strange to use `type` to refer only to concrete, mutable, struct-like types.
- `type` is the most obvious type-defining keyword, but usually `immutable` is preferable and recommended.
Here are some alternate keyword suggestions:
- `mutable` -- opposite of `immutable`!
- `struct` -- at least says something about what sort of type it is
- `reftype` -- for "reference type", which also conveys some of its key properties
There are many types of types (struct, mutable struct, abstract, primitive, union), only some of which are structs, so it would be misleading to use type to describe structs.
DNF
August 29, 2024, 9:23pm
4
Also, struct is an established name for this purpose, especially in the ‘C family’ of languages.