New beta 2 release of ARM uLisp for feedback


Common Lisp has a lot of edge cases. For this one, see section Specifically:

If incrementing the index for dimension j caused it to equal dimension j, that index is reset to zero and the index for dimension j-1 is incremented (thereby performing these three steps recursively), unless j=0, in which case the entire algorithm is terminated. If incrementing the index for dimension j did not cause it to equal dimension j, then a space is printed.

If *print-readably* is true , the array prints in an implementation-defined manner; see the variable *print-readably* . In particular, this may be important for arrays having some dimension 0.

The #nA syntax does not support zero-dimensions.


I think I was wise to say that I’m only supporting one or two dimensions (which excludes zero!).


OK, there’s a Beta 5 on GitHub which I hope resolves all the issues with arrays!

One further comment:

(eq #() #()) --> nil
(eq #2A(()) #2A(())) --> nil

You could establish that each of these pairs are the same array by using array-dimensions.


Thanks for the excellent feedback on the array facilities!

Has anyone tried format?


I’m not super hot with the CL format so…
It doesn’t appear that I can left justify numbers nor right justify strings. Is that correct?

Also, I got the following:

{18}30719> (format t "The number is ~-10d" 3.14)
Error: Escape!

I know what the problem is but “Error: Escape!” as the message???


I’ve seen that happen occasionally when I’ve rather mucked up the internals of the interpreter.


I have not used format in about a decade. (I admit, I just print/princ/prin1/terpri my stuff together.) My conclusion is format is working.

Yes, I confirm that fe2o3’s example throws an error (yet works fine not in SBCL), but will be fine if you omit the minus and change it to:

(format t “The number is ~10d” 3.14)

If x is defined, then

(setf x (format nil “The answer is ~a” 42))

really does set x to that value (and I think this is ever going to be its most important function: dumping stuff into a string). And also, if I change nil to t and do:

(setf x (format t “The answer is ~a” 42))

  • then x is actually set to nil. That is what SBCL does, too.

These all throw errors - as they SHOULD:
(format t “~{~a/~a ~}” #(1 2 3 4 5 6))
(format t "alpha ~r " 20)
(format t “~}” '(A))

A trailing tilde is ignored - which is fine, and it is good it does not crash the environment:

(format t “~x~” 16) --> 10

(format t “test ~d” -2.0) --> test -2.0

  • this is what SBCL does, too

(format t “test ~g” -2) --> test -2

  • HERE, however, SBCL gives -2. and not -2, to indicate the floating point nature. (But given you do all in float anyway, e.g. stuff like (/ 2 3) gives 0.6…, I think it doesn’t matter.)

Another thing - which is FINE - apparently boundp tolerates unquoted function names:
(boundp boundp) --> nil (which is correct, but e.g. SBCL throws an error).

All in all, I think format looks solid and is fine.


Oh no, that one is easy to trigger: I think this has to do with the ANSI escape sequences. To generate it, do e.g.: “Esc, q” or “Esc, e” or whatever. Basically when you sort of “mistype” and your terminal has still “trash” on it (that sometimes may be invisible). Happens to me in regular Linux (i.e. nothing to do with uLisp) all the time - I think because touching several keys at once can produce a garbage keystroke.


The built-in symbols evaluate to themselves, which is why the quote is not needed. However, this should be t, not nil. uLisp is a Lisp-1, and there is a value bound to this symbol. Hmm.


Well, yes. It’s supposed to happen when you send an escape down the line. Which the terminal does for … quite a few things.

I’ve left the code in a position where I can consistently make it produce that error on a given input.

And then reset the chip. (Without touching the reset button, mind.)


Thanks for the excellent feedback on format.

As in Common Lisp you can left justify numbers by using the ~a directive:

> (format t "~5a is the answer" 23)
23    is the answer

You can right justify strings by using the ~d directive (which seems counter-intuitive!):

> (format t "~5d is the answer" "Me")
   Me is the answer

That’s odd - on an ATSAMD51 I get:

> (format t "The number is ~-10d" 3.14)
The number is 
    "The number is ~-10d"
Error: 'format' invalid directive

Ah - I can reproduce the behaviour you’re getting if I put a stray tilde into the input field:

> (format t "The number is ~-10d" 3.14)~
Error: escape!

Perhaps that’s what happened?


As @odin says, the built-in symbols evaluate to themselves so no quote is needed. However in uLisp I allow you to redefine the built-in symbols. I think this is useful because a user may create a variable unaware that it’s the same name as a little-used function. You can restore the built-in behaviour by doing makunbound on it - which is possible in uLisp because the built-ins are in read-only memory.


Yeah, probably go some unexpected character in the input buffer.


Version 3.2 of uLisp is now released, so this topic is closed.