Issue #8430 has been reported by mrkn (Kenta Murata). ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430 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/8ca0c9a53593e5... 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.

on 2013-05-21 15:31

on 2013-05-21 15:44

Issue #8430 has been updated by mrkn (Kenta Murata). I updated the patch for fixing negative rational numbers: https://github.com/mrkn/ruby/commit/b16f4da893c1cb... ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39466 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/8ca0c9a53593e5... 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.

on 2013-05-22 04:08

Issue #8430 has been updated by nobu (Nobuyoshi Nakada). Shouldn't tDIV2 be only if IS_SPCARG(c)? ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39471 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/8ca0c9a53593e5... 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.

on 2013-05-22 04:49

Issue #8430 has been updated by knu (Akinori MUSHA). I think it should be added as an operator rather than a literal notation. A literal should not look like an expression, or it will fail you when you find out you have to give up the // notation in order to constify a numerator and/or a denominator of a rational literal like that. Also, I guess runtime cost would not change much if it were introduced as operator. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39472 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/8ca0c9a53593e5... 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.

on 2013-05-22 05:29

Issue #8430 has been updated by charliesome (Charlie Somerville). > Also, I guess runtime cost would not change much if it were introduced as operator. Rational is immutable, so if it it was introduced as a literal, the same Rational instance could be re-used, similar to how symbols and fixnums work. If // was introduced as an operator, a new object would need to be allocated each time, similar to strings. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39473 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/8ca0c9a53593e5... 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.

on 2013-05-22 06:45

Issue #8430 has been updated by phluid61 (Matthew Kerwin). charliesome (Charlie Somerville) wrote: > > Also, I guess runtime cost would not change much if it were introduced as operator. > > Rational is immutable, so if it it was introduced as a literal, the same Rational instance could be re-used, similar to how symbols and fixnums work. > > If // was introduced as an operator, a new object would need to be allocated each time, similar to strings. At the risk of asking something stupid, could it be both? I'm thinking of unary minus / literal negative number. (Assuming there's such a thing in Ruby as a literal negative (?)) ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39476 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/8ca0c9a53593e5... 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.

on 2013-05-22 10:16

Issue #8430 has been updated by nobu (Nobuyoshi Nakada). I also prefer an operator. https://github.com/nobu/ruby/commit/7ff6073d703069... ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39481 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/8ca0c9a53593e5... 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.

on 2013-05-22 10:22

Issue #8430 has been updated by mrkn (Kenta Murata). knu (Akinori MUSHA) wrote: > I think it should be added as an operator rather than a literal notation. > > A literal should not look like an expression, or it will fail you when you find out you have to give up the // notation in order to constify a numerator and/or a denominator of a rational literal like that. I made another implementation of the rational number literal implemented in token-level. The implementation is available in https://github.com/mrkn/ruby/commit/f0bf41b6593866... Whitespaces around of // aren't permitted in this implementation. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39482 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/8ca0c9a53593e5... 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.

on 2013-05-22 10:25

Issue #8430 has been updated by mrkn (Kenta Murata). nobu (Nobuyoshi Nakada) wrote: > I also prefer an operator. > > https://github.com/nobu/ruby/commit/7ff6073d703069... Pretty nice! I love this if introducing // as a operator is accepted. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39483 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/8ca0c9a53593e5... 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.

on 2013-05-29 02:48

Issue #8430 has been updated by mrkn (Kenta Murata). Yesterday I ask matz about merging it to trunk, he said it is ok with experimental mark like refinements. And I confirmed that nobu's quo-operator doesn't conflict with empty regexps: $ .prefix/bin/ruby -e 'f=1; i=2; p(f //i)' (1/2) $ .prefix/bin/ruby -e 'def f(a); p a; end; i=2; p(f //i)' //i //i ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39549 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/8ca0c9a53593e5... 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.

on 2013-05-29 10:37

Issue #8430 has been updated by nobu (Nobuyoshi Nakada). It does change the interpretation of the following code foo.split // bar It is "foo.split(//); bar" currently, but it would be "foo.split.//(bar)" with the patch. Of course it's possible to address it by heuristically, but I wonder if it's good or worth to do. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39555 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/8ca0c9a53593e5... 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.

