My first stab at this problem was in C
#define 2 5
assert(2+2 == 10);
Unfortunately
error: macro name must be an identifier
I also tried Scheme
(define 2 5)
but
can't define a non-symbol: (define 2 5)
I was wondering if there are any programming languages where this is possible.
I sincerely hope not.
But that said, I do know of a way in Java: you can use reflection to adjust the values of the cached boxed
Integer
s: a JVM must cache all values in the range -128 to +127, and there does exist a mechanism to adjust the numeric values in that cache!See https://codegolf.stackexchange.com/questions/28786/write-a-program-that-makes-2-2-5/28818#28818 for more details. Here's the code in full:
The output is 5, essentially achieved by redefining the number 4.