Jan Wielemaker wrote:
> ...
> On 2012-02-06, Mats Carlsson <matsc560515@gmail.com> wrote:
>> ...
>> SICStus Prolog's goal_expansion can't generate clauses. We have
>> term_expansion for that.
>
> We all have :-) We all know that goal_expansion/2 is not needed (well,
> if you restrict goal_expansion/2 to compile-time translation; I
> understand that SICstus also uses it in meta-calling). The nice aspect
> of goal_expansion/2 is that it performs all the work of unpacking and
> repacking control-structures and meta-calls for you.
It is not only that. While term_expansion provides a very simple
interface to do very general transformations, I believe it breaks
down as soon as you want to combine multiple such transformations
within one Prolog application. As far as I know, it is not easy
to merge several sets of term_expansion rules, and at the same time
correctly determine the context of terms, obey module visibility
rules, and get correct transformation fixpointing.
While goal_expansion is an improvement, ultimately I think a scheme
similar to the one described in
http://arxiv.org/abs/1012.4240
section 4.3 is better for software engineering.
-- Joachim