View Single Post
  #7 (permalink)  
Old 02-02-2012, 06:33 PM
Jan Burse
Guest
 
Posts: n/a
Default Re: The do and ISO (Was: Permutations: a tail of two representations)

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
> http://www.eclipseclp.org/software/loops/index.html
>
> 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

http://www.sics.se/sicstus/docs/4.1....r_002ddol.html

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
iteration. Nice.

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.

Bye

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.

http://code.google.com/p/styla/sourc...ents/Lib.scala

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),
[...]


Reply With Quote