Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mutually recursive functions #43

Closed
mostafa-abdullah opened this issue Jul 20, 2017 · 1 comment
Closed

Allow mutually recursive functions #43

mostafa-abdullah opened this issue Jul 20, 2017 · 1 comment

Comments

@mostafa-abdullah
Copy link
Contributor

mostafa-abdullah commented Jul 20, 2017

Example

def f(x):
    if x == 0:
        return 1
    return g(x - 1)

def g(x):
    if x == 0:
        return 2
    return f(x - 1)

The approach I plan to take is to pre-analyze all function definitions and store the corresponding z3 types in the context, so when the inferencer encounters the g function call (whose definition didn't appear yet) it will have its type already in the context.

The problem with this is that it will allow some incorrect programs to type, like the following one:

def f(x):
    if x == 0:
        return 1
    return g(x - 1)

f(1)

def g(x):
    if x == 0:
        return 2
    return f(x - 1)

Because by the time f is called, g wouldn't have appeared yet.

What do you think? Do you think the above example is tolerable? Can we consider it as a normal run-time error that is not type-related?

@caterinaurban caterinaurban changed the title [Enhancement] Allow mutually recursive functions Allow mutually recursive functions Aug 3, 2017
@caterinaurban
Copy link
Owner

This issue was moved to caterinaurban/Typpete#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants