Function definition

Aaron J. Seigo aseigo at kde.org
Sat Jul 26 13:34:09 UTC 2014


On Saturday, July 26, 2014 09:12:19 Ivan Čukić wrote:
> > Hopefully we don't have to mark functions as recursive (tail or
> > otherwise)... that said ...
> 
> Was not meant as an instruction to the compiler, but as a request to get an
> error if the compiler can not make it into a loop.

the compiler should be able to detect tail recursion on its own. it's a 
special case of what is needed for tail call optimization anyways.

what could be nice in the compiler is to warn when any function is 
recursive[1] and grows the stack with each recurse.

in fact, if there was to be such a tag i'd prefer to see a "developer knows, 
stop bugging me" tag that gets applied to non-tail-recursive functions stating 
that the function is known to be such. that way developers would have to tag 
functions that can potentially blow the stack, otherwise face a warning.

possible downside: it's often quite OK to have non-tail-recursive functions if 
you *know* the number of iterations is small (e.g. due to a known to be small 
data set) and that might lead to a more functions than desired being marked 
this way?

what do you think? 

[1] or for extra niftiness: mutually recursive .. perhaps even N-cycle 
multiple recursion for a reason N

-- 
Aaron J. Seigo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://kde.org/pipermail/funq-devel/attachments/20140726/5f57e832/attachment.sig>


More information about the Funq-devel mailing list