Next / Previous / Contents / Shipman's homepage

25.2. AbSym.bind(): Try to add a binding

Adding a binding to an unbound symbol always succeeds. If the symbol has an existing binding, we call the .combine() method on that binding and pass it the new binding; this will either succeed or raise ValueError if the bindings are not compatible. See the general discussion in Section 24, “class AbTab: The symbol table for codes”.

nomcompile3
# - - -   A b S y m . b i n d

    def bind ( self, abBind ):
        '''Add or combine bindings.
        '''
        #-- 1 --
        # [ if self has no binding ->
        #     self  :=  self bound to abBind
        #     return
        #   else -> I ]
        if self.binding is None:
            self.binding = abBind
            return

For the generic interface definition of the .combine() method, see Section 26, “class AbBind: Base class for bindings”.

nomcompile3
        #-- 2 --
        # [ if self.binding combines with abBind ->
        #     self.binding  :=  self.binding combined with abBind
        #   else -> raise ValueError ]
        self.binding = self.binding.combine ( abBind )