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

  2015-09-23 12:18, Florent Georges wrote:
> Hi,
> 
> I think {{ ... }} are used quite a lot in other languages,

A search in the 9,600 JavaScript files on my local computer found
  456 >>> (it's a JavaScript operator along with <<< and ===)
    6 ]>> (array reference followed by bitshift operator)
    0 }>>
   27 }> (Josh found this more common on symbolhound)
  213 ]> (e.g. array ref followed by comparison)
   24 "]> (e.g. constructing an MSIE HTML "if" as a string)
1257 }}  (e.g. almost any use of jQuery will contain this)
  213 ]>  (e.g. constructing a CDATA section by string manipulation)
    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.

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 Wednesday, 23 September 2015 18:34:52 UTC