technomancy / robert-hooke

Hooke your Clojure functions!
Other
358 stars 27 forks source link

Potential for StackOverflowError #17

Open devth opened 10 years ago

devth commented 10 years ago

If you add too many hooks to a fn, you will unsurprisingly encounter a java.lang.StackOverflowError.

These calls appear between each fn invocation:

    clojure.lang.AFn.applyToHelper (AFn.java:167)
    clojure.lang.AFn.applyTo (AFn.java:151)
    clojure.core$apply.invoke (core.clj:619)
    robert.hooke$compose_hooks$fn__1381.doInvoke (hooke.clj:40)
    clojure.lang.RestFn.invoke (RestFn.java:421)

I added 124 hooks to my fn :)

Obviously my own fault, but you may want to add a warning in docs.

Edit: or this could be an excuse to investigate a constant-space implementation with recur.