Fork me on GitHub
#beginners
<
2015-08-26
>
teamaverage00:08:27

Hi all just a question about function naming conventions - what does "^:export" mean within say '(defn ^:export go-cljs []' ?

teamaverage00:08:24

and I've also seen functions that are protocol implementations start with "-" as in "-list"

rauh00:08:25

@teamaverage: It means it'll survive advanced compilations. It's translated to a goog.exportSymbol IIRC

rauh00:08:55

Ie. you can use that symbol (with namespace) to call from javascript even after advanced compilation and name munging

teamaverage00:08:08

ah cool thanks

potetm02:08:23

@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.

potetm02:08:11

I usually use it by default, because wrappers for your protocol functions are pretty useful.

escherize06:08:49

What does this mean, exactly: #'some-symbol

escherize06:08:55

Kind of hard to google

paradoxquine06:08:06

i googled it by searching for “hash quote symbol clojure"

paradoxquine06:08:20

i’ve had good luck finding reader macros by typing out the words for the characters

escherize06:08:50

Ah cool, so it returns the namespaced name of the some-symbol

escherize06:08:27

kind of like a function pointer?

escherize06:08:13

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

escherize06:08:31

Is there a way to know what the most popular lein templates are?

tap06:08:38

@escherize: Just of your reference, #’symbol returns what’s called “Var”. One of the purpose of Var is to enable code reload

tap06:08:24

user=> (type #'a)
clojure.lang.Var

sveri07:08:27

@escherize: Popular does not always mean its useful or good 😉

jhchabran08:08:30

@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&amp;q=lein&amp;s=stars&amp;type=Repositories&amp;utf8=%E2%9C%93

rauh11:08:33

@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)

Alex Miller (Clojure team)12:08:14

Is a helpful companion to the reader page

samueldev14:08:48

I've got a couple of syntactic sugar questions

samueldev14:08:52

(at least I assume that's what these are)

samueldev14:08:25

how do I insert code gracefully into slack...

samueldev14:08:44

(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))

samueldev14:08:49

in this function

samueldev14:08:58

.getGroupPermission and .add

samueldev14:08:02

don't appear to be defined in this file anywhere

samueldev14:08:13

I'm assuming the "." prefixing the function name means something

samueldev14:08:15

same with ArrayOfGroupPermission., with a dot after

roberto14:08:41

in this example, it is taking array-of-group-permission which is an instance of ArrayOfGroupPermission and calling getGroupPermission() on it

roberto14:08:05

and then passing the output, and calling add(group-permission) on that.

roberto14:08:39

so, getGroupPermission and add are instance methods of ArrayOfGroupPermission

rauh14:08:46

@samueldev: Also: All the glory details here: http://clojure.org/java_interop

samueldev15:08:42

thanks folks!

samueldev15:08:48

so dot suffix = create new instance of class

samueldev15:08:03

dot suffix = call the instance function of said instantiated class

samueldev15:08:09

dot prefix** on that second one