[Development] RFC: more liberal 'auto' rules?

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Dec 8 16:53:41 CET 2015

On 2015-12-08 09:52, Oswald Buddenhagen wrote:
> On Mon, Dec 07, 2015 at 03:39:25PM +0100, Marc Mutz wrote:
>> - auto everywhere in C++ means that the type of the rhs defines the
>> type of the variable
> it starts with the fact that you didn't specify that you mean just local
> variables - it's your unstated assumption. your triple emphasis that
> it's not necessary *anywhere* in python implied that you do indeed mean
> more than just locals.

Any variable definitions, actually... not just local, but also member
(static or otherwise) and global. Although IME, AAA is not pushed so
much for other than local variables. (Also, 'auto' for NSDM's requires
compiler support for default initializers, which is less widely
available than 'auto' itself.)

>> - the simiarity with C++ auto is that no type name is visible
>>   - this is what I was referring to
>> - the difference to C++ (auto or not) is that in Python, the variable is weakly
>>   typed / dynamically typed / duck-typed, however you may want to call it.
>> - in particular, the variable can hold an integer first, then a string, and
>>   later an object of class type. Conversely, any type can be held in any
>>   variable.
>>   - this is orthogonal to the omission of the type name, which C++ auto and
>>     the whole thread is all about, thus *completely irrelevant* to the
>>     discussion.
> no, it's actually not orthogonal, and that's the whole point. in the
> generic case, it's impossible to implement "auto *everywhere*" without
> going dynamic.

To be clear, the "everywhere" here is limited to variable declarations.
(Which must be definitions. Which is one of the objectives of AAA; it
prevents uninitialized variables.) Function/method parameters are
specifically excluded.

(Although using 'auto' there - which C++ is actually moving to allow,
although I'm not necessarily thrilled by such - is still not dynamic
typing; rather, it is implicit templatization. There are some possible
benefits to this, along the lines of AAA, but overall there are many
more drawbacks.)


More information about the Development mailing list