bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66178: 30.0.50; cperl-mode inconsistent hash key fontification


From: Mauro Aranda
Subject: bug#66178: 30.0.50; cperl-mode inconsistent hash key fontification
Date: Sun, 24 Sep 2023 19:21:02 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1

tags 66178 notabug
close 66178
quit


On 24/9/23 10:44, Harald Jörg wrote:
> tags 66178 + wontfix
> thanks
>
> Mauro Aranda <maurooaranda@gmail.com> writes:
>
>> emacs -Q
>> C-x C-f bug.pl
>> M-x cperl-mode
>> my %factorial = (
>>           0 => 1,
>>           zero => 1
>>          );
>>
>> zero is recognized as a string, 0 is not.
>
> This might look surprising, but it is intentional.
>
> zero is a bareword which undergoes hash-key stringification.
>
> The digit 0, on the other hand, is converted to a string according to
> Perl's type conversion rules.  That is a different thing: Perl's type
> conversion converts all of 0, 000, 0.0, 0E0 to the hash key "0".
>
> Let me expand your example to demonstrate some more cases where the hash
> key is (correctly) not fontified as a string:
>
> my %hash = (
>      "0"    => 'The string "0"',
>      "00"   => 'The string "00"',
>      0      => 'A number which is converted to the string "0"',
>      00     => 'A number which is converted to the string "0"',
>      0.0    => 'A number which is converted to the string "0"',
>      0E0    => 'A number which is converted to the string "0"',
>      zero   => "A bareword which is stringified",
>      zero() => "The function's return value is the key",
>      +zero  => "The function's return value is the key",
> );

Thank you for the explanation, it makes more sense to me now.  I'm
tagging this one as notabug and closing.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]