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

2001-07-09 Thread David L. Nicol

Matt Youell wrote:
 
 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.

So you're saying you would $@ to remain undefined after

$NewName=join('',map {${[a..z]}[rand 26]} 1..10);
eval \$Freshone = new $NewName;

What would $Freshone be?  a blessed reference to undef?


-- 
   David Nicol 816.235.1187
It's widely known that the 'F' in RTFM is silent. -- Olie




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



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

2001-07-05 Thread John Porter

Matt Youell wrote:
 The terminology was new to me, however.

I made it up.

-- 
John Porter




RE: Anyone actually experienced with object inheritance?

2001-07-05 Thread Hong Zhang


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.

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.

They share all other properties of interface class.

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.

Hong

Michael G Schwern wrote:

 Rather than stumbling around in the dark here, is anyone actually
 experienced with object inheritance?  Any Self programmers out there?
 Someone that's actually used this technique often and understands what
 works and what does?  Any books/articles to recommend?

Its not quite the same thing, but Java does have the concept of
anonymous classes (it names them 'inner' classes): Is Perl6 going
to have a similar concept?


Dave.
--
Dave Whipp, Senior Verification Engineer,
Fast-Chip inc., 950 Kifer Rd, Sunnyvale, CA. 94086
tel: 408 523 8071; http://www.fast-chip.com
Opinions my own; statements of fact may be in error. 



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

2001-07-05 Thread David L. Nicol

Matt Youell wrote:
 
   MI thing, but now it's sounding like a constructor bubbling scheme, like

 
 Ah, yes. I've had to deal with that problem several times in the past. The
 terminology was new to me, however.
 
 Has there been a proposed solution?
 
 Thanks,
 
 - Matt


What's the problem again?

I mean, really, any OO shop has it's local culture, of what the base
classes
are and so forth.

We've got multiple possible working off-the-shelf inheritance systems that
offer various levels of abstraction and various features.

Is there a standard?  No.  Does there need to be one? I don't see a need
for it.

For introducing New Syntax For Perl Six, which is a game that is Really
Tiresome Since The Suggestions Get Ignored Anyway, what do we want?

A superset of all features available in all OO languages, with a clearly
defined extension declaration system?

Rewriting rules for new syntax, and a standardized shorthand that starts
one
off ahead of where one must now start off?

-- 
   David Nicol 816.235.1187
It's widely known that the 'F' in RTFM is silent. -- Olie




Re: Anyone actually experienced with object inheritance?

2001-07-05 Thread David L. Nicol

Hong Zhang wrote:
 
 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.
 
 Hong

You could use a hasa relation as well, as long as the node object
has a link to the owner.

package ListableObject;
sub new {
my $O = new Object;
$O-addfield(node = Node::new({Ownedby= $O}));# or something like this
};

It would of course be easier to get wrong.

-- 
   David Nicol 816.235.1187
It's widely known that the 'F' in RTFM is silent. -- Olie




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

2001-07-05 Thread Matt Youell

 What's the problem again?

 I mean, really, any OO shop has it's local culture, of what the base
 classes
 are and so forth.

That pretty much sounds like the problem, in a nutshell.

And shop-level is a pretty narrow point of view. What about something that I
d/l from the net, where the code is out of my control and unfamiliar? Why
can't I reuse code predictably w/o having to figure out how a particular
individual/organization allows it?

 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.




matt youell
http://www.youell.com/matt/
think different - just like everyone else







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

2001-07-04 Thread David L. Nicol

Matt Youell wrote:
 
 Forgive my woeful ignorance Could someone define data aggregation by
 inheritance? From John's original mention I thought this was some oblique
 MI thing, but now it's sounding like a constructor bubbling scheme, like in
 C++, etc.

I understood it to mean automatic constructor bubbling.  Which is something 
all the various Class::Whatever modules provide, AFAIK.


-- 
   David Nicol 816.235.1187
And the cow threw up seven times, and said:
Say it now and say it loud, I'm a cow and I am proud.




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

2001-07-04 Thread Piers Cawley

[EMAIL PROTECTED] writes:

 On Tue, Jul 03, 2001 at 10:26:39AM +0100, Piers Cawley wrote:
  Hmm... let me write it first would you? Shouldn't be *too* hard.
  Suggestions for a real name for it?
 
 Class::Anonymous?  Class::Anon?
 
 PS  base has to take an array ref.  Don't forget MI!

