Ignore:
Timestamp:
Jun 15, 2005, 11:38:16 AM (19 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
04f6a4e219c5180c44ff638afd7e63cc8ffa3699
Parents:
d0eb8c62a0f20ffc02130a688aabd569d1ac4430
Message:
*bricken: scope fixes, refactoring


git-svn-id: file:///usr/local/Singular/svn/trunk@8368 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/openmathserver/binding.py

    rd0eb8c rc012463  
    1 from objects import OMobject, OMsymbol
     1from objects import OMObjectBase, OMsymbol
    22from cd import *
    33from omexceptions import *
    44from itertools import izip
     5from copy import copy
    56cdFns1=OMcd("fns1")
    67lambdasym=OMsymbol("lambda",cdFns1)
     
    910    return lambdasym==sym
    1011   
    11 class OMbinding(OMobject):
     12class OMbinding(OMObjectBase):
     13    """hopefully fixed possible problems: reevaluation writes new scope, if it isn't
     14       meant so, references do not work correctly because of scopes
     15       solve this by first evaluation to bounded OMbinding"""
    1216    def __init__(self, binder,variables,block):
    1317        super(OMbinding,self).__init__()
     
    1519        self.binder=binder
    1620        self.variables=variables
     21        self.bounded=False
    1722    def evaluate(self,context):
    1823        assert islambda(self.binder)
    19         self.scope=context.scopeFromCurrentScope()
    20         return self
     24        if not self.bounded:
     25            mycopy=copy(self)
     26            mycopy.scope=context.scopeFromCurrentScope()
     27            mycopy.bounded=True
     28            return mycopy
     29        else:
     30            return self
    2131    def bind(self, args):
    2232        #print args, self.variables
Note: See TracChangeset for help on using the changeset viewer.