New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
say True but False # should be 'True' (advent2010-day19) #3390
Comments
From @dwarring[08:09] <dwarring> r: my $value = True but False; say $value |
From @cokeOn Wed May 21 13:36:58 2014, david.warring wrote:
This is from an old advent post that was pre-Christmas; is this actually a bug in current rakudo we should fix, or is the advent post out of date? -- |
The RT System itself - Status changed from 'new' to 'open' |
From @dwarringThe behavious still seems the same: % perl6 --v This is inconsistent with: % perl6 -e'my $s = 0 but True; say $s; say $s.so;' On Tue Aug 09 08:23:37 2016, coke wrote:
|
From @smlsI wouldn't call that inconsistent. `but True` overrides the boolean aspect of an object, and in the case of an object of type Bool, its value *is* its boolean aspect. Also, is there any practical benefit to what this ticket asks for, or is it purely meant as a fun gimmick? |
From @dwarringAgree that's not equivalent, this is maybe a better counter example: % perl6 -e'my $s = 0 but 42; say $s' On Wed Aug 10 10:51:20 2016, smls75@gmail.com wrote:
|
From @smlsYou're right, that one *is* inconsistent with `True but False`. `$bool1 but $bool2` and `$int1 but $int2` should either both override the value, or both *not* override the value. |
From @zoffixznetOn Thu, 11 Aug 2016 06:14:52 -0700, smls75@gmail.com wrote:
There's actually no inconsistency and the infix:<but> is much less magical: The infix:<but> operator with the RHS that isn't a role *creates* a role with a single method <Zoffix> m: my So the results you claim are inconsistent actually are: % perl6 -e'my $s = False but True; say $s; say $s.so;' - `but True` mixes in a role with method called `Bool` that returns `True` In this example: % perl6 -e'my $s = 0 but True; say $s; say $s.so;' - Everything is the same as in the previous example, except the original object is an Int And since we know that .gist on Ints calls .Str, we can predict that mixing in a Str object will change the output of `say`: <Zoffix> m: my $s = 0 but 'meows'; say $s; say $s.so; Indeed it did change the output of `say` and since we did not override .Bool this time, the `.so` output gives False now. So then, if we mixin both a Str and a Bool, we'll affect both outputs: <Zoffix> m: my $s = (0 but 'meows') but True; say $s; say $s.so; So as far as I can see, there's no bug or inconsistency. Closing the ticket. Cheers, |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#121940 (status was 'resolved')
Searchable as RT121940$
The text was updated successfully, but these errors were encountered: