gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

true and false are not reserved #173

Closed apblack closed 4 years ago

apblack commented 5 years ago

According to the spec, true and false are not reserved words. Is this what we want?

The effect of this is to imply that true and false are defined in the standardGrace dialect, and they could be redefined by a programmer in an inner scope to be something else. They could also be given another meaning in another dialect.

This could even be useful, but I think that it's more likely to be dangerous.

minigrace treats true and false specially, to stop them from being redefined. I did this after seeing students assigning to self. I suspect that the spec should simply say that true and false are amongst the reserved tokens, but wanted to check whether the current situation was intentional or not.

apblack commented 4 years ago

I recall @kjx arguing that true and false are just defined identifiers, and that, in principle, a user could redefine them. Indeed, minigrace takes care to allow user-defined "truthy" and "falsy" values that have the type, and behaviour, of true and false, while (potentially) having other behaviours as well. (See, for example, _t157_truthytest.grace).

If a teaching dialect wants to prohibit re-declaration of true and false, then it can of course do so.

So, I'm going to close this issue: true and false are intentionally not reserved, as it says in the specification.