Skip to content
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

All digit words in angle-bracket word quoting don't come out the same as the literally quoted word #5825

Closed
p6rt opened this issue Nov 26, 2016 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 26, 2016

Migrated from rt.perl.org#130184 (status was 'resolved')

Searchable as RT130184$

@p6rt
Copy link
Author

p6rt commented Nov 26, 2016

From @briandfoy

Adapted from the Stackoverflow answer at​:
http://stackoverflow.com/a/40824226/2766176

I'm using moar (2016.10) on macosx (10.10.5) darwin (14.5.0) (These
variables are quite nice!)

This came out of a problem I had with set membership. It turns out
that the way you make the set matters, and the way you make the
candidate member matters. In my case, there's a bug with angle-bracket
word quoting.

I used the [angle-brackets form of the quote
words](https://docs.perl6.org/language/quoting#Word_quoting:_qw). The
quote words form is supposed to be equivalent to the quoting version
(that is, True under `eqv`). Here's the doc example​:

  <a b c> eqv ('a', 'b', 'c')

But, when I try this with a word that is all digits, this is not equivalent​:

$ perl6

< a b 137 > eqv ( 'a', 'b', '137' )
False

But, the other forms of word quoting are!

qw/ a b 137 / eqv ( 'a', 'b', '137' )
True
Q​:w/ a b 137 / eqv ( 'a', 'b', '137' )
True

The angle-bracket word quoting uses
[IntStr](https://docs.perl6.org/type/IntStr):

my @​n = < a b 137 >
[a b 137]
@​n.perl
["a", "b", IntStr.new(137, "137")]

Without the word quoting, the digits word comes out as [Str]​:

( 'a', 'b', '137' ).perl
("a", "b", "137")
( 'a', 'b', '137' )[*-1].perl
"137"
( 'a', 'b', '137' )[*-1].WHAT
(Str)
my @​n = ( 'a', 'b', '137' );
[a b 137]
@​n[*-1].WHAT
(Str)

@p6rt
Copy link
Author

p6rt commented Nov 27, 2016

From @briandfoy

This appears to be a problem with the docs. In https://docs.perl6.org/language/quoting#Word_quoting:_qw , there's no mention of the special value processing. The current text strongly implies that <...> is the same qw//. There's no note about the :v adverb.

@p6rt
Copy link
Author

p6rt commented Nov 27, 2016

From @zoffixznet

On Sat, 26 Nov 2016 15​:47​:38 -0800, comdog wrote​:

Adapted from the Stackoverflow answer at​:
http://stackoverflow.com/a/40824226/2766176

I'm using moar (2016.10) on macosx (10.10.5) darwin (14.5.0) (These
variables are quite nice!)

This came out of a problem I had with set membership. It turns out
that the way you make the set matters, and the way you make the
candidate member matters. In my case, there's a bug with angle-bracket
word quoting.

I used the [angle-brackets form of the quote
words](https://docs.perl6.org/language/quoting#Word_quoting:_qw). The
quote words form is supposed to be equivalent to the quoting version
(that is, True under `eqv`). Here's the doc example​:

\<a b c> eqv \('a', 'b', 'c'\)

But, when I try this with a word that is all digits, this is not equivalent​:

$ perl6

< a b 137 > eqv ( 'a', 'b', '137' )
False

But, the other forms of word quoting are!

qw/ a b 137 / eqv ( 'a', 'b', '137' )
True
Q​:w/ a b 137 / eqv ( 'a', 'b', '137' )
True

The angle-bracket word quoting uses
[IntStr](https://docs.perl6.org/type/IntStr):

my @​n = < a b 137 >
[a b 137]
@​n.perl
["a", "b", IntStr.new(137, "137")]

Without the word quoting, the digits word comes out as [Str]​:

( 'a', 'b', '137' ).perl
("a", "b", "137")
( 'a', 'b', '137' )[*-1].perl
"137"
( 'a', 'b', '137' )[*-1].WHAT
(Str)
my @​n = ( 'a', 'b', '137' );
[a b 137]
@​n[*-1].WHAT
(Str)

Thanks for the reqport, however, what you describe is not a bug, as the angle brackets
have special feature to construct IntStr, NumStr, RatStr, and ComplexStr allomorphs as
well as specify Rat and Complex literals.

The documention was just misleading. I corrected it in​:
Raku/doc@fa0b8f6

@p6rt
Copy link
Author

p6rt commented Nov 27, 2016

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

@p6rt
Copy link
Author

p6rt commented Nov 27, 2016

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Nov 27, 2016
@p6rt
Copy link
Author

p6rt commented Nov 27, 2016

From @lizmat

I think this is not a bug but the result of angle brackets quoting, which creates allomorphs​:. It is even documented​:

https://docs.perl6.org/language/glossary#index-entry-Allomorph

Hope this helps.

On 27 Nov 2016, at 00​:47, brian d foy (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by "brian d foy"
# Please include the string​: [perl #​130184]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=130184 >

Adapted from the Stackoverflow answer at​:
http://stackoverflow.com/a/40824226/2766176

I'm using moar (2016.10) on macosx (10.10.5) darwin (14.5.0) (These
variables are quite nice!)

This came out of a problem I had with set membership. It turns out
that the way you make the set matters, and the way you make the
candidate member matters. In my case, there's a bug with angle-bracket
word quoting.

I used the [angle-brackets form of the quote
words](https://docs.perl6.org/language/quoting#Word_quoting:_qw). The
quote words form is supposed to be equivalent to the quoting version
(that is, True under `eqv`). Here's the doc example​:

<a b c> eqv ('a', 'b', 'c')

But, when I try this with a word that is all digits, this is not equivalent​:

$ perl6

< a b 137 > eqv ( 'a', 'b', '137' )
False

But, the other forms of word quoting are!

qw/ a b 137 / eqv ( 'a', 'b', '137' )
True
Q​:w/ a b 137 / eqv ( 'a', 'b', '137' )
True

The angle-bracket word quoting uses
[IntStr](https://docs.perl6.org/type/IntStr):

my @​n = < a b 137 >
[a b 137]
@​n.perl
["a", "b", IntStr.new(137, "137")]

Without the word quoting, the digits word comes out as [Str]​:

( 'a', 'b', '137' ).perl
("a", "b", "137")
( 'a', 'b', '137' )[*-1].perl
"137"
( 'a', 'b', '137' )[*-1].WHAT
(Str)
my @​n = ( 'a', 'b', '137' );
[a b 137]
@​n[*-1].WHAT
(Str)

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant