Strong typing and physical units
Paolo Invernizzi
paolo.invernizzi at gmail.com
Tue Jul 28 12:33:35 UTC 2020
On Tuesday, 28 July 2020 at 11:04:00 UTC, Cecil Ward wrote:
> Of course, in C I used to do something like strong typing with
> an opaque type achieved by using something like typedef struct
> _something {} * type1; and then I had to do casting to get back
> the real type, which was unchecked but it did prevent the user
> from mixing up the types type1 and type2 say as they weren’t
> assignment compatible.
>
> I would really like strong typing to be a built in feature.
> Would anyone else support this?
Once upon a time, typedef was present and backed by the compiler,
but nowadays you can find it in Phobos [1], but with some quirk
...
[1] https://dlang.org/phobos/std_typecons.html#.Typedef
More information about the Digitalmars-d-learn
mailing list