__rcall__???

Tres Seaver tseaver at starbase.neosoft.com
Mon Dec 20 21:49:02 EST 1999


In article <385E74B8.CC2CFFC8 at math.okstate.edu>,
David C. Ullrich <ullrich at math.okstate.edu> wrote:
>
>
>Tres Seaver wrote:
>
>> In article <002101bf4a98$01eda860$922d153f at tim>,
>> Tim Peters <tim_one at email.msn.com> wrote:
>> >[David C. Ullrich]
>> >>     So why isn't there a magic __rcall__, that would go with
>> >> __call__ like the other __rop__'s go with __op__?
>> >>
>> >>     It seems useful to me to allow x to alter the way f behaves
>> >> when you call f(x); ...
>> >
>> >Probably for the same reason there's no __rgetitem__ for the benefit of the
>> >millions of programmers who want
>> >
>> >    x[i]
>> >
>> >to use x as an index into sequence i <wink>.  That is, AFAIK nobody ever
>> >asked for it before, and it's not screamingly natural (you're not really
>> >*surprised* at the lack of __rcall__, right?).
>>
>> Smells like Visitor/multimethods/DoubleDispatch to me, and it _is_ a vacuum
>> which people code around, in most languages except Lisp and its progenty;
>> David is apparently the first to propose this particular solution
>> (quite Pythonic, it seems to me,
>
>    I got an email saying something about "Visitor methods". I won't ask what
>that is, I'll look it up somewhere.

* double dispatch
    selecting the method to be called based on the classes of both objects
	involved (as distinct from single dispatch, like a virtual function in
	C++,

* multimethods (Lisp and derivatives)
    all arguments contribute to the selection algorithm.

* Visitor
    a design pattern [1] used to implement double dispatch in languages
	which don't have multimethods as a native construct.


[1] "design pattern" is the meme to use when searching: try hillside.net for
    starters

>(I didn't think that I was the first person
>in the universe to wonder about this, but I don't know any of that programming
>stuff. In my implementation the concept is "ettiquette":  Data and Function
>both descend from Nice. Nice objects are very careful about stepping on
>other objects' toes - everyone else has a veto power.)
>
>> only adding slots to the jump
>> table is not likely to win wide support).
>
>    Wasn't actually saying that it should be added to the langauge,
>mainly wanted to make certain that it wasn't already there.
>
>> >better-hope-for-santa-to-do-it-cuz-i-doubt-guido-will-ly y'rs  - tim
>>
>> Looking-hopefully-for-sinterklaas'ly,
>>
>    Wondering-whether-you-guys-find-your-'-'-keys-wear-out-first,
>
>um, I mean
>
>    Wondering-whether-you-guys-find-your-'-'-keys-wear-out-first'ly,

yes-but-sinterklaas-brings-us-new-ones-each-year'ly,

Tres.
-- 
---------------------------------------------------------------
Tres Seaver           tseaver at palladion.com       713-523-6582
Palladion Software    http://www.palladion.com



More information about the Python-list mailing list