• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

5.3 Syntax changes
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • SWI-Prolog extensions
        • Syntax changes
          • Operators and quoted atoms
          • Compound terms with zero arguments
          • Block operators
    • Packages

5.3.3 Block operators

Introducing curly bracket and array subscripting.148Introducing 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:

[ ]
This operator is typically declared as a low-priority yf postfix operator, which allows for array[index] notation. This syntax produces a term []([index],array).
{ }
This operator is typically declared as a low-priority 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))

ClioPatria (version V3.1.1-51-ga0b30a5)