[racket] Help On User Libraries - The Basics

From: Ray Racine (ray.racine at gmail.com)
Date: Sun Aug 21 12:23:44 EDT 2011


I've been using Racket on and off for years and am currently in an 'on'
period.  Whenever I come back, I seem to hit it seems I hit same conceptual
brick walls.   Here is one of them: How does one create and use a simple,
basic, User Library / Collection?

For the current conversation, for now, assume the following context: 1)
Using racket at the command-line (i.e., no DrRacket) 2) No Planet. 3) Fresh
as of this morning built Racket from HEAD on Linux 4) Typed Racket

The goal is to write a few common utility / library code that I frequently
reuse in various projects.

First question, are "collections" the way to do this?

Assuming yes, I create a personal "rktlib" collection root and populate it
with a collection "c1" which has a subcollection "sc1".

$ mkdir -p /code/rktlib/c1/sc1

In c1/ I create top.rkt
#lang typed/racket/base
(provide hello)
(require "sc1/there.rkt")
(define (hello)
  (printf "Hello ~a\n" (there)))

In c1/sc1/
#lang typed/racket/base
(provide there)
(define (there) "there")

And finally in c1/ create an info
#lang setup/infotab
(define name "c1")

Again, for now, lets put aside the 57 varieties of 'require'.

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
Welcome to Racket v5.1.3.3.
> (require c1/top)
> (hello)
Hello there

Works, so now compile it to zos.

[ray at ray rktlib]$ rlwrap /usr/local/racket/bin/racket -i  -S /code/rktlib
Welcome to Racket v5.1.3.3.
> (require compiler/compiler)
> (compile-collection-zos "c1")
for-each: expects type <proper list> as 2nd argument, given: #<void>; other
arguments were: #<procedure:.../compiler/cm.rkt:594:4>

 === context ===
/usr/local/racket/collects/compiler/compiler-unit.rkt:199:13: for-loop

Next question, what am I doing wrong?

Important!!! - the above error line of 199 is off from the github HEAD code
as I've added a few printfs in compiler-unit.rkt elided above.  I think the
original line was #194 in compiler-unit.rkt.

Which branches out into another one of those brick walls.   Errors and how
to deal with them.

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.

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?

Thanks in advance,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110821/2f458c0f/attachment.html>

Posted on the users mailing list.