[External] : Re: Are templated string embedded expressions "method parameters" or "lambdas"?

forax at univ-mlv.fr forax at univ-mlv.fr
Fri Oct 29 18:44:33 UTC 2021


----- Original Message -----
> From: "Brian Goetz" <brian.goetz at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Jim Laskey" <james.laskey at oracle.com>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Sent: Vendredi 29 Octobre 2021 20:26:28
> Subject: Re: [External] : Re: Are templated string embedded expressions "method parameters" or "lambdas"?

>> Do we really need to support the second case at all ?
> 
> Yes :)
> 
>> Instead of
>>    "Hello \{name()}"
>>
>> it can be written to something like
>>    () -> F."Hello \{name()}"
> 
> That deprives your callee of the opportunity to choose the formatter for
> you.  Whoops, now the feature is way less expressive.  One of the goals
> here is to enable APIs to accept TSs as parameters, and be in control of
> the when and how of formatting.

If you want the API to choose the formatter, you can take it as parameter like a normal lambda

  formatter -> formatter."Hello \{name()}"


You do not need to provide an access to a TemplateString explicitly in the language because you can have a TemplatePolicy identity that returns the one taken as argument.

> 
>>
>> I think the choice between eager and lazy should be reflected in the syntax,
> 
> Oh great, two subtly different sets of semantics.  Way to overspend the
> complexity budget.

I don't understand, those expressions, lambdas and method references already exist in Java.

Rémi


More information about the amber-spec-experts mailing list