enum pointers or class references limitation

Nicholas Wilson via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 31 01:52:00 PDT 2017


On Thursday, 31 August 2017 at 08:40:03 UTC, Dmitry Olshansky 
wrote:
> On Wednesday, 30 August 2017 at 12:28:10 UTC, Timon Gehr wrote:
>> On 30.08.2017 11:36, Dmitry Olshansky wrote:
>>> The subj is not (any longer) supported by compiler. In fact 
>>> it used to produce wrong code sometimes and now it just 
>>> plainly rejects it.
>>> 
> [..]
>>
>> I think the underlying reason why it does not work is that 
>> dynamic array manifest constants are messed up. I.e. class 
>> reference `enum`s are disallowed in order to avoid having to 
>> make a decision for either inconsistent or insane semantics.
>
> Well from my point of view enum is just evaluate this 
> expression at the usage site. So any array or class instance 
> will be created anew at the point of usage.
>
> What are the problems with enums and dynamic arrays?

I think Timon is referring to:

enum int[] foo = [1,2,3];

auto bar = foo;
auto baz = foo;

assert(!(bar is baz)); // Passes


More information about the Digitalmars-d mailing list