[m-rev.] for review: Make some compiler predicates tail recursive with LCMC.

Zoltan Somogyi zoltan.somogyi at runbox.com
Thu Oct 15 16:44:58 AEDT 2015



On Thu, 15 Oct 2015 14:26:46 +1100, Peter Wang <novalazy at gmail.com> wrote:
> The "lcmc" annotations are how I remind myself not to break the tail recursion
> property.  I can change them or delete them if they are too cryptic.

I think what you have there now is fine.

> diff --git a/compiler/module_qual.m b/compiler/module_qual.m
> index 5cab3cb..acac78a 100644
> --- a/compiler/module_qual.m
> +++ b/compiler/module_qual.m
> @@ -816,10 +816,10 @@ module_qualify_items_in_src_item_blocks([SrcItemBlock0 | SrcItemBlocks0],
>      list(error_spec)::in, list(error_spec)::out) is det.
>  
>  module_qualify_items_loop(_InInt, [], [], !Info, !Specs).
> -module_qualify_items_loop(InInt, [Item0 | Items0], [Item | Items],
> -        !Info, !Specs) :-
> +module_qualify_items_loop(InInt, [Item0 | Items0], Itemss, !Info, !Specs) :-
>      module_qualify_item(InInt, Item0, Item, !Info, !Specs),
> -    module_qualify_items_loop(InInt, Items0, Items, !Info, !Specs).
> +    module_qualify_items_loop(InInt, Items0, Items, !Info, !Specs),
> +    Itemss = [Item | Items]. % lcmc

Could you please change the variable naming scheme here to avoid
the "ss" suffix? I think Items = [HeadItem | TailItems] should do fine,
with corresponding HeadItem0 and TailItems0 names.

Similarly in the other modules.

The diff is otherwise fine.

Zoltan.


More information about the reviews mailing list