Thanks so much for the insight, Rich.

Shantanu

On Aug 31, 6:24 pm, Rich Hickey <[email protected]> wrote:
> To expound:
>
> (+ "we" "er") is a user error.
>
> We rely on the runtime type system of the host to efficiently detect
> type errors. Unfortunately, the JS runtime does not consider that an
> error, thus it is not generating an exception.
>
> That is much different from there being semantics for (+ "we" "er") -
> there aren't. Nor is it guaranteed to continue to produce "weer".
>
> Nowhere does Clojure promise that all user errors will become
> exceptions, and it is a constant balancing act to add more checks
> without compromising the performance of correct programs.
>
> If and when we have a debug mode of runtime these kind of checks would
> be possible there.
>
> Rich
>
> On Aug 31, 8:24 am, David Nolen <[email protected]> wrote:
>
>
>
>
>
>
>
> > No one has offered a way to prevent that without slowing things down.
>
> > On Friday, August 31, 2012, Shantanu Kumar wrote:
> > > Hello,
>
> > > On the Clojure REPL I notice this:
>
> > > user=> (+ 1 2)
> > > 3
> > > user=> (+ 1 "er")
> > > ClassCastException java.lang.String cannot be cast to
> > > java.lang.Number  clojure.lang.Numbers.add (Numbers.java:126)
>
> > > user=> (+ "we" "er")
> > > ClassCastException java.lang.String cannot be cast to
> > > java.lang.Number  clojure.lang.Numbers.add (Numbers.java:126)
>
> > > user=> (1 "we" 1)
> > > ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
> > > user/eval952 (NO_SOURCE_FILE:1)
>
> > > However, on the ClojureScript REPL I notice the following:
>
> > > ClojureScript:cljs.user> (+ 1 2)
> > > 3
> > > ClojureScript:cljs.user> (+ 1 "er")
> > > "1er"
> > > ClojureScript:cljs.user> (+ "we" "er")
> > > "weer"
> > > ClojureScript:cljs.user> (- "we" 1)
> > > NaN
>
> > > This difference in behavior can be explained by platform-specific
> > > semantics, but I want to know whether this is by design.
>
> > > Shantanu
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Clojure" group.
> > > To post to this group, send email to 
> > > [email protected]<javascript:;>
> > > 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] <javascript:;>
> > > 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 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

Reply via email to