Re: Ways to add behavior

2005-11-08 Thread Larry Wall
On Mon, Nov 07, 2005 at 08:44:28PM +0100, TSa wrote: : HaloO, : : Larry Wall wrote: : > : ::Takes3Ints ::= :(Int,Int,Int --> Any); : > : : > : my &foo:(Takes3Ints); : > : > I'd say that has to be something like: : > : > my &foo:(Takes3Ints:); : > : > or maybe one of : > : > my

Re: Ways to add behavior

2005-11-07 Thread TSa
HaloO, Larry Wall wrote: > : ::Takes3Ints ::= :(Int,Int,Int --> Any); > : > : my &foo:(Takes3Ints); > > I'd say that has to be something like: > > my &foo:(Takes3Ints:); > > or maybe one of > > my &foo:(Takes3Ints \!); > my &foo:(\Takes3Ints); > my &foo\(Takes3Ints); >

Re: Ways to add behavior

2005-11-07 Thread Larry Wall
On Mon, Nov 07, 2005 at 09:37:04AM -0800, Larry Wall wrote: : It would be nice to generalize this sufficiently to be able to declare : polymorphic objects resembling match objects: : :my $matchobj(Poly: Key^Int^Notthere --> Any); : : Or maybe that should be: : :my $matchobj\(Highlander)

Re: Ways to add behavior

2005-11-07 Thread Larry Wall
On Mon, Nov 07, 2005 at 01:05:16PM +0100, TSa wrote: : With the introduction of kind capture variables ^T we could complety : drop the subtype special form. As you pointed out the adding of constraints : happens with the where clause anyway. Thus we return to the usage of the : compile time name as

Re: Ways to add behavior

2005-11-07 Thread TSa
HaloO, Larry Wall wrote: : or is 'bound of' proper english? It doesn't really resonate for a native speaker. --snip-- : > Plus, as we've defined : >them above, subtypes are the most generic type you can name in Perl. --snip-- I wasn't using the term "generic" in a type-theoretic sense.

Re: Ways to add behavior

2005-11-07 Thread TSa
HaloO, Stevan Little wrote: This is actually the principe behind the Ruby style singleton methods (the shadow class), it basically creates an anon-class which inherits from $x's original class, then it rebinds/blesses $x into the anon- class. It is very simple really :) Yes, it's the typic

Re: Ways to add behavior

2005-11-05 Thread Larry Wall
On Sat, Nov 05, 2005 at 01:55:11AM +0100, TSa wrote: : Larry Wall wrote: : >The notion of constraints or limitations is already conveyed by : >"where", and some subtypes may just be aliases. : : Wouldn't 'bound' work? Perhaps combined with 'on': : : bound SmallInt on Int where { 0 < $_ < 100 };

Re: Ways to add behavior

2005-11-04 Thread TSa
HaloO, Larry Wall wrote: At the moment, I think the weakest word choice is "subtype". People from certain cultures will confuse subtypes with subclasses. Not to mention submethods and subroutines! The notion of constraints or limitations is already conveyed by "where", and some subtypes may

Re: Ways to add behavior

2005-11-04 Thread TSa
HaloO, Larry Wall wrote: On Wed, Oct 26, 2005 at 04:56:23PM -0600, Luke Palmer wrote: : > Then ^T $x binds T to the kind of $x. And $x.kind == $y.kind asks : > if two objects are of the same type, : : Don't you mean $x.kind eqv $y.kind? I start to dislike the eqv name as generic value compar

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-27 Thread Rob Kinyon
On 10/27/05, Larry Wall <[EMAIL PROTECTED]> wrote: > On Thu, Oct 27, 2005 at 05:37:13AM -0400, Rob Kinyon wrote: > : Will I be able to do something like: > : > : package Foo; > > Hmm, you just started in Perl 5 mode. > > : $*VERSION = 1.3.2; > > Perl 5 would get confused here, so I'm presuming Perl

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-27 Thread Larry Wall
On Thu, Oct 27, 2005 at 05:37:13AM -0400, Rob Kinyon wrote: : Will I be able to do something like: : : package Foo; Hmm, you just started in Perl 5 mode. : $*VERSION = 1.3.2; Perl 5 would get confused here, so I'm presuming Perl 6. But Perl 6 isn't likely to let you override the global run-tim

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-27 Thread Rob Kinyon
On 10/26/05, Larry Wall <[EMAIL PROTECTED]> wrote: > On Wed, Oct 26, 2005 at 07:35:05PM -0700, chromatic wrote: > : On Wed, 2005-10-26 at 21:58 -0400, Rob Kinyon wrote: > : > : > Plus, the argument is a straw man. Instead of: > : > > : > class Some::Class is also { > : > } > : > > : > you w

