Hi,<div><br></div><div>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?</div>
<div><br></div><div>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</div>
<div><br></div><div>The goal is to write a few common utility / library code that I frequently reuse in various projects.</div><div><br></div><div>First question, are "collections" the way to do this?</div><div>
<br></div><div>Assuming yes, I create a personal "rktlib" collection root and populate it with a collection "c1" which has a subcollection "sc1".</div><div><br></div><div>$ mkdir -p /code/rktlib/c1/sc1</div>
<div><br></div><div>In c1/ I create top.rkt</div><div><div>#lang typed/racket/base</div><div>(provide hello)</div><div>(require "sc1/there.rkt")</div><div>(define (hello)</div><div> (printf "Hello ~a\n" (there)))</div>
</div><div><br></div><div>In c1/sc1/ </div><div><div>#lang typed/racket/base</div><div>(provide there)</div><div>(define (there) "there")</div></div><div><br></div><div>And finally in c1/ create an info</div><div>
<div>#lang setup/infotab</div><div>(define name "c1")</div></div><div><br></div><div>Again, for now, lets put aside the 57 varieties of 'require'.</div><div><br></div><div>Fire up my repl with the path to my personal collection and invoke.</div>
<div><div>[ray@ray rktlib]$ rlwrap /usr/local/racket/bin/racket -i -S /code/rktlib</div><div>Welcome to Racket v5.1.3.3.</div><div>> (require c1/top)</div><div>> (hello)</div><div>Hello there</div></div><div><br></div>
<div>Works, so now compile it to zos.</div><div><br></div><div><div>[ray@ray rktlib]$ rlwrap /usr/local/racket/bin/racket -i -S /code/rktlib</div><div>Welcome to Racket v5.1.3.3.</div><div>> (require compiler/compiler)</div>
<div>> (compile-collection-zos "c1")</div><div>for-each: expects type <proper list> as 2nd argument, given: #<void>; other arguments were: #<procedure:.../compiler/cm.rkt:594:4></div><div><br>
</div><div> === context ===</div><div>/usr/local/racket/collects/compiler/compiler-unit.rkt:199:13: for-loop</div><div>/usr/local/racket/collects/racket/private/misc.rkt:87:7</div></div><div><br></div><div>Next question, what am I doing wrong?</div>
<div><br></div><div>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.</div>
<div><br></div><div>Which branches out into another one of those brick walls. Errors and how to deal with them. </div><div><br></div><div>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.</div>
<div><br></div><div>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?</div>
<div><br></div><div>Thanks in advance,</div><div><br></div><div>Ray</div>