Лог консультации по парадигмам, 05.10.2016
Материал из SEWiki
# НЕТ В КОДЕ РЕШЕНИЯ ВООБЩЕ
if a + b > 2:
print(a)
print(b)
else:
print(b)
print(3)
# А вот это - есть.
prog = Conditional(
BinaryOperation(
BinaryOperation(Reference("a"), "+", Reference("b")),
">",
Number(2)
),
[Print(Reference("a")),
Print(Reference("b"))],
[Print(Reference("b")),
Print(Number(3))]
)
lv = ...
rv = ...
if op == "+":
return lv + rv
elif op == "-":
pass
elif op == "*":
pass
else
assert False, "Unknown operation"
evaluate(scope)
Read("foo").evaluate(scope):
Scope: var_name --> var_value
int top_var;
Scope top_var;
if (...) {
int a;
Scope: a --> ...; top_scope -> ...
// ...
}
// a уже нет
if (...) {
int a;
}