Re: Delimiters for String Templates (the ultimate Bike Shed!)

On 2015-09-23 14:34, Liam Quin wrote:
> [...]

Michael Dyck pointed out that the start-interpolation string must also 
not be one that occurs often in the wild.

> A search in the 9,600 JavaScript files on my local computer found
>  456 >>> (it's a JavaScript operator along with <<< and ===)
<<< 12 matches

>    6 ]>> (array reference followed by bitshift operator)
<<[ 1 match (in a syntax highlighter, unlikely to be a problem)

>    0 }>>
<<{ 1 match, in a URL

>   27 }> (Josh found this more common on symbolhound)
<{ 12 matches - if we were continuing to work on XQuery I'd want to 
reserve
    <{...}...> for e.g. Clark Notation, or for computed element names.

>  213 ]> (e.g. array ref followed by comparison)
<[ 190 matches

>   24 "]> (e.g. constructing an MSIE HTML "if" as a string)
<[" had zero matches for me in JavaScript

> 1257 }}  (e.g. almost any use of jQuery will contain this)
{{ 91 matches (+ 1 more in a JSON file) but I really don't think {{...}} 
will fly.

>  213 ]>  (e.g. constructing a CDATA section by string manipulation)
(this was an accidental duplicate; <[ had 190 matchinf JavaScript files)

>    0 }@@
>    0 ]@@
>         Josh found 7 @@{ results on symbolhound; four of these
>         were mail messages from someone writing a preprocessor that
>         used @@{....}; looks like it's playframework.org, which is
>         the subject of the other 3 matches on symbolhound.
>         There were no matches for }@@ or ]@@ which is what matters for 
> us.

@@{ 0
@@[ 0

Liam

> So of the ones "not likely to be included accidentally",
> 
> @@{...]@@ and @@{...}@@ passes the "highly visible" test.
> 
> <<[...]>> and <<{....}>> fail "highly visible" in an XQuery context
> but might be OK in the middle of Jav
> aScript and JSON and CSS.
> 
> {{...}} won't fly at all, neither will <[...]>
> 
> The importance of "highly visible" is increased if you take e.g. 200
> lines of CSS with substitution, immediately followed by another 100
> lines of CSS with substitution, followed by 300 lines of JSON, and
> want to check the boundaries between them. It's not important with the
> one to three line examples we've been using on the list, but you could
> use concat() just as well for those.
> 
> I could live with either <<[...]>> <<{...}>> or @@.
> 
> A possible advantage of << is that Perl (and bash) uses it:
> 
> my $css = <<EOF;
>    @page normal {
>      width: 11in;
>    }
> EOF
> 
> (where EOF is any word, single-quoted to inhibit interpolation).
> 
> Liam

-- 
Liam Quin, W3C
XML Activity Lead;
Digital publishing; HTML Accessibility

Received on Saturday, 26 September 2015 22:26:18 UTC