Version 1.7 released


#1

uLisp Version 1.7 adds the pretty printer function pprint, which allows you to print functions in a nicely formatted way, and a trace feature using trace and untrace, allowing you to trace the calls to and returns from up to three functions at a time.

It also fixes a long-standing bug which could give incorrect results when two functions using the same symbols called each other.


#2

Thank you very much for the new release.

I found a different behaviour between version 1.7 and version 1.6.
I defined:
(defvar pns '(13))
(defun out§ (pinmode p 1))
(defun on§ (digitalwrite p t))
(defun off§ (digitalwrite p nil))
(defun d5() (delay 500))
(defun b1 () (mapc out pns) (mapc on pns)(d5)(mapc off pns)(d5)(b1))
(b1)

In version 1.7, I get many “debug” or tracing output like (in version 1.6 no output was given):
1338>
(b1)
1: (nil 13)
2: (nil 13)
3: (nil 13)

I did not set any trace option.
Any suggestions?


#3

Kaef,

Thank you for finding this. I forgot to initialise an array, and in your case the random initial contents caused it to think that you were tracing b1.

The fix is to change the line:

unsigned int TraceFn[tracemax]

to:

unsigned int TraceFn[tracemax] = {0, 0, 0};

Let me know if that works.


#4

I’m not sure but I think I found the source of this issue.
In function tracing() I added this lines at the beginning:
if (name == nil)
return 0;
I didn’t test any tracing with this change.


#5

I tested your suggestion, but the result stays the same. Because TraceFn[] is a global variable the compiler should initialize it with {0, 0, 0}.


#6

Yes, you’re right. In that case I’m baffled. The function tracing() should never be called with name==nil.


#7

JohnsonDavies,

there is another issue with the trace-function.
When turning (trace on) in my example, (b1) did not trace the ‘on function call’. I think this is caused because the function is called by mapc.
Doing (dotimes (x 10) (on 13)) works as it should.
I think we need to test fn_funcall() (or fn_apply()?) for tracing also.

Regards,
Kaef


#8

This is a general feature of Lisp, because funcall, apply, mapc, and mapcar, don’t necessarily know the name of the function supplied to them. The workaround is to do:

(defun b1 () (mapc out pns) (mapc (lambda (x) (on x)) pns)(d5)(mapc off pns)(d5)(b1))


#9

I see, thank you very much.
I have to learn a lot about lisp…


#10

No, what you were expecting is quite reasonable. I will try and come up with a good explanation of why it’s not possible.


#11