[mercury-users] Tail call optimisation in hlc grades

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Aug 29 01:12:33 AEST 2007


On Mon, 20 Aug 2007, Michael Day wrote:

>> I don't think so, you still don't get tail recursion for insert_items/4
>> even if you make the modes `in' and `out'.  I think it's more likely
>> the type that may be causing the problem here (in fact if you change the
>> arguments to make what was the array, polymorphic you do get tail
>> recursion.)  I'll keep looking into this one.
>
> It would be good to figure out what's going on, as it seems like it would 
> affect any seemingly tail recursive predicate using arrays.

What's going on is that the ml code generator, i.e. the HLDS->MLDS pass,
is inserting some redundant casts after the recursive call.  The
resulting code is no longer a candidate for tail call optimisation.

I'm testing a fix for this at the moment.

Cheers,
Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list