D
Daniel Berger
Hi,
Just a random thought that I think was inspired by several people on
the list asking about getting the name of the method from within the
method - why don't we have Method.new? In other words, what if this:
def foo(x, y=1)
end
Was the equivalent of this?
x = Method.newname => 'foo', arameters => ['x', 'y'], :defaults =>
{'y' => 1})
Object.include(x) # or bind(x) or something
Similar to an UnboundMethod I suppose, but with more options. Wouldn't
it be easier to get method metadata with this approach? And give
programmers the ability to associate any methods with any class or
module?
class Bar
def foo(x, y=1)
p methodfoo).metadata # => @name => 'foo', @parameters =>
['x','y'], :defaults => {'y' => 1})
end
end
Or is this totally stupid?
If this has been discussed before just point me to the thread.
Regards,
Dan
Just a random thought that I think was inspired by several people on
the list asking about getting the name of the method from within the
method - why don't we have Method.new? In other words, what if this:
def foo(x, y=1)
end
Was the equivalent of this?
x = Method.newname => 'foo', arameters => ['x', 'y'], :defaults =>
{'y' => 1})
Object.include(x) # or bind(x) or something
Similar to an UnboundMethod I suppose, but with more options. Wouldn't
it be easier to get method metadata with this approach? And give
programmers the ability to associate any methods with any class or
module?
class Bar
def foo(x, y=1)
p methodfoo).metadata # => @name => 'foo', @parameters =>
['x','y'], :defaults => {'y' => 1})
end
end
Or is this totally stupid?
If this has been discussed before just point me to the thread.
Regards,
Dan