On Sat, Feb 10, 2024 at 5:48 PM Simon Hartley <scrhart...@yahoo.co.uk.invalid> wrote:
> I've made an implementation of #on here: > > https://github.com/scrhartley/apache-freemarker/commit/cee8d076b02e8dbcae0b84eabc76814aaea8baf6 > > * Fall-through does not occur when using #on. > * #on supports multiple conditions > * #default may be used with #on > * This implementation doesn't allow mixing #case and #on. > * When #on has been used in the #switch then #break and #continue are not > supported, otherwise the legacy behavior is used. This means that the > behavior in a #default depends upon whether an #on has been used. > I would say that if you're going to go for this, you should really introduce an entirely new directive, like maybe #match, either #match/#case or maybe #match/#on. And then just leave #switch alone. That strikes me as cleaner, though what do I know? I'm just the guy who implemented this in code all those years ago. Actually, now that I think about it, this #switch/#case with default fall-through should really have been deprecated and then later removed in the early 2000's. As far as I can see, everybody would be better off without it! But now it's been there for so many years...This kind of construct made sense in a system programming language like C because the construct can be translated into a very efficient jump table in machine code, but... JR > > I've updated some of the tests, but I'm unsure if that's sufficient. I saw > that switch.ftl exists, but since it's in the jython25 tests I left it > alone. After my changes "gradlew check" still passes. I haven't updated the > manual. > > I'm now looking for feedback and possibly next steps. What should happen > to get this ready for merge request? > > --- > Best regards, > Simon Hartley > > > > > > > > > On Saturday, 10 February 2024 at 09:31:32 GMT, Daniel Dekany < > daniel.dek...@gmail.com> wrote: > > > > > > > Because there's not an explicit closing tag for #case or #on, the use of > #break in the following avoids a trailing newline > > > Yeah, but that's really a hack. I mean, we have the same whitespace issue > with #else, and #elseif. So this is just not the feature where we address > whitespace issues in general. > >