Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

Can't adverb approximately-equals operator in Rakudo #5333

Open p6rt opened 8 years ago

p6rt commented 8 years ago

Migrated from rt.perl.org#128210 (status was 'open')

Searchable as RT128210$

p6rt commented 8 years ago

From @masak

\ m​: my $x = 0; say $x ≅ 0 :tolerance(1e-3) \ rakudo-moar 7a4ca4​: OUTPUT«===SORRY!=== Error while compiling /tmp/Pvx3eWkBNW␤You can't adverb &infix​:\<≅> [...] \ can't adverb? o rly? \ how do I $x ≅ 0 :tolerance ? \ m​: my $x = 0; say ($x ≅ 0, :tolerance(1e-3)) \ rakudo-moar 7a4ca4​: OUTPUT«(True tolerance => 0.001)␤» \ like that? \ no, probably not ... \ nope, that's just printing a pair, not passing an adverb. \ I believe I haz found... a bug * masak .oO( dun dun DUN ) * masak submits rakudobug

p6rt commented 8 years ago

From @masak

\ m​: my $x = 0.0001e0; say infix​:\<≅> $x, 0, :tolerance(1e-3); # Indeed a bug, this works. \ rakudo-moar 7a4ca4​: OUTPUT«True␤»

p6rt commented 8 years ago

From @MasterDuke17

I've been looking into this and just got some clarification from TimToady on expected behaviour for adverbs and chains in general ( http://irclog.perlgeek.de/perl6/2016-06-02#i_12589974). The gist is that adverbs should be placed at the end of a chain and then distributed to all the operators in the chain, which will of course make the example in this ticket "just work".

Dan

p6rt commented 8 years ago

The RT System itself - Status changed from 'new' to 'open'

p6rt commented 7 years ago

From @bduggan

It seems that it is possible adverb custom operators, e.g.

perl6 -e 'sub infix​:\<~>($x,$y,​:$z) { say "$x $y $z" }; 1 ~ 2 :z(12)' 1 2 12

However, when these are chained, the adverb is not distributed

perl6 -e 'sub infix​:\<~>($x,$y,​:$z) { say [$x,$y,$z].perl; 9 }; 1 ~ 2 ~~~ 3 :z(12)' [1, 2, Any] [9, 3, 12]

So, if adverbs are made to distribute across infix operators in general then I suppose this existing behavior would change.