auto storage class - infer or RAII?

Georg Wrede georg.wrede at nospam.org
Sun Nov 12 10:12:42 PST 2006


Walter Bright wrote:
> Lionello Lunesu wrote:
> 
>>> (a) Get rid of 'auto'.
>>
>> I completely agree. The current "auto" can then be tagged as 
>> deprecated and removed Jan 1st!
>>
>>> (b) Create a new keyword that is more obviously read as 'type 
>>> inference'.
>>
>> I like "var".
> 
> My problem with "var" is the history of the keyword. Back in the olden 
> days, there were two main camps of programmers - the Pascal people, and 
> the C people. Each camp looked with disdain upon the other as "not 
> getting it". The Pascal crowd progressed to Modula 2, Object Pascal, and 
> eventually Delphi. The C family progressed to C++, Java, and D. There 
> didn't seem to be much voluntary mixing up, people would switch camps 
> only under duress.

These are big things, no denying it.

> So I have a real (possibly outdated) concern that "var" appearing in D 
> will make the language distasteful to the C crowd. The appearance of a 
> language matters a lot, it's like the clothes one wears that identifies 
> one (consciously or not) as being with a particular group.
> 
> And that's why I've avoided using "var".
> 
> ("let" is far worse, as it gives the impression that D is some sort of 
> new Basic language.)

Good point. "let" is a lot worse than var. And still, I used "let" a lot 
in Scheme. Go figure.

But then, the very concept of type inference is not exactly a C concept, 
and hence it's sort of OK to then have a, er, unforgettable word for it, 
right? Things have also changed: in the old days it was pretty much 
Pascal vs C, but today everybody is fluent in a half dozen other 
languages as well, some of which do use "var".

But the biggest thing of all with "var" is, it's only three letters! 
It's certainly easier to type than 
"let_the_compiler_freely_infer_the_type_here".

<joke>How about "we"? Shorter still. Oh, what does it stand for? Well 
obviously it's whatever. Can't get much more appropriate.</joke>

>>> (c) Create a new keyword that is more obviously read as 'resource
>>> destruction at end of scope'.
>>
>> I like "scope"



More information about the Digitalmars-d mailing list