L5 · LanguagesProgramming Languages 101 · part 4 of 6

List* l or List *l? The Oldest Style War in Programming

Three spellings that mean the same thing to the compiler. People have argued about where the asterisk goes since the 1970s, because the question is really about what a declaration is. Here's the whole debate, and how Go avoided it.

Takumi Yamada
· 8 min read
cppcgopointersprogramming-languageshistory

Here are three function signatures. To the C++ they are identical. They are read the same way, they have the same types, and they produce the same .

void add(List* l);
void add(List *l);
void add(List * l);

The spaces around the asterisk mean nothing to the compiler. Even so, where to put the asterisk is one of the oldest arguments among C and C++ programmers. It started about fifty years ago, and it still comes up in code reviews today.

I don't think it lasts because programmers like arguing. It lasts because it isn't really about spaces. It's about what a declaration is. Both sides are right about something. The language's grammar supports one side, and the way most programmers think about types supports the other.

This post covers the whole debate: what each side believes, the grammar rule underneath, the trap that started the classic C style, how complicated declarations can get, and how newer languages avoided the problem.

Camp 1: List* l, the asterisk belongs to the type

This is the modern C++ view. The asterisk is part of the type. The variable's type is " to List", so the symbol that says "pointer" should sit next to List. The declaration then reads as a type, followed by a name.

List* l;        // read as (List*) l, "l has type pointer-to-List"

C++ programmers tend to think about types this way, because in C++ a type is something you work with directly. You can pass List* to a template, give it another name with an alias, and choose between functions based on it.

Bjarne Stroustrup, who created C++, writes int* p. In his FAQ he describes the split like this: C++ programmers tend to focus on the type, and C programmers tend to focus on the expression. Most modern C++ codebases and style guides follow Camp 1.

A round portrait of Bjarne Stroustrup, with his name below.
Bjarne Stroustrup, who created C++, in 2013. He writes int* p, with the asterisk next to the type.Photo: Victor Zavyalov for ICPCNews, CC BY 2.0, via Wikimedia Commons (original). Changes: cropped to a circle and placed on a card with the name.

Camp 2: List *l, the asterisk belongs to the variable

This is the classic C view. The asterisk goes next to the name.

List *l;        // read as "*l is a List"

The idea behind it is called declaration mirrors use, and it's not just a habit. It's how C was actually designed. Dennis Ritchie, who created C, made declarations work like this: you write an expression that uses the variable, and in front of it you write the type that the expression produces.

Two older men in suits standing side by side at an award ceremony, with a glass trophy in front of them.
Dennis Ritchie (right), who created C and its declaration syntax, with his former Bell Labs colleague Doug McIlroy at the Japan Prize ceremony in 2011.Photo: Denise Panyik-Dale, CC BY 2.0, via Wikimedia Commons (original). Changes: cropped.

So List *l; says that when you write *l, you get a List. The declaration shows how the variable is used. That's also why int a[10] puts the brackets after the name: the expression a[i] is an int. And it's why function pointers in C look the way they do.

CAMP 1modern C++List*lthe typethe nameread as:l has the type pointer to ListCAMP 2classical CList*lwhat you getthe expressionread as:the expression *l is a List
The same three tokens, grouped the way each camp reads them. The outlined box is the one that holds the asterisk.

So Camp 2 has the language's grammar on its side. It has one more argument too: a trap that catches people who write in Camp 1's style.

The trap

Declare two pointers on one line, in Camp 1's style.

List* a, b;

This looks like it declares two pointers. It doesn't. The compiler reads a as a List* and b as a plain List.

The reason is Ritchie's grammar. The asterisk was never part of the type. It belongs to the name that follows it. So the compiler actually reads the line like this.

List (*a), (b);   // one pointer, one value
LOOKS LIKEList* a, b;List*abtwo pointerswhat the spacing suggests,and not what it meansPARSES ASList (*a), (b);List*abpointerplain Listthe asterisk belongs to thename a, so b never gets one
Top, the reading that the spacing suggests. Bottom, the grouping the grammar uses.

To get two pointers, you have to write the asterisk once for each name. That forces you into Camp 2's spelling.

List *a, *b;      // now both are pointers

This is why many C programmers learned to put the asterisk next to the variable. Their style makes the code look like what the compiler does. Written in Camp 1's style, List* a, b; looks like it means something it doesn't. Written as List *a, b;, it at least shows that only a has the asterisk.

Camp 1's answer is a rule rather than a spelling: always declare one variable per line. That rule is in the C++ Core Guidelines, and it makes the trap impossible.

Here is the debate in short. Camp 1 matches how programmers think, where a type is a thing. Camp 2 matches how the compiler reads, where a declaration is an expression. Each side needs one extra rule for the case where its own view doesn't work.

How deep the rabbit hole goes

If "declaration mirrors use" stopped at *l, either style would be fine. But with more complicated types, the rule gets hard to read, and that's why many people dislike it.

Here is a pointer to a function that takes two ints and returns an int.

int (*fp)(int a, int b);

That's still readable, but only just. The parentheses around (*fp) are needed. Without them, the line would declare a function that returns a pointer. Now make one of the parameters a function pointer too, and leave out the parameter names, which C allows.

