6.6 Overruling Module Boundaries
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Modules
        • Overruling Module Boundaries
          • Explicit manipulation of the calling context
            • @/2
    • Packages

6.6.1 Explicit manipulation of the calling context

Quintus' derived module systems have no means to separate the lookup module (for finding predicates) from the calling context (for qualifying meta arguments). Some other Prolog implementations (e.g., ECLiPSe and IF/Prolog) distinguish these operations, using @/2 for setting the calling context of a goal. This is provided by SWI-Prolog, currently mainly to support compatibility layers.

@(:Goal, +Module)
Execute Goal, setting the calling context to Module. Setting the calling context affects meta-predicates, for which meta arguments are qualified with Module and transparent predicates (see module_transparent/1). It has no implications for other predicates.

For example, the code asserta(done)@world is the same as asserta(world:done). Unlike in world:asserta(done), asserta/1 is resolved in the current module rather than the module world. This makes no difference for system predicates, but usually does make a difference for user predicates.

Not that SWI-Prolog does not define @ as an operator. Some systems define this construct using op(900, xfx, @).