Perl << stays green after variable but not after number

14 views
Skip to first unread message

Philip Brenan

unread,
Jul 25, 2017, 6:46:02 PM7/25/17
to scintilla-interest
Geany 1.27, Perl << stays green after variable but not after number, please see attached.
PerlLeftShiftGreen.png

KHMan

unread,
Jul 25, 2017, 11:41:58 PM7/25/17
to scintilla...@googlegroups.com
On 7/26/2017 6:46 AM, Philip Brenan wrote:
> Geany 1.27, Perl << stays green after variable but not after
> number, please see attached.

First, allow me to remind you that providing the text of the
snippets in question will greatly facilitate testing. Copying and
pasting the samples will only cost a few seconds of your time, and
everybody who is interested in the issue will benefit.

Please remember the above. Thank you.

Having said that, let's move on to the issue at hand.

Here's your snippet (Sample A):
===============================
my $a = 1 << '1';
my $b = $a << 'a';
my $c = 1;

See this snippet (Sample B):
============================
# From Perl library ActivePerl/DocTools/PSP/Socket.pm
$stdout = \*stdout;
print $stdout <<AUTH_REQUIRED;
some text
AUTH_REQUIRED

Unless you have an iron-clad method to disambiguate these things,
I would choose Sample B over Sample A. And I mean iron-clad,
otherwise it will be another whack-a-mole exercise. The perl
lexer's heuristics usually highlight expressions on the RHS
properly. Also, heuristics are not expected to operate perfectly
for an entire dataset.

I question the real-world use of things like '1' or 'a'. I would
very much like to see real-world code where folks use 'a' on the
RHS. perldoc says: "Arguments should be integers." Sure, and we
should cover expressions too. In Sample A, $a is 2, and $b is also
2. The '1' is auto-converted to 1, but the 'a' becomes 0 (possibly
'a' to bareword a to zero). How useful is that? You might as well
write '1' as 1, while the 'a' there is not useful at all except
for party games.

Congratulations! You have stumbled upon yet another dusty corner
of the Perl lexer. It's a nothingburger. Feel free to test more. :-)

--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia

Reply all
Reply to author
Forward
0 new messages