Require tail call optimization for Swift function with annotation

Originator:pavol.vaskovic
Number:rdar://19424909 Date Originated:09-Jan-2015 12:08 PM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
 
Summary:
Following the discussion in DevForums[1] about the need for guaranteeing tail call optimization, have you considered handling the tail call optimization with annotiation like in Scala? [2]

> The Scala compiler will automatically optimize any truly tail-recursive method. If you annotate a method that you believe is tail-recursive with the @tailrec annotation, then the compiler will warn you if the method is actually not tail-recursive. This makes the @tailrec annotation a good idea, both to ensure that a method is currently optimizable and that it remains optimizable as it is modified.
> Note that Scala does not consider a method to be tail-recursive if it can be overridden. Thus the method must either be private, final, on an object (as opposed to a class or trait), or inside another method to be optimized.

[1] https://devforums.apple.com/message/1051120#1051120
[2] http://stackoverflow.com/a/3114245/41307

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!