#1 inconsistent binding in bagof (Javascript, Python)


In Javascript, the following return different answers but the shouldn't:

bagof(X, (X = Y ; Y = 1), B).


bagof(X, (Y = X ; Y = 1), B).


  • Jeff Thompson

    Jeff Thompson - 2008-08-09
    • assigned_to: nobody --> jefft0
  • Jeff Thompson

    Jeff Thompson - 2009-01-29
    • summary: inconsistent binding in bagof (Javascript) --> inconsistent binding in bagof (Javascript, Python)
  • Jeff Thompson

    Jeff Thompson - 2009-07-26

    Analysis: On the first pass, the key for _bagForFreeVariables is the unbound Y, so on the second pass with Y is bound to 1, the key in _bagForFreeVariables is (incorrectly) mutated to 1. This doesn't happen in the second case because the unbound X, not Y, is stored as the key. (This doesn't happen in C# because the dictionary stores the hash of unbound Y for the key and doesn't look at the value on the second pass.)

    To fix, it is tempting to use copy_term when storing the key in _bagForFreeVariables, but then this will incorrectly give 2 answers:
    bagof(X, (X = Y ; X = Y), B).


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks