2015-02-14 20:03 GMT+01:00 Jony Hudson <[email protected]>:
> Ah, I see. I don't know how to do that. But, the function name should be
> in the stack trace associated with the exception. Is there a particular
> reason you also want to put it in the message?
>
Well if I enter in the REPL:
(round :dummy 12.4)
I only get:
Exception ERROR: round [:high|:low|:normal] <VALUE> user/round
(repl-startup.clj:30)
So it is very useful to have it in the message. ;-)
On Saturday, 14 February 2015 18:45:12 UTC, Cecil Westerhof wrote:
>
>>
>>
>> 2015-02-14 18:58 GMT+01:00 Jony Hudson <[email protected]>:
>>
>>> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.