[plt-scheme] Template Forms

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Thu Mar 4 14:38:20 EST 2010

Normally I would make a macro, but I'm not sure if there is anything I need
to do to tie it into the @ syntax. In the little writeup on 'in' it says it
expands to a for/list with a begin/text. I haven't found any documentation
on begin/text though. I should probably should try a similar expansion
myself.

On Thu, Mar 4, 2010 at 2:14 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:

> On Thu, Mar 4, 2010 at 9:45 AM, Doug Williams
> <m.douglas.williams at gmail.com> wrote:
> > The template documentation in Web: PLT Web Applications includes a little
> > blurb about the in special form that wraps a for/list to make it easier
> to
> > use. Are there other helper forms for other binding forms. In particular,
> > are there any that wrap simple let or let-values?
> >
> > A real example from a template that generates Graphviz output:
> >
> > The following uses in and looks nice. It binds the values and generates
> the
> > line for each query result.
> >
> > @in[(action-class-id action-class-label) (in-query `(action-class
> ,rule-id
> > ?id ?label))]{
> > "@|rule-id|":"action-class" -> "@|action-class-id|" [style=dashed];
> > }
> >
> > But, since there should be exactly one result to that query and there is
> a
> > lighter-weight function, query-values, that has more appropriate
> semantics -
> > in particular, it will generate an error if there is not exactly one
> result,
> > I'd rather use let-values than the sequencing form.
> >
> > @let-values[(((action-class-id action-class-label) (query-values
> > `(action-class ,rule-id ?id ?label))))]{
> > @list{
> > "@|rule-id|":"action-class" -> "@|action-class-id|" [style=dashed];
> > }}
> >
> > works just fine, but is rather cumbersome. Is there a better way to write
> > this using @ syntax?
>
> If you limit yourself to one body, you could use a macro like:
>
> (let-values-ish [(a b) expr] ... expr)
>
> You could parse a little more and make
>
> (let-values-ish (a b) expr ... expr)
>
> work. But I haven't written either of these or something like it.
>
> Jay
>
> >
> > Doug
> >
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
> >
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://teammccarthy.org/jay
>
> "The glory of God is Intelligence" - D&C 93
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100304/b221115c/attachment.html>

Posted on the users mailing list.