How to write *include* like Ruby?

lijie <[email protected]> Sat, 19 May 2012 22:48:12 +0800
Newsgroups gmane.comp.lang.io
Message-ID <CABQ_GqmKtK3BBZ0BCOb9gqGG90MhyNtzEx+JqdKaGJhrmKuhnA@mail.gmail.com>
Hi,

I want to write Io code like Ruby meta programming. *Module#include* is an
important method to extend classes.

In Io, I wrote some code:

include := method (module,
>   call sender addTrait(module)
> )
>
> Validations := Object clone do (
>   validate := method(args,
>     "validate" println
>   )
> )
>
> Person := Object clone do (
>   include(Validations)
> )
>
> Person println


outputs:

 Validations_0x7fd8a8c8d440:

  type             = "Validations"

  validate         = method(args, ...)




The type of Person is "Validations".

Then I try to call *include* after create Person:

Person := Object clone
>
> Person do (
>   include(Validations)
> )


outputs:

 Person_0x7f90ab496ee0:

  type             = "Person"

  validate         = method(args, ...)


This is my expectation. But I want to do all things in the prototype
creation. How to write the corrective *include* method?