Discussion:
[gambit-list] Marc, does Gambit evaluate left-to-right order always or only generally?
Marc Feeley
2017-11-13 13:45:25 UTC
Permalink
Execution order is arbitrary. The interpreter and compiler don’t use the same ordering. The interpreter tends to be mostly left-to-right, but don’t count on it.

Marc
Hi Marc!
Does Gambit evaluate left-to-right order always or only generally?
Thanks,
Adam
Marc Feeley
2017-11-14 02:03:50 UTC
Permalink
Left as an exercice to the reader…

Marc
Wow.
Can you give an actual code exampe where compiled (or interpreted) code not does left to right?
I think all I observed in practice in the past was left to right.
Adam
Execution order is arbitrary. The interpreter and compiler don’t use the same ordering. The interpreter tends to be mostly left-to-right, but don’t count on it.
Marc
Hi Marc!
Does Gambit evaluate left-to-right order always or only generally?
Thanks,
Adam
Adam
2017-11-18 08:32:15 UTC
Permalink
Evaluation is always separated between procedure calls though, so the
undefined order only regards specifically the order in which the operator
and arguments are evaluated, right?

(
E.g.:

For the code (A (B C D) (E F G)), let's call (B C D) X1 and (E F G) X2,
here: While the evaluation order within the block B C D, and within the
block E F G, and within the block A X1 X2, is undefined, the internal
evaluation of X1 and X2 is never mixed so that you'd get an evaluation
order B to F to D, right?

Any mix where A, X1, X2 are kept separate could happen thoug, e.g. A, C, B,
D, F, E, G or F, E, G, D, B, C, A.
)
Left as an exercice to the reader

Marc
Wow.
Can you give an actual code exampe where compiled (or interpreted) code
not does left to right?
I think all I observed in practice in the past was left to right.
Adam
Execution order is arbitrary. The interpreter and compiler don’t use
the same ordering. The interpreter tends to be mostly left-to-right, but
don’t count on it.
Marc
Hi Marc!
Does Gambit evaluate left-to-right order always or only generally?
Thanks,
Adam
Marc Feeley
2017-11-18 12:56:36 UTC
Permalink
In Scheme it is allowed that the oder of evaluation of A, B, C, …, G is permuted arbitrarily. The calls (B …) and (E …) can also happen in any order, but obviously after their respective arguments are evaluated. And the call (A …) can only happen after both calls (B …) and (E …).

It is hard for me to say if this ordering liberty is used by the compiler. So don’t rely on any particular ordering.

Marc
Evaluation is always separated between procedure calls though, so the undefined order only regards specifically the order in which the operator and arguments are evaluated, right?
(
For the code (A (B C D) (E F G)), let's call (B C D) X1 and (E F G) X2, here: While the evaluation order within the block B C D, and within the block E F G, and within the block A X1 X2, is undefined, the internal evaluation of X1 and X2 is never mixed so that you'd get an evaluation order B to F to D, right?
Any mix where A, X1, X2 are kept separate could happen thoug, e.g. A, C, B, D, F, E, G or F, E, G, D, B, C, A.
)
Left as an exercice to the reader…
Marc
Wow.
Can you give an actual code exampe where compiled (or interpreted) code not does left to right?
I think all I observed in practice in the past was left to right.
Adam
Execution order is arbitrary. The interpreter and compiler don’t use the same ordering. The interpreter tends to be mostly left-to-right, but don’t count on it.
Marc
Hi Marc!
Does Gambit evaluate left-to-right order always or only generally?
Thanks,
Adam
Loading...