Questions tagged [order-of-execution]
The order in which events occur in a software system. Distinct from [operator-precedence], which covers the order in which operators are applied when evaluating an expression in a programming language.
195
questions
-4
votes
1
answer
44
views
Interesting XOR expression evaluation in javascript
Tried out the expression a ^= b ^= a ^= b with a and b taking values 3 and 5 respectively. When executed in Javascript the answer is a = 0 and b = 5, but when run in C the variables got reversed to a =...
0
votes
0
answers
46
views
`await` vs `.then()` : order of execution [duplicate]
I'm trying to understand the order of execution of JavaScript promises. In the following code, thenFn() is invoked after awaitFn(), but thenFn() still executes(complete the task) first. Can someone ...
0
votes
0
answers
10
views
many parallel CMAKE/CTEST test: how do I guarantee 1 test completes before another test starts?
I write some math heavy libraries (e.g. multidimensional polynomials, coordinate system transformations, geolocation, probability distributions, a "statistics processor" which is effectively ...
1
vote
1
answer
111
views
Why do dictionaries in Python check for a key-existing during assignment?
So I heard that dict instances in Python will check if a key already exists before assigning a value. This seems very redundant to me, and I will explain why with an example.
EXAMPLE:
if(key in ...
2
votes
1
answer
128
views
Different results obtained when using MSVC compiler and GCC compiler
I have this simple little code:
#include <iostream>
int Add (int x, int y) {
std::cout << "In Add(), received " <<x<< " and " <<y<< "\...
-3
votes
3
answers
135
views
What is the operator precedence/order of evaluation in this complex expression, and why is the result -129?
I don't understand in which order actions take place in C++ expressions.
For example:
Why do we get here -129? Can you explain order of actions?
#include <stdio.h>
int main()
{
char a = 60;
...
0
votes
2
answers
36
views
tkinter, using buttons to progress a text adventure game
I wanted to make a text-based adventure game. It seemed easy enough, I just make a gigantic tree of if statements and get input from the user at every step. However, then I decided to try and make a ...
4
votes
1
answer
151
views
What is the order of destruction of the two entries of a std::pair?
Only 5 tags are allowed, but please, take it as c++20 and c++23 are in the list too, because I'd like to know about those standards as well, in case something has changed since c++17.
Is the order of ...
0
votes
0
answers
24
views
Default Execution Order of Test Classes in JUnit 4
Pretty much the title says it all. Note that the question is order of "classes" not the test methods inside them. Per answers here, the default execution order of test methods within a class ...
0
votes
2
answers
258
views
In Salesforce, how does a row lock error happen when there's only a single transaction (thread) executing?
When a user 'action' (in a general sense) is executed in Salesforce, assuming no callouts or async jobs are executed, isn't the code running in a single thread/transaction? Assuming so, how is it that ...
-1
votes
1
answer
55
views
The execution order of the promise according to the return type [duplicate]
I would like to know the reason why the execution order varies depending on what is returned in a then callback:
var a = Promise.resolve();
var b = a.then(function a_then() {
console.log(1);
...
0
votes
1
answer
65
views
Execution order question when processing JavaScript asynchronous functions (promise)
I'd like to know the order in which the JavaScript code below is executed and why. In particular, I would like to learn more about the contents of the code that goes into the microtask queue, focusing ...
2
votes
1
answer
51
views
JavaScript Operator Precedence, Assignment, and Increment?
In JavaScript (JS), ++ has higher precedence than += or =. In trying to better understand operator execution order in JS, I'm hoping to see why the following code snippet results in 30 being printed?
...
1
vote
2
answers
53
views
order of execution confusion
SELECT First_name,last_name,email,ROUND (AVG(Amount),2) AS moneyspent
FROM Customer INNER JOIN Payment
ON Customer.customer_id= Payment.customer_id
WHERE Staff_id=2
GROUP BY First_name,last_name,...
0
votes
0
answers
28
views
Is Lock protection needed in synchronous functions when using asyncio framework?
My question in a nutshell is, how exactly does the asyncio framework executes code?
Let's say I have some synchronous function which uses some data e.g. in a global variable. This context is fully ...
1
vote
0
answers
34
views
Async calls in c++ ordered by completion [duplicate]
I am learning asynchronous programming in c++, consider the following code:
#include<iostream>
#include<future>
#include<chrono>
#include<thread>
#include<...
-3
votes
1
answer
80
views
Order of execution for functions on either side of the assignment operator
I want to implement a function
$input = ['key1', 'value1', 'key2', 'value2'];
// $output = ['key1' => 'value1', 'key2' => 'value2'];
$output=[];
do {
$output[current($input)] = next($input);
...
0
votes
1
answer
189
views
Does the GROUP BY occur after the operations that occur in the SELECT statement? (BigQuery)
From what I have read on e.g. https://www.sisense.com/blog/sql-query-order-of-operations/ I understand that SQL statements will execute in the order:
1: FROM, 2: WHERE, 3: GROUP BY, 4: HAVINIG, 5: ...
1
vote
1
answer
76
views
Why does the location of the SUM() in an IF statement matter in a GROUP BY scenario when the grouped by column is changed? (BigQuery)?
I have some electrical meter data that I want to group by meter and convert all data to baseline units. The below query does that:
SELECT meter,
IF(unit="kWh" OR unit="kW", &...
2
votes
2
answers
88
views
When a thread is executing make_shared, can another thread do something to cause a leak of the object that make_shared creates via new?
From Effective Modern C++, Item 21, I learned that one advantage of std::make_shared over new+std::shared_ptr is that code like this
processWidget(std::shared_ptr<Widget>(new Widget), ...
19
votes
3
answers
2k
views
Are multidimensional array accesses sequenced?
Take the following:
int a(void) {
puts("a");
return 0;
}
int b(void) {
puts("b");
return 1;
}
int c(void) {
puts("c");
return 2;
}
int d(void) {...
1
vote
1
answer
37
views
Explaining the Output of Comparison Expressions Involving Strings and Lists in Python [duplicate]
Hej,
I have the following code snippet and I don't understand the output:
a = "foo"
b = "foo"
c = "bar"
foo_list = ["foo", "bar"]
print(a == b in ...
0
votes
0
answers
113
views
Loop Hop Board Game
I keep getting a "10s Timeout" error for this Hackerrank though I pass the initial test case, I now seek assistance to increase the speed of my code. The problem is:
code for the following ...
0
votes
1
answer
44
views
identifier not being recognized in a 'with' statement using a subquery in Snowflake
so I have a table that's sort of like this:
DELIVERY_AREA_ID,DELIVERY_RADIUS_METERS,EVENT_STARTED_TIMESTAMP
234sfd,4000,2020-01-01 12:19:29.719
234sfd,6500,2020-01-01 12:31:40.325
234sfd,3500,2020-01-...
-2
votes
2
answers
83
views
Q20. What is the order of execution of the lines of the following program? [duplicate]
Q20. What is the order of execution of the lines of the following program?
def f1(x): #1
temp = x + 1 #2
return temp #3
def f2(y): #4
t = y -1 #5
v = f1(t) #6
return v #7
#8
print(f2(5)) #9
...
-2
votes
1
answer
41
views
Java: Order of Operations Unclear [closed]
First question:
I wrote a program to calculate gift tax. When tested with input value: 14491 the output was -25436.3. I can't figure out how this number was calculated. Can anyone help explain this? ...
-1
votes
1
answer
52
views
Why does the date-range of the table on the left side of a LEFT JOIN not limit the bytes processed in the same way as a where clause?
I'm trying to understand why the date-range restriction imposed by the first table in a Left Join does not limit the Bytes Processed in the same way as adding a WHERE clause with the same restriction ...
0
votes
1
answer
321
views
How to know the order of functions to be executed in PostgreSQL?
For example, I was told that WHERE will be executed before GROUP BY, and HAVING will be afterwards, so the lines of code should be written in that order.
How could I know or from where should I read ...
1
vote
1
answer
121
views
Powershell problem with order of execution in script [duplicate]
I'm having a problem with unexpected order of things being run and returned in the below Powershell script.
The Write-ArrayToTable function is to output the data in the arrays in a pretty table-like ...
0
votes
1
answer
50
views
Maintain dependency between two tables while executing triggers in oracle
How we can maintain dependency between two tables while executing triggers in oracle??
As we know we can use follows clause if we have single table and multiple triggers based on that table but my ...
0
votes
0
answers
45
views
Order of function calls is an c++ arithmetic operation [duplicate]
Suppose we have this code (seen in an interview test), the order of arithmetical operations is well defined in the standard (left to right), but the question is: the order of execution for the ...
0
votes
1
answer
245
views
Jasper Reports : variables referencing other variables?
Inside a Jasper report, I'd like to have something with two non-cumulative variables (computed for each record) :
var_age : a calculation of age based upon elements of the current record.
...
-10
votes
1
answer
727
views
How does operator precedence affect order of evaluation? [duplicate]
How does operator precedence affect order of evaluation, not the difference between them? To better illustrate my question, I will include a short explanation of operator precedence below.
The ...
2
votes
3
answers
112
views
Does the ORDER BY clause return a Virtual Table?
My understanding is that relational tables aren't ordered.
I also understand that each step, or phase, of the query execution returns a "virtual table" which is passed as input to the next ...
4
votes
1
answer
422
views
Priority of tuple (un)packing with inline if-else
Apologies in advance for the obscure title. I wasn't sure how to phrase what I encountered.
Imagine that you have a title of a book alongside its author, separated by -, in a variable title_author. ...
0
votes
1
answer
49
views
Python Order of Execution Libraries / Tools
I'm trying to bugfix a pretty large codebase (~100 000 lines) of purely python code and it would be very helpful to have a way to see what code is being run and in which order. Does anyone know of a ...
2
votes
1
answer
698
views
What is the evaluation order of function arguments?
I'm using this version of Go:
$ go version
go version go1.18 windows/amd64
The results are different when struct A has only one field and B has two or above fields, and it just happens when parameter ...
0
votes
0
answers
241
views
Sequential execution of 2 functions in JavaScript
I am not very familiar with async/await and promises. Currently having two individual functions - to export files from X and upload those files to Y correspondingly.
export const exportFiles = async (...
0
votes
1
answer
33
views
Does an implicit typecast in Java have an effect on the order of operations?
I have a snippet from my code where a statement that seems like it should evaluate to "false" actually returns true.
long composite = -1L;
ArrayList<Long> ...
1
vote
1
answer
120
views
Operator precedence and order of evaluation in the implementation of std::transform
SUMMARY
I stumbled upon the implementation of std::transform and I could not figure out why it works in the case where we transform a container in-place. In particular, I found this expression ...
1
vote
2
answers
550
views
Order of execution of statements in Nodejs event emitter program
I tried the following NodeJs example:
const EventEmitter = require('events');
var eventEmitter = new EventEmitter();
var fun1 = (msg) => {
console.log("Message from fun1: " + msg);
};...
0
votes
0
answers
73
views
IEnumerable Query with ContinueWith: Order of completion guarantee?
I have an input array that I need to produce an output that is in the same order. If I run
source.Select((item, index) =>
remoteDb.Where(condition).FirstOrDefaultAsync()
.ContinueWith(result -...
-1
votes
1
answer
96
views
When does a function call copy its pass-by-value arguments relative to the argument sequences?
I would like to understand this code snippet as much as the undefined behavior permits it:
int i = 0;
printf("%d %d %d", i, ++i, i++);
output:
2 2 0
From what I can tell:
a comma , ...
0
votes
1
answer
215
views
Why two logically same conditions in postgresql case clause have different behavior?
I have two queries is postgresql:
1. SELECT CASE WHEN (1=1) THEN NULL ELSE cast(1/0 as text) END;
2. SELECT CASE WHEN (EXISTS (SELECT 10)) THEN NULL ELSE cast(1/0 as text) END;
As you might have ...
7
votes
2
answers
1k
views
Static final variable initialization (in Java) incorrect during Kotlin CI Tests
I manage an open source project and have a user reporting a situation which I think is impossible according to Java's order of initialization of static variables in classes. The value of a static ...
0
votes
1
answer
64
views
Why are the inputs to my guess_nonlinear() all 1s?
The N2 diagram for my full problem is below.
The N2 diagram for the coupled portion of the problem is below.
I have a DirectSolver handling the coupling between LLTForces and ImplicitLiftingLine, ...
1
vote
1
answer
649
views
Precedence of Function Calls/Priority of Function Calls
int p(int *ptrP){
*ptrP=20;
return *ptrP;
}
int q(int *ptrQ){
*ptrQ=30;
return *ptrQ;
}
int main(){
int answer=0,a=10;
answer=p(&a)+q(&a); // line Alpha,for ...
0
votes
0
answers
30
views
Tuple assignment order [duplicate]
Let's take the following fibonacci generator:
def fib():
previous = 0
current = 1
tmp = None
while True:
tmp = current + previous
previous = current
current = ...
22
votes
3
answers
3k
views
What does seq actually do in Haskell?
From Real World Haskell I read
It operates as follows: when a seq expression is evaluated, it forces its first argument to be evaluated, then returns its second argument. It doesn't actually do ...
1
vote
1
answer
61
views
Different order of interpretation depending on the context?
I have the following rules to convert a structure.
cmap(predicate(_,Verb,named(N)),[S1,S2]) :-
next_uid(NewVar),
S1 =.. [named,N,NewVar],
S2 =.. [Verb,NewVar].
cmap(predicate(_,Verb,Subj),S)...