[DIP] In-place struct initialization

cym13 via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 30 15:05:29 PDT 2016


On Saturday, 30 July 2016 at 21:45:31 UTC, Cauterite wrote:
> On Saturday, 30 July 2016 at 21:42:42 UTC, cym13 wrote:
>> ...
>
> Here's something you might enjoy in the meantime:
> https://github.com/Cauterite/dlang-pod-literals/blob/master/podliterals.d

Thanks, I'm aware of this work but some points just aren't good 
enough IMHO. We can do better than that. First of all the syntax 
is too far appart from traditional field assignment which is 
always done using ':' . I understand why it is so but still it 
makes one more thing to remember. Calling lambdas all the time 
isn't free while the change I propose is static. Those lambdas 
aren't optimized away by DMD and while that might change I just 
don't feel like trusting it. And more importantly it doesn't work 
with common structs, you have to pass it to your template first 
and then it isn't the struct anymore. There are just too many 
ways for this to get wrong in my opinion.

Note that I find the idea ingenious and interesting, I just think 
we can do better than that.


More information about the Digitalmars-d mailing list