[racket] Scribble: requiring an LP from another LP

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Nov 25 08:41:03 EST 2014

Bits of code in the chunks are separate from the bits of code outside
of the chunks. The parts outside of the chunks are the documentation
for whatever code you're writing so in chapter1.rkt, when you put the
require there you're pulling the definition of atom? into the
documentation part, not the implementation part. You can pull it into
the implementation part by putting the require into the chunk.

Is that what you intended?

Robby


On Mon, Nov 24, 2014 at 10:51 PM, Jacob Mitchell
<jacob.d.mitchell at gmail.com> wrote:
> I'm new to Scribble and I'm running into some problems splitting my literate
> program across multiple files.
>
> The documentation says an rkt file with a "#lang scribble/lp" can be
> required from another Racket program like any other rkt file. That works
> fine, but requiring one scribble/lp from another doesn't seem to work. In
> particular, functions defined in the dependent scribble/lp aren't available
> to @chunks in the referencing scribble/lp, even when they're explicitly
> exposed via (provide ...).
>
> To clarify, here's an example involving a few files placed in the same
> directory.
>
>
>> ;; FILE: main.scrbl
>> #lang scribble/base
>> @require[scribble/lp-include]
>> @lp-include["prelude.rkt"]
>> @lp-include["chapter1.rkt"]
>>
>>
>>
>>
>>
>> ;; FILE: prelude.rkt
>> #lang scribble/lp
>> @chunk[<prelude>
>> (provide atom?)
>> (define atom?
>>   (lambda (x)
>>     (and (not (pair? x)) (not (null? x)))))]
>>
>>
>>
>> ;; FILE: chapter1.rkt (fails to access the Prelude's definition of
>> "atom?")
>> #lang scribble/lp
>> @require["prelude.rkt"]
>> @chunk[<atom?-test>
>> (define atom-test (atom? 1))]
>>
>>
>>
>> ;; FILE: prelude-lib-test.rkt (successfully accesses "atom?")
>> #lang racket
>> (require "prelude.rkt")
>>
>>
>>
>> (define atom-test (atom? 1))
>
>
> In prelude-lib-test.rkt atom-test evaluates to #t as expected. However, when
> I try to evaluate atom-test from chapter1.rkt I'm met with this error:
>
>> atom-test: undefined;
>>  cannot reference an identifier before its definition
>
>
> Is there something else I should try, or is requiring LPs from LPs like this
> not currently supported?
>
> Cheers,
> Jake
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

Posted on the users mailing list.