[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: before, after and around Ruby 1.9

Trans

9/6/2007 3:57:00 PM



On Sep 5, 6:32 pm, Joel VanderWerf <vj...@path.berkeley.edu> wrote:
> Yukihiro Matsumoto wrote:
> > Hi,
>
> > In message "Re: before, after and around Ruby 1.9"
> > on Thu, 6 Sep 2007 03:07:14 +0900, Trans <transf...@gmail.com> writes:
>
> > |Any chance Ruby 1.9 will have before, after and around method
> > |composition support?
>
> > No. Wait for 2.0 for built-in method combination. The vague plan is
> > making open-class to stack methods on the current ones, unless
> > explicitly removed, i.e.
>
> > class Foo < Object
> > def foo
> > puts "Foo#foo (1)"
> > end
> > end
> > class Foo # re-open
> > def foo
> > super # calls the first foo
> > puts "Foo#foo (2)"
> > end
> > end
>
> What if you want to reopen _without_ the "around" semantics? Could we
> have these two variations:
>
> class Foo < Foo # <-- This is a type error in 1.8
> def foo; super; end # AROUND
> end

Almost an anonymous cut.

> class Foo
> def foo; super; end # REDEFINE
> end
>
> At least that is a conservative extension.

The downside here is it's static syntax --making it harder to work
with in dynamic metacode.

T.


1 Answer

gabriele renzi

9/7/2007 10:10:00 AM

0

On Fri, 07 Sep 2007 00:57:09 +0900, Trans wrote:


>> What if you want to reopen _without_ the "around" semantics? Could we
>> have these two variations:
>>
>> class Foo < Foo # <-- This is a type error in 1.8
>> def foo; super; end # AROUND
>> end
>
> Almost an anonymous cut.
>
>> class Foo
>> def foo; super; end # REDEFINE
>> end
>>
>> At least that is a conservative extension.
>
> The downside here is it's static syntax --making it harder to work
> with in dynamic metacode.

shouldn't this work as expected in this case?

Foo = Class.new(Foo) { def foo; super; end} #AROUND

Actually, it already does, but raises a warning :)

--
goto 10: http://www...
blog it: http://riffraff.bl...
blog en: http://www.rif...