pass result of bootstrapped function to Bootstrap.resolve
Caveats
all code will be executed twice can be avoided by wrapping it in if __name__ == "builtins"
assigning bootstrapped functions to variable and calling the variables will cause problems, can be partially fixed by changing the implementation to:
using the bootstrap decorator instead of adding Bootstrap.resolve on all call outside bootstrapped functions or
outputting two function with one of them just being a wrapper to start the bootstrapping
Note: These fixes only help for calls outside of bootstrapped function
Example Transformation
Original
Transformed
```python
@bootstrap
def abc1(n):
if n == 0 or n == 1:
return 1
return abc2(n - 1) + n
@bootstrap
def abc2(n):
if n == 0 or n == 1:
return 1
return abc1(n - 1) * n
def main():
print(abc1(1000))
```
```python
def abc1(n):
if n == 0 or n == 1:
yield 1
yield ((yield abc2(n - 1)) + n)
def abc2(n):
if n == 0 or n == 1:
yield 1
yield ((yield abc1(n - 1)) * n)
def main():
print(Bootstrap.resolve(abc1(1000)))
```
Transformations it does
Inside bootstrapped function:
return
toyield
yield
before calls to bootstrapped functionsOutside bootstrapped functions:
bootstrap
decoratorBootstrap.resolve
Caveats
if __name__ == "builtins"
assigning bootstrapped functions to variable and calling the variables will cause problems, can be partially fixed by changing the implementation to:
Bootstrap.resolve
on all call outside bootstrapped functions orNote: These fixes only help for calls outside of bootstrapped function
Example Transformation