[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: About 1.9 #__method__ feature.

Trans

7/8/2006 5:04:00 AM


Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: About 1.9 #__method__ feature."
> on Mon, 3 Jul 2006 23:33:54 +0900, transfire@gmail.com writes:
>
> |I think the name __method__ is probably a poor choice b/c "shadow
> |methods" (as I call them) do the same thing as their non-shadow forms.
> |Eg. #__send__ and #send, #__id__ and #id, etc. But #__method__ is an
> |exception since #method currently returns a Method object given the
> |name, not the name of the current context.
>
> It's not conjunction with __send__ etc. but with __FILE__ and
> __LINE__. Besides that, I am no longer fond of __send__ and __id__,

I'm with you, ditch __send__ and __id__. But why not ditch all the
__'s if they are ugly, including __FILE__, __LINE__? What's wrong with
globals: $LINE, $FILE, $METHOD, or better yet $line, $file, $method?
After all we use globals for lots of *current* things like $' and
$stdin, and $FILENAME.

> I'd rather like to remove them if it's possible. Use invoke_method
> and object_id respectively instead.

Please consider #object_send. The "object_" prefix indicates that it
something best left alone -ie. this is defined by object/kernel and you
override it only at your own peril! I think this is a great mnemonic
device. I also think #class ought to become #object_class (which would
also free us from having to use the receiver: self.class) That would
give us:

object_id
object_class
object_send

Then for the all methods that bypass access resitrictions:

instance_send
instance_eval
instance_exec
instance_variable_get
instance_variable_set
instance_variables

That way it's consistant, intuitive, easy to use and easy to learn.

The only exceptions is #instance_of? But that's moot if you ask me b/c
it's safer to ask the class anyway. So preferably we would have
Class#class_of?(obj) plus a word alias for Module#=== like
Module#ancestor_of?(obj).

T.


9 Answers

Daniel DeLorme

7/8/2006 12:17:00 PM

0

transfire@gmail.com wrote:
> object_id
> object_class
> object_send
>
> Then for the all methods that bypass access resitrictions:
>
> instance_send
> instance_eval
> instance_exec
> instance_variable_get
> instance_variable_set
> instance_variables

I agree with that proposal, and I think it underlines a fundamental dichotomy
that I've been seeing in the discussion. Basically some people approach this as
users; they want the names to reflect how the methods are used. And some people
approach it as language designers; they want the names to reflect what is
actually going on inside the interpreter. I think the first approach is the
correct one; an interface is not supposed to reveal all the ugly or complicated
or subtle details of the architecture within.

Daniel

Sean O'Halpin

7/8/2006 12:28:00 PM

0

On 7/8/06, transfire@gmail.com <transfire@gmail.com> wrote:
>
> Please consider #object_send. The "object_" prefix indicates that it
> something best left alone -ie. this is defined by object/kernel and you
> override it only at your own peril! I think this is a great mnemonic
> device. I also think #class ought to become #object_class (which would
> also free us from having to use the receiver: self.class) That would
> give us:
>
> object_id
> object_class
> object_send
>
> Then for the all methods that bypass access resitrictions:
>
> instance_send
> instance_eval
> instance_exec
> instance_variable_get
> instance_variable_set
> instance_variables
>
> That way it's consistant, intuitive, easy to use and easy to learn.
>

+1

Sean

Ara.T.Howard

7/8/2006 2:20:00 PM

0

dblack

7/8/2006 2:34:00 PM

0

Ara.T.Howard

7/8/2006 2:45:00 PM

0

Trans

7/8/2006 3:03:00 PM

0


dblack@wobblini.net wrote:

> Maybe Sean was right that you and I are really saying the same thing
> in different ways :-) At least, we seem to have converged on "send!".

But Matz want's to get away from #send, and for good reason -- it's too
likely to be overriden, which is the whole reason we ended up with
__send__. So by it's very nature it needs to be more unique and there
are only two ways to achieve that: make it longer or make it esoteric.
I prefer longer.

T.


Simon Kröger

7/8/2006 3:11:00 PM

0

ara.t.howard@noaa.gov wrote:
> On Sat, 8 Jul 2006 dblack@wobblini.net wrote:
>
>> Maybe Sean was right that you and I are really saying the same thing
>> in different ways :-) At least, we seem to have converged on "send!".
>
> indeed - 'instance_send' gives me carpal tunnel just thinking about it! ;-)
>
> -a

*rofl* you need another signature!

This one:

"suffering increases your inner strength. also, the wishing for
suffering makes the suffering disappear."

was just there to comment this email of yours. It has done it's deed.

cheers

Simon

btw: I don't see a problem with send! either.

Ara.T.Howard

7/8/2006 3:27:00 PM

0

Sean O'Halpin

7/8/2006 4:56:00 PM

0

On 7/8/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
>
> indeed - 'instance_send' gives me carpal tunnel just thinking about it! ;-)
>
> -a

And these don't? ;)

> obj.internal :send, 'msg', 'arg'
> obj.internal{ send 'msg, 'arg' }
> _(obj){ send 'msg', 'arg' }

To be honest, send! seems fine to me too but matz has already nixed it.

Regards,
Sean