Newsgroups: perl.perl6.language
From: Austin_Hasti...@Yahoo.com (Austin Hastings)
Date: Sat, 13 Dec 2003 12:50:50 -0500
Local: Sat, Dec 13 2003 12:50 pm
Subject: RE: Vocabulary
> -----Original Message----- I'm not convinced these are errors. Having a role override methods makes > From: Larry Wall [mailto:la...@wall.org] > Sent: Friday, December 12, 2003 8:30 PM > On Fri, Dec 12, 2003 at 05:17:37PM -0500, Austin Hastings wrote: > : Good. I like the mixin being available at either time. This > makes properties > : a lot more useful since I can provided "default" or "normal" values: > : > : role Celebrated > : does Date > : does { > : method celebrated($d) { return $d.date; } > : } > : > : class Birthday does Celebrated { > : has $.date; > : } > : > : my Birthday $d = Birthday.new('February', 29, 2004) but > : Celebrated('March', 01, 2004); > : > : print "My birthday is celebrated $d.celebrated"; > More generally, you can write the rest of the class knowing that the > : I presume that the linear order (compile time) or chronological order of > The original Traits paper specifies that it's illegal to compose two sense in a lot of ways. Consider, for example, a caching or persistence implementation that It seems to me there's an argument both ways -- 1. Code written in the absence of a role won't anticipate the role and 2. Roles may be written to deliberately supercede the methods of their This doesn't take into account role vs. role conflicts (which seem more Perhaps an "exact signature" rule would work? Such that if the method was an Alternatively, perhaps a role must declare its method to be multi or not, (Which takes us to retroactive multi-fication. Ugh.) Or perhaps you just have to say "this method overloads". > As for the relationship of "Trait" methods to other methods At compile time, right? Whereas composition (but=) overrides declaration at > declarations, an explicit method declaration in the class proper > overrides the composed methods, while composed methods override > anything else in the inheritance hierarchy. run-time? > : Which is it, by the way? Or is there MTOWTDI, such as a method Yeah, the concept is useful enough that it's probably worth a spoonful of > modifier for > : specifying polymorph behavior? > The default way might well be the way specified in the Traits paper. > : method CONFORM is wrapped { ... call ... } > That would be another way to do it, except that you might still have > : > A property is a simple kind of role that supplies a single attribute. > That's why I suggested some syntactic sugar for it. But I admit that sugar. Perhaps it were better to think of a clever way of defining a batch of named constants in a class declaration, so that enums could be full classes if they want to be: class Month is Int { > : > You can use one of these subtypes without specifically This isn't hiding/overriding directly, but resolving an ambiguous value > implying the role > : name. So saying > : > > : > $bar but Red > : > > : > might give you a value with the property Color. > : > : This is smart and helpful. I like it. However, there needs to > be a way to > : specify what to do when multiple roles share the same values. > For example, > : if I have NeededBy and Estimated roles: > : > : my $birthday = "02/29/2004" but March; > : my $ship_date = "01/01/01" but NeededBy(February); > Conflicts within a class either need to be reported as soon as they're (February) which could belong to either the NeededBy or the Estimated roles. Consider C<green> -- does it mean Color(green) or Ripeness(green)? > : > You can write the corresponding boolean test using the smart match Two good points. > : operator: > : > > : > $bar ~~ Red > : > > : > and it (smartly) picks out the Color property to compare > with, provided > : > it's unambiguous. You can use that syntax to compare against any > : > subtype or junction of subtypes: > : > > : > $bar ~~ Redish&Whiteish # pinkish > : > > : > : Disambiguation? > : > : $bar ~~ NeededBy(February) > : > : or > : > : $bar.NeededBy ~~ February > Certainly the second form should work, unless it blows up because > NeededBy[January|July] > so NeededBy::January is probably not going to cut it. =Austin You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||