I was looking a bit into the Stratego interpreter code as I noticed it’s slow because exceptions are used in control flow, and then I noticed this snippet near the end of CallT.java, in the evaluateWithArgs method:

class WithArgsHook extends Hook {
    boolean result;
        @Override
        public IConstruct onFailure(IContext env) throws InterpreterException {
            result = false;
            return null;
        }
        @Override
        public IConstruct onSuccess(IContext env) throws InterpreterException {
            result = false;
            return null;
        }
}

Shouldn’t onSuccess set result to true, instead of false? (If not, this at least deserves a big comment next to it, as in other places onSuccess does appear to set a result to true ;-))

Didn’t test yet as I don’t know a way (yet) to test whether this is actually a bug.

Submitted by Tobi Vollebregt on 7 January 2011 at 17:24

On 7 January 2011 at 18:02 Lennart Kats commented:

Yes, that seems to be a bug. Fixed in r21644. It was probably introduced as the code was changed at some point to get rid of some of the exception-based control flow… The method is very rarely called though, so that may explain why it hasn’t caused any real problems yet. And yes, there’s still a case of exception-based control flow left, which probably explains at least some of the performance difference compared to the compiler, but it’s certainly not the only explanation.


On 14 January 2011 at 17:54 Lennart Kats closed this issue.

Log in to post comments