Skip to main content
Tweeted twitter.com/#!/StackProgrammer/status/286004547665682432
Tried to make the title more explicative.
Link
Giorgio
  • 19.8k
  • 16
  • 89
  • 137

The Motivation and pitfalls (?) of the auto keyword in C++11

added 7 characters in body
Source Link
gnat
  • 20.5k
  • 29
  • 117
  • 310

I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in

auto x = 1; 

Since

  1. var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and
  2. AFAIAs far as I understand the new semantics of auto breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here)

I wanted to ask if there was a special reason for choosing auto (in favour of var or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released?

Also, are there any possible incompatibilities we should watch out for when recompiling legacy C++ code with a C++11 compiler?

I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in

auto x = 1; 

Since

  1. var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and
  2. AFAI understand the new semantics of auto breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here)

I wanted to ask if there was a special reason for choosing auto (in favour of var or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released?

Also, are there any possible incompatibilities we should watch out for when recompiling legacy C++ code with a C++11 compiler?

I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in

auto x = 1; 

Since

  1. var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and
  2. As far as I understand the new semantics of auto breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here)

I wanted to ask if there was a special reason for choosing auto (in favour of var or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released?

Also, are there any possible incompatibilities we should watch out for when recompiling legacy C++ code with a C++11 compiler?

Made the focus of the question more precise.
Source Link
Giorgio
  • 19.8k
  • 16
  • 89
  • 137

Why was the keyword The auto chosen for C++ implicit variables?keyword in C++11

I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in

auto x = 1; 

Since

  1. var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and
  2. AFAI understand the new semantics of auto breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here)

I wanted to ask if there was a special reason for choosing auto (in favour of var or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released?

Also, are there any possible incompatibilities we should watch out for when recompiling legacy C++ code with a C++11 compiler?

Why was the keyword auto chosen for C++ implicit variables?

I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in

auto x = 1; 

Since

  1. var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and
  2. AFAI understand the new semantics of auto breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here)

I wanted to ask if there was a special reason for choosing auto (in favour of var or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released?

The auto keyword in C++11

I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in

auto x = 1; 

Since

  1. var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and
  2. AFAI understand the new semantics of auto breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here)

I wanted to ask if there was a special reason for choosing auto (in favour of var or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released?

Also, are there any possible incompatibilities we should watch out for when recompiling legacy C++ code with a C++11 compiler?

Improved the formulation of the question.
Source Link
Giorgio
  • 19.8k
  • 16
  • 89
  • 137
Loading
added 23 characters in body
Source Link
Giorgio
  • 19.8k
  • 16
  • 89
  • 137
Loading
Source Link
Giorgio
  • 19.8k
  • 16
  • 89
  • 137
Loading