[CM] Backtrace in s7

Kjetil Matheussen k.s.matheussen at gmail.com
Sun Oct 5 12:35:27 PDT 2014


Hi Bil and the rest of you,

I've added s7 as an extension language [1] to the 3.0 branch [2]
of the Radium music editor [3].

Some details about it: A small web server running inside Radium
is communicating with an external python script. This python script
functions as a repl for S7 [5]. This method works excellently, since the
repl doesn't have to be restarted if radium crashes, and you don't
have to run radium (which is quite bloated) from inside
emacs (which I'm using as lisp code editor). Right now I'm working
on rewriting all the mouse handling in s7, since the current
code (written in c) needs to be rewritten anyway, and this is simpler
to implement in scheme than in c.

S7 has so far been an excellent scheme implementation for me.
It's impressively fast (even mysteriously impressively fast, at
least for calculating the fibbonacci numbers), the api is dead simple,
and it's simple to embed into other programs. It's a quite perfect
extension language I would say.



But I wonder if it's possible to get a more detailed
backtrace if something goes wrong?

For instance, if I run the following code:
"
(define (d)
  (e))
(define (c)
  (d))
(define (b)
  (c))
(define (a)
  (b))
(a)
"

I get this response:

"
 syntax-error
error message: [
;e: unbound variable
;  /home/kjetil/radium3.0/bin/scheme/mouse/bug.scm[9]
;    "/home/kjetil/radium3.0/bin/scheme/mouse/bug.scm", line 2
;
; d: (e)
; (load "/home/kjetil/radium3.0/bin/scheme/...
"

Which is good, but sometimes not good enough, since I tend
to write a lot of spaghetti-like code.

Ideally, something like this would be nice:

"
;5. e: unbound variable, bug.scm[2]
;4. (d), bug.scm[4]
;3. (c), bug.scm[6]
;2. (b), bug.scm[8]
;1. (a), bug.scm[9]
"

I've looked over the documentation, experimented with code
that catches exceptions and inspecting data that calls "owlet",
but haven't found a way to get the kind of backtrace I want.

Is it possible to get this type of backtrace at all? Or perhaps
there is a different and perhaps better way to debug an s7 program?
I can live without this kind of backtrace though, so it's not
a big problem, and certainly not a show stopper.



I also have a feature request, which might be a lot of work
to implement, but would also be very nice to have. The feature is to give
warnings for undefined variables and functions.

For instance, if you try to evaluate

(define (hello)
   (let ((hello2 9))
     (+ hello2 hello3))

s7 would give a warning if hello3 isn't defined.
Guile has recently gotten this feature, and when
I developed a small software package for guile earlier this year,
it probably saved me a lot of time, since discovering undefined
variables and functions in code during runtime is harder and more
random than getting a message about it during compile time.
I think the lisp language "Shen" also has this feature, and that
in Shen you can turn off the warning by using a special macro,
I think the name might be "extern" or something like that.
(I.e. "(extern hello3)").

Thanks for reading,
-Kjetil


[1] https://github.com/kmatheussen/radium/blob/3.0/api/protos.conf
[2] https://github.com/kmatheussen/radium/tree/3.0
[3] http://users.notam02.no/~kjetism/radium/
[4]
https://github.com/kmatheussen/radium/blob/3.0/embedded_scheme/scheme.cpp
[5] https://github.com/kmatheussen/radium/blob/3.0/bin/scheme/repl.py
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/mailman/private/cmdist/attachments/20141005/fb414c95/attachment.html 


More information about the Cmdist mailing list