15 May 06:25
Re: Singleton methods on Float and Bignum
From: Evan Phoenix <evan <at> fallingsnow.net>
Subject: Re: Singleton methods on Float and Bignum
Newsgroups: gmane.comp.lang.ruby.core
Date: 2008-05-15 04:25:47 GMT
Subject: Re: Singleton methods on Float and Bignum
Newsgroups: gmane.comp.lang.ruby.core
Date: 2008-05-15 04:25:47 GMT
On May 14, 2008, at 8:33 PM, Joel VanderWerf wrote: > Evan Phoenix wrote: >> Is this still true? Is there a real reason to not allow methods >> singleton methods to be added to Float or Bignum instances? > > x = 1.0 > def x.foo; end > (1.0).foo # what should happen here? Good point. #foo only existed on the instance created by the '1.0' syntax returned to 'x'. So the justification would be that because there is syntax for them, each time they appear the same in syntax should behave exactly the same? That seem right? > > > Would floats be stored in some kind of table, like symbols, so that > the last line works? If so, every float returned by a method would > have to be looked up in the table to get the unique float object. No? > > > If, OTOH, each float instance, regardless of #==, can respond to > different methods, then there is a major abstraction leak. > > -- > vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407 >
RSS Feed