What criteria for "good"? I'm not aware of any lib that preports
"enterprise quality" or anthing like that. I've played with the ideas
though. Prototype-based OOP interests me. On the surface it appears as
simple as aliasing an Object#new to #$dup and instantiation a bunch of
initiaial prototypes for each class -- of course some classes won't
play nice woth this, like File for instance.
Other than that I also played around with this:
module ProtobaseKernel
def meta ; (class << self; self; end) ; end
def obj(&blk)
o = Object.new
o.instance_eval(&blk)
h = {}
iv = o.instance_variables
iv.each { |k| h[k[1..-1].to_sym] = o.instance_eval{
instance_variable_get(k) } }
o.meta.class_eval {
h.each { |k,v|
case v
when Proc
#define_method(k){ |*args| v[*args] }
attr_reader k
else
attr_accessor k
end
}
}
o
end
def fn(&blk)
proc(&blk)
end
def new(o=nil)
return o.clone if o
return self.clone
end
end
class Object
include ProtobaseKernel
end
# Example -----------------
person = obj {
@name = ''
@age = 0
@announce = fn { |x| "#{x}, #{name} is #{age}" }
}
person.name = 'Tom'
person.age = 35
puts person.announce['Peter']