Time to kill T() as (sometimes) working T.init alias ?
Jonathan M Davis
jmdavisProg at gmx.com
Sun Dec 9 14:10:06 PST 2012
On Sunday, December 09, 2012 13:41:46 Jonathan M Davis wrote:
> Declaring a struct which contains reference types and does a deep copy with
> postblit obviously incurs a performance cost, but it's up to the programmer
> who declared it to decide whether that's worth it or not. I see no reason
> for the language to try and disallow that. That's overly restrictive.
Not to mention, we've already discussed fixing current features so that they
stop disallowing certain idioms. For instance, in order to make it so that
caching and lazy loading and whatnot are not disallowed in classes due to
issues with const, we've talked about removing toString, opEquals, toHash, and
opCmp from Object. Then the programmer can decide whether they want to use
const or not and we'd no longer be disallowing the idioms that are prevented
by forcing const on Object.
You're basically suggesting that we disallow any idiom which requires that
structs be deep copied, and I think that that's bad policy. It's one thing to
encourage programmers to not write such structs and to use other idioms like
COW or reference counting. It's another thing entirely to disallow them. It's
one of C++'s prime tenets to try and not force the programmer to program in a
certain way or in a certain paradigm, and I think that D should do the same.
If we want to encourage certain idioms and discourage others, fine. But
outright disallowing them is a bad idea IMHO.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list