Preserving the entered integer format


#1

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.


#2

Is the performance penalty to pprintall only or to the whole system? If it’s pprintall only I’d say do it, but I don’t think its worth it if it slows down other stuff


#3

It’s a penalty to the whole system. Here are the differences between the latest ARM version and the test version:

Version GC tak q2
4.8c 1.3 ms 11.5 s 25.4 s
4.8 test 1.3 ms 11.6 s 25.7 s

David