Is D 0.163 D 1.0?

Andrei Khropov andkhropov at nospam_mtu-net.ru
Tue Jul 25 08:25:42 PDT 2006


Don Clugston wrote:

> It's lamer as a keyword, IMHO. It's not an English word.

'var' is short for 'variable' like 'int' is short for 'integer'


> 'auto' has been
> widely promoted for exactly that purpose in C++

Yes, but in C++ only. And don't forget that in C++ there is already a
(redundant but still valid) keyword 'auto' that means scoped variables like it
was in D before type inference:

This is a quote from "Stroustrup. The C++ programming language, 3rd ed":

--------------------------------------------------------------------------------

Automatic memory, in which function arguments and local variables are
allocated. Each entry into a function or a block gets its own copy. This kind
of memory is automatically created and destroyed; hence the name automatic
memory. Automatic memory is also said ‘‘to be on the stack.’’ If you absolutely
must be explicit about this, C++ provides the redundant keyword *auto*.
--------------------------------------------------------------------------------

So it would be also confusing in C++ if they accept this proposal.

> I cannot understand the attraction to 'var'.

Because it is meaningful (short for 'variable') and already used in several
languages (JavaScript, C# 3.0, Scala...) for this purpose.


P.S. And I like 'val' (from 'value') in Scala that means immutable variable (in
fact just named constant or value), compare:

--------------------
Scala: val i = 1;
--------------------
C++: const int i = 1;
--------------------

It's short and readable (IMHO).

-- 
AKhropov



More information about the Digitalmars-d mailing list