const &
This commit is contained in:
parent
1cbf2802f8
commit
6e2eb11bf9
4
ml.cpp
4
ml.cpp
|
|
@ -1708,7 +1708,7 @@ bool MlEnvironment::has(std::string name) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the value associated with this name in this scope
|
// Get the value associated with this name in this scope
|
||||||
MlValue MlEnvironment::get(std::string name) const {
|
MlValue MlEnvironment::get(const std::string& name) const {
|
||||||
// Meta operations
|
// Meta operations
|
||||||
if (name == "eval") return MlValue("eval", builtin::eval);
|
if (name == "eval") return MlValue("eval", builtin::eval);
|
||||||
if (name == "type") return MlValue("type", builtin::get_type_name);
|
if (name == "type") return MlValue("type", builtin::get_type_name);
|
||||||
|
|
@ -1790,7 +1790,7 @@ MlValue MlEnvironment::get(std::string name) const {
|
||||||
|
|
||||||
std::map<std::string, MlValue>::const_iterator itr = defs.find(name);
|
std::map<std::string, MlValue>::const_iterator itr = defs.find(name);
|
||||||
if (itr != defs.end()) return itr->second;
|
if (itr != defs.end()) return itr->second;
|
||||||
else if (parent_scope != NULL) {
|
else if (parent_scope != nullptr) {
|
||||||
itr = parent_scope->defs.find(name);
|
itr = parent_scope->defs.find(name);
|
||||||
if (itr != parent_scope->defs.end()) return itr->second;
|
if (itr != parent_scope->defs.end()) return itr->second;
|
||||||
else return parent_scope->get(name);
|
else return parent_scope->get(name);
|
||||||
|
|
|
||||||
2
ml.h
2
ml.h
|
|
@ -28,7 +28,7 @@ public:
|
||||||
// creating a lambda function.
|
// creating a lambda function.
|
||||||
bool has(std::string name) const;
|
bool has(std::string name) const;
|
||||||
// Get the value associated with this name in this scope
|
// Get the value associated with this name in this scope
|
||||||
MlValue get(std::string name) const;
|
MlValue get(const std::string& name) const;
|
||||||
// Set the value associated with this name in this scope
|
// Set the value associated with this name in this scope
|
||||||
void set(std::string name, MlValue value);
|
void set(std::string name, MlValue value);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue