Hi all,
We've discussed this before, but I can't see there's an RFC for it.
I'd love to see warnings when references are used in ways that we probably
did not intend.
Stringified references don't warn:
$ perl -Mwarnings -E 'my $foo = bless {}, "asdf"; say "$foo"'
asdf=HASH(0x14f80aa80)
Numification warns if you do that to a string:
$ perl -Mwarnings -E 'my $foo = "asdf"; say $foo + 1'
Argument "asdf" isn't numeric in addition (+) at -e line 1.
1
But not with a reference:
$ perl -Mwarnings -E 'my $foo = []; say $foo + 1'
5754627201
Regexes:
$ perl -Mwarnings -E 'my $foo = []; say $foo =~ /\d/'
1
Do we consider this a problem? (I do). If so, what are all the cases where
we'd need to catch this and warn? What would the warnings category be?
Best,
Curtis "Ovid" Poe
--
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/
We've discussed this before, but I can't see there's an RFC for it.
I'd love to see warnings when references are used in ways that we probably
did not intend.
Stringified references don't warn:
$ perl -Mwarnings -E 'my $foo = bless {}, "asdf"; say "$foo"'
asdf=HASH(0x14f80aa80)
Numification warns if you do that to a string:
$ perl -Mwarnings -E 'my $foo = "asdf"; say $foo + 1'
Argument "asdf" isn't numeric in addition (+) at -e line 1.
1
But not with a reference:
$ perl -Mwarnings -E 'my $foo = []; say $foo + 1'
5754627201
Regexes:
$ perl -Mwarnings -E 'my $foo = []; say $foo =~ /\d/'
1
Do we consider this a problem? (I do). If so, what are all the cases where
we'd need to catch this and warn? What would the warnings category be?
Best,
Curtis "Ovid" Poe
--
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/