On 02/20/2017 06:44 AM, timmyjose wrote:

> 3). Not so much a fan of "auto", but it does have its uses, of course.

For completeness, D's 'auto' does not have the same meaning as C++'s auto. Wait... it actually has! :) But with the meaning of the 'auto' keyword from the olden C days: automatic storage class. (I correct this at the end.)

- C has 'auto', meaning "automatic storage class"

- 'auto' is redundant because it's the default anyway

- C++11 re-purposes 'auto' to mean automatic type inference (Ali and others initially assume 'auto' is the same in D.)

- D has automatic type inference universally without special keyword:

    const i = 42;    // No auto

- D needs a place holder to satisfy its syntax rules in certain cases

    i = 42;    // Definition or a typo? Compilation error!

- D brings back the original meaning of 'auto':

    // Yes, automatic storage class but now everybody's happy
    auto i = 42;

Correction: It's actually the 'auto attribute' in D with the venerable responsibility of "The auto attribute is used when there are no other attributes and type inference is desired." Good job, auto! :o)

Ali

Reply via email to