[mercury-users] memo and zero-arity functions

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Jul 31 11:14:31 AEST 2006


On 29-Jul-2006, Michael Day <mikeday at bigpond.net.au> wrote:
> :- pragma foreign_proc(c,
>         value_exists,
>         [will_not_call_mercury, thread_safe], "
>     SUCCESS_INDICATOR = (Value != NULL);
> ").

No, tabling in general cannot possibly be made as efficient as this code.
The reason why your code works is that it exploits the knowledge that only
non-NULL values of the global variable are valid. If the tabled predicate
returned an integer, there would be no bit pattern one could use to indicate
"there is no value here", so this scheme wouldn't work.

I'll look into applying your optimization automatically to tabled predicates
in the cases where it is applicable.

Zoltan.
--------------------------------------------------------------------------
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