auto storage class - infer or RAII?
Bill Baxter
wbaxter at gmail.com
Sat Nov 11 13:17:49 PST 2006
Carlos Santander wrote:
> Walter Bright escribió:
>
>> The auto storage class currently is a little fuzzy in meaning, it can
>> mean "infer the type" and/or "destruct at end of scope". The latter
>> only has meaning for class objects, so let's look at the syntax. There
>> are 4 cases:
>>
> Since this has been talked a lot already, I'll only say: auto for RAII,
> and something else (eg: var) for type inference.
> IMHO.
I agree. Even if "everybody else is doing it", I think auto is a poor
choice for an automatic type deduction indicator. I'd be much happier
with any of
var foo = expression;
val foo = expression;
def foo = expression;
let foo = expression;
As an added bonus all of those are one character less than the current
auto. Which is good, since automatic type deduction is basically a
typing saving feature to begin with. To me 'auto' in front of an
identifier looks like it's saying this is an "automatic variable",
which, going back to the original K&R book, has always meant a local,
scoped variable. It sounds like it's going to do something at run time.
For anyone who complains "I'm using that as a variable name already",
I'll write you a script to fix your files. Here you go
perl -pi -e 's/(\W)(val)(\W)/${1}${2}_${3}/g' *.d
Or if you may already have things name val_ in your code
perl -pi -e 's/(\W)(val_*)(\W)/${1}${2}_${3}/g' *.d
--bb
More information about the Digitalmars-d
mailing list