Numbers in various formats are well supported by Ruby, but, for many of them,
there is no convenient shorthand for entering literal constants.  Also,
think about code that manipulates Times, Dates, Lat/Long coordinates,
complex numbers, etc.

All literals must be derived from some combination of Symbols, Strings,
Floats, and Integers.  So, one typically ends up with unfortunate syntax
like:  BigDecimal("3.14159") and chafes at the thought.

What if, in a way somewhat analogous to :method_missing, Ruby had simple
hooks to allow substitution of literal objects for the text of otherwise
illegal identifiers?

Perhaps the time is ripe to revisit this idea...  
http://markmail.org/search/?q=ruby-core+allowing+custom+number+literal+suffixes

so that Domain Specific Languages implemented entirely in Ruby could define
their own convenient, domain specific literal constant syntax without
requiring changes to the core interpreter.  

And, arguments about the superiority of binary vs. decimal or visa-versa
would not be nearly as important.
(Cue inspirational music while running for the door ;-)

- brent



Joel VanderWerf wrote:
> 
> mathew wrote:
>> Fixed  point decimal numbers, on the other hand--those actually exist
> 
> So why not define a FixedPoint class, based on Integer, with all the 
> operations and #coerce? It will be more efficient (and simpler) than 
> decimal float, and Float can remain IEEE float, which is what most 
> numerical libraries use anyway. Perhaps this suggestion would be more 
> acceptable if there were a literal notation for fixed point? What about 
> "_123.45" for 12345/100?
> 
> Food for thought:
> 
> http://gcc.gnu.org/wiki/FixedPointArithmetic
> 
> -- 
>        vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-ruby-core%3A22325--suggestions-for-float-tp22144150p22429628.html
Sent from the ruby-core mailing list archive at Nabble.com.