remove duplicated functionality
This commit is contained in:
18
ml.cpp
18
ml.cpp
@@ -1165,18 +1165,6 @@ MlValue read(std::vector<MlValue> args, MlEnvironment &env) {
|
|||||||
return run(line, env);
|
return run(line, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read line from stdin
|
|
||||||
MlValue read_line(std::vector<MlValue> args, MlEnvironment &env) {
|
|
||||||
eval_args(args, env);
|
|
||||||
|
|
||||||
if (args.size() != 0)
|
|
||||||
throw MlError(MlValue("read-line", read_line), env, TOO_MANY_ARGS);
|
|
||||||
|
|
||||||
std::string line;
|
|
||||||
std::getline(std::cin, line);
|
|
||||||
return MlValue::string(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the contents of a file
|
// Get the contents of a file
|
||||||
MlValue read_file(std::vector<MlValue> args, MlEnvironment &env) {
|
MlValue read_file(std::vector<MlValue> args, MlEnvironment &env) {
|
||||||
eval_args(args, env);
|
eval_args(args, env);
|
||||||
@@ -1425,7 +1413,8 @@ MlValue get_env(std::vector<MlValue> args, MlEnvironment &env) {
|
|||||||
if (const char* env_p = std::getenv(args[0].as_string().c_str()))
|
if (const char* env_p = std::getenv(args[0].as_string().c_str()))
|
||||||
return MlValue::string(env_p);
|
return MlValue::string(env_p);
|
||||||
else
|
else
|
||||||
return MlValue::nil();
|
// TODO maybe better to return MlValue::nil();
|
||||||
|
return MlValue::string("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set environment variable
|
// set environment variable
|
||||||
@@ -2208,11 +2197,10 @@ std::map <const std::string, Builtin> builtin_funcs
|
|||||||
std::make_pair("exit", builtin::exit),
|
std::make_pair("exit", builtin::exit),
|
||||||
std::make_pair("quit", builtin::exit),
|
std::make_pair("quit", builtin::exit),
|
||||||
std::make_pair("print", builtin::print),
|
std::make_pair("print", builtin::print),
|
||||||
std::make_pair("input", builtin::input),
|
|
||||||
std::make_pair("random", builtin::random),
|
std::make_pair("random", builtin::random),
|
||||||
std::make_pair("include", builtin::include),
|
std::make_pair("include", builtin::include),
|
||||||
|
std::make_pair("input", builtin::input),
|
||||||
std::make_pair("read", builtin::read),
|
std::make_pair("read", builtin::read),
|
||||||
std::make_pair("read-line", builtin::read_line),
|
|
||||||
std::make_pair("read-file", builtin::read_file),
|
std::make_pair("read-file", builtin::read_file),
|
||||||
std::make_pair("read-file-lines", builtin::read_file_lines),
|
std::make_pair("read-file-lines", builtin::read_file_lines),
|
||||||
std::make_pair("write-file", builtin::write_file),
|
std::make_pair("write-file", builtin::write_file),
|
||||||
|
|||||||
Reference in New Issue
Block a user