Thanks for the comments, you are correct that type 
hinting<http://clojure.org/java_interop#Java Interop-Type Hints>is only to 
support performance optimization, no exceptions are thrown. The 
source for the set function suggests that it would not be free to call on 
sets, it converts its argument to a sequence and then rebuilds a set from 
that.

I tried adding a manual check based on 'instance?', and ran it through the 
old 'time clojure blah.clj' profiler (running 2*10^8 calls, 6 runs each), 
the performance penalty was lost in the noise (over ~1 minute of runtime 
per run).

Would this approach (probably with some more rigorous performance 
profiling) be something likely to be included in the language, is it 
idiomatic? 

On Saturday, September 28, 2013 4:01:10 PM UTC-4, John Hume wrote:
>
> On Sep 28, 2013 1:47 PM, "splondike" <splo...@gmail.com <javascript:>> 
> wrote:
> >
> > Can anyone else think of a reason why we should not add type hints to 
> the functions, or why coercing the arguments to sets is better (or 
> something else I haven't thought of)?
>
> IIRC, type hints are only used by the compiler to generate non-reflective 
> interop code. If you don't do interop, they have no effect. (So you won't 
> get an exception if you pass an incompatible type, unless there's a Java 
> method call in there, and I doubt clojure.set does (m)any.) 
>
> Iff clojure.set could call clojure.core/set on the appropriate args with 
> zero performance penalty when the arg were already a set, then I think I'd 
> want it to do so. 
>
> I'd guess the thinking behind the current code is "if they want to do set 
> operations on their data, let them decide when and how to get that data to 
> be a set." 
>

-- 
-- 
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