Re: Ann: delay pack
"Richard A. O'Keefe" <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 10/08/2013, at 6:22 AM, Ian Tegebo wrote: > Wow. I find it surprising that delay/1 didn't already exist. Could > someone more experienced comment as to previous approaches? There are two previous approaches. NU Prolog had 'when' declarations where you stated conditions under which a goal was to be *activated*, e.g. ?- append(A, Z, AZ) when A ; AZ. ?- succ(A, B, C) when ground(A), ground(B). ?- succ(A, B, C) when ground(B), ground(C). ?- succ(A, B, C) when ground(C), ground(A). There was a program that would automatically generate these for you for nicely behaved predicates. Some other Prologs have 'delay' declarations where you state conditions under which a goal is to be *suspended*, i.e., the opposite of the NU Prolog convention: :- delay succ(A, B, C) when var(A), var(B), var(C). :- delay append(A, Z, AZ) when var(A), var(AZ). I believe the "delay rule" convention is more powerful, but I always found the "activation rule" was easier for me to use, because it linked in with reasoning about termination. However expressed, the information belongs with the *definition* of a predicate, not with its uses.