Auto syntax REALLY revisited

Mike Capp mike.capp at gmail.com
Tue Feb 21 05:18:11 PST 2006


In article <43FAF3AC.2080609 at nospam.org>, Georg Wrede says...
>
>> I want another word substituted
>> for 'auto'! We can't have it mean "autotype and/or RAII", at the same
>> time. That is just too much of a disgrace.

Amen.

>To summarize:
>
>It would be handy to have a class that _requires_ RR instantiation.

And it's not that big a leap. Currently I believe you can declare a class "auto"
to force all instances to be auto; you'd just have to beef up this rule to say
that ONLY instances of auto classes can be declared auto.

This is probably going to get me chased out of town with torches and pitchforks,
but I'd actually like to go one step further and rule that ONLY auto classes can
define destructors. The thinking being that if you care enough about a managed
resource to write a destructor to release it, you almost certainly want that
destructor called deterministically. Relying on the garbage collector to call it
for you in a timely fashion is almost certainly setting you up for a nasty
surprise. Far too many people still seem to think that GC is a panacea for
resource management generally, not just memory management, and until they're
jolted out of that I don't have much hope for D's RAII support improving.

(Incidentally, what's with this "RR"??? I've never seen it before in 10 years of
writing C++. If you mean RAII, it's probably less confusing to the reader to say
RAII, however silly an acronym it might be.)

cheers,
Mike





More information about the Digitalmars-d mailing list