[Xotcl] Issue with mixin delete

Gustaf Neumann neumann at wu-wien.ac.at
Mon May 8 23:46:23 CEST 2006


Scott Gargash schrieb:
>
> Is this documented somewhere? It surprised me.
>
in the source (joke).
>
>
> > PS: wouln't be conditional mixins a solution for your problem?
>
> I don't know.  What do you mean by "conditional mixin"?  
>
mixins with guards. see following example. -gustaf


  Class Fly -instproc fly {} {puts "[my signature]: yippee, fly like an 
eagle!"}
  Class Sing -instproc sing {} {puts "[my signature]: what a difference 
a day make"}

  Class Animal -parameter age
  Animal instproc unknown args { puts "[my signature]: how should i $args?"}
  Animal instproc signature {} { return "[self] [my info class] ([my 
age] years)" }

  Class Bird -superclass Animal
  Class Penguine -superclass Bird
  Class Parrot -superclass Bird
  Class Duck -superclass Bird

  Parrot tweedy -age 1
  Penguine pingo -age 5
  Duck donald -age 4
  Parrot lora -age 6

  Bird instmixin {{Fly -guard {[my age]>2 && ![my istype Penguine]}} Sing}
  foreach bird [Animal allinstances] { $bird fly }

> Scott
>



More information about the Xotcl mailing list