Mutual recursion #32
Labels
No Label
accepted
bug
clj
documentation
enhancement
errors
infrastructure
later
next
now
optimization
proposal
question
research
semantics
syntax
ux
vm
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: twc/ludus#32
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Tracking:
fn foo
will parse as a forward declarationfn foo
At current, the validator will reject mutually recursive functions.
First of all, do we want mutual recursion? Do we need it? Where? (For example, writing a recursive descent parser requires mutual recursion...)
In Janet, the way you do this is:
In Clojure, you'd do this:
The Ludus equivalent to the former is:
A Ludus equivalent to the latter could be:
This seems pretty straightforward to implement: parse, validate, and run. In addition, it has the added benefit of ensuring that you can only forward-declare functions. You could also easily validate that a forward-declared function is actually implemented.
It would still have to be a runtime error if you call a declared function that hasn't been defined yet.
See https://rosettacode.org/wiki/Mutual_recursion#
We need mutual recursion for Sierpinski triangles, which we want to do in Computer Class. Shifted milestone to recognize this.
Added in
bbd41a0f74
Format: