|
Tail recursion elimination and logical shortcut operators: msg#00415lang.scala
It looks as tho' the current (2.3.3) Scala compiler's ability to eliminate tail calls is frustrated by the logical shortcut operators. Looking at the decompiled output, in this case, def foo(n : Int) : Boolean = n == 1 || foo(n-1) the tail call isn't eliminated, but in the equivalent, def foo(n : Int) : Boolean = if(n == 1) true else foo(n-1) it is. Or are they equivalent? Does the definition of || as, def || (p: => Boolean): Boolean carry any deeper significance which prevents the call of foo(n-1) in the first case being identified as a tail call (rather than merely making it more difficult)? Cheers, Miles |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: two things about defs: 00415, Alexander Sergeev |
|---|---|
| Next by Date: | Re: Hmmm...: 00415, David Pollak |
| Previous by Thread: | Brace style bias?i: 00415, Miles Sabin |
| Next by Thread: | Empty Iterators: 00415, Miles Sabin |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |