From 24f3e6ca67053e366cc24db5c0c1e59cac424604 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Tue, 12 Nov 1996 14:32:20 -0800
Subject: [PATCH] clone and new added

Rev: lib/master.pike:1.5
---
 lib/master.pike | 64 ++++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/lib/master.pike b/lib/master.pike
index c5947dee41..6a6c4c65c6 100644
--- a/lib/master.pike
+++ b/lib/master.pike
@@ -2,36 +2,6 @@ string describe_backtrace(mixed *trace);
 
 string pike_library_path;
 
-/* This function is called when an error occurs that is not caught
- * with catch(). It's argument consists of:
- * ({ error_string, backtrace }) where backtrace is the output from the
- * backtrace() efun.
- */
-void handle_error(mixed *trace)
-{
-  predef::trace(0);
-  werror(describe_backtrace(trace));
-}
-
-/* Note that create is called before add_precompiled_program
- */
-void create()
-{
-  /* make ourselves known */
-  add_constant("master",lambda() { return this_object(); });
-  add_constant("describe_backtrace",describe_backtrace);
-  add_constant("version",lambda() { return "Pike v0.2"; });
-  add_constant("mkmultiset",lambda(mixed *a) { return aggregate_multiset(@a); });
-  add_constant("strlen",sizeof);
-
-  add_constant("clone",lambda(program p,mixed ... a) 
-                   	{ return p(@a); } );
-  add_constant("new",lambda(program p,mixed ... a) 
-                   	{ return p(@a); } );
-
-  random_seed(time() + (getpid() * 0x11111111));
-}
-
 mapping (string:program) programs=([]);
 
 /* This function is called whenever a module has built a clonable program
@@ -69,6 +39,40 @@ program cast_to_program(string pname)
   return programs[pname]=ret;
 }
 
+/* This function is called when an error occurs that is not caught
+ * with catch(). It's argument consists of:
+ * ({ error_string, backtrace }) where backtrace is the output from the
+ * backtrace() efun.
+ */
+void handle_error(mixed *trace)
+{
+  predef::trace(0);
+  werror(describe_backtrace(trace));
+}
+
+
+
+object new(mixed prog, mixed ... args)
+{
+  return ((program)prog)(@args);
+}
+
+/* Note that create is called before add_precompiled_program
+ */
+void create()
+{
+  /* make ourselves known */
+  add_constant("master",lambda() { return this_object(); });
+  add_constant("describe_backtrace",describe_backtrace);
+  add_constant("version",lambda() { return "Pike v0.2"; });
+  add_constant("mkmultiset",lambda(mixed *a) { return aggregate_multiset(@a); });
+  add_constant("strlen",sizeof);
+  add_constant("new",new);
+  add_constant("clone",new);
+
+  random_seed(time() + (getpid() * 0x11111111));
+}
+
 /*
  * This function is called whenever a inherit is called for.
  * It is supposed to return the program to inherit.
-- 
GitLab