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.1 Operators and quoted atoms

As of SWI-Prolog versionĀ 7, quoted atoms loose their operator property. This means that expressions such as A = 'dynamic'/1 are valid syntax, regardless of the operator definitions. From questions on the mailinglist this is what people expect.151We believe that most users expect an operator declaration to define a new token, which would explain why the operator name is often quoted in the declaration, but not while the operator is used. We are afraid that allowing for this easily creates ambiguous syntax. Also, many development environments are based on tokenization. Having dynamic tokenization due to operator declarations would make it hard to support Prolog in such editors. To accomodate for real quoted operators, a quoted atom that needs quotes can still act as an operator.152Suggested by Joachim Schimpf. A good use-case for this is a unit library153https://groups.google.com/d/msg/comp.lang.prolog/ozqdzI-gi_g/2G16GYLIS0IJ, which allows for expressions such as below.

?- Y isu 600kcal - 1h*200'W'.
Y = 1790400.0'J'.