News for hackers. Stuff that matters.
Re:Types Are Moving to the Right by jstimpfle on Saturday March 16, 2019 @06:45PM (#19410871)
That's why C is usually parsed with a symbol table, which is the way it was meant to be parsed. When parsing "foo * bar;", then it should be clear after parsing "foo" whether the statement is a variable declaration or an expression syntax. (It's a variable declaration if "foo" is registered as a type in the symbol table).

The advantage of this style is that types align nicely to the left and no additional keywords (like let) are required. The disadvantage is that parsing becomes highly contextual. We can't start with parsing somewhere in the middle of a file.

Re:Types Are Moving to the Right by millstone on Sunday March 17, 2019 @02:55AM (#19412618)
Mostly it just seems silly to use * for both pointers and arithmetic. We're not hurting for sigils even in ASCII.
Re:Types Are Moving to the Right by jstimpfle on Sunday March 17, 2019 @11:35AM (#19414521)
In C, for example dollar-sign and at-sign are unused and could be used for pointers. But I don't like those. Both are visually clunky characters.

Personally I like how it is in Pascal - caret sign for pointer types, and postfix unary operator caret for dereference, like^.this which doesn't need an additional syntax ( like->this is just (* like).this in C). But now, caret is usually also the XOR operator.

The deeper problem is that Pascal cannot use caret as XOR binary operator since postfix operators cannot easily be distinguished from binary operators with only 1 token lookahead - it would require more lookahead or type resolution to determine that it's not a binary operator. While in C the deref operator is a prefix which can be distinguished from binary operators without lookahead.

Re:Types Are Moving to the Right by thedufer on Saturday March 16, 2019 @10:55PM (#19411925)
That seems insufficient - what if foo is both a type and a variable?
Re:Types Are Moving to the Right by colanderman on Saturday March 16, 2019 @11:13PM (#19411995)
It can't be.

(Additionally, in C++, where `struct/enum/class foo` can be shortened to `foo`, the variable interpretation is always preferred.)