On Tue, 4 Jan 2005, Florian Gro? wrote:

> Mathieu Bouchard wrote:
> > First, Rational.reduce(a,b) has a shortcut as Rational(a,b) already.
> > Then you could do:
> > require "rational"
> > require "complex"
> > module Kernel
> >   alias Q Rational
> >   alias C Complex
> > end
> While this is a nice idea I don't feel sure about polluting the global 
> method space with one-character names.

Hahaha, so you prefer to pollute the Ruby grammar instead?

What's that aversion for the global namespace, that is so great that
instead it is preferred to instead add things to the _grammar_ ???

> And I think it would not cause many problems to make an yet unused
> syntax do something meaningful.

The syntax of Ruby is already complicated enough, imho, but a better
reason against the 0.5R syntax is that it can only represent rationals
that have denominators that divide a power of ten. If you allow the use of
0,0b,0x prefixes it doesn't change because those notations allow even less
denominators (only powers of two). However I recall some languages use a
notation like 2r3 to mean specifically Q(2,3), while 2/3 means something
else (usually the float 0.666... or the 0 integer).

While we're at it, why not adding such syntax:

 * while Complex===3i with a lowercase i, the uppercase I,J,K suffixes
   would be of class Quaternion.

 * 7m9 would be a literal meaning the set of all 9*m+7 numbers,
   which is an object of class ModuloInteger.

(just kidding!)

_____________________________________________________________________
Mathieu Bouchard -=- Montr?al QC Canada -=- http://artengine.ca/matju