triska / clpz

Constraint Logic Programming over Integers
https://www.metalevel.at/prolog/clpz
184 stars 15 forks source link

Update custom constraint example #24

Open jeshan opened 1 year ago

jeshan commented 1 year ago

Syntax usage was outdated (since clpfd days). It took me quite some head scratcing to realise that run_propagator extensions should be a dcg rule nowadays!

jeshan commented 1 year ago

I suppose it should be updated for scryer as well https://github.com/mthom/scryer-prolog/blob/master/src/lib/clpz.pl

but somehow it rejects the syntax for mysterious reasons.

jeshan commented 1 year ago

Turns out that this too isn't complete yet: after I load that code (that has clpz:run_propagator), I see that zcompare(A,B,C) no longer holds elsewhere!

Can @triska clarify of a minimum working example?

update: adding :- multifile clpz:run_propagator/4. to both the snippet example and the library code fixes the issue.

jeshan commented 1 year ago

Ulrich, I could change it but Sicstus rejects the double slash as "invalid predicate indicator". :- multifile(clpz:run_propagator/4). works fine.

! Type error in argument 1 of (multifile)/1
! expected dynamic_decl, but found clpz:run_propagator//2
! goal:  multifile clpz:run_propagator//2
! Approximate lines: 2414-2415, file: '/path/to/file.pl'
The procedure run_propagator/4 is being redefined from multifile to non-multifile.
    New file: /path/to/file.pl
Do you really want to redefine it?  (y, n, p, s, a, b, or ?) 

image

Maybe we leave it as is for Sicstus but update the scryer version instead?