Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RuleTransformer fully recursive [#257] #421

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

dcsobral
Copy link
Contributor

RuleTransformer for the past eleven years or more has first recursed,
then applied the rewrite rules as it backed out of the recursion.

That prevented rewrite rules from acting on changes of previous rules
unless they recursed themselves.

The workaround has always been chain rule transformers instead of
calling one rule transformer with all the rules. This change basically
re-implements RuleTransformer as that workaround, and introduces
a NestingTransformer which does the nesting.

Clearly, if you have N rules you'll now recurse N times instead of
once, though each rule is still only applied once for each element.

On the other hand, a RewriteRule that recursed would incur in
exponential times, and now they don't need to.

The original behavior has no reason to be. It didn't prevent
rules from seeing each other changes, nor was it particularly
concerned with performance. With API changes coming on 2.0, I
believe this is the right time to introduce this change.

RuleTransformer for the past eleven years or more has first recursed,
then applied the rewrite rules as it backed out of the recursion.

That prevented rewrite rules from acting on changes of previous rules
unless they recursed themselves.

The workaround has always been chain rule transformers instead of
calling one rule transformer with all the rules. This change basically
re-implements RuleTransformer as that workaround, and introduces
a NestingTransformer which does the nesting.

Clearly, if you have N rules you'll now recurse N times instead of
once, though each rule is still only applied once for each element.

On the other hand, a RewriteRule that recursed would incur in
exponential times, and now they don't need to.

The original behavior has no reason to be. It didn't prevent
rules from seeing each other changes, nor was it particularly
concerned with performance.  With API changes coming on 2.0, I
believe this is the right time to introduce this change.
@dcsobral
Copy link
Contributor Author

Fixes #257

@SethTisue SethTisue changed the title Make RuleTranformer fully recursive [#257] Make RuleTransformer fully recursive [#257] May 7, 2020
@SethTisue
Copy link
Member

is there someone watching this repo who could review this...?

@dcsobral
Copy link
Contributor Author

is there someone watching this repo who could review this...?

And there was a deafening silence...

@SethTisue
Copy link
Member

SethTisue commented Dec 5, 2020

@ashawley @dcsobral wdyt, should we maybe just merge this?

@dcsobral how confident are you in the change? if you're pretty confident, I'd be okay with merging it

@dcsobral
Copy link
Contributor Author

dcsobral commented Dec 5, 2020

@SethTisue I rely on the tests. I've always found it hard to reason about the XML transformation code.

Copy link
Member

@SethTisue SethTisue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. seems fair game to me for 2.0, but let's give Aaron a week or two to object, perhaps he knows something you and I don't

@dcsobral
Copy link
Contributor Author

It's been 18 days now.

@SethTisue SethTisue merged commit 2dcbb85 into scala:master Dec 23, 2020
@SethTisue
Copy link
Member

another backstop is the community build; I've included this change here: scala/community-build#1333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants