At 07:12 PM 6/29/2001 -0400, Michael G Schwern wrote:
>Please look at Class::Object before responding.  URL below.
>
>
>On Fri, Jun 29, 2001 at 06:36:31PM -0400, John Porter wrote:
> > [EMAIL PROTECTED] wrote:
> > > "Any sufficiently encapsulated hack is no longer a hack."
> >
> > Who said that?  I think it's wrong.
>
>Me.

Well, you're wrong--it's still a hack. The encapsulation just makes it 
possible to remove the hack and replace it with something less hackish at 
some point later. (Yeah, I know--like that ever happens with software...)

>They're NO SLOWER than normal objects, it uses all the normal OO
>channels, it was very simple and small to implement and it WORKS!
>Now, right this second, with perl 5.

There are space costs involved here that aren't obvious.

Each package has its own stash, and every method call you make on an object 
in that package puts a cached entry to that method into the stash. In perl 
5, that's a full GV per unique method. Plus the extra time overhead to 
populate the cache--not a huge hit, but not free.

With perl 6, you'll also see a rather significant space cost, as every 
package that has objects blessed into it will end up with a full vtable. 
I'm not sure how big that'll be, but I expect it'll add another 2K per 
package. (Plus the time to build the vtable on first bless)

Granted neither set of costs is exorbitant, but generating the packages on 
the fly isn't free.

For some applications of objects, this doesn't strike me as the appropriate 
way to approach things. Being able to alter the inheritance tree for an 
object on the fly or, more to the point, to be able to have two objects of 
the same class have different methods strikes me as a useful thing. You may 
have two groups of methods that are identical in name and signature but 
behave mildly differently. Having separate classes for the threaded and 
unthreaded versions of an object seem silly, as does the case where an 
object changes class merely because some of the methods behave slightly 
differently. (Should a disk-backed object look like a different class than 
a non-disk-backed object if they behave identically to the program?)

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to