ALGOL 68 has the nice property that there are no variables/lvalues: There are names that are bound to constant values, and there are values that are addresses. "int x := 5" is shorthand for stack-allocating an int and binding x to its address (so the type of x is "ref int").
-
Show this thread
-
This seems much nicer than lvalues, which are probably much more complicated than most people think. The trouble is that dereferencing everything would be very annoying syntactically. ALGOL 68 solves that by implicitly coercing "ref t" to "t". I don't really like that.
2 replies 0 retweets 0 likesShow this thread -
For example, if you write "f(x)" in C, you know that x is being passed by value. If you write "f(x)" with implicit dereferencing, you can't tell without knowing the types. There are some other potential ambiguities. Is there a better solution to this?
1 reply 0 retweets 0 likesShow this thread -
Replying to @shachaf
Those are the three sane designs: all values constant but there are pointers you can read or write; both constant and mutable values but you can only copy or pass mutable as pointers by taking addresses; and const+mutable+references+pointers.
2 replies 0 retweets 1 like -
Replying to @TimSweeneyEpic @shachaf
Clearly C++ got it wrong, and Algol68-ML-Haskell is semantically cleanest. C’s answer is probably best for the abstraction level of C, but once you get to things like templates or type classes with type deduction, the distinction between “int” and “const int” weighs heavy.
1 reply 0 retweets 2 likes
In a language that’s highly structured, you have to say how “int” and “const int” are distinguished for locals, data structure fields, inferred types, etc. Is it encoded in the type? In the name? In a third place? What happens to covariance? So maybe Algol68 is universally best.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.