[plt-scheme] Template Forms

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Thu Mar 4 11:45:45 EST 2010

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))))]{
"@|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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100304/5d866256/attachment.html>

Posted on the users mailing list.