[mercury-users] memo and zero-arity functions

Julien Fischer juliensf at csse.unimelb.edu.au
Sat Jul 29 22:16:14 AEST 2006


On Sat, 29 Jul 2006, Michael Day wrote:

> Would it be possible to optimise the implementation of pragma memo for
> zero-arity functions, like this:
>
>    :- pragma memo(bigfunc/0).
>
>    :- func bigfunc = complicated_type.
>
>    bigfunc = big_nasty_function_symbol_with_many_arguments(...).
>
> Perhaps the current implementation is optimised for functions with
> arguments that can return many different values, as Prince gains a 2%
> speed up if I replace this function with an impure one that uses a global
> variable to store the single return value, like this:

I would suggest using a constant mutable rather than memoization in this
situation.  (See section 9.6 of the reference manual.)

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