Triple quoted strings

Nathan de Vries nathan at atnan.com
Wed Mar 5 23:17:25 PST 2008


On Thu, 2008-03-06 at 00:14 +0000, Peter Hall wrote:
> Except that it would have a few unexpected behaviours, especially
> around the & and < characters.

What would those unexpected behaviours be? Here document syntax is
available (and relatively standard) in UNIX shell, PHP, Perl & Ruby.
Python seems to be the only language that has strayed from the
traditional syntax, and I'm not entirely sure why ES4 is planning to
follow suite. 

Some advantages of traditional here document syntax can be seen below
(all Ruby):

  # Standard here document
  foo = <<EOS
  bar
  EOS
  
  # Here document, with stripped leading whitespace
  def foo
    return <<-EOS
      bar
    EOS
  end
  
  # Stacked here documents
  foo(<<DOC1, <<DOC2)
  this string is passed as the first argument
  DOC1
  this string is passed as the second argument
  DOC2

It seems that triple-quoted string literals only seem to cover the first
case.


Cheers,

--
Nathan de Vries
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 1878 bytes
Desc: not available
Url : http://mail.mozilla.org/pipermail/es-discuss/attachments/20080306/8d946045/attachment-0002.bin 


More information about the Es4-discuss mailing list