compile/take!

Syntax: (take! NAME), (take! (item OBJ KEY)), (take! (attr OBJ NAME))

Behaviour: Reads the target’s value, clears the target, and returns the value, through takeq, take-item, or take-attr by the target’s shape. The subscript and dot suffixes read to the item and attribute forms. A taken binding stays bound to its ref but empty.

Examples:

var y 5
(take! y)              ;; 5; y is now empty

var d #{"j": 5}
(take! d["j"])         ;; 5; d is now {}

set! box.v 3
(take! box.v)          ;; 3; the attribute is gone

See also: del!, which clears without returning.