Re: Ways to add behavior

2005-10-27 Thread Michele Dondi
On Wed, 26 Oct 2005, Rob Kinyon wrote: I'd like to take this moment and point to my somewhat hand-wavy metamodel proposal from last week. When Stevan and I were talking about this, we called it a "quark." "Atom" also works quite nicely, but quarks are cooler. They're also colorful. Does this m

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread Luke Palmer
On 10/26/05, Rob Kinyon <[EMAIL PROTECTED]> wrote: > What about: > > class Foo is also { > method foo() { ... } > } > > Where the second foo() is no longer what the first foo() did. Just overwrite the vtable. > Furthermore, let's say you have: > > class Bar isa Foo { >

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread Larry Wall
On Wed, Oct 26, 2005 at 07:35:05PM -0700, chromatic wrote: : On Wed, 2005-10-26 at 21:58 -0400, Rob Kinyon wrote: : : > Plus, the argument is a straw man. Instead of: : > : > class Some::Class is also { : > } : > : > you would do: : > : > class My::Version { : > does Some::C

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread chromatic
On Wed, 2005-10-26 at 21:58 -0400, Rob Kinyon wrote: > Plus, the argument is a straw man. Instead of: > > class Some::Class is also { > } > > you would do: > > class My::Version { > does Some::Class; > } > > Problem solved. Don't forget the fun of modifying all existin

Re: Ways to add behavior

2005-10-26 Thread chromatic
On Wed, 2005-10-26 at 14:52 -0400, Uri Guttman wrote: > > "LW" == Larry Wall <[EMAIL PROTECTED]> writes: > LW> One wants to coin a word like "Qlass". Unfortunately "qlass" is > LW> too easy to misread as "glass". Oy veh, I'm getting notions of > LW> "the qlass is half empty" for a par

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread Rob Kinyon
On 10/26/05, Luke Palmer <[EMAIL PROTECTED]> wrote: [snip] > Okay, an open class means you can add methods to it, right? So, let's > say you have this class: > > class Foo { > method foo() {...} > method bar() {...} > } > > And this code: > > my Foo $x = Foo.new; >

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread chromatic
On Wed, 2005-10-26 at 19:22 -0600, Luke Palmer wrote: > But we find that many programmers make decisions that trade > readability and extensibility for an extra 1% of speed, even when they > are writing a command-line frontend to MPlayer[1]. If those people > are module writers, then we have a bu

Re: Ways to add behavior

2005-10-26 Thread Larry Wall
On Wed, Oct 26, 2005 at 06:34:48PM -0700, Larry Wall wrote: : On Wed, Oct 26, 2005 at 04:56:23PM -0600, Luke Palmer wrote: : : > Then ^T $x binds T to the kind of $x. And $x.kind == $y.kind asks : : > if two objects are of the same type, : : : : Don't you mean $x.kind eqv $y.kind? : : : : Ugh. :

Re: Ways to add behavior

2005-10-26 Thread Larry Wall
On Wed, Oct 26, 2005 at 04:56:23PM -0600, Luke Palmer wrote: : > Then ^T $x binds T to the kind of $x. And $x.kind == $y.kind asks : > if two objects are of the same type, : : Don't you mean $x.kind eqv $y.kind? : : Ugh. Now that infix:<::> has come available, maybe I mean: $x.kind :: $y.k

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread Larry Wall
On Wed, Oct 26, 2005 at 08:48:12PM -0400, Rob Kinyon wrote: : If a role is an immutable class, that means that its internals cannot : be changed. Hence, the compiler can trust that it will be the same at : the end as at the beginning. Which means it's optimized. Which means : my objects run faster

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread Luke Palmer
On 10/26/05, Rob Kinyon <[EMAIL PROTECTED]> wrote: > On 10/26/05, chromatic <[EMAIL PROTECTED]> wrote: > > On Wed, 2005-10-26 at 20:29 -0400, Rob Kinyon wrote: > > > > > I would prefer to use roles as they're closed by default, leaving > > > "class" to be my powertool, if I need the power. > > > >

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread Rob Kinyon
On 10/26/05, chromatic <[EMAIL PROTECTED]> wrote: > On Wed, 2005-10-26 at 20:29 -0400, Rob Kinyon wrote: > > > I would prefer to use roles as they're closed by default, leaving > > "class" to be my powertool, if I need the power. > > I don't understand this desire; can you explain your reasoning?

Re: Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread chromatic
On Wed, 2005-10-26 at 20:29 -0400, Rob Kinyon wrote: > I would prefer to use roles as they're closed by default, leaving > "class" to be my powertool, if I need the power. I don't understand this desire; can you explain your reasoning? (NB: "closed" here, as I use it, still *does not* correspond

Roles vs. Classes (was Re: Ways to add behavior)

2005-10-26 Thread Rob Kinyon
> : 3) Aren't classes mutable and roles immutable by default only? Or has > : this changed? > > Of course. To change the default for a role, call it a class, and > to change the default for a class, call it a role. :-) Does this mean that roles are the recommended way to create immutable classes

Re: Ways to add behavior

2005-10-26 Thread Luke Palmer
On 10/26/05, Larry Wall <[EMAIL PROTECTED]> wrote: > So maybe we can define our terms like this: > > type: a completely generic metaterm for any of the following, > and then some. > > class: a mutable interface object that manages instances in the > "classical" way, with covariant d

Re: Ways to add behavior

2005-10-26 Thread Larry Wall
On Wed, Oct 26, 2005 at 03:54:35PM -0400, Rob Kinyon wrote: : > So maybe we can define our terms like this: : > : > type: a completely generic metaterm for any of the following, : > and then some. : > : > class: a mutable interface object that manages instances in the : > "classical

Re: Ways to add behavior

2005-10-26 Thread Rob Kinyon
> So maybe we can define our terms like this: > > type: a completely generic metaterm for any of the following, > and then some. > > class: a mutable interface object that manages instances in the > "classical" way, with covariant derivational properties. > > role: an immutable

Re: Ways to add behavior

2005-10-26 Thread Uri Guttman
> "LW" == Larry Wall <[EMAIL PROTECTED]> writes: LW> One wants to coin a word like "Qlass". Unfortunately "qlass" is LW> too easy to misread as "glass". Oy veh, I'm getting notions of LW> "the qlass is half empty" for a partially instantiated object. [EMAIL PROTECTED], i think you ne

Re: Ways to add behavior

2005-10-26 Thread Larry Wall
On Wed, Oct 26, 2005 at 12:22:07PM -0400, Stevan Little wrote: : : On Oct 26, 2005, at 12:05 PM, Larry Wall wrote: : >Of course, there are other words that are somewhat synonymous with : >"class", Unfortunately "sort" is already hosed. Maybe "kind". : : Actually "kind" is used in the "Core Calcu

Re: Ways to add behavior

2005-10-26 Thread TSa
HaloO, Austin Frank wrote: Which (sort of) takes us back to TSa's (non)sign-off note from 10/5, wherein he suggested: I just can't help it, I love the good work done on this list! And thanks for spelling the acronym correctly. The Kindly One of a class beeing the representative like the Presi

Re: Ways to add behavior

2005-10-26 Thread Brent 'Dax' Royal-Gordon
Larry Wall <[EMAIL PROTECTED]> wrote: > Of course, there are other words that are somewhat synonymous with > "class", Unfortunately "sort" is already hosed. Maybe "kind". > Then evolutionists could make jokes about the K(T) boundary, and > creationists could make jokes about "reproducing after the

Re: Ways to add behavior

2005-10-26 Thread Ruud H.G. van Tol
Stevan Little: > They present an rather interesting view on things, that the > definition of the instance creating portion of a "class" should be > seperated from the "class" or "kind" portion of the class. Its quality. Its character. Its features. Its face. -- Grtz, Ruud

Re: Ways to add behavior

2005-10-26 Thread Rob Kinyon
On 10/26/05, Stevan Little <[EMAIL PROTECTED]> wrote: > > On Oct 26, 2005, at 12:05 PM, Larry Wall wrote: > > Of course, there are other words that are somewhat synonymous with > > "class", Unfortunately "sort" is already hosed. Maybe "kind". > > Actually "kind" is used in the "Core Calculus for M

Re: Ways to add behavior

2005-10-26 Thread Ruud H.G. van Tol
Larry Wall: > But perhaps it wouldn't be kind. 'caste' wouldn't either. For inspiraton: type sort class variety brand category breed manner style nature form hue caste set background stage setting milieu locale range assortment selection mixture strain suite scenery rank grade division status ge

Re: Ways to add behavior

2005-10-26 Thread Jonathan Scott Duff
On Wed, Oct 26, 2005 at 09:05:22AM -0700, Larry Wall wrote: > Of course, there are other words that are somewhat synonymous with > "class", Unfortunately "sort" is already hosed. Maybe "kind". Maybe we could go with something Linnaean like "family" or "genus" even though their relation to "class"

Re: Ways to add behavior

2005-10-26 Thread Stevan Little
On Oct 26, 2005, at 12:05 PM, Larry Wall wrote: Of course, there are other words that are somewhat synonymous with "class", Unfortunately "sort" is already hosed. Maybe "kind". Actually "kind" is used in the "Core Calculus for Metaclasses" paper which I brought to the hackathon (not sure if

Re: Ways to add behavior

2005-10-26 Thread Austin Frank
Larry Wall wrote: Of course, there are other words that are somewhat synonymous with "class", Unfortunately "sort" is already hosed. Maybe "kind". Then evolutionists could make jokes about the K(T) boundary, and creationists could make jokes about "reproducing after their kind". Some of us coul

Re: Ways to add behavior

2005-10-26 Thread Larry Wall
On Wed, Oct 26, 2005 at 11:31:28AM -0400, Rob Kinyon wrote: : > That's just self.meta.add_method($label, $method) by my lights. : > A .meta already implies/ignores the .class coercion. If we are to : > support prototype-based programming $x.meta *must not care* whether : > it has been given a clas

Re: Ways to add behavior

2005-10-26 Thread Rob Kinyon
> That's just self.meta.add_method($label, $method) by my lights. > A .meta already implies/ignores the .class coercion. If we are to > support prototype-based programming $x.meta *must not care* whether > it has been given a class or an instance or something in between. > What I am calling a "cla

Re: Ways to add behavior

2005-10-26 Thread Larry Wall
On Tue, Oct 25, 2005 at 05:17:40PM -0400, Stevan Little wrote: : Larry, : : On Oct 25, 2005, at 4:37 PM, Larry Wall wrote: : >On Mon, Oct 24, 2005 at 06:33:20AM -0700, Ashley Winters wrote: : >: # behavior through prototype -- guessing realistic syntax : >: Base.meta.add_method( : >: do_it =>

Re: Ways to add behavior

2005-10-25 Thread Stevan Little
Larry, On Oct 25, 2005, at 4:37 PM, Larry Wall wrote: On Mon, Oct 24, 2005 at 06:33:20AM -0700, Ashley Winters wrote: : # behavior through prototype -- guessing realistic syntax : Base.meta.add_method( : do_it => method ($arg) { : say "doing $arg!"; : }); : : : # or, just add it

Re: Ways to add behavior

2005-10-25 Thread Larry Wall
On Mon, Oct 24, 2005 at 06:33:20AM -0700, Ashley Winters wrote: : # behavior through prototype -- guessing realistic syntax : Base.meta.add_method( : do_it => method ($arg) { : say "doing $arg!"; : }); : : : # or, just add it to a single instance : $x.meta.add_method( : do_it

Ways to add behavior

2005-10-24 Thread Ashley Winters
I'm mentally going over the ways to do it. class Foo; # the perl5 way use base <>; sub new { my $class = shift; my $self = $class.SUPER::new(@_); # syntax? return $self; } sub do_it { my($self, $arg) = @_; say "doing $arg!"; } class Foo is Base { # the perl6 way m