<div dir="ltr">Hi Hannes,<div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 27, 2017 at 10:58 AM, H. Hirzel <span dir="ltr"><<a href="mailto:hannes.hirzel@gmail.com" target="_blank">hannes.hirzel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="gmail-">On 2/27/17, DavidLeibs <<a href="mailto:david.leibs@gmail.com">david.leibs@gmail.com</a>> wrote:<br>
> I realize this is a few years old but I wanted to give an update on my<br>
> quest<br>
> for quasi-literals.  I did a complete quasi-literal framework for Java when<br>
> I moved over to Oracle Labs.  It used the annotation compiler + a few<br>
> tweeks<br>
> to the scanner and parser.  You could extend the name space of the<br>
> quasi-literal and have inline SQL or APL.  All the parsing, validation, and<br>
> code rewriting happened at compile time. We proposed it to the Java Product<br>
> guys and got ignored to death.<br>
><br>
> As to the characters I did backquote for simple quasi-literal Strings and<br>
> used Oxford Brackets for the quasi-literals with a language namespace. <|<br>
> ...|>.  Back quote can be hard to see but is nice for String substitute.<br>
><br>
> At this point in time the language that does it most right is JavaScript.<br>
> Thanks Mark Miller for all the hard work over the years!<br>
<br>
</span>Thanks David for following up this discussion.<br>
<br>
I wonder if just going for JavaScript ES6 solution (back-ticks) would<br>
be the most straightforward thing to do?<br></blockquote><div><br></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px"> I did a quick hack in Squeak but didn't have time to finish is.  I wrote some tests.  Complex cases worked, small tricky cases broke the scanner.</div><div style="color:rgb(0,0,0);font-size:12.800000190734863px"><br></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px"><div>MCHttpRepository</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>location: '<a href="http://source.squeak.org/inbox" target="_blank">http://source.squeak.org/<wbr>inbox</a>'</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>user: ''</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>password: ''</div></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px"><br></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px">Compiler.quasiliteral-eem.280<br></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px"><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>[Derived from Compiler-nice.279, and renamed from</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">     </span> the bogusly named Compiler.quasiquote-eem.248]</div><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>Add a quasi-literal form for "string interpolation", that allows</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>convenient embedding of expressions within a format string,</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>and provides a convenient way of embedding literal strings</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>within an alternative literal string syntax whose string delimiter</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>is different.</div><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>e.g.</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">          </span>`hello [#cruel] world!`</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">       </span>evaluates to</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">          </span>'hello cruel world'.</div><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">         </span>`S1[B1]...SN[BN]SN+1`</div><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>is equivalent to</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">              </span>{ 'S1'. [B1] value. ... 'SN'. [BN] value. 'SN+1' } concatenateQuasiLiteral</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>where concatenateQuasiLiteral sends asString to each</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>element and answers the concatenation of those elements.</div><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>however, single-statement blocks are inlined, so e.g. the</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>above `hello [#cruel] world!` is compiled as</div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">          </span>{ 'hello '. #cruel. ' world!' } concatenateQuasiLiteral</div><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>See e.g. Tests.quasiliteral-eem.296 for tests and examples.</div></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px"><br></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px">Tests.quasiliteral-eem.296<br></div><div style="color:rgb(0,0,0);font-size:12.800000190734863px"><div><br></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>Renamed from the bogus quasiquote to quasiliteral.</div></div><div><span class="gmail-m_-4965549046425065128gmail-Apple-tab-span" style="color:rgb(0,0,0);font-size:12.800000190734863px;white-space:pre-wrap">        </span><span style="color:rgb(0,0,0);font-size:12.800000190734863px">Added Balazs' errors as failing tests.</span> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
--Hannes<br>
<br>
<br>
<a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals" rel="noreferrer" target="_blank">https://developer.mozilla.org/<wbr>en/docs/Web/JavaScript/<wbr>Reference/Template_literals</a><br>
<br>
Syntax<br>
----------<br>
<br>
`string text`<br>
<br>
`string text line 1<br>
 string text line 2`<br>
<br>
`string text ${expression} string text`<br>
<br>
tag `string text ${expression} string text`<br>
<br>
<br>
Description<br>
----------------<br>
<br>
Template literals are enclosed by the back-tick (` `) (grave accent)<br>
character instead of double or single quotes. Template literals can<br>
contain place holders. These are indicated by the Dollar sign and<br>
curly braces (${expression}). The expressions in the place holders and<br>
the text between them get passed to a function. The default function<br>
just concatenates the parts into a single string. If there is an<br>
expression preceding the template literal (tag here),  the template<br>
string is called "tagged template literal". In that case, the tag<br>
expression (usually a function) gets called with the processed<br>
template literal, which you can then manipulate before outputting. To<br>
escape a back-tick in a template literal, put a backslash \ before the<br>
back-tick.<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>