[m-dev.] New pragmas for tail recursion warnings

Paul Bone paul at bone.id.au
Fri Nov 13 17:20:46 AEDT 2015


On Fri, Nov 13, 2015 at 05:08:20PM +1100, Paul Bone wrote:
> 
> Recently Ian improvement to warnings about tail recursive code, I removed
> warnings for calls that are obviously non-tail recursive. Such as for the
> first recursive call in something like qsort.
> 
> What I'd like to do next to make these warnings more usable by adding two to
> four pragmas to control the warnings on a finer level.  The motivation for
> this is as follows.  A programmer enables this warning for their whole
> project or module, but they have some code that isn't, and will never be,
> tail recursive.  So they should be able to use a pragma to disable this
> warning for this one procedure.
> 
> Likewise, another programmer does not enable this warning for their project
> or module.  But they have a procedure that they know may be called with very
> large inputs, so it's important that that procedure is tail recursive.  They
> should be able to enable the warning for that procedure.
> 
> What I'd like to have reviewed at this stage are the names and syntax of the
> pragmas.
> 
>     % This pragma works on all procedures of a given predicate/function.
>     :- pragma no_warn_tail_recursion(NAME/ARITY).
> 
>     % This pragma works on a single procedure.
>     :- pragma no_warn_tail_recursion(NAME(ARG_MODES*)).
> 
>     :- pragma warn_tail_recursion(NAME/ARITY).
>     :- pragma warn_tail_recursion(NAME(ARG_MODES*)).

Argh,  I meant to say no_warn_non_tail_recursion and
warn_non_tail_recursion, these match the option name
--warn-non-tail-recursion.


-- 
Paul Bone



More information about the developers mailing list