on 2013-05-30 05:17

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/8ca0c9a53593e5... 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.

on 2013-05-30 15:35

Issue #8430 has been updated by mrkn (Kenta Murata). phluid61 (Matthew Kerwin) wrote: > 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? It collides to the conditional operator, ?:, for example: expr ? 1:2 As I discussed with matz and akr today, the token-level implementation of // doesn't introduce incompatibility, so it can be introduced safely. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39568 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/8ca0c9a53593e5... 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.

on 2013-06-08 07:25

Issue #8430 has been updated by rohansoni619 (Rohan Soni). different symbol changes the interpretation. http://www.jaro.in/international-MBA-1-year.html ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-39786 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/8ca0c9a53593e5... 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.

on 2013-06-23 20:39

Issue #8430 has been updated by headius (Charles Nutter). Not sure if the debate still rages, but something that keeps the numerator and denominator together in a single "literal" seems better to me. Why not add another % literal? %R{1,2} There's no other literals that are produced via a magic infix operator, and it seems confusing to me. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40100 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/8ca0c9a53593e5... 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.

on 2013-06-24 01:52

Issue #8430 has been updated by phluid61 (Matthew Kerwin). headius (Charles Nutter) wrote: > Not sure if the debate still rages, but something that keeps the numerator and denominator together in a single "literal" seems better to me. Why not add another % literal? > > %R{1,2} > > There's no other literals that are produced via a magic infix operator, and it seems confusing to me. +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.? ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40105 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/8ca0c9a53593e5... 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.

on 2013-06-24 17:26

Issue #8430 has been updated by mrkn (Kenta Murata). > %R{1,2} It isn't similar to a fraction. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40118 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/8ca0c9a53593e5... 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.

on 2013-06-24 22:45

Issue #8430 has been updated by headius (Charles Nutter). mrkn (Kenta Murata) wrote: > > %R{1,2} > > It isn't similar to a fraction. Does it have to be? How about %R{1/2} then? ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40120 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/8ca0c9a53593e5... 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.

on 2013-06-24 22:49

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/8ca0c9a53593e5... 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.

on 2013-06-28 03:41

Issue #8430 has been updated by mrkn (Kenta Murata). headius (Charles Nutter) wrote: > If the slash syntax is more to @mrkn's liking, these examples would be %R{-1/2} and %R{1/-2}. I don't hate this form. It is better than %R{1,2}. But I think 1//2 looks like a fraction than %R{1/2}. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40184 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/8ca0c9a53593e5... 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.

on 2013-06-28 04:03

Issue #8430 has been updated by phluid61 (Matthew Kerwin). mrkn (Kenta Murata) wrote: > headius (Charles Nutter) wrote: > > If the slash syntax is more to @mrkn's liking, these examples would be %R{-1/2} and %R{1/-2}. > > I don't hate this form. It is better than %R{1,2}. > But I think 1//2 looks like a fraction than %R{1/2}. Slightly bike-shedding, but I have issues with // as an operator. For one, it immediately screams "comment" at me, even though ruby comments use #, simply because so many other languages use it. Then after that, I wonder at the relationship between / and // when compared to * and ** (i.e. is // meant to mean some sort of multi-phased divide, or a logarithm?) The reason I particularly like %R{1/2} is that it contains the existing division operator, 1/2, without any modification, so at a glance you can see that 1/2 and %R{1/2} are in some way equivalent, but the %R{} around it adds some flavourful difference. The %R format also lends itself to interpolation, if such is deemed to be useful, e.g. %R(-#{foo}/2), which could arguably be more or less useful than variable operands. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40185 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/8ca0c9a53593e5... 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.

on 2013-07-27 09:16

Issue #8430 has been updated by matz (Yukihiro Matsumoto). The final idea was "1r" to be "Rational(1,1)". We also accept the idea of "1i" as "Complex(0,1)". Matz. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40713 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/8ca0c9a53593e5... 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.

on 2013-07-27 09:29

