Skip to content

Commit

Permalink
Update OR=
Browse files Browse the repository at this point in the history
  • Loading branch information
shawwn committed Feb 6, 2019
1 parent 2f42517 commit ac8567d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions arc.arc
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,17 @@ See [[atomic]]."
(= x 2 y 4)
_)

(mac or= args
`(do ,@(map [cons 'or-assign _] (pair args))))

(mac or-assign (slot value)
`(atomic
,(if (ssyntax slot)
`(or-assign ,(ssexpand slot) ,value)
(alist slot)
`(or ,slot (= ,slot ,value))
`(or (if (bound ',slot) ,slot) (= ,slot ,value)))))

(def lastcons (xs)
"Returns the absolute last link of list 'xs'. Save this value to efficiently
append to 'xs'."
Expand Down Expand Up @@ -2750,11 +2761,6 @@ of 'x' by calling 'self'."
(3 4)
(4)))

(mac or= (place expr)
(let (binds val setter) (setforms place)
`(atwiths ,binds
(or ,val (,setter ,expr)))))

(defextend iso (x y) (isa x 'table)
(and (isa x 'table)
(isa y 'table)
Expand Down

0 comments on commit ac8567d

Please sign in to comment.