Re: goal_expansion

Paulo Moura <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 10/02/2014, at 16:13, Jan Wielemaker <[email protected]> wrote:

> ...
> P.s.	It seems though that Jonathon wants to rewrite source
> 	files.  If this is the case, goal_expansion/2 is not
> 	for you.  It is there, such that you can write human
> 	readable code that actually needs to be something hard
> 	to read and write.  To me, that is the opposite, but
> 	perhaps I didn't understand the OP.

By coincidence, and to give a contrasting example, I'm using Logtalk's goal_expansion/2 hook predicate exactly for rewriting source files, where is the perfect tool for the job: I got Logtalk 3 running under Quintus Prolog but this system provides e.g. some built-in predicates such as open/4, write_term/3, and read_term/3 that use a different argument order from the one that become standard. When compiling portable code that uses these predicates, goal_expansion/2 is used to simply shuffle the arguments to what Quintus Prolog expects. This is better alternative than e.g. maintaining different code variants for different systems or using conditional compilation directives. 

Cheers,

Paulo

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:[email protected]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.