wish: scala2 code expressions syntax in xml to '${<expr>}'

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

wish: scala2 code expressions syntax in xml to '${<expr>}'

griba2010
Now that there is a new big version change ahead (scala2)
I would vote for a change in the syntax for xml embedded code
from actual pair of curly braces
{<expr>}
to the more traditional and widely used in other frameworks, dollar prefixed
${<expr>}
so regular text curly braces, actually "{{<text>}" doubling the open one
could be written as "{<text>}"

Although this is not essential, it would bring some peace of mind to people
that switch often between application frameworks.

Cheers!
Gabriel Riba.





Reply | Threaded
Open this post in threaded view
|

Re: wish: scala2 code expressions syntax in xml to '${<expr>}'

Martin Odersky
Gabriel Riba wrote:
> Now that there is a new big version change ahead (scala2)
> I would vote for a change in the syntax for xml embedded code
> from actual pair of curly braces
> {<expr>}
> to the more traditional and widely used in other frameworks, dollar prefixed
> ${<expr>}
> so regular text curly braces, actually "{{<text>}" doubling the open one
> could be written as "{<text>}"
>
Which frameworks are using ${...}? We modeled our scheme after XQuery,
which also uses simple {...}.

Cheers

  -- Martin
Reply | Threaded
Open this post in threaded view
|

Re: wish: scala2 code expressions syntax in xml to '${<expr>}'

griba2010

"Martin Odersky" <[hidden email]> ha escrit en el missatge dels grups de
discussió:[hidden email]...

> Gabriel Riba wrote:
> > Now that there is a new big version change ahead (scala2)
> > I would vote for a change in the syntax for xml embedded code
> > from actual pair of curly braces
> > {<expr>}
> > to the more traditional and widely used in other frameworks, dollar
prefixed
> > ${<expr>}
> > so regular text curly braces, actually "{{<text>}" doubling the open one
> > could be written as "{<text>}"
> >
> Which frameworks are using ${...}? We modeled our scheme after XQuery,
> which also uses simple {...}.
>

I have realized that the syntax '${' <expr> '}' is used to embed short
expressions  in *ML frameworks that,  like JSP, have other means to include
multiline code

while '{' <expr> '}' seems mainly used in frameworks that want to fit in a
"multiline" code block(s), eg XQuery, Javascript XML extension,

for short expressions '${<expr>}' is more easyly recognized visually within
xml text than '{<expr>}' because of the two character sequence '${'

but probably I am not aware enough of the Scala language and I should leave
it to
the authors.

Here is a list of  some frameworks and their handling of the question.


  JSP. Java Server Pages  uses the ${<expr>} syntax to embed expressions in
html
  http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010522

  LaszloSystems XML component language uses ${<expr>} in attributes
  http://www.laszlosystems.com/lps-3.1.1/docs/guide/constraints.html

  Struts uses the ${<expr>} syntax too.
  http://struts.apache.org/struts-el/struts-el.html

  Java Server Faces uses the number-sign prefixed #{<expr>}
  http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFPage10.html#wp119849
  but may change to a "Unified Expression Language"
  with ${<expr>} for immediate evaluation and #{<expr>} for late eval.
  http://java.sun.com/products/jsp/reference/techart/unifiedEL.html

  Zope Template language uses ${<path>}
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/AppendixC.stx#3-173

  Coldfusion uses #<expr># like in
<CFOUTPUT>#Request.field_name1#</CFOUTPUT>
  http://www.macromedia.com/v1/documents/cf4/AcrobatDocs/40quickref.pdf

--------

  XQuery FLWOR expressions use {<expr>}
  http://www.w3.org/TR/2005/WD-xquery-20050915/#id-flwor-expressions

  Javascript's XML extension (ECMA-357) uses the braces {<expr>} as in Scala
  http://www.ecma-international.org/publications/standards/Ecma-357.htm

  Microsoft XAML uses {<expr>} in attributes
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnintlong/html/longhornch03.asp

  Microsoft Comega will use {<expr>} in XML
  http://research.microsoft.com/Comega/doc/comega_whatis.htm

--------

Cheers!

Gabriel Riba.




Reply | Threaded
Open this post in threaded view
|

Re: wish: scala2 code expressions syntax in xml to '${<expr>}'

Martin Odersky
Gabriel Riba wrote:
>
> I have realized that the syntax '${' <expr> '}' is used to embed short
> expressions  in *ML frameworks that,  like JSP, have other means to include
> multiline code
>
> while '{' <expr> '}' seems mainly used in frameworks that want to fit in a
> "multiline" code block(s), eg XQuery, Javascript XML extension,
>
Thanks for the extensive analysis! It seems both idioms are used widely,
and there are good reasons for either one of them. So it's probably best
for Scala to leave it as it is.

Cheers

  -- Martin