DCG meta-predicate error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DCG meta-predicate error

Samer Abdallah-3
Hi,
There appears to be a bug in the handling of meta-predicates that
expect a DCG goal as an argument:

:- meta_predicate foo(//,?,?).

foo(G) --> phrase(G).

test --> foo({writeln(hello)}).

Using SWI v. 7.1.7 results in
Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning:
Warning: {}/3, which is referenced by
Warning:        /Users/samer/src/sandpit/prolog/test.pl:4: 1-st clause of test/2

Samer.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20140318/7883a4ec/attachment.bin>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|

Re: DCG meta-predicate error

Paulo Moura-2
Hi Samer,

On 18/03/2014, at 18:11, Samer Abdallah <[hidden email]> wrote:

> Hi,
> There appears to be a bug in the handling of meta-predicates that
> expect a DCG goal as an argument:
>
> :- meta_predicate foo(//,?,?).
>
> foo(G) --> phrase(G).
>
> test --> foo({writeln(hello)}).
>
> Using SWI v. 7.1.7 results in
> Warning: The predicates below are not defined. If these are defined
> Warning: at runtime using assert/1, use :- dynamic Name/Arity.
> Warning:
> Warning: {}/3, which is referenced by
> Warning:        /Users/samer/src/sandpit/prolog/test.pl:4: 1-st clause of test/2

I get:

$ swipl
% /Users/pmoura/.plrc compiled 0.00 sec, 2 clauses
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.1.9-53-g30fa74b-DIRTY)
Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- [user].
:- meta_predicate foo(//,?,?).
|:
|: foo(G) --> phrase(G).
|:
|: test --> foo({writeln(hello)}).
|: % user://1 compiled 0.00 sec, 6 clauses
true.

?- listing(test/2).
test(A, B) :-
        foo({writeln(hello)}, A, B).

true.

?- listing(foo/3).
:- meta_predicate foo(//,?,?).

foo(A, B, C) :-
        phrase(A, B, C).

true.

?- phrase(test, []).
hello
true.

If I put your code in a file and consult it I get no warnings:

$ swipl
% /Users/pmoura/.plrc compiled 0.00 sec, 2 clauses
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.1.9-53-g30fa74b-DIRTY)
Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- [samer].
% samer compiled 0.00 sec, 6 clauses
true.

Are you using a different SWI-Prolgo version or testing the code in a different way?

Cheers,

Paulo

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

Email: <mailto:[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------




_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog