The DCG // syntax + aliasing loses meta_predicate behavior?

I’m not sure if this is a bug or if I’m making a mistake. I have some workarounds that work for me, but I wanted to report this in case it’s a bug or if anyone has advice.

When I try to use_module using the // DCG syntax and as aliasing the predicate, it loses its meta_predicate behavior (it doesn’t prefix it with the module). This only happens when I use both the // and as aliasing.

I’m using SWI-Prolog version 9.2.4.

Examples


Using both // and as is broken

:- module(foo).
:- use_module(library(dcg/high_order),
              [ sequence//2 as seq
              ]).

seq(bar, S) does not prefix my predicate with my module.

I get an error that looks like Unknown procedure: dcg_high_order:bar/3


DCG // only (Good)

:- module(foo).
:- use_module(library(dcg/high_order),
              [ sequence//2
              ]).

sequence(bar, S) does prefix my predicate to foo:bar.


Alias as only (Good)

:- module(foo).
:- use_module(library(dcg/high_order),
              [ sequence/4 as seq
              ]).

seq(bar, S) does prefix my predicate to foo:bar.

1 Like

You hit a bug. I pushed a fix to the swipl-devel GIT repo. Note that renaming during import is a SWI-Prolog extension to the de-facto standard module system that is (AFAIK) only shared by YAP.

As a work-around, you can add the meta-predicate declaration for seq//2. That is ugly, but will keep working also after this fix gets into the releases. Alternatively, rebuild from the GIT source :slight_smile:

2 Likes