I haven't forgotten it, I just don't like it. Consider it added. Now
to write some tests and documentation.

-- 
Piers Cawley
www.iterative-software.com




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

2001-07-04 Thread John Porter

Matt Youell wrote:
 Forgive my woeful ignorance Could someone define data aggregation by
 inheritance? From John's original mention I thought this was some oblique
 MI thing, but now it's sounding like a constructor bubbling scheme, like in
 C++, etc.

Right.  Perl doesn't have it by default, and *can't* have it
except under certain rather strict constraints, e.g. when all
players are playing by the Class::Struct rules, or some other
more elaborate alternative.

-- 
John Porter




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

2001-07-04 Thread Matt Youell

  MI thing, but now it's sounding like a constructor bubbling scheme, like
in
  C++, etc.

 Right.  Perl doesn't have it by default, and *can't* have it
 except under certain rather strict constraints, e.g. when all
 players are playing by the Class::Struct rules, or some other
 more elaborate alternative.

Ah, yes. I've had to deal with that problem several times in the past. The
terminology was new to me, however.

Has there been a proposed solution?

Thanks,

- Matt




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

2001-07-03 Thread Piers Cawley

Piers Cawley [EMAIL PROTECTED] writes:

 Michael G Schwern [EMAIL PROTECTED] writes:
 
  On Mon, Jul 02, 2001 at 04:18:31PM -0400, Michael G Schwern wrote:
   On Mon, Jul 02, 2001 at 12:59:51PM -0700, David Whipp wrote:
Its not quite the same thing, but Java does have the concept of
anonymous classes (it names them 'inner' classes): Is Perl6 going
to have a similar concept?
  
  Okay, maybe I don't understand anonyous classes, but isn't this pretty
  much the same thing:
  
  package Foo;
  
  {
  package My::Anon::Class;
  @ISA = qw(Whatever);
  sub new { ... }
  sub bar { ... }
  }
  
  sub new {
 my($class) = shift;
 my $anon = My::Anon::Class-new;
 ...
  }
 
 No. Need to be able to do:
 
 my $anon = My::Anon::ObjectFactory-new(base = 'ClassName',
 method1 = sub {...},
 method2 = sub {...},);
 
 Comes in very handy in Unit::Test, especially when you're writing
 tests to test the test harness...

Hmm that's not quite right, since you need to be able to pass in
arguments to the anonymous class's constructor...

my $anon = My::Anon::ObjectFactory-new({base = 'Class',
 method1 = sub { ... },
 method2 = sub { ... }},
@constructor_args);

-- 
Piers Cawley
www.iterative-software.com




Re: Anyone actually experienced with object inheritance?

2001-07-03 Thread Michael G Schwern

On Tue, Jul 03, 2001 at 12:10:19AM +0200, Bart Schuller wrote:
 The Apple Newton was programmed in NewtonScript, a prototype-based
 language. http://www.cc.gatech.edu/~schoedl/projects/NewtonScript/ seems
 like a nice overview.

Ahh, its derived from Self.


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
I've just gone through a lung-crushing breakup with my blender and I don't 
think I should screw my forehead alone tonight.



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

2001-07-03 Thread Piers Cawley

Michael G Schwern [EMAIL PROTECTED] writes:

 On Tue, Jul 03, 2001 at 08:34:00AM +0100, Piers Cawley wrote:
  my $anon = My::Anon::ObjectFactory-new({base = 'Class',
   method1 = sub { ... },
   method2 = sub { ... }},
  @constructor_args);
 
 Cool!  When will the module be on CPAN? ;)

Hmm... let me write it first would you? Shouldn't be *too* hard.
Suggestions for a real name for it?

-- 
Piers Cawley
www.iterative-software.com




Re: Anyone actually experienced with object inheritance?

2001-07-03 Thread Joe McMahon

On Tue, 3 Jul 2001, Bart Schuller wrote:

 The Apple Newton was programmed in NewtonScript, a prototype-based
 language. http://www.cc.gatech.edu/~schoedl/projects/NewtonScript/ seems
 like a nice overview.

NewtonScript was an excellent language; with prototype-based inheritance,
you could get an application running almost trivially.

If there was a nice way to implement this type of inheritance (as an
option, and in a module woul be fine by me), I'd highly recommend it.
Combining prototyping and Tk could be a tremendously big win.

 --- Joe M.





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

