I suppose that most math calculations would be isolated to a couple of classes.
These could all "include Math", thus simplifying the call.

Is this good style?  Is it the Ruby way?  Is there any performance hit by
including the same module in two classes?

BTW my question remains unanswered.  Christoph mentioned namespaces as if they
were different from modules, and I don't know what he was talking about.

--Gavin


----- Original Message -----
From: "William Djaja Tjokroaminata" <billtj / z.glue.umd.edu>


> Hi,
>
> I think in Ruby, if you are sure that in your script there are no others
> with names such as "cos" and "sin", you could simply put
>
>     include Math
>
> and then you can simply write
>
>     z = cos(x) * sin(y)
>
> Regards,
>
> Bill
> ============================================================================
> Gavin Sinclair <gsinclair / soyabean.com.au> wrote:
>
> > ----- Original Message -----
> > From: "Christoph" <chr_news / gmx.net>
> > Newsgroups: comp.lang.ruby
>
> >> Actually I don't really mind so much writing abs(x) or sin(x)
> >> but I just cannot get over the ``Math'' prefixes Math.cos(x),
> >> Math.sin(x) ....  they are reaaally tacky.
> >>
> > Pardon my ignorance, but I don't see what the alternative to Match.cos(x)
is,
> > nor do I understand the talk of namespaces.  The only alternative to
> > Math.cos(x) is Kernel::cos(x), isn't it?  That would eventually lead to
name
> > clashes.  Is namespaces a solution here?
>
> >> /Christoph
>
> > Gavin