In older textbooks1 one frequently encounters operator declarations like the following:
?- op(1200,fx,(:-)).
^ ^
These round brackets used to be necessary. But today, they are no longer needed:
| ?- writeq(op(1200,fx,(:-))).
op(1200,fx,:-)
Why are they no longer needed? How does the standard cope with this situation?
1 p.97 6. Standard Operator Declarations of MU-Prolog 3.2db reference manual, appearing in Negation and Control in Prolog by Lee Naish, LNCS 238, Springer-Verlag 1985.
Brackets are only needed for compounds formed from complex ions. But what is a complex ion? Well, it’s an ion that is made up of more than one element. The most common examples of complex ions are: You’re expected to know the formulae of these complex ions (and their charges) for the exam.
The reason is that you need to put a bracket around the complex ion to show how many of those whole complex ions there are in the compound. That’s it for brackets!
No brackets. That’s it. Simple! Brackets are only needed for compounds formed from complex ions. But what is a complex ion? Well, it’s an ion that is made up of more than one element. The most common examples of complex ions are: You’re expected to know the formulae of these complex ions (and their charges) for the exam.
Brackets are only needed for compounds formed from complex ions. But what is a complex ion? Well, it’s an ion that is made up of more than one element. The most common examples of complex ions are:
All of the following refers to ISO/IEC 13211-1:1995. Let me move inside out...
6.5.1 graphic char = ":";
graphic char = "-";
6.4.2 graphic token char = graphic char;
graphic token = graphic token char, { graphic token char };
name token = graphic token;
6.4 name = [ layout text sequence (* 6.4.1 *) ], name token;
6.3.1.3 atom = name;
6.5.3 open char = "(";
close char = ")";
comma char = ",";
6.4.8 open token = open char;
close token = close char;
comma token = comma char;
6.4.1 (* grammar rules for layout text sequence were omitted *)
6.4 comma = comma token;
open ct = open token;
close = [ layout text sequence ], close token;
6.3.3.1 arg = atom; (* if that atom is an operator *)
arg = term; (* otherwise: priority = 999 *)
6.3.3 arg list = arg;
arg list = arg, comma, arg list;
6.3.3 term = atom, open ct, arg list, close ;
So we come back to the initial question:
These round brackets used to be necessary. But today, they are no longer needed. Why are they no longer needed? How does the standard cope with this situation?
Let's assume T = op(1200,fx,:-)
holds.
T
is a compound term provided in functional notation.
T
is covered by above rule term = atom, open ct, arg list, close;
atom
matches op
, which is the functor of T
.
open ct matches an open bracket.
the "middle part" (the arguments of T
) is covered by the grammar rules for arg list
.
arg list
is a non-empty list of arg
.
What's arg
?
a term with priority less than 1000, the priority of (',')/2. E.g., 1200
and fx
.
an atom that is an operator. (No strings attached!)
close matches a closing bracket.
Quoting:
An argument (represented by
arg
in the syntax rules occurs as the argument of a compount term or element of a list. It can be an atom which is an operator,or a term with priority not greater than 999. When an argument is an arbitrary term, its priority shall be less than the priority of the ',' (comma) operator so that there is no conflict between comma as an infix operator and comma as an argument or list element separator.
Note:
This concept of an "argument" ensures that both the terms
f(x,y)
andf(:-, ;, [:-, :-|:-])
are syntactically valid whatever operator definitions are currently defined. Comma is not an atom and the following "terms" have syntax errors:f(,,a)
,[a,,|v]
, and[a,b|,]
; but the following two terms are syntactically valid:f(',',a)
,[a,','|v]
, and[a,b|',']
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With