IN Cthe name is insideint3(*fp)1(int a, int b)21fp is a pointer2to a function that takes two ints3and that function returns an int
Reading order for the first declaration: the middle, then the right, then the left.
int (*fp)(int (*)(int, int), int);

Rob Pike made this point when he explained why Go dropped C's style. In int (*)(int, int) it's not clear where a name would go. It's not even obvious that the thing is a function pointer.

A round portrait of Rob Pike, with his name below.
Rob Pike, one of Go's three designers, speaking in 2010.Photo: Kevin Shockey, CC BY 2.0, via Wikimedia Commons (original). Changes: cropped to a circle and placed on a card with the name.

If the function also returns a function pointer, you get declarations that you have to read from the inside out, going around the parentheses.

int (*(*fp)(int (*)(int, int), int))(int, int);

That's a real, legal declaration. It has the same shape as one of the best known hard-to-read lines in C, the declaration of the Unix function signal().

void (*signal(int sig, void (*func)(int)))(int);

C programmers invented a reading method for these, called the clockwise spiral rule. They also built a tool, cdecl, whose only job is to translate C declarations into English, and it's still online. When people need a tool to read a syntax, I think the syntax is the problem. Modern C++ handles this in two ways. An alias gives a complicated type a short name, and auto lets the compiler work out the type so you don't write it at all.

How Go ended the war

Go's designers had seen fifty years of arguments about the asterisk, the two-pointer trap and the spiral rule. They made a change that C couldn't make without breaking old code: they reversed the declaration.

In Go, the name comes first and the type comes second, and you read from left to right.

var l *List            // "l is a pointer to List"
var a, b *List         // both pointers, no trap possible
f := func(x, y int) int { ... }
var fp func(func(int, int) int, int) int

The last line is the hard-to-read declaration from the previous section. fp is a variable that holds a function. That function takes two arguments, another function and an int, and returns an int. In Go you can read it from left to right in one pass, the same way you would say it aloud. Pike described the design like this: the name always comes first, so it's always clear what is being declared, and the type after it reads like a sentence.

Cinside out3intresult1(*fp)name2(int (*)(int, int), int)parametersstart at the name in the middle,go right, then come back leftGOleft to right1var fpname2func(func(int, int) int, int)parameters3intresultone pass, in the orderyou would say it
One function pointer declared in each language. The numbers are the order you have to read the parts in.

This removes the whole debate. There is nowhere to put a space that matters, because *List is one type, written in the type's position. The asterisk can't attach to the name, so Camp 2's grammar argument no longer applies. When you declare several names, they all share one type, so the trap is gone too.

Both sides got what they wanted. Camp 1 said the asterisk is part of the type, and in Go it is. Camp 2 said a declaration should not look like something it isn't, and in Go it can't. Neither side won. The thing they were arguing about was removed.

Go wasn't the only language to do this. Java kept C's order, type first, but moved brackets onto the type, so you write int[] a instead of int a[], for the same reason. Java still accepts the old C spelling, which shows how long these habits last. Rust, Kotlin, Swift and TypeScript all followed Go's order, with the name first and the type after it.

The genre, not the instance

The asterisk debate is the best known of a whole group of arguments, where the compiler doesn't care and people do.

const int versus int const is the same debate with a different word. The compiler reads both the same way, and people read them differently. Where to put braces, tabs versus spaces, and i++ versus ++i in a loop are other examples.

Each of these lasts for the same three reasons. Either choice costs nothing. Mixing the two styles in one codebase does cost something, because it makes the code harder to read. And each style reflects a different way of thinking about the code.

That's why arguments don't settle these debates. A decision does: a style guide, a formatting tool, or a language designer who removes the choice.

That's the real lesson here. gofmt comes with Go and allows exactly one format, so the asterisk debate can't happen in a Go codebase. The cost is that nobody gets their personal preference. C++ leaves the choice open, and the cost is many small arguments in code reviews. Both have a cost, but only one of them still causes arguments fifty years later.

Where to stand

If you write C++ every day, the practical answer is short. Follow the convention your codebase already uses, declare one name per line, and let a formatter such as clang-format enforce it. Then the question stops mattering, which was the goal all along. If you are choosing for a new team, List* l with one declaration per line is the most common modern C++ style, and the trap can't happen with it.

And if Go's pointer declarations have ever looked backwards to you, coming from C, they aren't backwards. They are the design that ended this debate.

Check yourself

3 questions · nothing is saved
  1. 1.Writing List *l follows the idea "declaration mirrors use". What does the declaration say?
  2. 2.What rule lets the List* l style avoid the two-pointer trap?
  3. 3.How did Go end the debate?

Who wrote this

Author profile and background

Takumi Yamada

Takumi Yamada

· Backend Engineer

Backend engineer building services, databases, Linux tooling, and NEGEN SYSTEMS. Writing about low-level mechanics, distributed systems, and real-world security.

End of post
NEGEN SYSTEMS
Receipt · post 16 of 31
Written
Apr 3, 2026
Length
1,664 words · 8 min
Built
…
Served by
…
Delivered
…
Over the wire
…
Go's share
…
Next in Programming Languages 101 · part 5 of 6

From C++ to Go: Demystifying Pointers, Slices, and Errors

Go code looks like C++, but the ideas behind it are different. Three things I had to learn again while building a todo app in Go: errors are values, a slice is a small header that points at the data, and the asterisk does two jobs.

6 min read
From other series