Jul. 21st, 2012

izard: (Default)
Finding a bug in my code in 90% of the cases has two phases:
1. This part of the code I wrote is correct, this must be compiler/library bug!
2. I think "ohh, how stupid was I writing that in the first place. This is so trivial and is of course a my fault!"

=> (map buggy-fn array)
< classcastexception java.lang.Long cannot be cast to clojure.lang.IFn >
=> (count array)
2
=> (buggy-fn (first array))
()
=> (buggy-fn (second array))
()
; Let's try contrib.trace! Never done that...
=> (defn reproduce [array] (map buggy-fn array))
=> (dotrace [reproduce] (reproduce))
# < illegalstateexception dynamically="dynamically" bind="bind" non-dynamic="non-dynamic" var:="var:" >
; Ooops - does not work, will have to resort to debug/dbg output traces as usual.


From the session above, looks like something really wrong is happening with clojure, it can't be that calling a pure function from map is different from calling it with explicit arguments. However I am 90% sure that after I debug the buggy-fn, I will find my coding error.

Upd: Found it, the function buggy-fn is not pure, so it was a side effect.

Profile

izard: (Default)
izard

June 2025

S M T W T F S
1234567
891011121314
15161718192021
22 23242526 2728
2930     

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 3rd, 2025 04:00 am
Powered by Dreamwidth Studios