scala - Could a lazy val be tail-recursive? -
lazy val seq: unit = { println("a") seq }
can call expression above tail-recursively?
i guess argue in sense, yes - when evaluated, seq
recursively evaluate itself, , evaluation last action performed.
regardless of whether can called tail-recursive, though, there doesn't seem of point it. there no exit condition nor, if try , keep code purely functional, can there one: there no parameter, means there no "state" pass deeper evaluations , nothing test against break recursion.
also, if indeed tail-recursive, it's not form of tail recursion recognised or supported scala - evaluate seq
, stackoverflowerror
.
Comments
Post a Comment