What is the view point of the JDK team about string interpolation
arjan tijms
arjan.tijms at gmail.com
Mon Mar 14 10:16:00 UTC 2016
Hi,
On Mon, Mar 14, 2016 at 3:17 AM, Behrang Saeedzadeh <behrangsa at gmail.com>
wrote:
> We already have two expression languages (JSP's and JSF's) that finally got
> integrated into the Unified EL.
We're even a step beyond unified EL, and have EL 3 as a completely
standalone spec now, directly useable in Java SE with minimal setup ;)
See:
https://web.archive.org/web/20150923201252/https://weblogs.java.net/blog/swchan2/archive/2013/07/01/standard-deviation-illustration-expression-language-30-servlet-environment
Kind regards,
Arjan Tijms
> Even though they are used outside Java
> classes, I am not sure what would be the benefit of yet another way for
> String interpolation in the Java sphere. A subset of the Unified EL might
> be a better option (e.g. leading to more consistency across the whole
> platform).
>
> To quote Jan L. A. van de Snepscheut (probably a misattribution):
>
> *In theory there is no difference between theory and practice; in practice
> there is.*
>
>
> In practice, AFAIK, using the following syntaxes:
>
> - "foo #{...} bar"
> - "foo ${...} bar"
> - "foo \(...) bar"
>
> Have not caused any real-world problems in languages like Ruby,
> JavaScript/Groovy, and Swift. Also IMHO aesthetically they are more
> beautiful. So, I personally prefer any of them to $"..." which reminds me
> of Objective-C's @"..." that I never liked.
>
> Anyhow, just my 2 cents.
>
> *P.S:* IMHO, it would be nice if the Java language and its related projects
> had uservoice accounts similar to Visual Studio:
>
> https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/category/30931-languages-c
>
> Best regards,
> Behrang Saeedzadeh
>
>
>
>
>
>
> On 11 March 2016 at 12:31, Neal Gafter <neal at gafter.com> wrote:
>
> > We like string interpolation in C#
> > <https://msdn.microsoft.com/en-us/library/Dn961160.aspx>. I think it
> > would be a nice addition to Java, presuming its benefit/cost compares
> > favorably to other things under consideration. Java tends to be more
> > conservative about adding complexity to the language than C#, so it is
> > natural to find differences like this.
> >
> > We looked at two syntax options: first *"Fixed stuff \{expression} etc"*
> > where you put an expression inside a string between curly braces prefixed
> > by a backslash. That has the advantage that you can just start typing it
> > into the middle of an existing string. It has the disadvantage that it
> > silently turns a *constant* expression into a *non-constant* expression,
> > and it is a little more work than the other option because of the
> backslash.
> >
> > Our second option was *$"Fixed stuff {expression} etc"*, and that is what
> > we ended up going with.
> >
> > Either way it would be defined by translation into a call to
> > *String.format*. You would probably want to add syntax to support format
> > specifiers, and a way of deferring the formatting so that, for example,
> it
> > can be localized.
> >
> > The nice thing about this is that common problems that would cause
> > *IllegalFormatException* with *String.format* ether cannot occur or
> > become compile-time errors.
> >
> >
> > On Fri, Dec 19, 2014 at 8:40 AM, Brian Goetz <brian.goetz at oracle.com>
> > wrote:
> >
> >> Have you met String.format()?
> >>
> >> No direct language support is being considered for the forseeable
> future.
> >>
> >>
> >>
> >> On 12/15/2014 9:44 PM, Behrang Saeedzadeh wrote:
> >>
> >>> Hi,
> >>>
> >>> Does the JDK team have any view points about adding string
> interpolation
> >>> to
> >>> the Java language?
> >>>
> >>> Best regards,
> >>> Behrang
> >>> http://www.behrang.org
> >>>
> >>>
> >
>
More information about the discuss
mailing list