Skip to content

Circular predicate usage from different modules. #2992

Answered by triska
Kapelianovych asked this question in Q&A
Discussion options

You must be logged in to vote

It seems this is one of the very first use cases of higher-order phrase//N non-terminals! Very nice!

First, why the existence error? It occurs because expression/3 is not available in the context of the string module. No problem, we can make Scryer automatically add the required module-qualification with a meta_predicate/1 declaration in module string:

:- meta_predicate(string(2, ?, ?, ?)).

When we do this, then Scryer will automatically add the required module-prefix, and it will be as if you had written the invocation of string//2 as: string(expression:expression, Node).

But then we get:

?- phrase(expression(A), "'foo ${'1'}'").
   error(type_error(atom,expression:expression),(=..)/2).

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Kapelianovych
Comment options

@triska
Comment options

@Kapelianovych
Comment options

@triska
Comment options

Answer selected by Kapelianovych
@triska
Comment options

@Kapelianovych
Comment options

@triska
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants