Replies: 2 comments
-
|
I am strongly favorable to this, yet with a grain of salt:
Overall, I don't think we need a new concept, just more restricted semantics on simple |
Beta Was this translation helpful? Give feedback.
-
|
Ahh my mistake. I was thinking about alias and typing type. No i'm not proposing another syntax, just using the existing one. I always dislike it very much when someone typedefs a pointer type in C, like typedef Bar* Barp. You could of course do PoundForce and Newton, as doubles are base types as well. They would be different types. So the only changes from the current system would be:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently C2 allows aliasing a type like: type Name (implemenation type), eg
type SrcLoc u32;The main goal for aliasing is to allow developers to differentiate different meanings for the same base type. For example a u32 can be an name_idx or a src_loc. At the moment, the alias has a canonical type of the base type. So the alias behaves exactly as the implementation type, it only looks different in the source code. Let's call this weak aliasing. The issue with weak aliases is that the analyser can't find issues like:
My proposal is to make the types stricter, let's call this strong aliasing. Strong aliases only allows implicit conversion to/from the implementation type type.
my proposal:
As a note, Enum types are very similar to strong aliases for the implementation type.
Beta Was this translation helpful? Give feedback.
All reactions