technomancy / robert-hooke

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

fixed hooks-join-order problem, added a few comments to clarify thing… #21

Closed kindlychung closed 9 years ago

kindlychung commented 9 years ago

…s, all tests passed.

kindlychung commented 9 years ago

I also moved a few seemingly unused functions to the end of the file.

technomancy commented 9 years ago

Thanks, but this doesn't actually guarantee ordering. Array-maps will be converted into hash-maps when they grow past a certain size. Also, please don't include formatting changes alongside functionality changes.

kindlychung commented 9 years ago

I have pushed another commit. It's now uses ordered-map from amalloy's "ordered" library. https://github.com/amalloy/ordered

Sorry for the formatting changes, it's just intellij automatically reformatted the file.

technomancy commented 9 years ago

Upon considering this further, I don't think it's a good idea to guarantee ordering. Part of the point of Hooke is that each hook can be added independently. This means you can add a hook without knowing that another piece of code is also adding a hook to the same var elsewhere. So you need to write your hook without knowing what order it's going to be run in.

If you have two hooks in a case where you control both of them, simply compose them into a single hook and add that; that way you can control which comes first.

sogaiu commented 5 years ago

I noticed that the test 'test-no-arg' fails here -- is this possibly related because of the non-guarantee of execution order?