You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In scala, there is an annotation @tailrec that makes compilation fail if the function is not tail recursive. Tail recursion ensures that the function can be compiled into a loop, and ensures we don't blow the stack.
Bosatsu has the optimization, but no way to require that it happens. This seems against the bosatsu way of biasing towards stronger guarantees.
We could have syntax like:
defloop len(lst, acc):
recur let:
case []: acc
case [_, *tail]: len(tail, acc.add(1))
where defloop is just a def where all recursions are in the tail position. Since the tail check can be a kind of a lint, we can do that in parallel with other type checking so that we don't have the sequential error presentation issue.
I don't love the look of defloop, but maybe it's the best. Idk. Changing it should be pretty easy since that string can be changed with find and replace. Ideas:
thinking more: the last option above seems the best: if the recursion is tail recursive you must use loop. you use recur only when there is non-tail recursion. This allows a reader to clearly see which case we are in.
In scala, there is an annotation
@tailrec
that makes compilation fail if the function is not tail recursive. Tail recursion ensures that the function can be compiled into a loop, and ensures we don't blow the stack.Bosatsu has the optimization, but no way to require that it happens. This seems against the bosatsu way of biasing towards stronger guarantees.
We could have syntax like:
where defloop is just a def where all recursions are in the tail position. Since the tail check can be a kind of a lint, we can do that in parallel with other type checking so that we don't have the sequential error presentation issue.
I don't love the look of
defloop
, but maybe it's the best. Idk. Changing it should be pretty easy since that string can be changed with find and replace. Ideas:hmm... maybe the last one is best... it also makes the tail loop nature local to the function rather than at the top level.
The text was updated successfully, but these errors were encountered: