<br>2012/5/11 Ray Racine <span dir="ltr"><<a href="mailto:ray.racine@gmail.com" target="_blank">ray.racine@gmail.com</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Give '{' yada '}' definable language semantics in the sense of #lang yada.</div><div><br></div><div>Similar to SML-NJ Quote/Antiquote but leveraging Rackets more robust built-in language support.</div>
<div><br></div><div>So a source file could be.</div><div><br></div><div>==========</div><div>#lang racket</div><div>#lang {{ formula }}</div><div><br></div><div>(define x 3)</div><div>(define y 2)</div><div><br></div><div>
(define z {{ log (x + y) }}) </div><div><br></div><div>#lang {{ datalog }} ;; switch datalog language</div><div><br></div><div>(define result {{</div><div><table cellspacing="0" style="font-family:serif">
<tbody><tr><td style="padding-left:0px;padding-right:0px;vertical-align:baseline"><font face="arial, helvetica, sans-serif"><span></span><span> ancestor</span><span style="color:rgb(132,60,36)">(</span><span>A</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>B</span><span style="color:rgb(132,60,36)">)</span><span></span><span> </span><span></span><span style="color:rgb(132,60,36)">:-</span><span></span><span> </span><span></span><span>parent</span><span style="color:rgb(132,60,36)">(</span><span>A</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>B</span><span style="color:rgb(132,60,36)">)</span><span style="color:rgb(132,60,36)">.</span><span></span></font></td>
</tr><tr><td style="padding-left:0px;padding-right:0px;vertical-align:baseline"><font face="arial, helvetica, sans-serif"><span></span><span> ancestor</span><span style="color:rgb(132,60,36)">(</span><span>A</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>B</span><span style="color:rgb(132,60,36)">)</span><span></span><span> </span><span></span><span style="color:rgb(132,60,36)">:-</span><span></span></font></td>
</tr><tr><td style="padding-left:0px;padding-right:0px;vertical-align:baseline"><font face="arial, helvetica, sans-serif"><span></span><span> </span><span></span><span>parent</span><span style="color:rgb(132,60,36)">(</span><span>A</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>C</span><span style="color:rgb(132,60,36)">)</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>D</span><span></span><span> </span><span></span><span style="color:rgb(132,60,36)">=</span><span></span><span> </span><span></span><span>C</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>ancestor</span><span style="color:rgb(132,60,36)">(</span><span>D</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>B</span><span style="color:rgb(132,60,36)">)</span><span style="color:rgb(132,60,36)">.</span><span></span></font></td>
</tr><tr><td style="padding-left:0px;padding-right:0px;vertical-align:baseline"><font face="arial, helvetica, sans-serif"><span></span><span> parent</span><span style="color:rgb(132,60,36)">(</span><span>john</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>douglas</span><span style="color:rgb(132,60,36)">)</span><span style="color:rgb(132,60,36)">.</span><span></span></font></td>
</tr><tr><td style="padding-left:0px;padding-right:0px;vertical-align:baseline"><font face="arial, helvetica, sans-serif"><span></span><span> parent</span><span style="color:rgb(132,60,36)">(</span><span>bob</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>john</span><span style="color:rgb(132,60,36)">)</span><span style="color:rgb(132,60,36)">.</span><span></span></font></td>
</tr><tr><td style="padding-left:0px;padding-right:0px;vertical-align:baseline"><font face="arial, helvetica, sans-serif"><span></span><span> ancestor</span><span style="color:rgb(132,60,36)">(</span><span>A</span><span style="color:rgb(132,60,36)">,</span><span></span><span> </span><span></span><span>B</span><span style="color:rgb(132,60,36)">)</span><span style="color:rgb(132,60,36)">?<br>
</span></font><span style="background-color:transparent">}} )<br><br>#lang {{ formula }} ;; back to math formula<br><br>(define ans (some-procedure result {{ z^2 + 42 }}))</span></td></tr></tbody></table></div><div>=======</div>
<div><br></div><div>just works.</div><div><br></div></blockquote><div><br></div><div>Ooh. Nice idea.</div><div><br></div><div>-- </div><div>Jens Axel</div><div> </div></div>