Hacker News new | ask | show | jobs
by unrealhoang 529 days ago
that's the beauty of type after name, it's all left to right, even in special-cases of array, references, and the most confusing-contributor to cdecl: functions `func(int)[5]*string`: perfectly clear, just read left to right.
1 comments

What about a Map<int, String>?

You can't really encode a tree structure with only linear semantics (without at least something like s-expressions).

And type declarations are s-exprs.

The advantage of type after name is that it keeps the traversing order consistently pre-order (node, left, right), instead of either:

- the notoriously ridiculous spiral cdecl: reading stuff right (output), node (func name) and left (input)

- create a new name to describe the function in pre-order: Func<Input, Output>

But you can't know how many parameters do a user-defined "node" have. I don't see how it can work for generic data structures without a specific syntax for "the children of this node". Go also uses [] for generics, doesn't it?

At that point I find a uniform system (without special-casing arrays and pointers - they are also just types) would be simpler.