From: Yehuda Katz Date: 2009-02-26T12:56:22+09:00 Subject: [ruby-core:22531] Re: YASNP (Yet Another Selector NamespaceProposal) --001636e90dc3e3753c0463ca58d2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Charles' example was incomplete. The OP: module Foo; def to_s; 'blah'; end; end using Foo for String "hello".to_s -- Yehuda 2009/2/25 Martin Duerst > At 03:46 09/02/26, Charles Oliver Nutter wrote: > > >I wanted to point out that having the following namespace: > > > >module Foo; def to_s; 'blah'; end; end > >using Foo > >'hello'.to_s > > This might be a very silly question, but how does the module/namespace > Foo know that to_s is attached to class String (and strings such as > 'hello')? Or is it attached to all objects used after "using Foo"? > That wouldn't seem right for me, after all, Ruby is object-oriented, > which means methods go on classes, not on files. > > Regards, Martin. > > > > #-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University > #-#-# http://www.sw.it.aoyama.ac.jp mailto:duerst@it.aoyama.ac.jp > > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --001636e90dc3e3753c0463ca58d2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Charles' example was incomplete. The OP:

module Foo; def to_s; &= #39;blah'; end; end
using Foo for String
"hello".to_s
-- Yehuda

2009/2/25 Martin Duerst <= span dir=3D"ltr"><duerst@it.ao= yama.ac.jp>
At 03:46 09/02/26= , Charles Oliver Nutter wrote:

>I wanted to point out that having the following namespace:
>
>module Foo; def to_s; 'blah'; end; end
>using Foo
>'hello'.to_s

This might be a very silly question, but how does the module/namespace
Foo know that to_s is attached to class String (and strings such as
'hello')? Or is it attached to all objects used after "using F= oo"?
That wouldn't seem right for me, after all, Ruby is object-oriented, which means methods go on classes, not on files.

Regards, =A0 =A0Martin.



#-#-# =A0Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University<= br> #-#-# =A0http:/= /www.sw.it.aoyama.ac.jp =A0 =A0 =A0 mailto:duerst@it.aoyama.ac.jp





--
Yehuda Katz
Develope= r | Engine Yard
(ph) 718.877.1325
--001636e90dc3e3753c0463ca58d2--