4.33 Global variables
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Global variables
          • b_setval/2
          • b_getval/2
          • nb_setval/2
          • nb_getval/2
          • nb_linkval/2
          • nb_current/2
          • nb_delete/1
          • Compatibility of SWI-Prolog Global Variables
    • Packages
Availability:built-in
nb_linkval(+Name, +Value)
Associates the term Value with the atom Name without copying it. This is a fast special-purpose variation of nb_setval/2 intended for expert users only because the semantics on backtracking to a point before creating the link are poorly defined for compound terms. The principal term is always left untouched, but backtracking behaviour on arguments is undone if the original assignment was trailed and left alone otherwise, which implies that the history that created the term affects the behaviour on backtracking. Consider the following example:
demo_nb_linkval :-
        T = nice(N),
        (   N = world,
            nb_linkval(myvar, T),
            fail
        ;   nb_getval(myvar, V),
            writeln(V)
        ).