2001-07-03 Thread schwern

On Tue, Jul 03, 2001 at 10:26:39AM +0100, Piers Cawley wrote:
 Hmm... let me write it first would you? Shouldn't be *too* hard.
 Suggestions for a real name for it?

Class::Anonymous?  Class::Anon?

PS  base has to take an array ref.  Don't forget MI!


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



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

2001-07-03 Thread David L. Nicol

John Porter wrote:
 
 Michael G Schwern wrote:
   Give me data aggregation by inheritance
  Oooh, now that would be useful.
 
 Of course it would.  That's why nearly every OO language (beside Perl)
 has it.

package circular_list_node;
... # defines how the list_nodes do their quaint folk dances


package some_listable_datum;
@ISA = qw circular_list_node ;

sub new{
my $self = new circular_list_node;
...


That isn't data aggregation by inheritance?


-- 
   David Nicol 816.235.1187
And the cow threw up seven times, and said:
Say it now and say it loud, I'm a cow and I am proud.




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

2001-07-03 Thread Matt Youell

Forgive my woeful ignorance Could someone define data aggregation by
inheritance? From John's original mention I thought this was some oblique
MI thing, but now it's sounding like a constructor bubbling scheme, like in
C++, etc.

Thanks!


matt youell
http://www.youell.com/matt/
think different - just like everyone else






Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread John Porter

[EMAIL PROTECTED] wrote:
 Rather than stumbling around in the dark here, is anyone actually
 experienced with object inheritance?  Any Self programmers out there?
 Someone that's actually used this technique often and understands what
 works and what does?

I haven't used Self, only Lisp and Perl to do this.
It actually is very applicable in programming Frame systems,
which are a kind of souped-up semantic network thing,
used a lot in knowledgebases.

-- 
John Porter




Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread schwern

On Mon, Jul 02, 2001 at 08:32:04AM -0400, John Porter wrote:
 It actually is very applicable in programming Frame systems,
 which are a kind of souped-up semantic network thing,
 used a lot in knowledgebases.

Could you show me an example of what that is, how traditional
class-based OO tries to solve it and fails and how object inheritance
makes it really easy?

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



RE: Anyone actually experienced with object inheritance?

2001-07-02 Thread David Whipp

Michael G Schwern wrote:

 Rather than stumbling around in the dark here, is anyone actually
 experienced with object inheritance?  Any Self programmers out there?
 Someone that's actually used this technique often and understands what
 works and what does?  Any books/articles to recommend?

Its not quite the same thing, but Java does have the concept of
anonymous classes (it names them 'inner' classes): Is Perl6 going
to have a similar concept?


Dave.
--
Dave Whipp, Senior Verification Engineer,
Fast-Chip inc., 950 Kifer Rd, Sunnyvale, CA. 94086
tel: 408 523 8071; http://www.fast-chip.com
Opinions my own; statements of fact may be in error. 




Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread Michael G Schwern

On Mon, Jul 02, 2001 at 12:59:51PM -0700, David Whipp wrote:
 Its not quite the same thing, but Java does have the concept of
 anonymous classes (it names them 'inner' classes): Is Perl6 going
 to have a similar concept?

Are they really necessary?  You can get the same effect so many other
ways in Perl already, inner classes seem to be a way around alot of
Java's BSDM features, like interfaces.

Of course, if you REALLY want them I'm sure I can write a perl5 module
to pull them off. ;) Seriously, give me an example of how you'd like
to see it work (or point me at some docs) and I'll see what I can do.


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
my anus yearns now
warm paste fills me happily
saturday morning
-- imploded



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

2001-07-02 Thread Michael G Schwern

On Mon, Jul 02, 2001 at 04:18:31PM -0400, Michael G Schwern wrote:
 On Mon, Jul 02, 2001 at 12:59:51PM -0700, David Whipp wrote:
  Its not quite the same thing, but Java does have the concept of
  anonymous classes (it names them 'inner' classes): Is Perl6 going
  to have a similar concept?

Okay, maybe I don't understand anonyous classes, but isn't this pretty
much the same thing:

package Foo;

{
package My::Anon::Class;
@ISA = qw(Whatever);
sub new { ... }
sub bar { ... }
}

