From: "headius (Charles Nutter)" Date: 2013-06-25T05:49:13+09:00 Subject: [ruby-core:55636] [ruby-trunk - Feature #8430] Rational number literal Issue #8430 has been updated by headius (Charles Nutter). phluid61 (Matthew Kerwin) wrote: > headius (Charles Nutter) wrote: > > %R{1,2} > > +1 this seems to introduce the least potential for confusion and backwards-incompatibility. Question: at what place(s) would a negative sign be allowed? %R{-1,2}, %R{1,-2}, etc.? I suppose anywhere you can pass them to Rational's constructor...so both numerator and denominator. If the slash syntax is more to @mrkn's liking, these examples would be %R{-1/2} and %R{1/-2}. Note that since Rational() takes a string, the slashy %R format fits well the other % formats, in that % formats wrap something string-like that's then processed into a more specific data type, cacheable as a literal object in many cases. I really do not like the // magic infix literal format. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40121 Author: mrkn (Kenta Murata) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: current: 2.1.0 I would like to propose a new literal syntax for rational numbers. The implementation is available in my github repository: https://github.com/mrkn/ruby/commit/8ca0c9a53593e55d67f509fc403df616e2276e3a This patch implements a notation that consists of an integer, "//", and another integer, in a row. The first integer is the numerator, and the second is the denominator. Whitespaces are permitted between them. For example: 1 // 2 == Rational(1, 2) 1 // 1 == Rational(1, 1) 0 // 1 == Rational(0, 1) "0 // 0" occurs syntax error. I think this new syntax isn't conflict with an empty regexp because this implementation doesn't treat // as a binary operator. -- http://bugs.ruby-lang.org/