DMD 0.177 release

Brad Roberts braddr at puremagic.com
Sat Dec 9 14:14:30 PST 2006


Walter Bright wrote:
> Jarrett Billingsley wrote:
>> No offense, but would it honestly kill you to allow ctors in structs?  
>> We've been using static opCall as a _workaround_ for the lack of 
>> struct ctors, and making it part of the language doesn't really seem 
>> to be addressing the problem.  That, and it doesn't make any sense 
>> that classes use "this()" and structs use "static S opCall()".  We're 
>> starting to get into "overloading indexing in C++" territory.
> 
> It turns out that static opCall() and this() are equivalent. C++ has 
> some obscure rules to try to disambiguate them. I wished to avoid that 
> problem, and since static opCall() is routinely in use, picked them.

Just because someone at some time in the distant pass realized that 
opCall() simulates constructor-like behavior, it doesn't make it 'ok'; 
it makes it 'an ok work around'.

Think back over the last year.. how many people have asked how to create 
a constructor for structs?  How much you wanna bet none of them would 
have had to ask if 'this' wasn't misspelled as 'opCall'?

Since the desired behavior is construction, let's stop kidding ourselves 
and actually give structs both the behavior and the syntax of 
construction, please?  And while you're in there.. how about destruction 
and RAII?  I guess I'm in the camp that would like to see structs be 
closer to classes but am ok with them not supporting inheritance and 
other features that lead to vtables.

Later,
Brad



More information about the Digitalmars-d-announce mailing list