Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix signatures for set! #195

Open
shaunlebron opened this issue Oct 10, 2024 · 0 comments
Open

fix signatures for set! #195

shaunlebron opened this issue Oct 10, 2024 · 0 comments

Comments

@shaunlebron
Copy link
Member

shaunlebron commented Oct 10, 2024

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

@shaunlebron shaunlebron changed the title add extra arity for set! fix signatures for set! Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant