As I mentioned in my earlier post, I do think that the C++ syntax looks a little scary to beginers. I am not clear what concern you feel has not been raised?
mem - let me reword my post to make it clearer. I apologise for causing further confusion.
The 'concern' was that there was an error in the playground example, and we all missed it, which set off alarm bells in my head (but I do suffer from Tinnitus occasionally :-))
The IDE syntax highlights the keyword so the bug is easy to spot:
That's true, but this example illustrates how easy it is to make a mistake and not see it. It was their for more than 2 months, and it wasn't spotted. I assume several of us read it as a result of this thread, and it still wasn't spotted.
In this case, colour hadn't helped get it right. I didn't read it as an error as quickly in the overloaded version, as in the simple print() version. Maybe I'm just weird, but did you have the same experience?
Also, I feel colour should be used to help, but not be a replacement for clarity. Colour is a valuable visual overloading to convey meaning, but it can't be the only mechanism because most playground pages, books and examples are monochrome, not colour. (After all, some folks are colour blind, or have problems seeing at all)
I hope this post doesn't come across as argumentative, ...
No, now that I think I've "got you" I read this as helpful
..., I suspect we are in agreement that a simpler way to format output would be most welcome.
Almost in agreement. I'd like to have a way to format output for a tabular display, but I am unwilling to sacrifice simplicity and clarity of the majority of simple cases to get it.
Further, I don't mind typing quite a lot:
Serial.print(" y ");
Serial.print(" z ");
is okay with me, because it looks plausible.
I can show people how to create their own functions (pointing out setup() and loop() are examples). I can explain that there is a further idea of 'class' which they can investigate, which accounts for the 'Serial.' part. Folks seem okay with this.
Serial << ""x " << x << " y " << y << " z " << z << endl;
I agree with you, this is scary syntax. This feels like a big leap. It is nifty, and, in context of C++, clever. This is one of the few areas where I always disagree with a very dear friend (who was the first person in Europe to have a C++ compiler). I think it is clever rather than clear, especially if you also try to use "<<' to mean shift left.
Given that we are often working at low-level, writing embedded-style code, the shift-left meaning of "<<" seems more important than the convenience of using "<<" for output.[/edit]
IMHO, for the subset of C++ required to understand the majority of the Arduino language, we do not need
operator overloading and template classes.
For the record, I do not like the suggestion
Serial.println("x", x, "y", y, "z", z);
as an alternative. This would require a varargs mechanism for folks to write their own, and I'd prefer them to master 'class' and member function overloading before I'd tackle that one.
This may be a mistake in roypardi's email, but I don't like the notion that println would expand "x" to "x " (presumably because it is the first string?), and "y" to " y ". I assume it should have been written
Serial.println("x ", x, " y ", y, " z ", z);
- please don't use overloading of any operators to introduce any new meanings beyond C in File->Examples
- this implies, please don't use "<<", to mean print in Examples
- the fact that the "<<" overloading of print playground example had an error for two months suggests that there may be some issues with using operator overloading, though I accept that is not definitive
- if you really want a more compact way to print, consider new member functions, like out() or p(), which can be chained, but please keep that out of Examples too.
It is pretty easy to explain to programmers coming to the Arduino that the Arduino language is C with some great libraries, and helpful C++ additions. No one seems to panic. If I say it is C++, folks start to look a bit skittish, and I have to calm them down