From: Florian Gross Date: 2004-05-26T05:43:50+09:00 Subject: Re: ruby-dev summary 23459-23562 Mark Hubbart wrote: >> 1) What will yield(*[]) do? > I would assume the same as currently: it expands to zero arguments, > becomes yield() Yes, but does this translate to an empty Values object? What happens when it is used in assignment or block parameters? > Why would rescoping rules be changed? Currently, when you call > define_method, Class.new, Module.new, etc., the block is rescoped (is > that the right word?) and local variables never leak in. So, assuming > they don't make a silly change, define_method would be _exactly_ > orthogonal to def...end: Currently those constructs aren't identical and that allows us to do some very interesting stuff. IMHO that behaviour is also a good thing because it makes blocks very consistent. You also have access to variables of surrounding scopes in .instance_eval, for example. Here's an useless, but interesting example -- there are also cases where this is useful, however. class Foo count = 0 define_method(:initialize) do count += 1 @number = count end attr_accessor :number end (1..10).map { Foo.new.number } # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > Disclaimer: This is only based on the way I read it; I could very likely > be all wet. :) I don't know -- as always, it would be very interesting to know matz' opinion about all this. :) > cheers, > Mark Regards, Florian Gross