Hi guys,

wondering if Groovy's macro functionality could help here ?

While I see Daniel's point about the brevity/elegance of his implementation, I am wondering whether a low level language construct like switch-case should be modelled by a (non-inlined) closure, due to
1) the overhead involved
2) the (already mentioned by someone else) differing semantics of a closure and a block construct.
Once we go down that route, we might be stuck.

I am not sure about this, but it feels like being able to have at least limited closure inline support on the other hand might enable one to use closures in more places, and have the inline mechanism turn them into blocks again. Pie in the sky maybe, I don't know...

Last I wanted to mention that Java's end goal for switch seems to be to have pattern matching support - that would have to be added to Groovy in any case, to continue being Java compatible. And it (again feels like) that would be much more effort than having "proper" switch-as-expression support...

9.0 Euro Cents,
mg


On 04/11/2019 20:43, Daniel.Sun wrote:
This is just a reference implementation, we can tweak it over time.

Now that you have a prototype in hand for conversion to ClosureExpression
with nested SwitchStatement, would it be a good idea to at least try the
SwitchExpression route to see how much effort difference is involved?
As Cédric said, he wanted to implement a lot of features but had no time. I
can feel that he really likes Groovy. Frankly, same to me, I'm not sure if I
have enough time to tweak it in the near future... In order to push the
progress of Groovy 3, I sleep for 3~4 hours a day recently... It's 3:30 a.m.
in Shanghai... Please call me super man ;-)  And the reason why I set aside
extra time on features of Groovy 3.X / Groovy 4 is that my birthday is
coming, I try to make a "gift" for myself. If you like it too, that's great.
If not, it does not matter, I'll keep it :-)

Cheers,
Daniel.Sun



-----
Apache Groovy committer & PMC member
Blog: http://blog.sunlan.me
Twitter: @daniel_sun

--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html


Reply via email to