Errors resulting from number/string confusion are extremely difficult to debug due to several factors:
- TLisp doesn't have typed variables.
- The console displays strings without quotes wherever possible, making them difficult to distinguish from other data types.
- Some functions automatically convert string arguments to numbers, others return errors (which may be swallowed by their callers), and others have unpredictable behavior.
- Even with recent improvements, the function help doesn't specify the types of arguments and return values for most functions.
I think the simplest solution that would address most of the problem is for all functions that require numerical arguments to use a single helper function to convert strings if possible, and return an error if a string isn't a well-formatted number.
Here's some of the faulty code that prompted this. Why the block is never evaluated is left as an exercise for the reader:
(if (and (setq range (xmlGetAttrib theXML 'maxRadius)) (gr range 0) ) (block ...) )