Chris's Wiki :: blog/programming/EximObservation Commentshttps://utcc.utoronto.ca/~cks/space/blog/programming/EximObservation?atomcommentsDWiki2006-11-03T01:55:22ZRecent comments in Chris's Wiki :: blog/programming/EximObservation.By Chris Siebenmann on /blog/programming/EximObservationtag:CSpace:blog/programming/EximObservation:2327568a2fd73a72fc09de1391eed6007ce8d26bChris Siebenmann<div class="wikitext"><p>I thought I had some thoughts on Lispy Exim string expansions, but as I
started to write them down I found that they were less coherent than I
thought. I think that you need to keep <code>$</code> expansion for the sake of
sanity, so you wind up with expansions that looks like:</p>
<blockquote><p><code>${if {or {> 10 $var1} {< 20 $var2}} {long $var2 string} fail}</code></p>
</blockquote>
<p>and</p>
<blockquote><p><code>${lookup $username lsearch /etc/usermap $value $username}</code></p>
</blockquote>
<p>Words (except for a few special ones, like <code>fail</code>) are implicitly quoted
unless they occur in a special situation; you need to wrap stuff in
<code>{...}</code> only if it has spaces.</p>
<p>A certain amount of my cringe reaction at Exim's string expansions is
cultural; I think they would look much nicer if they had more
whitespace, but people apparently don't use whitespace very much even
when they could.</p>
</div>2006-11-03T01:55:22ZBy DanielMartin on /blog/programming/EximObservationtag:CSpace:blog/programming/EximObservation:a73c894ac29049daf8967f65c7f6b2c6827bcc8fDanielMartin<div class="wikitext"><p>Looking at exim's string expansion syntax, my first reaction is that it's the product of evolution, rather than out-and-out deliberate design.</p>
<p>(Well, no, my first reaction is "Oh yeah, I remember this" followed closely by "yeah, it sucked")</p>
<p>So... suppose you were going to design a lisp and were disguising it as a string expansion syntax. What might you do?</p>
<p>First off, I'd make it a lisp-1 (à la scheme) because I think lisp-<em>n</em>s where <em>n</em> > 1 are insane. Then, I'd replace <code>()</code> with <code>{}</code> and <code>,</code> with <code>$</code>. All other special characters (noteably <code>'</code>) would remain unchanged. The <code>,@</code> syntax would become <code>$@</code>.</p>
<p>Then, I'd transform any string that was to be expanded into a quasi-quote expression that's best illustrated by example:</p>
<p>Original: <code>myExpandedVar = blah blah $foo blah</code> <br>
Quasiquoted internal representation: <code>(set! myExpandedVar (apply 'string-concat `("blah blah " ,foo " blah)))</code></p>
<p>Original: <code>myExpandedVar = blah blah ${lookup 'table1 username} blah</code> <br>
Quasiquoted internal representation: <code>(set! myExpandedVar (apply 'string-concat `("blah blah " ,(lookup 'table1 username) " blah)))</code></p>
<p>Original: <code>myExpandedVar = blah blah ${foo 'table1 {or user from envelope-from}} blah</code> <br>
Quasiquoted internal representation: you can probably guess this by now</p>
<p>Hrm. As I get into more complicated expressions, the lisp-nature becomes less and less hidden. Perhaps this is a sign that more sepcialized functions need to be defined.</p>
</div>2006-11-01T12:23:57Z