Re: term_expansion/2 with DCG clauses

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 08/14/2013 04:28 AM, Richard A. O'Keefe wrote:
>
> On 14/08/2013, at 3:44 AM, Jan Wielemaker wrote:
>> This seems a logical way to access DCG expansion. The only price is that
>> you cannot created rules for -->/2 (nor for []/0 and ./2). Do these
>> systems have an agreed way to creates DCGs from expansion rules? I guess
>> Richard will know the rationale for not doing DCG after user expansion.
>
> If I recall correctly, DCG expansion was done *before* user expansion.
> With there being no goal_expansion in those days, this was important if
> you wanted users to be able to plug their own goal_expansion code in and
> have it apply to the result of DCG expansion.
> Further, DCG expansion was available as library code, so if you wanted it,
> you could very easily call it yourself.

So not doing DCG expansion if user expansion is involved seems out of
date. The idea to chain `translation packages' is also implemented in
Ciao and ECLiPSe (and Logtalk?), although the way the packages are
specified there is much more fine-grained.

If you want DCG translation and do further term expansion on the result,
you can call dcg_translate_rule/2. Would be nice if this had the same
name in all systems supporting DCGs ... As I understand it, some people
assume you can call expand_term/2 to achieve DCG translation. There are
two issues with that: it might do a lot more and it is probably a bad
idea to call expand_term/2 from term_expansion/2.  It surely easily gets
you into a loop.

I see no reason to change anything right now.

	Cheers --- Jan
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.