4 ms·
What does prevent : to become the assignment operator of a language? It's short, and quite "explicit". x: 2
by roselan 8y ago
What does prevent : to become the assignment operator of a language? It's short, and quite "explicit".
x: 2
- bwbw223 8y agoShift key?
- Izkata 8y agoThe Rebol family of languages works like that.
- 9214 8y agoExcept that it doesn't. ":" in "x:" is not an assignment operator and "x" is not a variable.
- Izkata 8y agoYes yes, it's a set-word! type in the "do" dialect. That's not how it's learned when first starting, though, and not usually the thing you're thinking about when using it moment-to-moment.
- mpweiher 8y agoSelf and Newspeak sort of do it this way, adding implicit self to Smalltalk's keyword syntax and accessor convention. These 'accessors' also work on local variables, there is no special syntax for assignment. So when you write x it means send the message x, which starts its lookup in the local environment and works itself outwards. When you write x:2 it sends the message x: with argument 2, also starting in the local environment. The accessors are automatically generated in pairs for slots. It sorta works, but it seems a bit too convoluted just to say "hey, we can do everything with just messaging".