sub new {
   my($class) = shift;
   my $anon = My::Anon::Class-new;
   ...
}


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
How can I stoop so low?  Years of practise, that's how. It's been hard
going but now I can stoop lower than a pygmy limbo dancer.
-- BOFH



Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread Damien Neil

On Mon, Jul 02, 2001 at 12:59:51PM -0700, David Whipp wrote:
 Its not quite the same thing, but Java does have the concept of
 anonymous classes (it names them 'inner' classes): Is Perl6 going
 to have a similar concept?

Inner classes and anonymous classes are actually different in Java.
(Anonymous classes are always inner classes; inner classes are not
always anonymous.) An inner class is a class contained within a
class; only the containing class may use the contained class.  An
anonymous inner class is an unnamed instantiation of an interface;
these are often used in places where Perl coders would use a closure.
(Java doesn't have closures.)

Both inner classes and anonymous inner classes exist for reasons
fairly specific to Java; they're very useful in a certain context,
but Perl has other ways to accomplish the same things.

  - Damien



Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread Jarkko Hietaniemi

On Mon, Jul 02, 2001 at 01:30:11PM -0700, Damien Neil wrote:
 On Mon, Jul 02, 2001 at 12:59:51PM -0700, David Whipp wrote:
  Its not quite the same thing, but Java does have the concept of
  anonymous classes (it names them 'inner' classes): Is Perl6 going
  to have a similar concept?
 
 Inner classes and anonymous classes are actually different in Java.
 (Anonymous classes are always inner classes; inner classes are not
 always anonymous.) An inner class is a class contained within a
 class; only the containing class may use the contained class.  An

I forget... has the possibility/utility of having nested namespaces
been discussed?

 anonymous inner class is an unnamed instantiation of an interface;
 these are often used in places where Perl coders would use a closure.
 (Java doesn't have closures.)
 
 Both inner classes and anonymous inner classes exist for reasons
 fairly specific to Java; they're very useful in a certain context,
 but Perl has other ways to accomplish the same things.
 
   - Damien

-- 
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen



Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread John Porter

David Whipp wrote:
 Its not quite the same thing, but Java does have the concept of
 anonymous classes (it names them 'inner' classes): Is Perl6 going
 to have a similar concept?

Well, Perl5 has neither of the features that would make inner
classes meaningful -- data structure aggregation by inheritance,
and (nested) namespace scoping.  I think there's been plenty of
call for the former in Perl6; the latter would be pretty nice too.

-- 
John Porter




Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread John Porter

Michael G Schwern wrote:
 Are they really necessary?  You can get the same effect so many other
 ways in Perl already, 

That is a very unhelpful attitude.

Give me data aggregation by inheritance, namespace scoping, and
interfaces, and then I'll grant that inner classes are easy to
tack on.

-- 
John Porter




Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread John Porter

Jarkko Hietaniemi wrote:
 I forget... has the possibility/utility of having nested namespaces
 been discussed?

Not sure; probably... but we'd need not just *nested* namespaces,
but namespace *scoping*.

Perhaps this could be done by allowing to attach a name to q
lexical scope; perhaps this could be conflated with normal labels.

-- 
John Porter




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

2001-07-02 Thread Michael G Schwern

On Mon, Jul 02, 2001 at 05:04:23PM -0400, John Porter wrote:
 Michael G Schwern wrote:
  Are they really necessary?  You can get the same effect so many other
  ways in Perl already, 
 
 That is a very unhelpful attitude.

We've already got everything and the kitchen sink proposed for Perl 6.
Remember, somebody's got to write all this.


 Give me data aggregation by inheritance

Oooh, now that would be useful.


 namespace scoping

Err... something like lexical namespaces?  my package Foo?

package Foo;
{
my package Bar;
sub baz { 42 }
}
print Bar-baz;  # *bt* Bar only exists in its scope.

Interesting, but do we need them in 6.0?


 interfaces

Pretty much covered by our discussions of method signatures and typing
earlier, no?  Yes, we need them.


 and then I'll grant that inner classes are easy to tack on.

You can always do this right now:

package Whatever;
sub foo {
my $self = shift;

my $obj = Class::Object-new;
$obj-sub 'bar', sub {
blah blah blah
};
$obj-sub 'yarrow', sub {
more blah
};

...now $obj acts like an instance of...
...an anonynous inner class...
}

When $obj goes away, all trace of its class goes away (thanks to a
helpful DESTROY method).  Same effect as an anonymous inner class in
Java.  One instance, methods defined on the spot, can't access it from
outside foo().  The syntax could use a little work...


And, of course, you can get the same effect if you don't sweat the
protections by just defining one package inside another.


Uh oh.  I smell another BDSM OO vs Happy-Go-Lucky OO argument brewing...

-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
WOOHOO!  I'm going to Disneyland!
http://www.goats.com/archive/980805.html



Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread Michael G Schwern

On Mon, Jul 02, 2001 at 05:09:58PM -0400, John Porter wrote:
 Perhaps this could be done by allowing to attach a name to q
 lexical scope; perhaps this could be conflated with normal labels.

my package Foo {
sub bar { ... }
}

perhaps?

-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
Jesus hates me.
http://www.unamerican.com/



Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread John Porter

Michael G Schwern wrote:
 my package Foo {
 sub bar { ... }
 }

Well... package is a magic perl5-inducing keyword in perl6, right?
Maybe namespace is the way to go.

-- 
John Porter




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

2001-07-02 Thread John Porter

Michael G Schwern wrote:
  Give me data aggregation by inheritance
 Oooh, now that would be useful.

Of course it would.  That's why nearly every OO language (beside Perl)
has it.


  and then I'll grant that inner classes are easy to tack on.
 You can always do this right now:
 ...
 my $obj = Class::Object-new;
 ...

No, that's not an inner class.  Man, you think Class::Object
is the answer to everything!  (Not that it ain't cool...)

-- 
John Porter




Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread schwern

On Mon, Jul 02, 2001 at 05:38:11PM -0400, John Porter wrote:
 Well... package is a magic perl5-inducing keyword in perl6, right?
 Maybe namespace is the way to go.

I think the idea was class.

Lexical namespaces can just mirror whatever happens to the rest of the
package/class system.

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



Re: Anyone actually experienced with object inheritance?

2001-07-02 Thread Bart Schuller

On Sun, Jul 01, 2001 at 04:35:16PM -0400, [EMAIL PROTECTED] wrote:
 Rather than stumbling around in the dark here, is anyone actually
 experienced with object inheritance?  Any Self programmers out there?
 Someone that's actually used this technique often and understands what
 works and what does?  Any books/articles to recommend?

The Apple Newton was programmed in NewtonScript, a prototype-based
language. http://www.cc.gatech.edu/~schoedl/projects/NewtonScript/ seems
like a nice overview.

The concept was put to good use, as you could inherit from objects
living in ROM, making them very lean.

There also was another type of inheritance: parent inheritance. Methods
could be looked up in containing objects, which could denote a visual
relationship (windows and subwindows), or non visual (subsystems inside
programs).

More info from the main architect at http://www.best.com/~wsmith/works.html

-- 
The idea is that the first face shown to people is one they can readily
accept - a more traditional logo. The lunacy element is only revealed
subsequently, via the LunaDude. [excerpted from the Lunatech Identity Manual]



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

2001-07-02 Thread Piers Cawley

Michael G Schwern [EMAIL PROTECTED] writes:

 On Mon, Jul 02, 2001 at 04:18:31PM -0400, Michael G Schwern wrote:
  On Mon, Jul 02, 2001 at 12:59:51PM -0700, David Whipp wrote:
   Its not quite the same thing, but Java does have the concept of
   anonymous classes (it names them 'inner' classes): Is Perl6 going
   to have a similar concept?
 
 Okay, maybe I don't understand anonyous classes, but isn't this pretty
 much the same thing:
 
 package Foo;
 
 {
 package My::Anon::Class;
 @ISA = qw(Whatever);
 sub new { ... }
 sub bar { ... }
 }
 
 sub new {
my($class) = shift;
my $anon = My::Anon::Class-new;
...
 }

No. Need to be able to do:

my $anon = My::Anon::ObjectFactory-new(base = 'ClassName',
method1 = sub {...},
method2 = sub {...},);

Comes in very handy in Unit::Test, especially when you're writing
tests to test the test harness...

-- 
Piers Cawley
www.iterative-software.com




Anyone actually experienced with object inheritance?

2001-07-01 Thread schwern

Rather than stumbling around in the dark here, is anyone actually
experienced with object inheritance?  Any Self programmers out there?
Someone that's actually used this technique often and understands what
works and what does?  Any books/articles to recommend?


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