--=-1+davn9fuSAJzrwdlHDP
Content-Type: multipart/alternative; boundary="=-R3fCLSE8hpPTaKGi5Wqj"


--=-R3fCLSE8hpPTaKGi5Wqj
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

I can't for the life of me figure out why the following code makes Ruby
puke when I try to execute it:


        module Rlang
          module Error
            class RlangException < Exception ; end
          end
          module Utility
            def e8(value) ; [value].pack('C') ; end
          end
          module External
            include Rlang::Error
            include Rlang::Utility
            TAG_CACHED_ATOM =3D e8(67)
          end
        end


The precise error I get is "junk.rb:11: undefined method `e8' for
Rlang::External:Module (NoMethodError)" which is the line with
"TAG_CACHED_ATOM =3D ..." in it.  I've tried the following changes with
the following results:


     1. Completely specify e8 by using "Rlang::Utility.e8" or
        "Rlang::Utility::e8".  This produces no change to the message
        whatsoever.
     2. Renaming bits and pieces under the assumption that I've got a
        naming clash with something deep.  This only changes the name of
        the method it claims to not be able to find.
     3. Moving the definition of e8 to be in the External module.  This
        is where brain damage sets in as the message doesn't change in
        the slightest.  (I am well and truly baffled by this stage.)
     4. Moving the definition of e8 to be in the Rlang module.  This
        results in, you guessed it!, no change to the message at all.
     5. Moving the definition of e8 to be outside of any module at all.
        This results in ... it works.


#5 is a solution but it is a truly suboptimal one in my opinion.  I do
not want to clutter up the global namespace of my clients with cryptic
little utility functions (in the real code there's about a dozen of
these).  So while I could live with #5, I would rather not if there was
a better way to do this.  Something deep about Ruby's module system is
eluding me here, I think, and I'd rather understand it than just cover
it over and inconvenience my clients' coding in the process.

--=20
Michael T. Richter <ttmrichter / gmail.com> (GoogleTalk:
ttmrichter / gmail.com)
The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny..." (Isaac Asimov)

--=-R3fCLSE8hpPTaKGi5Wqj
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; CHARSET=3DUTF-8">
  <META NAME=3D"GENERATOR" CONTENT=3D"GtkHTML/3.16.1">
</HEAD>
<BODY>
I can't for the life of me figure out why the following code makes Ruby puk=
e when I try to execute it:<BR>
<BR>
<BLOCKQUOTE>
<PRE>
<TT>module Rlang</TT>
<TT>&nbsp; module Error</TT>
<TT>&nbsp;&nbsp;&nbsp; class RlangException &lt; Exception ; end</TT>
<TT>&nbsp; end</TT>
<TT>&nbsp; module Utility</TT>
<TT>&nbsp;&nbsp;&nbsp; def e8(value) ; [value].pack('C') ; end</TT>
<TT>&nbsp; end</TT>
<TT>&nbsp; module External</TT>
<TT>&nbsp;&nbsp;&nbsp; include Rlang::Error</TT>
<TT>&nbsp;&nbsp;&nbsp; include Rlang::Utility</TT>
<TT>&nbsp;&nbsp;&nbsp; TAG_CACHED_ATOM =3D e8(67)</TT>
<TT>&nbsp; end</TT>
<TT>end</TT>
</PRE>
</BLOCKQUOTE>
<BR>
The precise error I get is &quot;<TT>junk.rb:11: undefined method `e8' for =
Rlang::External:Module (NoMethodError)</TT>&quot; which is the line with &q=
uot;<TT>TAG_CACHED_ATOM =3D</TT> ...&quot; in it.&nbsp; I've tried the foll=
owing changes with the following results:<BR>
<BR>
<OL TYPE=3D1>
    <LI TYPE=3D1 VALUE=3D1>Completely specify e8 by using &quot;Rlang::Util=
ity.e8&quot; or &quot;Rlang::Utility::e8&quot;.&nbsp; This produces no chan=
ge to the message whatsoever.
    <LI TYPE=3D1 VALUE=3D2>Renaming bits and pieces under the assumption th=
at I've got a naming clash with something deep.&nbsp; This only changes the=
 name of the method it claims to not be able to find.
    <LI TYPE=3D1 VALUE=3D3>Moving the definition of e8 to be in the Externa=
l module.&nbsp; This is where brain damage sets in as <B>the message doesn'=
t change in the slightest</B>.&nbsp; (I am well and truly baffled by this s=
tage.)
    <LI TYPE=3D1 VALUE=3D4>Moving the definition of e8 to be in the Rlang m=
odule.&nbsp; This results in, you guessed it!, no change to the message at =
all.
    <LI TYPE=3D1 VALUE=3D5>Moving the definition of e8 to be outside of any=
 module at all.&nbsp; This results in ... it works.
</OL>
<BR>
#5 is a solution but it is a truly suboptimal one in my opinion.&nbsp; I do=
 not want to clutter up the global namespace of my clients with cryptic lit=
tle utility functions (in the real code there's about a dozen of these).&nb=
sp; So while I <B>could</B> live with #5, I would rather not if there was a=
 better way to do this.&nbsp; Something deep about Ruby's module system is =
eluding me here, I think, and I'd rather understand it than just cover it o=
ver and inconvenience my clients' coding in the process.<BR>
<BR>
<TABLE CELLSPACING=3D"0" CELLPADDING=3D"0" WIDTH=3D"100%">
<TR>
<TD>
-- <BR>
<B>Michael T. Richter</B> &lt;<A HREF=3D"mailto:ttmrichter / gmail.com">ttmri=
chter / gmail.com</A>&gt; (<B>GoogleTalk:</B> ttmrichter / gmail.com)<BR>
<I>The most exciting phrase to hear in science - the one that heralds new d=
iscoveries - is not &quot;Eureka!&quot; but &quot;That's funny...&quot; (Is=
aac Asimov)</I>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

--=-R3fCLSE8hpPTaKGi5Wqj--

--=-1+davn9fuSAJzrwdlHDP
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBIM4K4LqyWkKVQ54QRAir+AJ9lx11ZBUuvu9V1YYZwsJBCX8NA/QCgrLAM
XPimDxSVAb1MyGVzbcgPtm4=
=eIvs
-----END PGP SIGNATURE-----

--=-1+davn9fuSAJzrwdlHDP--