Can we drop static struct initializers?

Don nospam at nospam.com
Mon Nov 23 23:59:29 PST 2009


BCS wrote:
> Hello Walter,
> 
>> Bill Baxter wrote:
>>
>>> On Fri, Nov 20, 2009 at 4:05 PM, Walter Bright
>>> <newshound1 at digitalmars.com> wrote:
>>>> Bill Baxter wrote:
>>>>
>>>>> Right, but if you do define it (in order to do something extra upon
>>>>> initialization -- validate inputs or what have you) then it no
>>>>> longer works at compile time.
>>>>>
>>>> Right, but the static initialization then shouldn't work, either.
>>>>
>>> Why not?  It works if you use static opCall(int,int) instead of
>>> this(int,int).
>>>
>> Because if you need runtime execution to initialize, a back door to
>> statically initialize it looks like a bug.
>>
> 
> who said anything about needing runtime? If the constructor can be 
> evaluated as CTFE with it's only result being the struct getting set up, 
> why not let it. I can think of serval useful thing to do with that 
> (validation, denormalization, etc.)
> 
> 
Read my post. It's just a compiler bug.



More information about the Digitalmars-d mailing list