This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-26
Channels
- # admin-announcements (33)
- # beginners (41)
- # boot (97)
- # clojure (220)
- # clojure-berlin (3)
- # clojure-russia (31)
- # clojure-sg (3)
- # clojurebridge (2)
- # clojurescript (137)
- # clojutre (13)
- # core-matrix (10)
- # core-typed (1)
- # cursive (18)
- # datascript (1)
- # datomic (93)
- # devops (6)
- # editors (18)
- # emacs (1)
- # funcool (43)
- # hoplon (4)
- # immutant (6)
- # instaparse (3)
- # jobs (25)
- # ldnclj (14)
- # ldnproclodo (4)
- # off-topic (20)
- # om (21)
- # rdf (79)
- # re-frame (14)
- # reagent (12)
- # ring-swagger (18)
- # yada (52)
Hi all just a question about function naming conventions - what does "^:export" mean within say '(defn ^:export go-cljs []' ?
and I've also seen functions that are protocol implementations start with "-" as in "-list"
@teamaverage: It means it'll survive advanced compilations. It's translated to a goog.exportSymbol
IIRC
Ie. you can use that symbol (with namespace) to call from javascript even after advanced compilation and name munging
ah cool thanks
@teamaverage the -
is a convention to denote that a function is from a protocol, and that there's a wrapper for that function in the namespace. I.e. it's kinda private"ish". Unless you're implementing the protocol.
I usually use it by default, because wrappers for your protocol functions are pretty useful.
@escherize: http://stackoverflow.com/questions/12862607/what-does-symbol-notation-mean-in-clojure may help
i googled it by searching for “hash quote symbol clojure"
i’ve had good luck finding reader macros by typing out the words for the characters
user> (defn call-a [] (#'a 1))
#'user/call-a
user> (def a inc)
#'user/a
user> (call-a)
2
user> (def a dec)
#'user/a
user> (call-a)
0
@escherize: Just of your reference, #’symbol
returns what’s called “Var”. One of the purpose of Var is to enable code reload
@escherize: Popular does not always mean its useful or good 😉
@escherize: I don’t know if you can get some stats with leiningen downloads like you’d do with rubygems but github stars is a way to get such a list https://github.com/search?o=desc&q=lein&s=stars&type=Repositories&utf8=%E2%9C%93
@escherize: Also, more general: Anything that starts with a #
is a reader macro expanded by the reader. They all described here: http://clojure.org/reader (this should solve future googling problems)
https://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
Is a helpful companion to the reader page
(s/defn create-array-of-group-permission :- ArrayOfGroupPermission
[group-permission :- GroupPermission]
(let [array-of-group-permission (ArrayOfGroupPermission.)]
(-> array-of-group-permission
(.getGroupPermission)
(.add group-permission))
array-of-group-permission))
in this example, it is taking array-of-group-permission
which is an instance of ArrayOfGroupPermission
and calling getGroupPermission()
on it
@samueldev: Also: All the glory details here: http://clojure.org/java_interop