user4478: I have a C++ class constructor like:
Motors(int p1=0, int p2=0);

However, when I attempt to instantiate it with named parameters like:
Motors motors(p1=123, p2=456);

the Arduino C/C++ compiler gives me the errors:
src/motors.ino:3: error: ‘p1’ was not declared in this scope
src/motors.ino:3: error: ‘p2’ was not declared in this scope

The compiler doesn't seem to support named parameters and thinks I'm referring to variables. I thought named parameters was a pretty widely supported feature, even in C++. What am I doing wrong?

user42: C++ doesn't support named parameters, and I doubt it ever will.
It has strict calling conventions which mean you couldn't re-order the parameters at call-time without adding an unnecessary layer of data duplication/indirection (which would hurt performance). It would also need a significant change to compiler architecture, as variable/parameter names are usually stripped out long before the linker is invoked.
If you want to achieve a similar effect though, you could use comment blocks instead, e.g.:
Motors motors(/*p1*/ 123, /*p2*/ 456);


4478: <p>I have a C++ class constructor like:</p>

<pre><code>Motors(int p1=0, int p2=0);
</code></pre>

<p>However, when I attempt to instantiate it with <a href="http://en.wikipedia.org/wiki/Named_parameter" rel="nofollow">named parameters</a> like:</p>

<pre><code>Motors motors(p1=123, p2=456);
</code></pre>

<p>the Arduino C/C++ compiler gives me the errors:</p>

<pre><code>src/motors.ino:3: error: ‘p1’ was not declared in this scope
src/motors.ino:3: error: ‘p2’ was not declared in this scope
</code></pre>

<p>The compiler doesn't seem to support named parameters and thinks I'm referring to variables. I thought named parameters was a pretty widely supported feature, even in C++. What am I doing wrong?</p>
 42: <p>C++ doesn't support named parameters, and I doubt it ever will.</p>

<p>It has strict calling conventions which mean you couldn't re-order the parameters at call-time without adding an unnecessary layer of data duplication/indirection (which would hurt performance). It would also need a significant change to compiler architecture, as variable/parameter names are usually stripped out long before the linker is invoked.</p>

<p>If you want to achieve a similar effect though, you could use comment blocks instead, e.g.:</p>



<pre><code>Motors motors(/*p1*/ 123, /*p2*/ 456);
</code></pre>
