Larry Wall wrote:
> Jonathan Lang wrote:
> : In a similar vein, what about making a disjunction of classes in an
> : C<is> or C<isa> clause synonymous with a sequence of appropriate 
> : clauses?  Ditto with traits and C<is>, roles and C<does>, attributes 
> : and C<has>, etc.; thus: 
> : 
> :   class DangerousPet does Pet & Predator {
> :   }
> : 
> : would be the same as
> : 
> :   class DangerousPet does Pet does Predator {
> :   }
> 
> Depends on how you look at it.  A DangerousPet is something that can
> act like either a Pet or a Predator, or both.  Sometimes you want &
> and sometimes you want |.  (Of course, a lawyer will tell you that
> "and" and "or" mean the same thing in a legal document.)  I suppose
> there could even be some sense in
> 
>     class DangerousPet does Pet ^ Predator {
>     }
> 
> meaning it can be a Pet or a Predator but not both at the same time.
> Of course, that probably means that you can't actually have any
> objects of type DangerousPet.  Or maybe it does, but you can't call
> any ambiguous DangerousPet methods without casting to either Pet or
> Predator.  Hmm...

Since disjunctions are unambiguous in their membership, this isn't a
problem for them; only for disjunctions, ajunctions, and (horrors!)
injunctions.  Admittedly, a class that C<is> an ajunction of classes would
be a cute way of creating something conceptually akin to a C union.  

I could see practical uses for the disjunctive forms; even there, I'm not
sure that the coding required to make the compiler handle things would be
worth the time invested - but it just might be.  I'm even less sure when
it comes to the other kinds of junctions.  

> That would mean that C<does> implies a constraint test on typeof($self)
> rather than classof($self).  (Presuming typed refs in the first place,
> of course.)

OTOH, C<is>, C<does>, and C<has> are declarative in nature, not
predicative; it's much like assignment vs. equality.  

=====
Jonathan "Dataweaver" Lang

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

Reply via email to