[pypy-dev] Object model

Rocco Moretti roccomoretti at netscape.net
Sun Feb 16 00:30:20 CET 2003

Armin Rigo <arigo at tunes.org> wrote:

>One of the problems with wrap()/unwrap() is when they are applied to
>containers.  As they are, they have to "translate" the whole structure
>recursively, which is often not a good idea.
>On the other hand, if we define more specialized purpose-oriented methods, we
>loose opportunities given by wrap()/unwrap() to let particular routines send
>or examine an arbitrary piece of data.  I'm thinking about type-based
>dispatch, for example, where you have to query the type of an object with the
>appropriate ObjectSpace method, and then unwrap() this type.
>I don't know which one is better.  Maybe both are useful.  I guess we will
>have to try and see.  Hopefully, trying both should be easy in the early

Now that I think of it, there is is no reason *not* to have both. As much 
as feasable, we can define special-purpose functions to aid in 
optimization and separation of concerns (e.g. have the truth() converter), 
but also have the generic functions (e.g. unwrap()) so that there is 
maximum flexibility available if we choose to use it. If we allow each to 
not work for some cases, having both can incorporate either extreme (just 
have the other function always fail).

We can get the best of all worlds.

The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

More information about the Pypy-dev mailing list