Hi all,
I'm working on a custom language interpreter and ran into a design issue regarding method dispatch.
The Problem:
I initially modeled closures as part of the class behavior (std::Behavior). However, when invoking a method, the dispatch mechanism would try to evaluate the closure object, which in turn triggered another dispatch, leading to infinite recursion.
My Solution:
I separated closures and classes into two distinct object types. Closures now have their own execution path that bypasses the standard class method dispatch.
The Question:
Is this a common pattern in language design, or is there a more elegant way to handle closures as first-class citizens within a class structure without hitting this recursion trap?
Repo: https://github.com/VP-xudon/Syclun/
Thanks for any insights!
Oh right, I used Tencent Codebuddy for DEBUGGING but not DESIGNING...
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)