[racket] abstracting over codeblock

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Sep 8 21:28:22 EDT 2011

I think Eli may have meant 'racket' when he wrote 'codeblock'.
codeblock operates on strings.

And the @[]{} stuff is really just read-level manipulations. It isn't
anything about expressions and whatnot.

Robby

On Thu, Sep 8, 2011 at 8:22 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> Thanks: that makes sense.  But in that case, setting aside the
> abstraction issue for a moment, could you explain why
>
> @codeblock{
>           (define (f x) (x "three"))
>           }
>
> works as expected -- it colors the sub-parts as the appropriate
> syntactic categories, not all as string -- but
>
> @codeblock[
>           (define (f x) (x "three"))
>           ]
>
> does not:
>
>  define: not allowed in an expression context in: (define (f x) (x
>  "three"))
>
> ?  That doesn't quite match my understanding of "`codeblock' expects
> code, and it's a macro that does the quoting itself".
>
> I did see in the Scribble docs the difference between {} and [], but
> now the interaction between macros (which work top-down) and
> expressions (which work bottom-up) is not so clear to me.
>
> Also, related to this and going back to the abstraction issue, when I
> type the very thing you suggested:
>
>  @(define-syntax-rule (mycode code ...) (codeblock code ...))
>
>  @mycode[
>   foo
>   bar]
>
> I get:
>
> Welcome to DrRacket, version 5.1.3 [3m].
> Language: scribble/manual; memory limit: 128 MB.
> . expand: unbound identifier in module in: foo
>
> pointing to the foo inside the [brackets], whereas
>
> @mycode{
>   foo
>   (define (f x) (x "three" 1 #\c))
>   bar}
>
> is handled and colored correctly....
>
> Thanks!
>
> Shriram
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



Posted on the users mailing list.