groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paolo Di Tommaso <paolo.ditomm...@gmail.com>
Subject Re: [Proposal] GString is implemented eager and treated as normal String since groovy 3.0.0
Date Sat, 08 Sep 2018 11:25:23 GMT
I would like to raise a flag here.

Stated the Groovy documentation a Gstring can be resolved both in a eager
and lazy manner:

def number = 1 def eagerGString = "value == ${number}"def lazyGString
= "value == ${ -> number }"
assert eagerGString == "value == 1" assert lazyGString ==  "value == 1"

number = 2 assert eagerGString ==  "value == 1"assert lazyGString ==
"value == 2"



http://groovy-lang.org/syntax.html#_special_case_of_interpolating_closure_expressions

The example you are reporting should *already* be reasolved eagerly and I
can agree that it can be confusing.

However the ability to resolve a GString lazily it's a very important
Groovy feature for DSL builders. Wipe it out would have a serious impact
(read destroy) on existing frameworks that rely on that feature.


Cheers,
Paolo

Mime
View raw message