auto storage class - infer or RAII?

Bruno Medeiros brunodomedeiros+spam at com.gmail
Tue Nov 14 03:08:23 PST 2006


Derek Parnell wrote:
> On Sat, 11 Nov 2006 10:48:00 -0800, Walter Bright wrote:
> 
>> 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.
> 
> Please excuse my bash and amateur crashing in here ... but Walter, for a
> very intelligent person, why is it that you just don't get it?
> 
> Type inference and RAII are two distinct, unrelated and orthogonal
> concepts. Using one keyword in subtly different syntax permutations to
> indicate both concepts is just plain stupid.
> 
> In each of the suggested permutations above, the code reader and writer
> will constantly be thinking "now what's the precise syntax again?"  This
> reminds me of the exact criticism that you have leveled against some C++
> constructs, and some syntax changes to D suggested by your supporters.
> Namely that the subtle differences in syntax variants is a cause of bugs
> and makes writing code harder - because they are not visually distinct
> enough for the average person.
> 

I *fully* agree. It comes a few days late, but I still wanted to say it. 
The irony and mischeviousness of the statement "The auto storage class 
currently is a *little fuzzy* in meaning" is teeth-grinding(or 
something). Walter, I hope that by judging the response in this thread 
you've seen that everyone agrees that these two language concepts should 
be well separated. There is really no discussion on that. The question 
to discuss is rather *how* that separations should be (which keywords, 
etc.).

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list