There is a small disadvantage for the IDE-based solution: we would need additional keywords. If those are not specified in the language itself, it will be a little harder to enforce no variables with the name of these “keywords” (especially in library code). On the other hand, these “keywords” could be context specific. Or we might reserve these keywords in the language specification without using them in the standard.
- Code verbosity reduction. Eliminate auto keyword or making it optional. Are there strong reasons to keep typing auto when compilers might deduce its presence just because it's missing (positional abscense)
The history of computer science shows that this is a bad idea! Rockets have exploded because of automatically declared variables. This was (and I believe still is) the default in Fortran. (However, in Fortran the first letter of the variable defines the type of the variable as either integer or floating point.) The problem that would arise is that a typo would accidentally introduce a new variable. I consider the compiler my best friend in pointing out typos as errors. Because of compiler errors I also only rarely use ‘auto’, but will specify the type of the variable type explicitly. Then the compiler will notify me when I don’t get the type that I expected. I prefer to tell the compiler everything I assume and let the compiler correct me if I’m wrong.
- Abstraction. Elevate abstraction on pointer dereference. Does it really matter if we use "." (dot) or "->" (arrow) to access internal structure?. I can foresee complexities with smart pointers, where both methods are used to access 2 different interfaces (for for smart_ptr object, arrow for accessing the dereferenced underlying object. But it might be a subject to brainstorm it further.
In plain C this would actually work (and also with raw pointers in C++). There is an interesting read about why we have the two versions in the first place:
https://retrocomputing.stackexchange.com/questions/10812/why-did-c-use-the-arrow-operator-instead-of-reusing-the-dot-operator/10858#10858The shortcuts allowed initially, are not valid C anymore. So, there is no reason for two different operators in C anymore.
Just as others have noticed, it gets complicated with operator overloading (smart pointers and iterators). There has also been a proposal for overloading operator. (by Herb Sutter?) which discusses some of the same problems. Maybe some of these solutions could be backported to your suggestion (like using .. instead of just . in certain cases to disambiguate). If we can get operator. into the standard (and force it to have the same behavior as operator->), we could merge the meaning of operator. and operator-> by allowing a . everywhere.
I'd appreciate opinions, problems or strong no-go reasons, or otherwise positive views if any.
I’m strongly against number 2. All modern (comparable) languages use a keyword to introduce a new variable (var, mut, …). With C++ this just happens to be auto (for historical reasons, as this keyword was available).
Best,
Marcos Mayorga
-- Std-Proposals mailing listStd-Proposals@lists.isocpp.orghttps://lists.isocpp.org/mailman/listinfo.cgi/std-proposals