Replies: 2 comments
-
|
FYI it's possible to do this with Codon's def fib(n: Literal[int]) -> Literal[int]:
return n if n < 2 else fib(n - 1) + fib(n - 2)Then |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I believe the compiler should be able to partly or completely evaluate any expressions at compile time that is not IO dependent without any special construct like this. Only IO dependent code should be evaluated at runtime. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The following example given in the readme should ideally take very little time as the compiler would be able to optimize away the calculation at compile time and just do printing only.
Only code which are input dependent should need runtime evaluation. Partly dependent code can be partly evaluated at compile time. Any code which is not dependent on any input ideally should be optimized away at higher optimization settings with possible slower compilation time, but should be optimized for compile time evaluations.
Beta Was this translation helpful? Give feedback.
All reactions