From: "phluid61 (Matthew Kerwin)" Date: 2013-05-30T12:16:48+09:00 Subject: [ruby-core:55205] [ruby-trunk - Feature #8430] Rational number literal Issue #8430 has been updated by phluid61 (Matthew Kerwin). =begin nobu (Nobuyoshi Nakada) wrote: > Of course it's possible to address it heuristically, but I wonder if it's good or worth to do. How about a different symbol? Since (({:})) is the standard mathematical symbol for ratio, why not define (({[+-]?\d+:\d+})) as an immediate Rational, and/or (({:})) as an operator? As an operator it conflicts with short symbol/hash syntax only in the case that the left-hand operand is a tIDENTIFIER (like local variable/function) and there is no whitespace before the (({:})). Not sure if that's better or worse than the empty regexp conflict. =end ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39564 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/