On Nov 29, 2008, at 8:03 AM, Ralf Bensmann wrote:
> But #(...) and (fn [] ...) should be the same? No, as stated here: http://clojure.org/reader The anonymous fn reader macro expands as follows: #(...) => (fn [args] (...)) If you think about it a bit: #(+ 2 %) => (fn [x] (+ 2 x)) Note the parens remain around the call. If #(42) were to become (fn [] 42), then #(+ 2 %) would become (fn [x] + 2 x), no parens, no call to +. Rich > > > On Sat, Nov 29, 2008 at 1:48 PM, Parth Malwankar <[EMAIL PROTECTED] > > wrote: > > On Nov 29, 5:29 pm, "Ralf Bensmann" <[EMAIL PROTECTED]> > wrote: > > Hi, > > > > is this the intended behavior? > > > > user=> #(nil) > > java.lang.NullPointerException (NO_SOURCE_FILE:12) > > user=> (def b #(nil)) > > java.lang.NullPointerException (NO_SOURCE_FILE:13) > > > > This is expected. > #(nil) is the same as (fn [] (nil)) and hence the failure. > (fn [] nil) is what you want. > > > This works: > > user=> #('nil) > > #<user$eval__43$fn__45 [EMAIL PROTECTED]> > > > > I am not very clear on whats happening here to comment. > > Parth > > > Thanks, > > -Ralf > > > > --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---