Skip to content

fix signatures for set! #195

@shaunlebron

Description

@shaunlebron

All of the following are equivalent, but the first is not documented:

  • (set! obj -field val)
  • (set! (. obj -field) val)
  • (set! (.-field obj) val)

Also, the second one is documented wrong as:

(set! (.- instance-expr instanceFieldName-symbol) expr)
;        ^ space should be removed

example using doto:

(def obj (doto (create-obj)
           (set! -field1 1)
           (set! -field2 2)))

the arity is only documented here in a parser comment:

(defmethod parse 'set!
  [_ env [_ target val alt :as form] _ _]
  (let [[target val] (if (= 4 (count form))
                       ;; (set! o -prop val)
                       [`(. ~target ~val) alt]

source from slack:

https://clojurians.slack.com/archives/C03S1KBA2/p1704890400974659
CleanShot 2024-10-10 at 09 43 20@2x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions