"-function" special?

1,749 views
Skip to first unread message

ClusterCat

unread,
Feb 25, 2012, 9:17:45 AM2/25/12
to clo...@googlegroups.com
Hi there,

in some clojure examples I see function names with a leading dash like
-main()
-getFoo() (in backing bean)
-setBar() (in backing bean)

Are these functions with leading dash anything special? Or is this dash
required for some interop?
I didn't find any documentation about it.

Thanks in advance,
Marcel

Moritz Ulrich

unread,
Feb 25, 2012, 3:16:56 PM2/25/12
to clo...@googlegroups.com
It's the default prefix for methods in classes generated by gen-class:
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

--
Moritz Ulrich

Stuart Sierra

unread,
Feb 26, 2012, 10:35:49 AM2/26/12
to clo...@googlegroups.com
The leading dash is a convention in two places:

- gen-class methods implemented by Clojure functions (e.g. -main)

- low-level method implementations of built-in protocols in ClojureScript

The dash has no special significance as far as the compiler is concerned, it's just part of the name.

-Stuart Sierra
clojure.com
Reply all
Reply to author
Forward
0 new messages