Re: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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?)
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?)
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?)
Matt Youell wrote: The terminology was new to me, however. I made it up. -- John Porter
Re: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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?)
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?)
[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?)
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?)
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?)
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: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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?)
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?)
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
Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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
Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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: Anonymous classes (was Re: Anyone actually experienced with object inheritance?)
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