2 + 2 = 5
Thursday, June 5, 2014
If you run this code:
IN: scratchpad << "\x32" create-in 5/2 define-constant >
IN: scratchpad 2 2 + . 5
As it turns out, a little bit ago I noticed that you can redefine numbers this way and filed a bug to start a conversation about this “feature”.
This exploits the parser, particularly the parse-datum word which searches a token for an already defined word, then if not found, tries to parse it as a number. Usually, we disallow words from being defined by a number using scan-word-name, but that doesn’t prevent you from doing it yourself as in the example above.
CONSTANT: 2+2 5 IN: scratchpad 2+2 . 5