WIP: Minimal hack to make recursion work #719

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
@sklam
Contributor

sklam commented Aug 20, 2014

This is a minimal HACK to get recursion working. The goal is to start a discussion about how to properly implement it and how do we handle other situation besides self recursion.

@pitrou

This comment has been minimized.

Show comment
Hide comment
@pitrou

pitrou Aug 20, 2014

Member

As a first step, it seems type inference should be able to track and refine inference results for several functions at once (i.e. there should be some kind of inference context spanning several functions).

Member

pitrou commented Aug 20, 2014

As a first step, it seems type inference should be able to track and refine inference results for several functions at once (i.e. there should be some kind of inference context spanning several functions).

@seibert

This comment has been minimized.

Show comment
Hide comment
@seibert

seibert Aug 20, 2014

Contributor

The discussion @sklam and I just had about how to implement mutual recursion would require that @jit separate adding the function type signature to the typing context and actually compiling it.

Adding the type signature(s) of the function would always happen immediately, but the compilation step would need to be deferred if we detect undefined globals in the Numba IR. The deferred compilation would be performed later, either triggered by a later @jit or an explicit call to the function.

Contributor

seibert commented Aug 20, 2014

The discussion @sklam and I just had about how to implement mutual recursion would require that @jit separate adding the function type signature to the typing context and actually compiling it.

Adding the type signature(s) of the function would always happen immediately, but the compilation step would need to be deferred if we detect undefined globals in the Numba IR. The deferred compilation would be performed later, either triggered by a later @jit or an explicit call to the function.

@mblondel

This comment has been minimized.

Show comment
Hide comment
@mblondel

mblondel Aug 30, 2014

More or less duplicate issues on recursion: #716, #507, #136, #991.

More or less duplicate issues on recursion: #716, #507, #136, #991.

@meawoppl

This comment has been minimized.

Show comment
Hide comment
@meawoppl

meawoppl Dec 9, 2014

Contributor

Ah. Do I understand this PR correctly in that it only supports where the recursed function being itself and of the same return type as the initial call?

Contributor

meawoppl commented Dec 9, 2014

Ah. Do I understand this PR correctly in that it only supports where the recursed function being itself and of the same return type as the initial call?

@seibert

This comment has been minimized.

Show comment
Hide comment
@seibert

seibert Dec 9, 2014

Contributor

Yes. We have not merged this because it is basically a hack on the type inference process. A better approach would separate function type registration from compilation, so that we can handle all the reasonable cases. (i.e. compilation of the function is deferred until we've seen all the type signatures that are needed, including itself or other functions in the case of mutual recursion)

Contributor

seibert commented Dec 9, 2014

Yes. We have not merged this because it is basically a hack on the type inference process. A better approach would separate function type registration from compilation, so that we can handle all the reasonable cases. (i.e. compilation of the function is deferred until we've seen all the type signatures that are needed, including itself or other functions in the case of mutual recursion)

@pitrou pitrou referenced this pull request Jun 9, 2016

Merged

Self-recursion hack #1928

@pitrou

This comment has been minimized.

Show comment
Hide comment
@pitrou

pitrou Jun 9, 2016

Member

Superseded by PR #1928.

Member

pitrou commented Jun 9, 2016

Superseded by PR #1928.

@pitrou pitrou closed this Jun 9, 2016

@sklam sklam deleted the sklam:min_recur_hack branch Sep 22, 2016

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