Proposal: Embedded Expressions for String Statements (original) (raw)
Stephen Colebourne scolebourne at joda.org
Sun Mar 15 15:03:05 PDT 2009
- Previous message: Proposal: Embedded Expressions for String Statements
- Next message: Proposal: Embedded Expressions for String Statements
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Stefan Schulz wrote:
SIMPLE EXAMPLE: String name = "Dave"; System.out.println("Hello, {name}!");
It shoud be noted that Groovy uses
"Hello, ${name}!"
and Fan uses
"Hello, $name!"
For Java, I'd always thought of going down the route of:
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">"</mi><mi>H</mi><mi>e</mi><mi>l</mi><mi>l</mi><mi>o</mi><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">"Hello, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">"</span><span class="mord mathnormal">He</span><span class="mord mathnormal" style="margin-right:0.01968em;">ll</span><span class="mord mathnormal">o</span><span class="mpunct">,</span></span></span></span>{name}!"
ie. a $ prefix to the string.
I know why the { notation is used, I ust think that staying in line with other close relative languages is important too.
Jeremy Manson wrote:
I'm sure this is obvious to everyone who isn't me, but I'm not sure what the big win is here. Basically, it looks to me as if you save a very small number of keystrokes:
IMO, its a lot more readable.
Stephen
- Previous message: Proposal: Embedded Expressions for String Statements
- Next message: Proposal: Embedded Expressions for String Statements
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]