<div dir="ltr"><div><div><div><div><div>Is this function ever particularly necessary? Its intended use seems to be like so:<br><br></div><div>(define-syntax (for/print stx)<br></div><div> (syntax-parse stx<br></div><div>
[(_ clauses . body)<br></div><div> (with-syntax ([([pre ...] [post ...]) (split-for-body #'body)])<br></div><div> (syntax<br> (for clauses<br></div><div> pre ...<br></div><div> (printf "~v/n" (let () post ...)))))]))<br>
<br></div><div>That way any #:break or #:final from the body ends up in pre ..., where the enclosing for loop will interpret them, and post ... will only include normal definitions and expressions.<br><br></div><div>But it seems to me there's a much easier way that should always work:<br>
</div><div><br></div>(define-syntax-rule (for/print clauses pre ... result)<br></div> (for clauses<br></div> pre ...<br></div> (printf "~v\n" result)))<br><br></div><div>This not only puts all #:break and #:final clauses in pre ..., it should guarantee result is an expression. Perhaps one should still write (let () result) in case result is (begin defn expr), but that's still simpler than using split-for-body.<br>
<br></div><div>My question is -- have I overlooked some clever subtlety here that makes split-for-body necessary, or is it usually easier to just decompose pre ... result rather than bothering with split-for-body?<br></div>
<div><div><div><div><div><div><div><br clear="all"><div>Carl Eastlund</div>
</div></div></div></div></div></div></div></div>