Go Down

Topic: Adding Streaming library to the Arduino core (Read 1 time) previous topic - next topic

avandalen

Streaming is an important c++ feature, therefore I don't understand why including of the Streaming library to the Arduino core was rejected. See here:
http://arduiniana.org/libraries/streaming/
Streaming makes printing text easier and the library is efficient, it generates no extra machinecode.
I hope the Arduino staff will add this library to the Arduino core or to the Contributed Libraries" list.

AlphaBeta

Quote
Streaming is an important c++ feature

Although it is an important c++ it does not imply that it should be a key feature of Arduino.
The ''stream insertion operator'' << and >> which actually is bit shift operators have caused quite a few discussions, and even more questions.
Many people find them cryptic, I've always though 'shift all the bytes of the string (or the object) into' whatever happenes to use/call the operator << or >>.

I think teaching function calls is better, and it looks cleaner, than stream insertion does. Although it results in longer code.

Quote
Streaming makes printing text easier and the library is efficient, it generates no extra machinecode.
I hope the Arduino staff will add this library to the Arduino core or to the Contributed Libraries[ch8221] list.


Although I've mostly argued against I agree.  :)

avandalen

Sorry, here I disagree.

Function calls cost many lines:
lcd.print("GPS #");
lcd.print(gpsno);
lcd.print(" date: ");
lcd.print(day);
lcd.print("-");
lcd.print(month);
lcd.print("-");
lcd.println(year);

With streaming everything can be written in one line:
lcd << "GPS #" << gpsno << " date: " << day << "-" << month << "-" << year << endl;

I prefer streaming and it generates no extra byte of code at all.

knuckles904

I know its nice to have it as default but it doesnt seem like that big a deal to insert
Code: [Select]
template<class T> inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }

Go Up