Re: Anyone actually experienced with object inheritance?

2001-07-06 Thread Michael G Schwern

On Thu, Jul 05, 2001 at 11:04:29AM -0700, Hong Zhang wrote:
 I don't think object inheritence has any significant advantage.
 Since it is not widely used and understood, we should not use it
 in Perl, period.

*cough* A little harsh.


 Its functionality can be achieved by many different ways. The 
 anonymous class is one of them. Personally I prefer using mixin.
 
 The mixin is similar to Java interface. The differences are that
 a) mixin can have instance fields, but they must be private.
 b) mixin can have method implementations.
 c) mixin can not have superclass.

Why no superclass?


 Here is an example:
 
 public mixin Node
 {
   private Node next, prev;
 
   public Node next() { return next; }
   public void next(Node n) { next = n; }
   public Node prev() { return prev; }
   public void prev(Node n) { prev = n; }  
 }
 
 Say if you want Thread can be easily inserted into LinkedList,
 you can write
 
 public Thread extends Object implements Node {
   ...
 }
 
 or
 
 public Thread extends Object, Node {
   ...
 }
 
 and don't bother to implement classic linked list node.

Given that Perl doesn't really have to worry about strict typing or
interfaces (at the very least it will be very optional in Perl 6) what
problem is this solving?

And how would this solve the Mail problem put forth by Ziggy?


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
I'm not actually Kevin Lenzo, but I play him on TV.



Re: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)

2001-07-06 Thread David L. Nicol

Matt Youell wrote:

  Is there a standard?  No.  Does there need to be one? I don't see a need
  for it.
 
 What's wrong with something simple, like saying all classes have an implicit
 new() method that is overloadable? Is this really *that* complicated? Maybe
 I'm not getting the Big Picture.

The problem is, where does this rule belong?  Right now, the constructor
is called Cnew is a cultural standard so strong that at least one
highlighting
code editor highlights it in Perl mode. Is this enforced?  No.  Why?
What if you want multiple constructors with redundant code, et cetera --
there is flexibility.

Selecting a group of standard class methods and insisting that a CPAN
upload be compliant with the standard, more restrictive than What The
Language Lets You Get Awat With -- that makes sense to me.

Perhaps the maintainers of Class::* could converge on a standard API,
including
a standard name for what the class mechanism in use in a particular
instance is.

But would the game be worth the candle?

-- 
   David Nicol 816.235.1187




Re: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)

2001-07-06 Thread Matt Youell

What if you want multiple constructors with redundant code, et cetera --
there is flexibility.

You could get that same flexibility from a mandated new(). If you don't want
to support new, overload it so that it does nothing. Or maybe that could be
the default behavior. The major benefit being a code-supported (but not
enforced) preference that could be relied upon to exist.

Of course, a queriable interface could offer the same sort of thing, at the
expense of an ugly test repeated everywhere.


 Selecting a group of standard class methods and insisting that a CPAN
 upload be compliant with the standard, more restrictive than What The
 Language Lets You Get Awat With -- that makes sense to me.

 Perhaps the maintainers of Class::* could converge on a standard API,
 including
 a standard name for what the class mechanism in use in a particular
 instance is.

Perhaps there is a solution offering more TMTOWTDI-ability.

I've seen a class keyword offered up as a replacement for package dwelling
classes. What if *those* classes had stricter rules, but packaged classes
where allowed to live on, untouched, in festering sin?

 But would the game be worth the candle?

As a rule, I try not to play games involving candles or other flammables.
;-)

- Matt

















Re: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)

2001-07-06 Thread Michael G Schwern

On Fri, Jul 06, 2001 at 12:41:42PM -0500, David L. Nicol wrote:
 But would the game be worth the candle?

IMHO not really.  Of all the potential quirks Perl's OO has, this is
one of the least quirky and least violated.

-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
BOFH excuse #21:

POSIX complience problem