Show
Ignore:
Timestamp:
08/12/06 19:55:50 (2 years ago)
Author:
audreyt
Message:

* First cut at proper compile-time role mixin support, based on

discussion on #perl6 about the semantics of "does".

class C {};
class D does C {};
D.isa(C); # False
D.does(C); # True

Composition works, and overriding role methods should work as well,
but concrete class/package names is not yet renamed, and role conflicts
is not yet validated. Still, a step toward the right direction.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/Match.hs

    r10736 r12176  
    22 
    33module Pugs.Prim.Match ( 
    4     op2Match, rxSplit, rxSplit_n, matchFromMR, pkgParents 
     4    op2Match, rxSplit, rxSplit_n, matchFromMR, pkgParents, pkgParentClasses 
    55) where 
    66import Pugs.Internals 
     
    279279    meta    <- readRef =<< fromVal ref 
    280280    fetch   <- doHash meta hash_fetchVal 
    281     attrs   <- fromVal =<< fetch "traits" 
    282     pkgs    <- mapM pkgParents attrs 
     281    attrs   <- fromVal =<< fetch "is" 
     282    attrs'  <- fromVal =<< fetch "does" -- XXX wrong 
     283    pkgs    <- mapM pkgParents (attrs ++ attrs') 
    283284    return $ nub (pkg:concat pkgs) 
    284285 
     286-- XXX - copy and paste code; merge with above! 
     287pkgParentClasses :: VStr -> Eval [VStr] 
     288pkgParentClasses pkg = do 
     289    ref     <- readVar (':':'*':pkg) 
     290    if ref == undef then return [] else do 
     291    meta    <- readRef =<< fromVal ref 
     292    fetch   <- doHash meta hash_fetchVal 
     293    attrs   <- fromVal =<< fetch "is" 
     294    pkgs    <- mapM pkgParentClasses attrs 
     295    return $ nub (pkg:concat pkgs)