Suppose E, F, and G are expressions that don't involve operators of higher precedence than the comma. Are the expressions ((E, F), G) and (E, (F, G)) equivalent in scalar, list, and/or void contexts? More precisely, can you always replace ((E, F), G) with (E, (F, G)) and vice-versa without affecting program execution?
Is the comma in Perl associative in all contexts?
74 Views Asked by fmg At
1
There are 1 best solutions below
Related Questions in PERL
- Perl Regex for converting query strings
- Cross compiling perl for Android ld.lld: error: unable to find library -lpthread
- Regexp to remove small numbers and leave large ones
- `df` command not capturing entire output in perl
- Webmin CentOS7 AWS backup errors - perl(S3::AWSAuthConnection) can't be installed
- How to ignore perm errors with Path::Tiny 'visit'? (Windows)
- Why does setting `*\` to a scalar (string) reference not result in auto printing
- Regex for deconstructing SQL where statement
- Random characters in DS record from Net::DNS:RR when calling print/string
- Perl with Selenium: cannot save the Web page with Ctrl+S
- openssl pbkdf2 and perl
- Strawberry Perl using a separate winlibs distro
- Perl / Undefined value as a HASH reference when running SNMP queries
- Timestamp with timezone: works with isql but not with DBD::Firebird
- Slurping a file ... syntax error - example from perldoc
Related Questions in EXPRESSION
- Evaluating this in Assembly (A % B) % (C % D)
- Creating Array of Arrays in Azure Data Factory
- Nested Expression in Powershell returning part of Expression
- Power BI Dax SUM
- BC30201 Expression expected in Power BI
- How to run a template job only if the previous job failed in Azure DevOps?
- Calculate the count and put in the same matrix table
- Expression tree - how to check if element of a list fulfills specific conditions?
- How to write ADF dynamic expression with SQL statements in multiple levels
- Get FieldExpression value in C#
- gtk4 + python workaround for unsupported functions bind_property_with_closures() and bind_property_full()
- Simple expression evaluation syntax
- Power Automate, get the max/biggest value from an output array
- How can I force a DataGridView to redraw or refresh after any front end changes to the data?
- Is there a runtime cost of assigning variables in Rust?
Related Questions in OPERATOR-PRECEDENCE
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Why is this SQL query returning rows from outside of the specificed date range
- Operator precedence in Java with assignment
- I don't understand how the final values of 2 variables are calculated after an addition of a pre-increment and post-increment
- Why does the PHP null-coalescing operator (??) behave irrationally with == and ===?
- How is pointer ++*ptr++ evaluated
- How do I implement precedence climbing correctly in rust
- How does Python parse `7 in x == True`?
- Why is the environment diagram in the following Python code inconsistent with its execution order?
- Operation sequence
- why does "int" come before "input"? I would like to understand the logic of this code
- Combining python "in" and "==" operator has confusing behavior
- Can you tell me the truth about order of evaluation VS precedence VS associativity in C?
- Why this operation is not following the precedence and associativity table in C?
- Why the bracket is not evaluated first in this Java program?
Related Questions in ASSOCIATIVITY
- Why only commutativity is sufficient for op-based CRDTs and not also associativity?
- I don't understand how the final values of 2 variables are calculated after an addition of a pre-increment and post-increment
- Can you tell me the truth about order of evaluation VS precedence VS associativity in C?
- Why this operation is not following the precedence and associativity table in C?
- How to generate all possible 3x3 matrices with fixed first row and column with entries from 0,1,2
- result of this expression is not what i learned
- tensorflow/numpy computations results depend on the processor
- Why do right associative extension methods have the opposite target from normal methods?
- Is there any difference between these two?
- Associativity of an if expression in Python
- Is the comma in Perl associative in all contexts?
- operator vs () parenthesis in JAVA
- How to rearrange newly defined associative terms in Coq?
- right associativity and order of execution of nested ternary operator in c++
- Why does x = x * y / z give a different result from x *= y / z for integers?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Context does not affect how code is parsed.
The comma/list operator is guaranteed to evaluate each operand from left to right (regardless of context).
From that and a couple more pieces of information, we can prove that
E, F, G,( E, F ), GandE, ( F, G )are equivalent.[1]Since you specifically mentioned context, we'll look at that in more detail.
For void, list or indeterminate[2] context c, we get the same context c for each item in all cases.
For scalar context (s), we get void context (v) for all but the last item in all cases.
I'd love to be able to say they compile identically, but they don't. Despite the documentation saying it's a binary operator, it's implemented as a n-ary operator. The parens causes another instance of the operator to be created (effectively making it a binary operator in your examples).
When it's the last expression of a sub, the context is only known at run-time, which I called "indeterminate". This makes no difference except for the the list/comma operator in scalar context. The run-time context is propagated to every operand, so you get s,s,s if it's only know at run-time, despite getting v,v,s if the context is known at compile-time.
As you can see above, this doesn't affect the answer.
E, F, G,( E, F ), GandE, ( F, G )are equivalent whether the context is known at compile-time or not.