Newsgroups: perl.perl6.language
From: dataweave...@yahoo.com (Jonathan Lang)
Date: Wed, 7 Jan 2004 17:12:46 -0800 (PST)
Local: Wed, Jan 7 2004 8:12 pm
Subject: RE: A modest question
Austin Hastings wrote: Valid, if wordy. Roles remain useful in that they provide a more concise > Jonathan Lang wrote: > > Maybe as an alternative to > > role Stringify {must stringify();} > > you might be able to say > > sub print_it ($thingie must stringify()) { > > Hmm... there's a certain elegance to being able to specify one or two > Indeed. I like the idea of dynamic anonymous roles -- it's more > sub print_it ($thingie must stringify()) {...} > Definitely gets down to the lowest level quickly, which is nice. Even > sub foo(Object $o) {...} > because you want to accept anything in the hierarchy. But it's nice to > sub foo(Object $o must stringify() must isa() must typeof()) {...} way of handling this if you want it - if you've got a dozen routines that all C<must isa() must typeof()>, you might be better off defining a role that makes those demands, and then just use it. > This kind of granularity does kind of imply a JavaScript-like ability to That's where C<but> comes in: > compose objects, too, no? (If you can compose requirements atomically, > why not compose capabilities, too?) > my $photon does Particle does Wave {...} = spark(); my $photon but does Particle does Wave {...} = spark(); would be equivelent to something like class _anonymous_photon does Particle does Wave {...} > > Also: in the first of these two, would classof($thingie) actually have In principle, I agree with you; in practice, it may not be workable. > > to have Stringify as a role, or would it be reasonable to instead say > > that classof($thingie) must meet Stringify's demands? The latter > > would require more work on the compiler's part, but would be > > considerably more flexible. > I prefer the latter. I want to be able to compose requirements on the > > Perhaps "Stringify $thingie" requires that the Stringify role must How would you handle the following: > > actually be used, while something like "$thingie like Stringify" would > > only require that Stringify's demands be met? > My thought would be that once you have an object in hand, you can do role Dog {must bark();} class crossPerson { class Trog does Tree does Dog { multi sub purchase(Dog $mansBestFriend) {...} my crossPerson $jack; my Trog $spot; Which, if any, of the subs should be called in each case? Or should the ===== __________________________________ 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.
| ||||||||||||||