2 ms·
Sorry, but it isn't that hard to build prototypes on top of classes in a dynamic language. The cleverest and shortest implementation I've seen is http://snippe
by btilly 17y ago
Sorry, but it isn't that hard to build prototypes on top of classes in a dynamic language. The cleverest and shortest implementation I've seen is http://snippets.dzone.com/posts/show/3378 http://snippets.dzone.com/posts/show/3378 where the following snippet of Ruby code does it:
Proto = Class.new(Class) # Beware: magic.
def Proto.clone
Class.new(self)
end
(Follow the link for an explanation of usage.)
However several other languages have implementations. For a random example see http://search.cpan.org/~teverett/Class-Prototyped-1.11/lib/Class/Prototyped.pm http://search.cpan.org/~teverett/Class-Prototyped-1.11/lib/C....