diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-11 00:01:04 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-11 00:01:04 +0000 |
commit | a64c1ec2a50f62d63872eac6bc740966602e87bd (patch) | |
tree | e4eab2e74b82eb51c4a5d9b3a132506895974f93 /cpp/sca/modules/eval/environment.hpp | |
parent | 89246640ca239097800fed58e7abc5bc050e3f56 (diff) |
Some code cleanup, removed unused functions, changed == empty-list to isNil to avoid unnecessary construction of empty lists, replaced some casts by generic declarations. Added simple maybe, failable and state monad classes to help return optional objects or failures and carry state around. Added utility functions to zip and unzip list.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@823981 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/sca/modules/eval/environment.hpp')
-rw-r--r-- | cpp/sca/modules/eval/environment.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cpp/sca/modules/eval/environment.hpp b/cpp/sca/modules/eval/environment.hpp index 4abf558cfa..671175b96d 100644 --- a/cpp/sca/modules/eval/environment.hpp +++ b/cpp/sca/modules/eval/environment.hpp @@ -80,16 +80,16 @@ const bool isDotVariable(const value& var) { } const Frame makeBinding(const Frame& frameSoFar, const list<value>& variables, const list<value> values) { - if (variables == list<value>()) { - if (values != list<value>()) + if (isNil(variables)) { + if (!isNil(values)) std::cout << "Too many arguments supplied " << values << "\n"; return frameSoFar; } if (isDotVariable(car(variables))) return makeBinding(frameSoFar, cdr(variables), makeList<value>(values)); - if (values == list<value>()) { - if (variables != list<value>()) + if (isNil(values)) { + if (!isNil(variables)) std::cout << "Too few arguments supplied " << variables << "\n"; return frameSoFar; } @@ -158,7 +158,7 @@ const Env setupEnvironment() { const value lookupEnvLoop(const value& var, const Env& env); const value lookupEnvScan(const value& var, const list<value>& vars, const list<value>& vals, const Env& env) { - if(vars == list<value> ()) + if(isNil(vars)) return lookupEnvLoop(var, enclosingEnvironment(env)); if(var == car(vars)) return car(vals); |