What is the shortest way to define an immutable token of unique type?

Max Haughton maxhaton at gmail.com
Mon Mar 15 12:59:49 UTC 2021


On Monday, 15 March 2021 at 09:45:44 UTC, Per Nordlöw wrote:
> On Sunday, 14 March 2021 at 16:37:58 UTC, Andrei Alexandrescu 
> wrote:
>> struct Hex {}
>> immutable Hex hex;
>
> What about making the type name optional (via a language 
> change) and allow
>
>     immutable struct { int x; int y; } hex;
>
> and if possible have it be lowered to a builtin tuple
>
>     immutable (int, int) hex;
>
> ?
>
> Does a struct and tuple with the same fields have the same 
> memory layout?

Some kind of lowering would hopefully be a way of getting tuples 
that work. Tuples-as-compiler-magic are embarrassing, tuples as a 
library are too complicated I find.

i.e. The tuple should be either a sister or close-child of a 
struct


More information about the Digitalmars-d mailing list