[SPL] New SPL Object handling
Clifford Wolf
clifford at clifford.at
Mon Apr 25 11:47:09 CEST 2005
Hi,
I've rewritten the object model used in SPL and commited the new code to
subversion in rev. 339. For the trivial cases you shouldn't notice any
difference (except that a smaller number of nodes is used by the vm for
the objects - resulting in a lower memory usage and smaller dump files).
But now there are some complex tricks possible too. E.g. (this is just
accademic - don't use such stuff in your programs! ;-)
var a, b;
function get_base_obj() {
var x = ^a;
object Foo {
method set_a(val) {
x = val;
}
}
return ^Foo;
}
function get_derived_obj(base) {
var x = ^b;
object Foo base {
method set_b(val) {
x = val;
}
}
return ^Foo;
}
var class = get_derived_obj(get_base_obj());
var o = new class();
o.set_a(23);
o.set_b(42);
debug "a=$a"; // output 23
debug "b=$b"; // output 42
such hacks where not possible with the old mechanism...
please let me know if you encounter any problems with the new VM. The
namespace lookup functions are really complex know. I've tried to test all
possible cases - but maybe I've forgotten one..
yours,
- clifford
--
+++>+>++++++[<+++++++>-]<..>++>++++++[<+++++>-]<.>>++++++[<+++++++++++>-]<.
>++>>++++[<++++[<+++++++>-]>-]<<.>+>>++++[<++++[<++++++>-]>-]<<.++++++++.<-
---.>---.<<<<-.>>>>---.<---.<<.<+..>.>>---.>>++++>>++++[<++++[<+++++++>-]>-
]<<..----.<<<--------.<<++++..>>>>>+++++++...<<<<<-.>>>>.<++++.---.>+++..<+
+++++.+++.>--.<<<<.>>>>---.<++.<<<+.>>>>+.++++.---.<----.>>--.<<<<<.>.<----
..>.>+++++++++.>>>>>>++++[<++++[<+++++>-]>-]<<.+++++.<<<<<<+.>.>.>-.--.+++.
>++++++.+++.-------.<++.<<<.>.>>>.>-.<--.<<<<++..>.<---..>>>>>>>++++++++++.
Men are from Mars. Women are from Venus. Computers are from hell.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.rocklinux.net/pipermail/spl/attachments/20050425/f8487106/attachment.bin
More information about the SPL
mailing list