[mercury-users] Tail call optimisation in hlc grades

Michael Day mikeday at yeslogic.com
Sun Aug 19 19:04:37 AEST 2007


> I have a predicate operating on a list that appears to be tail 
> recursive, yet in hlc grades it crashes when applied to a list 
> containing around 600k elements. Is tail call optimisation performed in 
> hlc grades?

To answer myself, yes tail call optimisation is performed, and in fact 
it appears to be performed on the predicate for which I thought it 
wasn't being performed.

However, it does not seem to be performed for the array.insert_items 
predicate, used by array.from_list, which means array.from_list will 
crash in hlc grades when given a long list. I don't know why the 
optimisation isn't being applied to this predicate, as it looks tail 
recursive to me. Something to do with the array modes perhaps?

One change that could be made to insert_items is to use unsafe_set, as 
the size of the array has been set in advance and the bounds checks 
performed by array.set are redundant.

Cheers,

Michael

-- 
Print XML with Prince!
http://www.princexml.com
--------------------------------------------------------------------------
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