One nice feature about uLisp is that you can list the functions you have defined, such as by using (pprintall). However, when you read in a function, the number base you used for representing an integer is lost.
For example, if you define:
(defun nibbles (word)
(list
(ash (logand word #xf000) -12)
(ash (logand word #x0f00) -8)
(ash (logand word #x00f0) -4)
(logand word #x000f)))
it’s pretty clear that this is a function to split a 16-bit number into a list of 4-bit nibbles:
> (nibbles #x1234)
(1 2 3 4)
However, if you list it using (pprintall) this meaning’s lost:
(defun nibbles (word)
(list
(ash (logand word 61440) -12)
(ash (logand word 3840) -8)
(ash (logand word 240) -4)
(logand word 15)))
This has slightly bugged me since the original version of uLisp, and I’ve now thought of a solution to it, but there would be a (slight) performance penalty.
Has anyone else noticed this, and would it be a worthwhile improvement?
Note that I wouldn’t attempt to preserve the format of other constants, such as floating-point numbers.