Proposal: Embedded Expressions for String Statements

rssh at gradsoft.com.ua rssh at gradsoft.com.ua
Fri Mar 20 14:32:53 PDT 2009


> funny, i just joined the list specifically to ask about this subject.
>
> why not just copy the groovy implementation of this?   $var or
> ${expresion} ?
> in groovy it would be:
> "[$field1, $field2, $field3]"
>
> or with the explicit expression syntax:
> "[${field1}, ${field2}, ${field3}]"
>
>

 Hmm, this broke, for example, near all tests of implementation of any
scripting language with special meaning of '$'.

 So, to be not dangerous for old code, string with embedded expressions
enabled  must be prefixed by special symbol ('@' ?)


> I hate escape characters :)
>
>
> On Thu, Mar 19, 2009 at 2:03 AM, Schulz, Stefan <schulz at e-spirit.de>
> wrote:
>> The concat-variant to me is even worse readable than the original
>> +-notation, having three consecutive commas in between.
>> The proposal already mentions concatenation of any kind as alternative,
>> although not mentioning concat(). Maybe worth expanding.
>>
>> Stefan
>>
>>> -----Original Message-----
>>> From: rssh at gradsoft.com.ua [mailto:rssh at gradsoft.com.ua]
>>> Sent: Wednesday, March 18, 2009 8:58 PM
>>> To: Howard Lovatt
>>> Cc: coin-dev at openjdk.java.net; Schulz, Stefan
>>> Subject: Re: Proposal: Embedded Expressions for String Statements
>>>
>>> > I like Stefan's proposed syntax and as a way of a motivating example
>>> > consider writing a toString method that gives the field
>>> values within
>>> > square brackets, now you would write:
>>> >
>>> > ═ ═ "[" + field1 + ", " + field2 + ", " + field3 + "]"
>>> >
>>> > With the proposal you would say:
>>> >
>>> > ═ ═ "[\{field1}, \{field2}, \{field3}]"
>>> >
>>> > Which I find clearer.
>>> >
>>>
>>> Just note: now we can use much cleaner
>>> ═concat( field1, ',' , field2, ',' field3 )
>>>
>>>
>>>
>>> > Many thanks to Stefan for writing this up formally.
>>> >
>>> >
>>>
>>>
>>>
>>>
>>
>>
>
>





More information about the coin-dev mailing list