Thread overview
`auto` keyword origins
Jun 26, 2023
Alexander Tretyak
Jun 26, 2023
Adam D Ruppe
Jun 26, 2023
Alexander Tretyak
Jun 26, 2023
Patrick Schluter
June 26, 2023

I'm just curious when was the auto keyword introduced in D?

The reason I am asking is because D language appeared in 2001, but C++ proposal with auto keyword new semantics dated April 28, 2003.

I always thought that auto in D was taken from C++. But what if it is opposite, i.e. C++11's auto was inspired by D's auto?

June 26, 2023
On Monday, 26 June 2023 at 00:00:48 UTC, Alexander Tretyak wrote:
> I'm just curious when was the `auto` keyword introduced in D?

 What's New for D 0.137
Oct 24, 2005
New/Changed Features

    Added implicit type inference.

from: https://digitalmars.com/d/1.0/changelog1.html


Though the auto keyword was around earlier (it actually comes from old C), and technically doesn't mean exactly what you think it means - the `auto` keyword isn't what's magic, you can use many others in its place (most the time) like `const` and `immutable` among more - but the feature referred to is the type inference.

> I always thought that `auto` in D was taken from C++. But what if it is opposite, i.e. C++11's `auto` was inspired by D's `auto`?

It probably went both ways. The C++ proposal you linked is definitely earlier than D adopting the thing, and perhaps D's use of it helped prompt the C++ committee to adopt it too.
June 26, 2023
Thanks for the reply!
June 26, 2023

On Monday, 26 June 2023 at 00:00:48 UTC, Alexander Tretyak wrote:

>

I'm just curious when was the auto keyword introduced in D?

The reason I am asking is because D language appeared in 2001, but C++ proposal with auto keyword new semantics dated April 28, 2003.

I always thought that auto in D was taken from C++. But what if it is opposite, i.e. C++11's auto was inspired by D's auto?

auto is a C keyword defining the storage class of a variable. It's placed at the same place as register/const and static.

In D it has the same role (i.e. it's a storage class). The type inference has nothing to do with auto. It is just necessary for the grammar to represent a type of a declaration.

a=1;

if the type is omitted, the parser cannot distinguish between a declaration with initialiser or an assignment. You have to put either a type or a storage class to disambguate

const a=1;
immutabe b=2L;
auto c=5.4;
static d=w"Hello";