UnquoteLink

From OpenCog
Jump to: navigation, search

The UnquoteLink may be used (typically by the pattern matcher) to escape a QuoteLink. As QuoteLink behaves like a Scheme/Lisp/Racket quasiquote, multiple nestings of QuoteLink require multiple nestings of UnquoteLink to escape. This is done by maintaining a quotation level (see QuoteLink for more info). For example

GetLink
   VariableNode "$Y"
   QuoteLink
      ListLink
         VariableNode "$X"
         UnquoteLink
            VariableNode "$Y"
         QuoteLink
            UnquoteLink
               VariableNode "$Z"

would match

ListLink
   VariableNode "$X"
   ConceptNode "A"
   QuoteLink
      UnquoteLink
         VariableNode "$Z"

with VariableNode "$Y" grounded with ConceptNode "A". That is variables $X and $Z gets quoted due to the quotation level being 1 in both cases.