Check out Grant Acedrex, our featured variant for April, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Game Courier History. History of the Chess Variants Game Courier PBM system.[All Comments] [Add Comment or Rating]
🕸💡📝Fergus Duniho wrote on Fri, Dec 11, 2020 02:15 AM UTC:

I previously made the variable prefixes recursive. This allows something like this:

set m Mars;
set p m;
echo ##p;

The expression ##p returns #m, which returns Mars. So, "echo ##p" prints Mars. While helpful, this breaks some code I previously used to check whether a variable has been set. This code no longer works:

set m Mars;
if == #m "#m":
  echo undefined;
else:
  echo #m;
endif;

When m is defined, #m should be its value, which is Mars, and "#m" should be the string "#m". But thanks to recursion of variable prefixes, or so I presume, the string "#m" is converted to #m, which is then converted to the value of m. So, the test == #m "#m" still returns true when m has been defined. This makes it useless for telling whether a variable has been defined.

In its place, you can use the test == var m null. When a variable is undefined, calling it with var instead of a prefix will return null. So, this code works properly:

set m Mars;
if == var m null:
  echo undefined;
else:
  echo #m;
endif;