binding not made in parallel

Description

The docstring for binding indicates "The new bindings are made in parallel (unlike let); all init-exprs are evaluated before the vars are bound to their new values."

You can observe this in Clojure:

but in ClojureScript bindings are made in serial as if with let:

Environment

None

Attachments

3

Activity

Show:

Mike Fikes July 19, 2018 at 10:47 PM

CLJS-2541-3.patch maintains the necessary logic but unrolls everything (avoiding allocation) and ends up being much closer to the original implementation.

Mike Fikes July 19, 2018 at 9:12 PM

CLJS-2541-2.patch is essentially the same as the first patch but uses JavaScript arrays instead of persistent vectors for temporary storage.

Mike Fikes February 22, 2018 at 3:15 PM

The defect also extends to with-redefs.

The attached patch ensures the correct evaluation order by placing values into temporary vectors.

Currently, if you macroexpand the example given in the ticket description, you get:

The patch revises the expansion so that you instead get:

The patch also fixes a place in cljs.pprint which has an invalid binding form. (It attempts to bind a var but provides no value.)

Additionally, the patch fixes places in cljs.js where the binding of r/alias-map was established using a function that itself relies on bindings that are established earlier in the binding form list.

Completed

Details

Assignee

Reporter

Approval

Accepted

Patch

Code and Test

Affects versions

Priority

Created February 21, 2018 at 12:17 PM
Updated August 3, 2018 at 8:06 PM
Resolved August 3, 2018 at 8:06 PM