Skip to content

Variable A and atom 'A' indistinguishable in JSON results. #3

@aindilis

Description

@aindilis

Hi anniepoo!

I have a use for JavaPengine, and I'm trying to get variables to work: If one, in ManualAsk.java, changes the following line:

for(Query q = p.ask("member(X, [a(taco),2,c])"); q.hasNext() ; ) {

to use instead:

member(X, [a(taco,A,_A,'A','C D'),b,dag,2,'2',c])

The following JSON is returned.

{"A":"A","X":{"args":["taco","A","_","A","C D"],"functor":"a"}}
{"A":"_","X":"b"}
{"A":"_","X":"dag"}
{"A":"_","X":2}
{"A":"_","X":"2"}
{"A":"_","X":"c"}

You can see that numbers are working correctly (it returns atom 2 as "2" but number 2 as 2). But with variables I do not see here any way to distinguish them, and I'm not sure what is happening to the _A, it looks like it may be becoming simply "_". I would expect this to read something like:

{"X":{"args":["taco",{"variable":"A"},{"variable":"_A"},"A","C D"],"functor":"a"}}

This is how SWIPL is handling it:

?- member(X, [a(taco,A,_A,'A','C D'),b,dag,2,'2',c]).
X = a(taco, A, _A, 'A', 'C D') ;
;
X = b .

?- 

Please let me know if I need to provide more information.

Best,
aindilis

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions