crowlogic / arb4j

arb4j is a Java API for the arbitrary precision ball arithmetic library found at http://arblib.org
Other
1 stars 0 forks source link

expression compiler: Extend 1-Level Variable Scope Resolution to Arbitrary Levels in Expression Trees #353

Closed crowlogic closed 5 months ago

crowlogic commented 6 months ago

Summary

Extend the scope resolution mechanism to identify independent variables in any ancestor expression, not just the immediate parent. This change aims to accurately reflect lexical scoping within nested expressions, ensuring variables are correctly recognized as independent based on their usage throughout the entire expression tree.

Problem Description

Currently, the system only checks if a variable is independent with respect to its immediate parent expression. This approach is insufficient for deeply nested expressions, where a variable might be independent in a broader context. The existing mechanism can lead to incorrect resolution of variable references.

Proposed Solution

Replace the isIndependentVariableOfParentExpression flag with a new mechanism, isIndependentVariableOfAnyAscendentExpression. This new method will traverse all ancestor expressions up to the root to determine if the variable serves as an independent input at any level of the expression tree.

Benefits

Implementation Considerations

Tasks

crowlogic commented 5 months ago

done