struct and default constructor

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 10 22:49:13 PDT 2014


On 10/10/2014 9:43 PM, Dicebot wrote:
> On Saturday, 11 October 2014 at 04:41:52 UTC, Walter Bright wrote:
>> On 10/10/2014 5:25 PM, Simon A wrote:
>>> D has native functional purity.  Couldn't you get the same
>>> benefits that you listed by allowing default constructors but
>>> requiring them to be pure?
>>
>> I suspect that CTFE can accomplish most of that today - with the exception
>> that CTFE will not allocate runtime memory for you.
>
> There is ER somewhere in bugzilla AFAIR about allowing CTFE-only struct default
> constructors.

Note that you can do (as pointed out upthread):

    struct S {
         int x = 7;
         string s = "hello";
    }

which then has default initialization. Of course, CTFE will work on those rvalues.


More information about the Digitalmars-d mailing list