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.<br>
<br><div class="gmail_quote">On Thu, Mar 4, 2010 at 2:14 PM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Thu, Mar 4, 2010 at 9:45 AM, Doug Williams<br>
<<a href="mailto:m.douglas.williams@gmail.com">m.douglas.williams@gmail.com</a>> wrote:<br>
> The template documentation in Web: PLT Web Applications includes a little<br>
> blurb about the in special form that wraps a for/list to make it easier to<br>
> use. Are there other helper forms for other binding forms. In particular,<br>
> are there any that wrap simple let or let-values?<br>
><br>
> A real example from a template that generates Graphviz output:<br>
><br>
> The following uses in and looks nice. It binds the values and generates the<br>
> line for each query result.<br>
><br>
> @in[(action-class-id action-class-label) (in-query `(action-class ,rule-id<br>
> ?id ?label))]{<br>
> "@|rule-id|":"action-class" -> "@|action-class-id|" [style=dashed];<br>
> }<br>
><br>
> But, since there should be exactly one result to that query and there is a<br>
> lighter-weight function, query-values, that has more appropriate semantics -<br>
> in particular, it will generate an error if there is not exactly one result,<br>
> I'd rather use let-values than the sequencing form.<br>
><br>
> @let-values[(((action-class-id action-class-label) (query-values<br>
> `(action-class ,rule-id ?id ?label))))]{<br>
> @list{<br>
> "@|rule-id|":"action-class" -> "@|action-class-id|" [style=dashed];<br>
> }}<br>
><br>
> works just fine, but is rather cumbersome. Is there a better way to write<br>
> this using @ syntax?<br>
<br>
</div></div>If you limit yourself to one body, you could use a macro like:<br>
<br>
(let-values-ish [(a b) expr] ... expr)<br>
<br>
You could parse a little more and make<br>
<br>
(let-values-ish (a b) expr ... expr)<br>
<br>
work. But I haven't written either of these or something like it.<br>
<br>
Jay<br>
<br>
><br>
> Doug<br>
><br>
> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
Assistant Professor / Brigham Young University<br>
<a href="http://teammccarthy.org/jay" target="_blank">http://teammccarthy.org/jay</a><br>
<br>
"The glory of God is Intelligence" - D&C 93<br>
</font></blockquote></div><br>