From 8241e46680bcae966f9eab2204ea443750373027 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 20 Sep 2009 21:49:53 +0000 Subject: [PATCH] Further refine how clone calls are dynamically generated, to avoid accidentally matching when we should not --- include/chaiscript/language/chaiscript_prelude.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/chaiscript/language/chaiscript_prelude.hpp b/include/chaiscript/language/chaiscript_prelude.hpp index 59b7e5d..406c2d2 100644 --- a/include/chaiscript/language/chaiscript_prelude.hpp +++ b/include/chaiscript/language/chaiscript_prelude.hpp @@ -14,7 +14,7 @@ #define chaiscript_prelude CODE_STRING(\ def new(x) { eval(type_name(x))(); } \n\ def clone(o) : is_type(o, "Dynamic_Object") { var new_o := Dynamic_Object(o.get_type_name()); for_each(o.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; } \n\ -def clone(x) : function_exists(type_name(x)) { eval(type_name(x))(x); } \n\ +def clone(x) : function_exists(type_name(x)) && call_exists(eval(type_name(x)), x) { eval(type_name(x))(x); } \n\ # to_string for Pair()\n\ def to_string(x) : call_exists(first, x) && call_exists(second, x) { \n\ "<" + x.first.to_string() + ", " + x.second.to_string() + ">"; \n\