tail call optimization not possible, should probably trigger an error
here TCO can not be done since c.tail.concat_list t is eventually wrapped in a lambda.
public concat_list (t Lazy (list A)) list A =>
match list.this
nil => t()
c Cons =>
# tricky, Lazy wrapping a Lazy.
# The expression following the colon
# is a Lazy and t is also a Lazy.
c.head : c.tail.concat_list t
We should probably show an error for cases like this since programmers will expect TCO being applied here.
This is not only wrapped in a lambda, but also wrapped into c.head.infix : (...), so this is IMHO not a tail call.
This code is maybe problematic since it re-wraps the whole first list into a new list. Did you run into any case where iterating the resulting list then causes deep recursion or quadratic performance? What is done this the result of concat_list to provoke such behaviour?
@fridis I experienced a StackOverflow, this was the reason for creating this issue.