[racket] Help On User Libraries - The Basics

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Aug 21 18:06:05 EDT 2011

6 hours ago, Ray Racine wrote:
> Fire up my repl with the path to my personal collection and invoke.
> [ray at ray rktlib]$ rlwrap /usr/local/racket/bin/racket -i  -S /code/rktlib

If you're working on a shell it would be better to use readline -- but
since you're using the git head, it's even better to use the new
`xrepl'.  Just add (require xrepl) to your ~/.racketrc, and you'll get
readline and an additional bunch of tools for REPL-use.

> In the old days it seemed I generally got an accurate error line and
> stack trace.  In the above error, I'm pretty sure the error is
> occurring in the "worker" for-each which is not lexically near line
> 194.  The context information is less than helpful in the sense that
> misc.rkt:87 is the repl's invoke and then the next thing I'm given
> is the for-loop error.  All in all a rather thin context to work
> with.

The stack information that you see is imprecise in the sense that
Matthew mentioned, and indeed errortrace compiles code with explicit
annotations so that you get precise information.  (But that comes at a
runtime overhead.)  With DrRacket, you get the extra errortrace
information when you have the debugging option on.

> I've tried to ask racket to provide a full stack trace with things
> like adding '-l errortrace' when invoking racket, but to no avail.
> So next question, how do I compel racket to provide the full call
> stack on errors?

When you add that flag you do get errortrace, but then it's tricky to
get the rest.

  racket -l errortrace

you get no REPL -- need to add a -i flag:

  racket -l errortrace -i

you get a REPL, but it has no useful binding -- you're missing the
language, so add `racket/init' too

  racket -l errortrace -l racket/init -i

which finally works.  Alternative shorter syntax for that:

  racket -lli errortrace racket/init

And if you're using `xrepl', you get a command that turns on
errortrace: ",errt".

(But as Matthew said, all of this depends on compiling code in an
"errortrace mode" so if you precompile your files, you don't get the
extra information.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.