{"action":"created","issue":{"url":"https://api.github.com/repos/SWI-Prolog/roadmap/issues/14","labels_url":"https://api.github.com/repos/SWI-Prolog/roadmap/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/SWI-Prolog/roadmap/issues/14/comments","events_url":"https://api.github.com/repos/SWI-Prolog/roadmap/issues/14/events","html_url":"https://github.com/SWI-Prolog/roadmap/issues/14","id":108473468,"number":14,"title":"Attributed variables: Interface convergence","user":{"login":"triska","id":7482140,"avatar_url":"https://avatars.githubusercontent.com/u/7482140?v=3","gravatar_id":"","url":"https://api.github.com/users/triska","html_url":"https://github.com/triska","followers_url":"https://api.github.com/users/triska/followers","following_url":"https://api.github.com/users/triska/following{/other_user}","gists_url":"https://api.github.com/users/triska/gists{/gist_id}","starred_url":"https://api.github.com/users/triska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/triska/subscriptions","organizations_url":"https://api.github.com/users/triska/orgs","repos_url":"https://api.github.com/users/triska/repos","events_url":"https://api.github.com/users/triska/events{/privacy}","received_events_url":"https://api.github.com/users/triska/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SWI-Prolog/roadmap/labels/Core","name":"Core","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-09-26T14:54:54Z","updated_at":"2015-12-18T15:38:49Z","closed_at":null,"body":"The SWI interface for attributed variables is currently not general enough to express what is needed.\r\n\r\nExample, taken from `library(clpb)`: `X = Y` should be equivalent to `sat(X =:= Y)`.\r\n\r\nThere thus are cases where we need to reason about variables *before* the unification takes place or, equivalently, any pre-existing triggering unifications are *undone* before the hook is called.\r\n\r\nI recommend convergence with the interface used by SICStus Prolog, also to increase portability across different Prolog systems, or the design of an interface that is at least as general. Please contact me if you have any questions about this issue and want to work on it."},"comment":{"url":"https://api.github.com/repos/SWI-Prolog/roadmap/issues/comments/165809447","html_url":"https://github.com/SWI-Prolog/roadmap/issues/14#issuecomment-165809447","issue_url":"https://api.github.com/repos/SWI-Prolog/roadmap/issues/14","id":165809447,"user":{"login":"JanWielemaker","id":3071146,"avatar_url":"https://avatars.githubusercontent.com/u/3071146?v=3","gravatar_id":"","url":"https://api.github.com/users/JanWielemaker","html_url":"https://github.com/JanWielemaker","followers_url":"https://api.github.com/users/JanWielemaker/followers","following_url":"https://api.github.com/users/JanWielemaker/following{/other_user}","gists_url":"https://api.github.com/users/JanWielemaker/gists{/gist_id}","starred_url":"https://api.github.com/users/JanWielemaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanWielemaker/subscriptions","organizations_url":"https://api.github.com/users/JanWielemaker/orgs","repos_url":"https://api.github.com/users/JanWielemaker/repos","events_url":"https://api.github.com/users/JanWielemaker/events{/privacy}","received_events_url":"https://api.github.com/users/JanWielemaker/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T15:38:49Z","updated_at":"2015-12-18T15:38:49Z","body":"current_predicate/2 and predicate_property/2 are out of the question.  For one thing, ISO\r\ncurrent_predicate/2 is not supposed to work for static code (works in SWI).  Second, these\r\nare just too slow operations.  A simple option is to define\r\n\r\n    system:verify_attributes(_Var, _Attr3, _Value) :- fail.\r\n\r\nI think I'm more in favour of having an undefined predicate trap, as that is far easier to debug\r\ninstead of a failing unification because somebody adds an attribute without defining a hook.\r\n\r\nCan you help clarifying what will happen if we do `put_attr(V, test, a)` and call `V = v`.  This is my picture with holes:\r\n\r\n  - Unify `V=v`, this pushes the wakeup goals.\r\n    - Does the actual binding happen?\r\n      - if yes, when and how is it undone?  Immediately after unification?  Just before\r\n        wakeup?\r\n      - if no, how to we protect against the occur check?  This would be problematic\r\n        if the answer above is _Immediately after unification_ because there may be\r\n        multiple unifications before wakeup is called.\r\n  - If wakeup is called\r\n      - We call `verify_attributes(Var, AttrList, Value)` in every module where we now call\r\n        attr_unify_hook/2.  The difference is that the binding is not yet made and you\r\n        have access to all other attributes on this variable.\r\n      - We can easily provide all attributes to all hooks without changing anything to the C\r\n        code.  Why do we need access to the variable bound (also next question)?\r\n  - When is the binding actually done?   Do the hooks to that?  That would mean\r\n    `X = Y, X == Y` is no longer necessarily true.  That would worry me.\r\n\r\n"}}