[m-users.] Enable LCMC tail recursion optimization by default?

Julien Fischer jfischer at opturion.com
Wed Apr 20 09:50:10 AEST 2016

On Tue, 19 Apr 2016, Dirk Ziegemeyer wrote:

> I have learned so far that tail recursion is important to avoid stack overflows and that code might look tail recursive but isn’t. Common predicates like list.map and list.append are not tail recursive in Mercury by default but can be transformed to be tail-recursive with the LCMC-option.
> (http://lists.mercurylang.org/archives/users/2016-March/008127.html)
> Enabling the option optimize_constructor_last_call only affects my own code but not the list library which was compiled during mercury installation without this option.
> Does it make sense to enable LCMC in future versions of the Mercury compiler by default in order to avoid duplicating the code for e.g. list.append in the own application?

As an aside: if your program is frequently appending large lists, you
may want to consider using a different structure entirely, e.g. cords in
the standard library, which provide O(1) concatenation.


More information about the users mailing list