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").
-
-
It's pretty odd that an lvalue is "a thing with an address" and a pointer is "the address of a thing". They're two views on the same thing but it works surprisingly well. Algol 68 has automatic dereferencing which seems worrying to me, but manual dereferencing gets cumbersome.
-
One thing that e.g. Haskell references can't do is "IORef (a,b) -> IORef a" (struct lvalue field access), which is of course critical in a language like C that cares about memory layout. This IRC conversation a while ago helped clarify things for me: http://slbkbs.org/ski-mercury.txt
- 14 more replies
New conversation -
-
-
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.
-
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.
End of conversation
New conversation -
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.