Skip to content

alter-var-root does not appear to change the variable's value #1166

Closed
@ikappaki

Description

@ikappaki

Hi,

I can't seem to get alter-var-root to alter any variable's root binding.

To reproduce, create a variable and alter its value. Even though the update happens, the variables root value remains the same as before the update

> basilisp repl
basilisp.user=> (def abc 7)
#'basilisp.user/abc

basilisp.user=> (alter-var-root #'abc (fn [x] (println :current x) (inc x)))
:current 7
nil

basilisp.user=> abc
7

The same works in clojure as expected

> clj
Clojure 1.12.0
user=> (def abc 7)
#'user/abc
user=> (alter-var-root #'abc (fn [x] (println :current x) (inc x)))
:current 7
8
user=>  abc
8

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions