From: Urabe Shyouhei Date: 2010-10-07T20:21:20+09:00 Subject: Re: Why does Module#include exclude the module's metaclass? --------------enig4F98637E64FE807CAE9594ED Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable (2010/10/07 10:59), John Mair wrote: > 1) I agree that singleton class of the module is actually a 'class' but= =20 > (if we allowed this behavior) it would only be included when and only=20 > when the module is included. We can just consider this a special=20 > exception, no? >=20 > This exception would only apply to singleton class of modules, of=20 > course, normal classes cannot be included in this way. So you were actually not asking why, but claiming this is wrong. Not sur= e for that. Your real_include gem breaks Class#ancestor in a strange way so I = guess there are some pitfalls, though noting particular. > 2) Given that class inheritance does include the singleton, do you not = > think it 'surprising' that module inclusion does not? I found it=20 > surprising. Tips: principle of least surprise is a wrong way for you to persuade matz= because at any moment he can say "I don't think so". Try a different rou= te. > 3) Many people get around this limitation in module inclusion by abusin= g=20 > the included() hook and then extending a ClassMethods submodule, I thin= k=20 > this is ugly. Maybe. But I think a module's having class method is itself ugly. It te= nds to smell like a API design mistake. I would recommend you to rethink why= you need such things. > 3) Out of curiosity, are there any other reasons (besides the one you=20 > gave) for why modules do not include the singleton? What reason did Mat= z=20 > give? No, I do not know other reasons. It is rather obvious to me. Of course = that does not ensure there is not reason though. --------------enig4F98637E64FE807CAE9594ED Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJMra0iAAoJEIG/BHYvGcFLR3kQAJPQ+tUdIMrD9Jv8BX82TxS+ SoxNPyd5PZ+G8feAXuLGjbHeYFfz/a2tKuRl145b5kZ8uP2WuyW9OrQp0HRfM0NB WZv9tAtrJRj5RXiCmEy/lZAlKwDp1fmh3KE6uNT7YX035xF8SCYsqVQ2mY9qxk1g ctCiuaOP6ERwuSCXXT4hnqAGqGXRSdTEQuioynw8znRk9EEFNT28ERfRwFlD/ldU 5HjNnGVn+x+fizuOxM551PSuc3NIH02MmP5x29sw7cYdTG4s6U2avB8C2cjCm4YW uinMXi6PLOc+sx57V4OaFmc4VaK41JqsBO+BJFyVCKjqlpYsN+KLb3psq7ZeB0bH fi1nitPQ+mkVQZ2XvBRgxdsG+Cji8b0e1Sgaes6DM1yTsqfhVKcLcfhRDPVULLaF Ns+YUZKVrVzKbU82dfr4kpDTF52cAjmjZw/E9s7IrIaL1+8TDBEQ3B3m4SeDMoDP Gh9+DPpyE1bl0Q3OYISvyliTSkZwvTDBsHSEL6rB7t7IfHifzkb2JXXqvoAe9q3d Ku+/kynBSjNKr4yw/N7FPmTfPit3hheyHzbCxsgjIEE0V++1RTnY71BCG2MVROz/ 5Qe7Wx0y+qlthFHKHrgmfEnuX/KYLFA+/3hTta16rbWsxAFQfwrZbo4ciZPkll/m raW2VNgm7Q0eOdJJh4y9 =h3k6 -----END PGP SIGNATURE----- --------------enig4F98637E64FE807CAE9594ED--