Answer the question
In order to leave comments, you need to log in
Tight binding, Russian equivalent?
In the Perl literature, the phrase "xxx binds tightly" is used to refer to an operator that acts on a neighboring operand without parsing the context, due to which, for example, the construction is erroneous
open FILE, "$file" || die "Can't open: $! \n";
open FILE, "$file" or die "Can't open: $! \n";
open(FILE, "$file") || die "Can't open: $! \n";
Answer the question
In order to leave comments, you need to log in
No, this just describes the precedence of operators. And using or
instead ||
helps not because y has or
a lower priority than y ||
(although it does), but because it is lower than a comma ( ,
), while y ||
is higher than a comma.
Parentheses are not syntactically related to operators; The parser that works with the operator precedence table, in fact, just places the brackets in the expression. And in this case, as I understand it, these are not brackets, but really a function call (I don’t know Perl, unfortunately). But in any case, the brackets in the given turn the left expression into an indivisible atom, and the parser will no longer pull it out "$file"
and attribute it to ||
. By the way, is there another option?
(open FILE, "$file") || die "Can't open: $! \n";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question