On Tue, 7 Dec 2010 02:58:11 -0500
Ken Wesson <kwess...@gmail.com> wrote:

> On Tue, Dec 7, 2010 at 2:15 AM, javajosh <javaj...@gmail.com> wrote:
> > Mike and I have had a nice off-line conversation where we enumerated
> > the possible things that can come after open-parens. I listed 7, he
> > added 3:

That wasn't meant to be offline, but it's probably not worth
resending. However...

> >> 1. A value (if the paren has a tick '(  )
> >> 2. A function.
> >> 3. A map - which is a psuedo function that takes a key as an arg.
> >> 4. A keyword - which is a psuedo function that takes a map as an arg.
> >> 5. A macro. This is the normal case, I think. Looking through the mailing
> >> list, it appears that most clojure programming questions revolve around
> >> which one of the hundreds of macros to invoke and in which order!
> >> 6. The Java form: (MyClass. )
> >> 7. The java method form (.doSomething)
> > 8. A function returning a function to invoke - ((find-my-function) )
> > 9. A loop - (recur )
> > 10. The anonymous function macro: #( )
> >
> > So, at least I know why I feel uneasy about open paren! It's super
> > overloaded.
> 
> Not really. (...) is a non-atomic s-expression. If it's evaluated
> unquoted, the first nested s-expression is evaluated and if it's not
> callable an exception is thrown. Macros, special forms (which are sort
> of like system-internal macros and are used to build all the other
> macros, and functions), Java constructors, Java methods, and functions
> are callable (and maps and keywords -- also vectors -- act as
> functions for this purpose).
> 
> The only real overloading always involves macros:
> 
> #() evaluates to a function and doesn't run its insides right away.
> Then again so does (defn foo [x] (inc x)) -- the (inc x) is run when
> foo is called, calling inc, but not when the (defn ...) is called.
> Macros can delay evaluation of their contents, and #() is a reader
> macro.
> 
> '(x y z) is another reader macro and expands to (quote (x y z)).

This was pretty much what I tried to explain as well, even including
the comment that I almost never used '( ) in clojure because vectors
worked as well.

> > Mike also points out that things that aren't functions (not used in
> > that context) can't be aliased with def or use.
> 
> Really?
> 
> user=> (def a 3)
> #'user/a
> user=> (def b a)
> #'user/b
> user=> b
> 3

This one I flubbed, because my vocabulary failed me. There are three
classes of values that can work when they show up in the first
position in an executable expression:

1) Functions, which can also be passed to higher order functions.
2) Macros, which can't, but can be aliased by def or use.
3) Java interop things (#6 6 & 7 on his list), which can't be aliased
   by def or use.

   <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to