From: trans Date: 2012-02-18T01:36:21+09:00 Subject: [ruby-core:42715] Classes as pure mixin conatiners ------=_Part_527_1893201.1329496577104 Content-Type: multipart/alternative; boundary="----=_Part_528_9443442.1329496577104" ------=_Part_528_9443442.1329496577104 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Some time ago, I suggested that it might be worth considering a design where Ruby classes remain free of any direct method definitions, and instead act only as containers for mixins. And that any method defined directly on the class syntactically would in actuality be added to a pre-class anonymous mixin under the hood. I bring this up again, not only because I think it's worth considering, but also I recently realized an experimental implmentation of it has already been created by Loren Segal called `metamorph`. https://github.com/lsegal/metamorph Though certainly not a complete or optimized implementation, it is something that can be tried out. The advantages of this idea include: * Simpler conceptual model, i.e. -- classes are just module containers. * Classes and modules become truly distinct --no more `class Class < Module`. * Better control of mixin order, including easily implemented "prepend" functionality. On the disadvantage side, the "Double Inclusion Problem" might become more pronounced, and it remains to seen what kind of speed hit it might entail. ------=_Part_528_9443442.1329496577104 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Some time ago, I suggested that it might be worth considering a design wher= e Ruby classes remain free of any direct method definitions, and instead ac= t only as containers for mixins. And that any method defined directly on th= e class syntactically would in actuality be added to a pre-class anonymous = mixin under the hood.

I bring this up again, not only because I thin= k it's worth considering, but also I recently realized an experimental impl= mentation of it has already been created by Loren Segal called `metamorph`.=

  https://github.com/lsegal/metamorph

Though certainly = not a complete or optimized implementation, it is something that can be tri= ed out.

The advantages of this idea include:

* Simpler concep= tual model, i.e. -- classes are just module containers.
* Classes and mo= dules become truly distinct --no more `class Class < Module`.
* Bette= r control of mixin order, including easily implemented "prepend" functional= ity.

On the disadvantage side, the "Double Inclusion Problem" might = become more pronounced, and it remains to seen what kind of speed hit it mi= ght entail.

------=_Part_528_9443442.1329496577104-- ------=_Part_527_1893201.1329496577104--