Exemplo n.º 1
0
def _funcOrMac(interp, form, env, funcormac):
    lit = form.pyvalue
    lambdalist = lit[1].pyvalue
    name = lambdalist.pop(0).name
    body = lit[2:]
    value = funcormac(O.String(name), lambdalist, body, env)
    E.define(env, name, value)
    return value
Exemplo n.º 2
0
 def testDefinition(self):
     """
     Defining z should add it to the innermost frame.
     """
     new = {}
     env = E.pushFrame(self.env, new)
     E.define(env, "z", 4)
     self.assertEquals(new["z"], 4)
Exemplo n.º 3
0
 def testDefinitionShadowing(self):
     """
     Defining x should change it in the innermost frame and not
     affect the binding of x in the outer frames.
     """
     new = {}
     env = E.pushFrame(self.env, new)
     E.define(env, "x", 5)
     self.assertEquals(self.init["x"], 1)
     self.assertEquals(new["x"], 5)
Exemplo n.º 4
0
def special_for(interp, form, env):
    # XXX! Put this in a separate cap.
    form = form.pyvalue
    name = form[1].name
    result = []
    for x in interp.evalForm(form[2], env).pyvalue:
        E.define(env, name, x)
        r = None
        for chunk in form[3:]:
            r = interp.evalForm(chunk, env)
        result.append(r)
    return O.List(result)
Exemplo n.º 5
0
def special_def(interp, form, env):
    lit = form.pyvalue
    value = interp.evalForm(lit[2], env)
    E.define(env, lit[1].name, value)
    return value