Working with Spanish version 7.4
I get
show invoke [(power ? / ? 1)] 2
power necesita recibir más cosas en invoke
[.maybeoutput apply :function :inputs]
Was expecting the same result as:
show invoke [(power ? / 2 1)] 2
1
I believe it has to do with the procedure "?" trying to consume the 1
But somehow the parenthesis are also involved in the bug because
show invoke [power ? / ? 1] 2
1
Haven't tested it in newer versions.
I think you're correct on both counts, Daniel. The
?consumes1as its input and the parens have something to do with it.The parens tell FMSLogo to do two things:
1) gather a variable number of inputs instead of the default number
2) report errors an unmatched parentheses
When considering subexpressions, you want the second behavior, but not the first behavior. However, when an infix operator is thrown into the mix, you get both behaviors, resulting in gathering the "max" inputs instead of the "default" inputs for
?.I can "simplify" your examples to a badly functioning:
And a correctly functioning:
This might not look simpler to you, but it's simpler when stepping through the evaluation engine. For reference, in prefix notation, this is:
Unfortunately, this bug also exists in UCBLogo so I cannot use it as a reference to see how Brian Harvey fixed it. I have an idea on how to fix it, but the evaluation/parsing engine is tricky code and so any change must be made carefully.
Diff:
I have committed [r5708] which fixes the problem reported and passes all of my regression tests. Even so, this is an area where my regression tests lack good coverage and where I lack expertise. I think it's correct but there's a risk of an unintended regression.
I've attached a fixed copy in case someone can report a regression before this change is released in an official build (which will be FMSLogo 8.1.0).
Related
Commit: [r5708]
Thanks David.
In all this years this is the first time I've come across this bug.
I'm going to start using this version fmslogo-8.0.2+.exe to see if I notice something broke.