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

Add tail recursion to IR #5228

Closed
wants to merge 11 commits into from
Closed

Conversation

chrisvittal
Copy link
Collaborator

@chrisvittal chrisvittal commented Jan 31, 2019

There is still work to do here, but it is now complete enough that InterpretSuite can be run properly on a minimal example.

Current TODOs:

  • Add C++ emit
  • Add Python api (experimental, for now)
  • Proper type checking in python? yes, but no type inference
  • Test ALL failure pathways
    • Mismatched Number of args between Loop and matching Recur
    • Mismatched types of args between Loop and matching Recur
    • Infinite loop detection
    • Not tail recursive detection

@chrisvittal
Copy link
Collaborator Author

Spun the wheel got Patrick, would also like @cseed, @tpoterba, @catoverdrive to look if they have time. Thanks!

@chrisvittal
Copy link
Collaborator Author

@patrick-schultz ping

Copy link
Collaborator

@patrick-schultz patrick-schultz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we continue to talk offline about the high level design, here are the minor nits I have so far.

@typecheck(recur_exprs=expr_any)
def make_loop(*recur_exprs):
if len(recur_exprs) != len(exprs):
raise TypeError('loop and recursion must have the same number of arguments')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably make this "Recursive call in loop has wrong number of arguments", and below something like "Type error in recursive call:"

Returns
-------
:class:`.Expression`
Result of the loop with `exprs` as inital loop values.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"initial"


for expr in exprs:
uid = Env.get_uid()
args.append(construct_variable(uid, expr._type, expr._indices, expr._aggregations))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find args confusing. How about loop_vars?

This includes
    * Python classes
    * Parsing
    * Interpret

TODOs:
    * Emit
    * C++ Emit
Also fix some type inferences in Loop and Recur

This iteration currently requires `loop` to take its return type as an
argument.
@chrisvittal
Copy link
Collaborator Author

This fundamentally needs to be rewritten now. I'll be able to fix all the merge conflicts, but it's probably better as a new PR.

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

Successfully merging this pull request may close these issues.

None yet

2 participants