Excellent suggestion. I wouldn't use "identifier", as that suggests other connotations to me and doesn't fit how I'm used to seeing Perl documented.
I would change "any word" to "a word". I find "any word" potentially misleading, as it could be interpretted as applying to words that are part of some larger expression to the left of the fat comma.
My first choice was to change "any word" to "a bareword", but the definition given for "bareword" in perldata is actually too narrow for this case. I define "bareword" as a "bare word", an unadorned word that Perl first tries to interpret as an operator or function call and then resorts to quoting if strict.pm doesn't prevent it. perldata defines "bareword" as "a bare word that doesn't mean something else", which I find unfortunate but acceptable.
Note that elsewhere in perldata it says:
The => operator is mostly just a more visually distinctive synonym for a comma, but it also arranges for its left-hand operand to be interpreted as a string -- if it's a bareword that would be a legal simple identifier (=> doesn't quote compound identifiers, that contain double colons).
which isn't using the "bareword" definition found in that same document (otherwise it would mean that x, for example, won't be turned into a string by => since x isn't a "bareword" according to the perldata documentation).
Update: Actually, even though x is an operator, it can also be a "bareword" that just gets quoted if strict.pm isn't in effect. Perhaps "if", "s", or "q" would've been better examples. I'm not absolutely certain that an unadorned ("bare") instance of "if", "s", or "q" can never turn into a bareword that gets stringified, but I can't think of any counterexamples. For example, try replacing "x" with other things in perl -MO=Deparse -e "0+x" vs in perl -MO=Deparse -e "print x=>0".
perldata also says:
In fact, an identifier within such curlies is forced to be a string, as is any simple identifier within a hash subscript. Neither need quoting.
just to note how the same situation is described for another case.
Finally, my example of x reminds me that the clarification should be expanded to "considered an operator, constant, or function call".
- tye
In reply to Re: Clarifying the Comma Operator (bareword)
by tye
in thread Clarifying the Comma Operator
by ig
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |