Paul Lindner <[EMAIL PROTECTED]> writes:

> On Thu, May 24, 2001 at 09:59:36AM -0400, Chip Turner wrote:
> > darren chamberlain <[EMAIL PROTECTED]> writes:
> > 
> > The nice thing about closures is they could hide any interface at all
> > behind them; all that is required is that the function that generates
> > the closure follow the very simple convention of "return the formvar
> > of the name starting with the first parameter you're called with."
> > There is absolutely no reliance upon the underlying object structure.
> > What you're suggesting is equivalent to assuming the object is derived
> > from some kind of base class that supports the param() method though
> > without actually having to be ISA of that class.  That's naughty OO
> > programming :)  Just because perl lets you be typeless doesn't mean
> > it's always in the best interest of clean design to do so.
> 
> I don't find a problem with passing an object that has a certain set
> of method signatures.  This is functionally loosely equivalent to a
> Java Interface..  Any perl object can implement a particular interface
> just by implementing the methods..  No base class required..

My only objection to this (as I stated in another email) is that it
leaves things largely unspecified.  It's similar to the old perl
problem of passing big hashes around; you assume the data is there,
but there's no real way to find out without checking keys and so
forth.  A simple $foo->isa('Widget::CGIData') can ensure that what
you're talking to is at least derived from the right thing.  Just
because perl would let you call methods on a class not derived from a
standard base doesn't mean it's necessarily appropriate.  An abstract
base class offers little overhead (especially if you override all of
the methods) while still giving that little bit of insurance about
just what you've been passed.  In a library that conceivably could be
used by a number of people, such discipline would probably be a nice
thing, even if it didn't actually buy anything in terms of performance
or features.

> But I agree, closure are very cool, and allow for an additional layer
> of abstraction between the objects, without having to create a proxy
> class..

Closures are definitely cool.  As someone else mentioned, requiring
-all- users of Widgets to use them probably limits the audience,
though, so some level of "smartness" in the Widget system would be
nice; perhaps autogenerating a closure for the things it knows about
(CGI.pm, libapreq, etc).

Chip

-- 
Chip Turner                   [EMAIL PROTECTED]
                              RHN Web Engineer

Reply via email to