T. Onoma
11/21/2003 6:13:00 AM
Now some for some rally crazy cross thought. First a complete interface
definition substantiated on an existent class.
type :IOInteface, *(IO.methods &
IO.private_methods &
IO.protected_methods)
def ameth(x)
IOInterface x
#---
x.read
end
now Lets use theoretical duck_signs with euphoria. will we be happy quackers?
type :big4, '>', 'to_i', 'succ' do |x|
x > 4
end
def ameth(x)
big4 x
#---
puts x.succ
end
method(:ameth).duck_signature # => [ [ 'succ' ] ]
method(:big4).duck_signature # => Holy Quack'n Ducks, Batman!
Consider:
def type(tname, *resp, &check)
define_method(tname) do |*v|
if $_tc
unless v.all? { |y| resp.all? { |z| y.send(:respond_to?, z) } }
raise TypeError, "#{v}"
end
unless v.all? { |y| check.call(y) }
raise TypeError, "#{v}"
end
end
return *v
end
end
can it be done?
1) infinite arity? hmm...have to be considered parameter of array?
2) conditioned (on global) how to signify signiture is conditional?
3) respond_to('all?') No, not *really* array try |y|?
4) y.send, of course, but means y.respond_to?, of course, but means y.z?
5) so... '>', 'to_i', 'succ', i guess?
my head hurts :( i fear godel will soon appear and slap my bitch funny.
BUT wait! There is an even simplier problem!!!!!......(see next post)
-t0