robert-hooke icon indicating copy to clipboard operation
robert-hooke copied to clipboard

Potential for StackOverflowError

Open devth opened this issue 10 years ago • 0 comments

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.

devth avatar Feb 05 '14 18:02 devth