3 ms·
Since we're working on Lisp internals, we can accept a few parentheses. The code has two asterisks, both in parameter declarations, indicating pointers. It ha
by kazinator 8y ago
Since we're working on Lisp internals, we can accept a few parentheses.
The code has two asterisks, both in parameter declarations, indicating pointers.
It has exactly one binary operator in the body, the assignment = denoting the one local side effect (stepping the iteration variable of the simple for (;;) loop).
All else is simple function calls. Except for the function pointer declaration, and perhaps not knowing car and cdr, an Awk or JS programmer might grok this.
The program doesn't abort; the exception was caught in the REPL. We were thrown right out of the GNU Debugger where we caused the problem, and back into the Lisp REPL. We can demonstrate that in other ways, like this:
(gdb) r
Starting program: /home/kaz/txr/txr-dbg
This is the TXR Lisp interactive listener of TXR 215.
Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
1> (catch (raise sig-trap) (error (x) (put-line `caught error: @x`)))
Program received signal SIGTRAP, Trace/breakpoint trap.
0x00132416 in __kernel_vsyscall ()
(gdb) p car(9)
caught error: car: 2 is not a cons
t
2> (+ 2 2)
4
3> _
gdb gets confused here, though:
3> (exit 0)
[Inferior 1 (process 8529) exited normally]
The program being debugged exited while in a function called from GDB.
Evaluation of the expression containing the function
(car) will be abandoned.
Quite understandably, it doesn't understand the exception handling and didn't notice that we jumped out; it still thinks we are executing the car function. Oh well!