How do you read the "<<" and ">>" symbols out loud? [closed]
Asked Answered
C

7

7

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 ____."
Chitter answered 13/3, 2017 at 23:47 Comment(17)
I believe they are called insertion and extraction operators.Tortoise
Correct, use insertion and extraction to denote << and >>.Itinerancy
As the question says, "insertion" is not a legitimate answer; it refers to context-specific operation, not the raw typographic symbol itself.Chitter
How does insertion refer to a more specific c++ operation? If so, please let me know which operationItinerancy
@OmidCompSCI: I'm looking for a typographical name; not any C++ operation. The answer should be usable whether the symbol is being used for bit-shifts, or insertion, or a mock Guillemet symbol within a text string.Chitter
But you are using these in the context of C++, especially with all those examples... If a student is learning C++, you tell them cout is followed by the insertion operator, in their head they can map insertionn to <<.Itinerancy
@Dai in cplusplus web: cplusplus.com/reference/istream/istream/operator%3E%3EItinerancy
@OmidCompSCI: Perhaps it would help to think of the question as: What is the general name for the symbol, whether used for bit-shifts or insertion or overloaded for something else entirely new?Chitter
@DanielR.Collins, understood. Whether this is useful information in learning c++ or teaching to students, I highly doubt it. If the student is struggling with basics of just learning the terminology of these symbols in a particular language, then CS is probably not for them. There is way more to spend time on in c++ than learning terminology of these things. I would love to see those students take a Theory of Computing/Automata course which is all about symbols, languages lol! I'll vote the question since there is a lot of confusion.Itinerancy
@Dai true, but if it is widely used and the point is to get the student or someone to type a particular symbol then why not use the wide term terminology?Itinerancy
@OmidCompSCI: Because it doesn't answer the question. Quoting from your source: "This operator (>>) applied to an input stream is known as..." (emphasis mine)Cantwell
Yet another way of interpreting the question: If a student asked, "Professor, I don't remember how to make an insertion operator, what symbol do I type?", how would one verbally answer that?Chitter
@DanielR.Collins: "open bracket" can be either < or [, so I use "open angle bracket" and "open square bracket".Cantwell
@MooingDuck why not less than symbol? This seems silly as it can continue and trickle down... "Professor what is an open angle bracket", and it can continue on and on. It should stop at one point, and I believe it should be simple as the extraction or insertion which is known terminologies, and once they learn it once they use it forever. Hence the answer below has proved it.Itinerancy
@OmidCompSCI: It's rare for programmers to call it "less than", I assume because it sounds like a comparison rather than a noun. I'm just telling you "open bracket" is ambiguous, so is rarely used. Most of us call it "open angle bracket" when there's no context.Cantwell
@MooingDuck: It sounds like you have a legitimate response; could you please write that up as an answer?Chitter
Like @MooingDuck brackets other than () I prefer to read as the style type, eg angle, square, curly. However I have also heard them as being referred to as chevron and double chevron, so << would be referred to as "double left chevron", I guess that is an overflow from the design and icon world, not sure how keen I am on it though, but just a comment to add that there are those who refer to it like that.Whenever
D
4

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.

Daren answered 13/7, 2017 at 0:47 Comment(3)
Also arrived here from Slashdot. A similar conundrum is the symbol used in lambda expressions/fat arrow functions/etc. to separate the parameters from the body: =>. (e.g. v => v.length;) However, in this case, my favorite solution is to read it as "goes to". (e.g. "vee goes to vee dot length") I think I picked up that convention from C#, but it's been a while and I can't be sure. So, maybe what we need is something like that which describes the mechanic rather than reading the symbols...Louvenialouver
@Shibumi: This question is strictly about reading the typographical symbols. Naming the mechanic instead would be a different question (perhaps one of the links in the current question).Chitter
@DanielR.Collins I suppose my contention was that attempting to strictly vocalise the symbols themselves may be a red herring -- and why there has been so much trouble surrounding it. In my opinion, choosing "goes to" or "fat arrow" rather than "equals greater than" or "equals right" solved the problem in that case and could potentially solve the problem here.Louvenialouver
C
1

A proposal: Taking the appearance of the insertion/extraction operators as similar to the guillemet symbols, we might look to the Unicode description of those symbols. There they are described as "Left-pointing double angle quotation mark" and "Right-pointing double angle quotation mark" (link).

So perhaps we could be calling the symbols "double-left angle" and "double-right angle".

Alternatively, Wikipedia in places uses the phrases "double less-than sign" and "double greater-than sign" (noting specifically "Not to be confused with guillemet"). (link)

Chitter answered 13/3, 2017 at 23:49 Comment(0)
C
1

"<" and ">" can be called chevrons. The former is a "left chevron" and the latter is a "right chevron".

  • We can read 'cout << "Hello";' as "c o u t left chevron left chevron left quotation mark H e l l o right quotation mark semicolon".

Thanks for asking this question! I have had the same question, but never asked it.

Today I found that John Purcell, a software development trainer, reads them as "chevron" in his C++ course and also found this question. So I am leaving this answer, and hope this is helpful.

Camisado answered 20/8, 2024 at 3:56 Comment(0)
C
0

My comment was mistaken (Chrome's PDF Reader has a buggy "Find in File" feature that didn't give me all of the results at first).

Regarding the OP's specific question about the name of the operator, regardless of context - then there is no answer, because the ISO C++ specification does not name the operators outside of a use context (e.g. the + operator is named "addition" but only with number types, it is not named as such when called to perform string concatenation, for example). That is, the ISO C++ standard does not give operator tokens a specific name.

The section on Shift Operators (5.8) only defines and names them for integral/enum types, and the section on Overloaded Operators does not confer upon them a name.

Myself, if I were teaching C++ and explaining the <</>> operators I would say "the double-angle-bracket operator is used to denote bitshifts with integer types, and insertion/extraction with streams and strings". Or if I were being terse I'd overload the word and simply say "the bitshift operator is overloaded for streams to mean something completely different".

Regarding the secondary question (in the comment thread) about the name of the <</>> operators in the context of streams and strings, the the C++14 ISO specification (final working-draft: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf ) does refer to them as "extractors and inserters":

21.4.8.9 Inserters and extractors
template<class charT, class traits, class Allocator>
basic_istream<charT,traits>&
operator>>(
   basic_istream<charT,traits>& is,
   basic_string<charT,traits,Allocator>& str
);

(and the rest of the >> operator overload definitions follow)

This is further expanded upon on 2.7.2.2.2:

27.7.2.2.2 Arithmetic extractors
operator>>(unsigned short& val);
operator>>(unsigned int& val);
operator>>(long& val);

(and so on...)

Culinary answered 14/3, 2017 at 0:14 Comment(5)
Good example, and they are officially termed extraction/insertion or extract/insertItinerancy
@DanielR.Collins I have revised my answer.Culinary
@OmidCompSCI: Only in the context of streams. Everywhere else in the spec calls it operator <Cantwell
This does not answer the question; I'm not looking for a name of an operator. I'm looking a typographical pronunciation, which is not specific to C++.Chitter
Currently I think just the 4th paragraph is on-topic to the posted question. I'd upvote if you edited it down to just that!Chitter
S
0
cout << "string" << endl;// I really just say "send string to see out. Add end line."
i++;  // i plus plus
auto x = class.func() // auto x equal class dot func
10 - ( i %4) * x;  // ten minus the quantity i mod four times x
stdout // stud-out
stderr // stud-err
argc   // arg see 
argv   // arg vee
char*   // char pointer
&f     // address of f
Semiweekly answered 13/7, 2017 at 7:34 Comment(0)
C
0

Reading from wikipedia https://en.wikipedia.org/wiki/List_of_typographical_symbols_and_punctuation_marks

<   Less-than sign  Angle bracket, Chevron, Guillemet
...
>   Greater-than sign   Angle bracket   
Cutthroat answered 20/8, 2024 at 4:51 Comment(0)
H
-2
  1. Just because it's an "extraction" or an "insertion" operator does not mean that is the OPERATION.
  2. The operation is "input" and "output"
  3. They are stream operators.
  4. The natural label would be c-out stream output double-quote Hello world exclamation double-quote stream output endline
  5. This the OPERATION you are doing (the verb)
  6. What the ARM calls the operator is irrelevant in that it is a systemic way of looking at things and we are trying to help humans understand things instead
Hyperon answered 13/7, 2017 at 5:59 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.