2015-02-14 18:58 GMT+01:00 Jony Hudson <jonyepsi...@gmail.com>:

> There might be a neater way, but
>
> (name (:name (meta (var reduce))))
>
> => "reduce"
>

​That is not what I meant. I have the following function:
    (defn round
      ([x] (round :normal x))
      ([mode x]
        (let [fn (case mode
                   :high    (static-fn Math/ceil)
                   :low     (static-fn Math/floor)
                   :normal  (static-fn Math/round)
                   (throw (Exception.
                           "ERROR: round [:high|:low|:normal] <VALUE>")))]
          (long (fn x)))))

I would like to use the function name in the throw. So that when I change
the function name to round-long, I do not need to change the throw
statement, because the name of the function is automatically filled.

​


> On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote:
>
>> In Bash I use the following construct:
>>     printf "${FUNCNAME} needs an expression\n"
>>
>> In this way I do not have to change the print statement when the name of
>> the function changes. Is something like this also possible in clojure?
>>
>> --
>> Cecil Westerhof
>>
>  --
> 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/d/optout.
>



-- 
Cecil Westerhof

-- 
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/d/optout.

Reply via email to