On Sun, Mar 24, 2013 at 2:07 PM, mcculloch <mccullochj(a)att.net> wrote:
I am defining a operator => in a package. My package uses a module that indirectly uses another package that defines the same operator, i.e. "foreign_interface" uses package "assertions". I need a different priority, but I am worried about conflicts or interference between the two?
What is the scope of a call to op/3?
The scope of a op/3 declaration (:- op(...)) is the module in which the op/3 appears, i.e., the one in which the package gets loaded.
The scope of a op/3 call (not a declaration) is the current execution.
Does it affect only the package it is in or does the last op/3 called for an operator supersede any previous call regardless of package?
If it is the latter, I need to use a different operator.
Yes, you will have to do this if you want to use two packages simultaneously; unless your operator does not conflict with the previous defined one (priority and associativity).
If you use the same operator '=>' than in argnames (used for record-like notation in terms):
:- op(950, xfx, (=>)).
There will be no (big) problem with the definition in the assertions package:
:- op(975, xfx,(=>)).
There seems to be no difference between 950 and 975 w.r.t. standard operators (',' is 1000, '+' is 900, nothing is between them).
I would rather use : but I was worried about conflicts there too.
Unfortunately :/2 is indeed used for module qualifications (and also in the assertions). It could lead to ambiguities (specially if you more advanced notations like fsyntax).
Optionally, we could enable '.' for module qualifier and free ':' for other purposes, but this would be incompatible with most other Prolog systems (e.g., lists.append(A,B,C) vs. lists:append(A,B,C)).
Note that there is already an experimental JSON parser in Ciao:
http://ciao-lang.org/docs/ciao/json.html
Would it make sense to share the same syntax in JSON and BSON terms? If so, and if we agree on a nicer syntax, we can change it.