Loading ...
Sorry, an error occurred while loading the content.

Re: [langsmiths] Mixins, traits and horizontal composition

Expand Messages
  • John Cowan
    ... It s also generally understood that traits don t have state: you create a class by listing its traits and its state variables. However, I ve been thinking
    Message 1 of 7 , Jun 17, 2010
    • 0 Attachment
      Mike Austin scripsit:

      > So on that note, I think traits can take the place of mixins, protocols
      > (Obj-C) and even predicate classes, where an object can change behavior
      > based on state. If traits were an array of horizontal objects (versus
      > vertical with inheritance), Impulse traits would look very similar to
      > Ruby's mixins:

      It's also generally understood that traits don't have state: you create a
      class by listing its traits and its state variables. However, I've been
      thinking about an alternative in which all state variables are private to
      a trait, the idea being that since state variables couple all methods
      that reference them, such that none should be replaced without replacing
      all, it makes sense to think of that set of methods and associated
      state variables as a trait, and then horizontally compose classes out of
      these state-bearing traits. Given that, it is no longer necessary to
      distinguish between classes and traits: incorporating a class is
      equivalent to incorporating the traits that the class incorporates.

      --
      Is not a patron, my Lord [Chesterfield], John Cowan
      one who looks with unconcern on a man http://www.ccil.org/~cowan
      struggling for life in the water, and when cowan@...
      he has reached ground encumbers him with help?
      --Samuel Johnson
    Your message has been successfully submitted and would be delivered to recipients shortly.