GithubHelp home page GithubHelp logo

Broken variable handling? about pyswip HOT 2 CLOSED

VorpalBlade avatar VorpalBlade commented on September 21, 2024
Broken variable handling?

from pyswip.

Comments (2)

VorpalBlade avatar VorpalBlade commented on September 21, 2024

I tried debugging this, and it seems the call to PL_get_chars in Variable.__init__ returns 0 and thus Variable.chars is never set. I assume this should be set to the print name of the variable and allow me to identify unique variables.

I don't have a minimal test case for this (though maybe I could try to write one), but this also happens with a more complex query:

In swipl:

refine(grandparent(Tgt0,Tgt1) :- true, [Tgt0,Tgt1], 0, 0, Results).
Results = [((grandparent(Tgt0, Tgt1):-parent(Tgt0, Tgt0)), 0, 1, [Tgt0, Tgt1]), ...]

And the same query via pyswip:

list(prolog.query(query))
Out[3]: 
[{'Tgt0': Variable(70),
  'Tgt1': Variable(73),
  'Results': [Functor(196877,2,:-(grandparent(Variable(83), Variable(84)), parent(Variable(85), Variable(86))),,(0, ,(1, [Variable(92), Variable(93)]))),
              ...]}]

As can be seen, here every time the same variable appears it has a unique identifier, which means the result is unusable for my application.

from pyswip.

VorpalBlade avatar VorpalBlade commented on September 21, 2024

I found an (the?) issue. The values in core.py for CVT_VARIABLE, BUF_RING etc no longer matches SWI-Prolog.h.
I don't know the exact version where these changes were introduced but it seems new version logic is needed for this.

from pyswip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.