Thank you. My example was contrived as I was reading through the Clojure
style guide (linked below). This kind of thing isn't specifically mentioned
so I had the urge to try it and it works. That got me thinking that this
would likely be bad style (hackish). I started Googling but did not find
anything yet. It is interesting though.

https://github.com/bbatsov/clojure-style-guide


On Mon, Nov 25, 2013 at 4:27 PM, Gary Trakhman <gary.trakh...@gmail.com>wrote:

> Yes, I'd consider this bad style, for one, you don't get the arglists
> metadata showing the names of variables during a repl session.  That
> metadata is on the var, and not the function itself.  I'm not familiar with
> Math/pow's function signature off the top of my head.
>
> I would consider it only in the specific case where you want a computation
> to happen at compile-time, perhaps by calling a function that returns a
> function (core.memoize, for instance).  The work to set up the cache is
> done during namespace initialization and never after.
>
>
> On Mon, Nov 25, 2013 at 4:18 PM, Frank Hale <frankh...@gmail.com> wrote:
>
>> Given the following code snippet would declaring a Var with an anonymous
>> function be considered bad style? Would there be any real use cases where
>> this would be regarded as a cleaner mechanism to declare a function rather
>> than declaring one with defn?
>>
>> user=> (def pow #(Math/pow %1 %2))
>> #'user/pow
>> user=> (pow 2 4)
>> 16.0
>>
>> --
>> --
>> 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
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to