Re: Ann: delay pack

Michael Hendricks <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAFHuXuYs=OTjpTCO7XL__=E1vG+9Ro-05vjuy=T2WzqugOR2Cw@mail.gmail.com>
On Fri, Aug 9, 2013 at 12:20 PM, Alan Baljeu <[email protected]> wrote:

> How does delay know when the argument is ready to be called?
>

The module has a list of acceptable modes for each
predicate<https://github.com/mndrix/delay/blob/master/prolog/delay.pl#L18>.
 For example

    mode(plus(g,g,_)).
    mode(plus(g,_,g)).
    mode(plus(_,g,g)).

where g means ground and _ means var.  As soon as arguments are
instantiated to match one of those modes, the underlying predicate is
called.  Inside the module, those mode/1 facts are expanded into code like:

    delay(plus(C, A, B)) :-
when((ground(A), ground(B);ground(C), ground(B);ground(C), ground(A)),
     plus(C, A, B))

-- 
Michael
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.