-
Notifications
You must be signed in to change notification settings - Fork 603
Description
Where
https://perldoc.perl.org/perlop#Operator-Precedence-and-Associativity
Description
I suggest to expand a table of attributes of operators. I'm not sure is this a good idea, but I'm leaving here as a suggestion. I wrote earlier the same into perlmonks forum ( https://perlmonks.org/?node_id=11126869 - "For discussion: operator attributes - associativity, chainity and ability to short-circuit" ). Here I'll add an example of a table, which can be further improved. I split some same precedence operators into separate lines but added vertical lines there. I'll attach a file with table for better readability - Operator_attribute_table.txt :
ASSOC. COND. SHORT-C. CHAINS OP.
left terms and list operators (leftward)
left ->
nonassoc ++ --
right **
right ! ~ \ and unary + and -
left =~ !~
left * / % x
left + - .
left << >>
nonassoc named unary operators
LEFT no yes yes < > <= >= lt gt le ge
| LEFT no yes yes == != eq ne ~~
| LEFT no no no <=> cmp
nonassoc isa
left &
left | ^
left yes yes no &&
left yes yes no || //
nonassoc .. ...
right yes no no ?:
right = += -= *= etc. goto last next redo dump
left , =>
nonassoc list operators (rightward)
right not
left yes yes no and
| left yes yes no or
| left no no no xor
Some reasons for that table are:
- in the current table when fields are filled with "chained" we do not see what is a direction of associativity (left or right).
- 'and' and 'or' are conditional but 'xor' isn't (by meaning of returned value). I think this info can be condensed here into table.
Also I think that this table can be a bit closer to the beginning of document. It is convenient to have it near the section name, where you can land by opening a link.