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

Peter Wang novalazy at gmail.com
Tue Apr 19 22:42:44 AEST 2016


On Tue, 19 Apr 2016 09:19:16 +0200, Dirk Ziegemeyer <dirk at ziegemeyer.de> 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?

Hi,

The standard library is compiled with --optimize-constructor-last-call.

We should consider enabling it by default.  I assume it would be done if
shown not to degrade performance of the compiler (the only benchmark
that matters ;)

Peter


More information about the users mailing list