Reputation: 11
Here is sample code
(def showscp
( let [ cf (seesaw.core/frame :title "cframe")]
(do
(seesaw.core/config! cf :content (seesaw.core/button :id :me :text "btn" ))
(.setSize cf 300 300)
(seesaw.core/show! cf)
cf
)
)
)
For get button, I use this
(defn find-me
([frame]
(let [ btn (seesaw.core/select frame [:#me] ) ] (do btn)
)
)
)
It cause error, like
Syntax error reading source at (REPL:2:1). EOF while reading, starting at line 2
(I guess :#me is problem in macro.)
why error cause, and how can I avoid error.
Is there more smart way than (keyword "#me")
Upvotes: 0
Views: 55
Reputation: 91982
#
is only special at the beginning of a token, to control how that token is parsed. It's perfectly valid as part of a variable name, or a keyword. Your code breaks if I paste it into a repl, but works if I retype it by hand. This strongly suggests to me that you've accidentally included some non-printing character, or other weird variant character, into your function.
Upvotes: 1
Reputation: 29958
The pound character (aka octothorpe) is a special reader control character in Clojure, so you can't use it in a literal keyword, variable name, etc.
Your suggestion of (keyword "#me")
will work, although it would probably be better to modify your code to just use the string "#me"
, or to eliminate the need for the pound-char altogether.
Upvotes: 0
Reputation: 16035
You can't use #, because it is a dispatch character.
# is a special character that tells the Clojure reader (the component that takes Clojure source and "reads" it as Clojure data) how to interpret the next character
Upvotes: 0