Esempio n. 1
0
        def the_assignment(new_val, val_fail):
            old_val = lookup_variable_value(var, env)
            set_variable_value(var, new_val, env)

            def restore_old_value(*args):
                set_variable_value(var, old_val, env)
                return continue_with(val_fail, *args)

            return continue_with(succeed, S.OK, restore_old_value)
Esempio n. 2
0
 def the_assignment(environment):
     set_variable_value(var, value_exec(environment), environment)
     return S.OK
Esempio n. 3
0
    match_args(is_cond, is_environment),
    lambda expression, environment:
    (g.eval(cond_to_if(expression), environment)),
)

g.define_eval_handler(
    match_args(is_let, is_environment),
    lambda expression, environment:
    (g.eval(let_to_combination(expression), environment)),
)

g.define_eval_handler(
    match_args(is_assignment, is_environment),
    lambda expression, environment: (set_variable_value(
        assignment_variable(expression),
        g.eval(assignment_value(expression), environment),
        environment,
    )),
)

g.define_eval_handler(
    match_args(is_definition, is_environment),
    lambda expression, environment: (define_variable(
        definition_variable(expression),
        g.eval(definition_value(expression), environment),
        environment,
    )),
)

# apply handlers
Esempio n. 4
0
 def restore_old_value(*args):
     set_variable_value(var, old_val, env)
     return continue_with(val_fail, *args)
Esempio n. 5
0
 def the_assignment(new_val, val_fail):
     set_variable_value(var, new_val, env)
     return continue_with(succeed, S.OK, val_fail)