[racket] using scribble/eval in conjunction with scribble/lp

From: Joel McCracken (mccracken.joel at gmail.com)
Date: Sun Dec 14 16:59:54 EST 2014

I have tried a few different things. In you case, I think adding a:

    @chunk[ <foo> (provide f)]

... will make lp-test work.

I'm still can't get lp.rkt to become self-referential, though.



On Sun, Dec 14, 2014 at 4:46 PM, Benjamin Greenman <blg59 at cornell.edu> wrote:
> I tried and failed to figure this out. In particular, when I create the
> example "lp.rkt" file described at the top of the scribble/lp docs and
> require it "in the normal manner", the identifier f is unbound for me.
>
> The code I'm using is pasted below:
>
> ;; lp.rkt
> #lang scribble/lp
>
> Literate programs have chunks of code, like this one:
>
> @chunk[<f>
>        (define (f x)
>          <fs-body>)]
>
> and this one:
>
> @chunk[<fs-body>
>        (* x x)]
>
> that, when assembled, produce a complete program, in this case:
>
> @racketblock[(define (f x)
>                (* x x))]
>
> -----
>
> ;; lp-test.rkt
> #lang racket
> (require "lp.rkt")
> (f 3) ;; Error!
>
>
>
> On Sun, Dec 14, 2014 at 2:24 AM, Joel McCracken <mccracken.joel at gmail.com>
> wrote:
>>
>> I'm trying to create a document that includes code, describes that
>> code, includes example usage, and exports some of the bindings so that
>> it may be included later.
>>
>> I've been looking at the scribble documentation, and it seems like all
>> this should be possible. I can't seem to figure out how to actually
>> run examples. Here's what I have:
>>
>> #lang scribble/lp
>>
>> @(require scribble/eval)
>>
>> This would be a wonderful way to accomplish things!
>>
>> @chunk[*
>>         (define (f x)
>>           <f-body>)]
>>
>> @chunk[<f-body>
>>         (* x x)]
>>
>>
>> And then, I could show an example:
>>
>> @examples[
>>         (f 10)
>> ]
>>
>>
>> Any advice would be really appreciated.
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users

Posted on the users mailing list.