Issue #8430 has been updated by mrkn (Kenta Murata). matz (Yukihiro Matsumoto) wrote: > The final idea was "1r" to be "Rational(1,1)". We also accept the idea of "1i" as "Complex(0,1)". Additionaly them, "1.2r" as "Rational(12, 10)" is also accepted. But the exponential form with "r" suffix like "1e-5r" is not accepted because it can make us confusing. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40714 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/8ca0c9a53593e5... 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.

on 2013-07-27 17:09

Issue #8430 has been updated by mrkn (Kenta Murata). Status changed from Open to Assigned Assignee changed from matz (Yukihiro Matsumoto) to mrkn (Kenta Murata) ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40717 Author: mrkn (Kenta Murata) Status: Assigned Priority: Normal Assignee: mrkn (Kenta Murata) 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/8ca0c9a53593e5... 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.

on 2013-08-01 09:53

Issue #8430 has been updated by takuto_h (Takuto Hayashi). File ratio_lit.patch added Hello. I wrote a patch for the rational number literal and recognized that a part of the proposed feature is confusable. If we accept "1.2r" as "Rational(12, 10)": 1/3r #=> (1/3) 0.4/1.2r #=> 0.33333333333333337 I think this feature's point is that "1/3r" can be seen as "1/3" followed by "r", so it can make us confusing that "0.4/1.2" followed by "r" is not a rational number. The attached file is a patch which accept "3r" and doesn't accept "1.2r". The implementation is also available at: https://github.com/takuto-h/ruby/commit/6827688ee6... Thank you. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40791 Author: mrkn (Kenta Murata) Status: Assigned Priority: Normal Assignee: mrkn (Kenta Murata) 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/8ca0c9a53593e5... 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.

on 2013-08-01 15:06

Issue #8430 has been updated by mame (Yusuke Endoh). takuto_h (Takuto Hayashi) wrote: > Hello. > I wrote a patch for the rational number literal Great. > and recognized that a part of the proposed feature is confusable. > > If we accept "1.2r" as "Rational(12, 10)": > 1/3r #=> (1/3) > 0.4/1.2r #=> 0.33333333333333337 > > I think this feature's point is that "1/3r" can be seen as "1/3" followed by "r", > so it can make us confusing that "0.4/1.2" followed by "r" is not a rational number. IMO, it does not matter because we don't usually write a rational whose numerator and denominator are decimal. Also, it is very clear and reasonable what happens. -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40797 Author: mrkn (Kenta Murata) Status: Assigned Priority: Normal Assignee: mrkn (Kenta Murata) 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/8ca0c9a53593e5... 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.

on 2013-08-01 17:20

Issue #8430 has been updated by mrkn (Kenta Murata). takuto_h (Takuto Hayashi) wrote: > Hello. > I wrote a patch for the rational number literal and recognized that a part of the proposed feature is confusable. Thank you. But I'd already have a patch made by me on the last Sunday. Although I've commited the changes based on my patch, I really appreciate your contribution for this issue. ---------------------------------------- Feature #8430: Rational number literal https://bugs.ruby-lang.org/issues/8430#change-40800 Author: mrkn (Kenta Murata) Status: Closed Priority: Normal Assignee: mrkn (Kenta Murata) 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/8ca0c9a53593e5... 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.

on 2013-08-01 18:54

On Aug 1, 2013, at 12:53 AM, takuto_h (Takuto Hayashi) wrote: > If we accept "1.2r" as "Rational(12, 10)": > 1/3r #=> (1/3) > 0.4/1.2r #=> 0.33333333333333337 > > I think this feature's point is that "1/3r" can be seen as "1/3" followed by "r", > so it can make us confusing that "0.4/1.2" followed by "r" is not a rational number. I haven't looked at the implementation, but my understanding was that 1/3r was seen as 1 divided by Rational(3,1). With that interpretation, I think 0.4/1.2r is not confusing: 0.4/1.2r is a Float (i.e. 0.4) divided by a Rational (i.e. Rational(12,10) or 1.2r). Float divided by Rational gives Float. To end up with a Rational result, use 0.4r/1.2r. > The attached file is a patch which accept "3r" and doesn't accept "1.2r". I very much like the idea of "1.2r", let's please keep accepting 1.2r. Thanks, Dave