The overhead is not as great as you think. In the newer crop of JS engines
it's surprisingly small and I imagine that it will get smaller.

I don't see this getting changed anytime soon as it allows for polymorphism
as well as handling the default case if provided. If you see a better way
to get the same behavior, we're all ears.

David

On Thu, Mar 8, 2012 at 1:02 PM, Philip K <p...@eleven-percent.at> wrote:

> Right now, when I define a deftype function f the generated js code looks
> something like:
>
> f = function(self, arg) {
>   if (self.func) {
>     return self.func(self, arg);
>   }
>   else {
>     // check if self implements protocol
>     return f._(self, arg);
>   }
> }
>
> This seems like an awful lot of indirection just for a function call. Is
> there a way to disable the protocol checks (maybe with advanced
> optimization?). Or do I have to define all functions outside the deftype in
> order to avoid the additional overhead of type checking?
>
> I mean, yes, the error messages are helpful, but when I call a deftype
> function with the wrong argument I'm gonna get a runtime error in 99% of
> the cases anyway when I access some invalid field.
>
> --
> 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 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

Reply via email to