auto storage class - infer or RAII?

Ary Manzana ary at esperanto.org.ar
Sat Nov 11 16:09:08 PST 2006


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:
> 
> class Class { }
> 
> 1) auto c = new Class();
> 2) auto Class c = new Class();
> 3) auto c = some_expression();
> 4) auto Class c = some_expression();
> 
> The ambiguity can be resolved by saying that if auto is used for type 
> inference, i.e. cases (1) and (3), then it does not mean RAII. If it is 
> not used for type inference, i.e. cases (2) and (4), then it does mean 
> RAII.
> 
> In the future, I'd like the following to work:
> 
> 5) auto c = Class();
> 
> which would mean type inference *and* RAII.

Is backward compatibility the main restriction that stops you from 
selecting two keywords distinct from "auto" (and a lot of other unclear 
stuff)?

If it's that, what you can do is propose a final, clean syntax for 
version 1.0 and get the programmers to update their codes to v1.0. I 
guess they will do that, at least active projects: old, abandoned 
projects sure will fail, as probably they fail now with some last 
language modifications.

I think no one but you want's to keep the "auto" keyword.

--
Ary



More information about the Digitalmars-d mailing list