Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you read the "<<" and ">>" symbols out loud?

Tags:

symbols

I'm wondering if there is a standard way, if we are pronouncing typographical symbols out loud, for reading the << and >> symbols? This comes up for me when teaching first-time C++ students and discussing/fixing exactly what symbols need to be written in particular places.

The best answer should not be names such as "bitwise shift" or "insertion", because those refer to more specific C++ operators, as opposed to the context-free symbol itself (which is what we want here). In that sense, this question is not the same as questions such as this or this, none of whose answers satisfy this question.

Some comparative examples:

  • We can read #include <iostream> as "pound include bracket iostream bracket".
  • We can read int a, b, c; as "int a comma b comma c semicolon".
  • We can read if (a && b) c = 0; as "if open parenthesis a double ampersand b close parenthesis c equals zero semicolon".

So an equivalent question would be: How do we similarly read cout << "Hello";? At the current time in class we are referring to these symbols as "left arrow" and "right arrow", but if there is a more conventional phrasing I would prefer to use that.

Other equivalent ways of stating this question:

  • How do we typographically read <<?
  • What is the general name of the symbol <<, whether being used for bit-shifts, insertion, or overloaded for something entirely new?
  • If a student said, "Professor, I don't remember how to make an insertion operator; please tell me what symbol to type", then what is the best verbal response?
  • What is the best way to fill in this analogy? "For the multiplication operation we use an asterisk; for the division operation we use a forward-slash; for the insertion operation we use ____."
like image 436
Daniel R. Collins Avatar asked Mar 13 '17 23:03

Daniel R. Collins


People also ask

What is >> operator called?

“>>” is extraction operator because “it extract data enter by user from console or input screen to some storage location identified by variable”.

What do you call << In CPP?

The symbol << is called insertion operation and output operator.


1 Answers

Saw this question through your comment on Slashdot. I suggest a simpler name for students that uses an already common understanding of the symbol. In the same way that + is called "plus" and - is (often) called "minus," you can call < by the name "less" or "less-than" and > by "greater" or "greater-than." This recalls math operations and symbols that are taught very early for most students and should be easy for them to remember. Plus, you can use the same name when discussing the comparison operators. So, you would read

std::cout << "Hello, world!" << std::endl;

as

S T D colon colon C out less less double-quote Hello comma world exclamation-point double-quote less less S T D colon colon end L semicolon.

Also,

#include <iostream>

as

pound include less I O stream greater

So, the answer to

"Professor, I don't remember how to make an insertion operator; please tell me what symbol to type."

is "Less less."

The more customary name "left/right angle bracket" should be taught at the same time to teach the more common name, but "less/greater" is a good reminder of what the actual symbol is, I think.

Chevron is also a neat name, but a bit obscure in my opinion, not to mention the corporate affiliation.

like image 60
Mark H Avatar answered Oct 18 '22 04:10

Mark H