Mercerenies / gdlisp

Lisp on the Godot platform
GNU General Public License v3.0
140 stars 1 forks source link

Out-of-order Evaluation on let Blocks #62

Open Mercerenies opened 2 years ago

Mercerenies commented 2 years ago

I suspect this isn't unique to let but applies to several forms of control flow.

[(foo) (let ((x (bar))) x) (baz)]

Assuming the functions foo, bar, and baz exist, this compiles to roughly

var x = bar()
return [foo(), x, baz()]

Notably, although it looks intuitively like foo, then bar, then baz will be run in the Lisp code, the actual order of evaluation is bar, then foo, then baz.

Do we care? Or do we consider the order of evaluation of values in a single expression undefined?

Mercerenies commented 1 year ago

Deferring to 2.x and heavily leaning toward just declaring this behavior undefined and making it more clear where the sequence points are. Will leave the issue open for now to think about it, but not a 1.x priority.