Open joshuabowers opened 3 years ago
Limits have yet to be implemented in GraphCa, so this is somewhat still relevant; however, this particular issue references implementation details that have not been present in the application for quite some time. I am tempted to close this, though further review is warranted.
The limit of an expression,
f(x)
asx
asymptotically approaches a given constant,c
, is an interesting mathematical tool, important for defining various calculus related concepts. Having limits would be useful for determining continuity, which would itself be useful for governing how an expression is plotted on a graph: known discontinuities should cause separately drawn segments, rather than connected line segments that jump across an asymptotic cusp (among potentially other interesting cases).ac1b7d54038301ab1743512e1c11b95b549a5156 introduces a new pegase visitor,
limitVisitor
, which purports to eventually be able to find limits of any given AST.limitVisitor
currently only defines two different node-types of the overall AST: REAL and COMPLEX. (I'm reasonably certain that COMPLEX makes some degree of sense, but am not entirely sure.) A series of problems were discovered in attempting to develop this:x -> 5
certainly looks similar in construction tox <- 5
. However, doing this unfortunately results in two issues: it masks whatever values might exist in scope for the variables of the expression; it also might result in those variables being substituted immediately for their values rather than symbolically evaluated. It would be cleaner to parameterize the construction oflimitVisitor
with the asymptotes, to avoid polluting scope.$context
. But, if$context
isScope
, and the previous point suggests that should be avoided, some other mechanism would be needed.Essentially, a pegase Visitor is just an object which has methods that follow a specific naming convention and method signature. There is no direct reason why this should have to be a singleton. So, theoretically, either of the two following approaches should suffice, but would need to be investigated:
In either case, the invoking context---either
evaluateVisitor
for the intended functionality, or the spec forlimitVisitor
---would need to create a new instance oflimitVisitor
with the captured data on a per-parse basis: