Introducing curly bracket and array subscripting.176Introducing
block operators was proposed by Jose Morales. It was discussed in the
Prolog standardization mailing list, but there were too many conflicts
with existing extensions (ECLiPSe and B-Prolog) and doubt about their
need to reach an agreement. Increasing need to get to some solution
resulted in what is documented in this section. These extensions are
also implemented in recent versions of YAP. The symbols []
and
{}
may be declared as an operator, which has the following
effect:
yf
postfix operator, which allows for array[index]
notation.
This syntax produces a term []([index],array)
.xf
postfix operator, which allows for head(arg) { body }
notation. This syntax produces a term {}({body},head(arg))
.Below is an example that illustrates the representation of a typical‘curly bracket language' in Prolog.
?- op(100, xf, {}). ?- op(100, yf, []). ?- op(1100, yf, ;). ?- displayq(func(arg) { a[10] = 5; update(); }). {}({;(=([]([10],a),5),;(update()))},func(arg))