Subject: Re: [SWIPL] About Applying a predicate to all the elements of a list

From: "Richard A. O'Keefe" <[email-masked]>
Date: Fri, 15 Dec 2000 14:14:10 +1300 (NZDT)

Nicos Angelopoulos <[email-masked]> wrote:
    alternatively one might use syntactic transformations
    during compile time and factor out the meta call,
    (term_expansion/2) 

    the transformation is straight forward since 
    it doesnt depend on any other information,

    the drawback of course is that you get
    extra clauses in your database and that these
    clauses are dynamic (due to use of assert)

No reason why they should be dynamic,
provided term_expansion/2 is Quintus-compatible.

If you want to construct a new predicate to be called in some clause,
you just return a *list* of clauses.
    
A rather better approach, which would not require you to allow all
predicates in a file to be discontiguous, would be to have a
end_of_file_expansion(+FileName, -ClauseList) hook that is called when
compile, consult, &c reach the end of a file.  Then you can squirrel
away all the clauses you want, and pick them up after all the other
predicates in the file.
.d