[sf-perl] Unusual Perl "feature"

Quinn Weaver quinn at pgexperts.com
Sun Feb 24 08:50:25 PST 2013


Indeed, it seems odd that the feature would be "turned on" in other contexts besides far commas. My guess is that the perlguts implementation of operators doesn't allow them to be context-sensitive, so that an operator like unary '-' must work everywhere, even in places where it has no use case.

--
Quinn Weaver
PostgreSQL Experts, Inc.  http://pgexperts.com/
1-888-743-9778 (my extension: 510)
Sent from my phone; pardon my brevity.

On Feb 23, 2013, at 2:23 PM, Earl Ruby <earl at ruby.org> wrote:

> While this is all interesting, I wasn't using the => operator in the
> example I gave, just =
> 
> 
> On Tue, Feb 19, 2013 at 10:09 AM, Quinn Weaver <quinn at pgexperts.com> wrote:
>> Nice catch! That makes total sense. I wrote a Perl/Tk app once, but I'd forgotten all about the -key convention. It Just Worked, so I never really thought about it. DWIM for the win.
>> 
>> --
>> Quinn Weaver
>> PostgreSQL Experts, Inc.  http://pgexperts.com/
>> 1-888-743-9778 (my extension: 510)
>> Sent from my phone; pardon my brevity.
>> 
>> On Feb 18, 2013, at 1:09 PM, Uri Guttman <uri at stemsystems.com> wrote:
>> 
>>> On 02/17/2013 09:40 PM, Quinn Weaver wrote:
>>>> On Feb 15, 2013, at 4:14 PM, Mark Kvale wrote:
>>>> 
>>>>> This is documented behavior; see
>>>>> 
>>>>> http://perldoc.perl.org/perlop.html#Symbolic-Unary-Operators
>>>>> 
>>>>> My guess on use? As the man says, '-bareword is equivalent to the string "-bareword"', allowing for fat comma keys without needing quotes, e.g.
>>>>> 
>>>>> (-bareword => 1, -title => 2)
>>>> 
>>>> But you don't need to quote keys anyway. This feature must exist for some other reason.
>>> 
>>> it was allowed because of perl/tk where all the keys (as in regular tk) are -foo style. so perl allows barewords of -foo to be autoquoted by =>.  this also allowed the - prefix to be a simple prefix - to the string op which is useful for those types of keys.
>>> 
>>> uri
>>> _______________________________________________
>>> SanFrancisco-pm mailing list
>>> SanFrancisco-pm at pm.org
>>> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>> _______________________________________________
>> SanFrancisco-pm mailing list
>> SanFrancisco-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
> 
> 
> 
> --
> Earl Ruby
> http://earlruby.org/
> http://www.linkedin.com/in/earlruby
> @earlruby


More information about the SanFrancisco-pm mailing list