Joachim Schimpf schrieb:
>> So a more proper do, based on mathematical abstraction
>> could use the (^) for declaring local variables in
>> the body, and even work on the fly without rewriting:
> The do-construct _does_ work without rewriting, you don't
> need goal_expansion etc. See the code in loops.pl at
> Whether you quantify local or global variables does not
> make a fundamental difference for the implementation.
> Ultimately, all you need is copy_term/2.
> -- Joachim
Oh, I didn't lookup the Eclipse implementation. Was
only looking at the SICStus implementation. This phrase
makes me think they do a rewriting:
> A do-loop is substituted by a goal:
> PreCallGoals, aux(CallArgs).
> where aux is a new, unique predicate symbol
I guess your loop.pl implementation of the meta
predicate is more efficient than my implementation,
since it determines some templates involved in
copy_term/2 only once and not during each
The file loop.pl also contains some fragments
for compile time rewriting, i.e. the predicate
t_do. But I don't see where it is called from,
and how the Name is generated and other book-
keeping for auxiliary clauses.
BTW: Styla has adapted some free variable
calculation from ROK (not.pl). Pitty it went
not into ISO setof/bagof. Would be easier
to define a *fully* mathematical (^)/2.
How much code would break if we switch
from 1 to 0 in the line below?
bagof(Template, Generator, Bag) :-
free_variables(Generator, Template, , Vars,1),