# New Ticket Created by  Tobias Leich 
# Please include the string:  [perl #123741]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123741 >


FROGGS: m: say (2/6).WHAT; say (2/6).perl.EVAL.WHAT # rakudobug
camelia: rakudo-moar 613c0b: OUTPUT«(Rat)␤(Str)␤»

jnthn: timotimo: Thing is, I think it's meant to be a RatStr, not just a
Rat?
timotimo: no
timotimo: Any such literal, when written without spaces, produces a pure
numeric value without a stringy allomorphism. Put spaces to override that:
timotimo:      <1/2>       # a Rat
timotimo:     < 1/2 >     # a RatStr
timotimo: http://design.perl6.org/S02.html#Allomorphic_value_semantics
jnthn: Oh...
timotimo: i have a failure in "weird-errors" and "start.t", but
otherwise 5 todos passed
timotimo: i'll just push it to a branch, because i'll have to AFK again
jnthn: The "any such literal" suggests that it extends to all Numeric forms?
jnthn: If so, can we (in the Action method for a <...> quote), do:
jnthn: if [it's just a single value not a list] {
timotimo: as in "doesn't have a space in it at all"? that sounds like
something nibblish
timotimo: but yeah, there ought to be a branch for complex numbers
there, too
jnthn:     try { ...call .Numeric on the string, if we are successful
then add result as a constant and update the QAST we'll produce }
jnthn: }
jnthn: m: say "1/2".Numeric.WHAT
camelia: rakudo-moar 613c0b: OUTPUT«(Rat)␤»
jnthn: m: say " 1/2".Numeric.WHAT
camelia: rakudo-moar 613c0b: OUTPUT«(Rat)␤»
jnthn: Ah
jnthn: Darn, that is soft on whitespace...
timotimo: that'd be "doesn't have spaces"
jnthn: Yeah, but maybe we can check if the string contains whitespace as
part of the initial "if"
timotimo: also not sure how <1 / 5> is supposed to work
jnthn: I'm quite sure we don't want the .Numeric logic implemented in
two places.
jnthn: So I'm reluctant to go special-casing it in the grammar.
Kristien: special cases break generic code
jnthn: Right.
jnthn: Do it with .Numeric and we get the complex and so on for free also.
dalek: rakudo/angular_bracket_literal_semantics: b49d943 | timotimo++ |
src/Perl6/ (2 files):
dalek: rakudo/angular_bracket_literal_semantics: this is how <1/5> could
produce a Rat directly.
dalek: rakudo/angular_bracket_literal_semantics: review:
https://github.com/rakudo/rakudo/commit/b49d943917
timotimo: that's fair.
timotimo: i could have just not pushed this branch then :)
jnthn: otoh, you could have your grammar rule call <numeric>
jnthn: '<' ~ <numeric> ~ '>'
timotimo: you mean '<' ~ '>' <numeric> :)
jnthn: And that probably also re-uses some logic.
jnthn: uh, yes
jnthn: But
jnthn: wait, don't use ~
jnthn: 'cus we don't want to explode
jnthn: We just want to parse it as a normal quote in that case
timotimo: it already uses ~ around the alteration
jnthn: Ah

Reply via email to