Changed to using to_string as dispatch instead of print and puts

This commit is contained in:
Jonathan Turner 2009-07-02 17:45:58 +00:00
parent 60b814f687
commit 6ddef8f918
2 changed files with 9 additions and 11 deletions

View File

@ -5,19 +5,17 @@
#define CHAISCRIPT_PRELUDE_HPP_ #define CHAISCRIPT_PRELUDE_HPP_
const char *chaiscript_prelude = " \n\ const char *chaiscript_prelude = " \n\
def puts(x) : call_exists(range, x) { \n\ def to_string(x) : call_exists(range, x) { \n\
puts(\"[ \") \n\ var outstr = \"[\" + x.join(\", \") + \"]\"\n\
x.for_each(fun(x) { puts(x); puts(\" \") }) \n\ outstr \n\
puts(\"]\") \n\ }\n\
def to_string(x) { \n\
var outstr = x.internal_to_string()\n\
outstr \n\
}\n\ }\n\
def puts(x) { \n\ def puts(x) { \n\
print_string(x.to_string()) \n\ print_string(x.to_string()) \n\
}; \n\ }; \n\
def print(x) : call_exists(range, x) { \n\
puts(\"[ \") \n\
x.for_each(fun(x) { puts(x); puts(\" \") }) \n\
print(\"]\") \n\
} \n\
def print(x) { \n\ def print(x) { \n\
println_string(x.to_string()) \n\ println_string(x.to_string()) \n\
}; \n\ }; \n\

View File

@ -472,8 +472,8 @@ namespace dispatchkit
add_oper_assign<std::string>(s); add_oper_assign<std::string>(s);
register_function(s, &to_string<const std::string &>, "to_string"); register_function(s, &to_string<const std::string &>, "internal_to_string");
register_function(s, &to_string<bool>, "to_string"); register_function(s, &to_string<bool>, "internal_to_string");
register_function(s, &unknown_assign, "="); register_function(s, &unknown_assign, "=");
bootstrap_pod_type<double>(s, "double"); bootstrap_pod_type<double>(s, "double");