ctford / leipzig

A music composition library for Clojure and Clojurescript.
Other
454 stars 26 forks source link

`leipzig.melody/then` argument order #15

Closed wontheone1 closed 5 years ago

wontheone1 commented 6 years ago

as in below example

(->>
  (phrase [3/3 3/3 2/3 1/3 3/3] ; Can you recognise the tune yet?
          [ 72  72  72  74  76])
  (then
    (phrase [2/3 1/3 2/3 1/3 3/3]
            [ 76  74  76  77  79])))

it becomes below with out the ->> macro

(then 
  (phrase [2/3 1/3 2/3 1/3 3/3]
            [ 76  74  76  77  79])
  (phrase [3/3 3/3 2/3 1/3 3/3] ; Can you recognise the tune yet?
          [ 72  72  72  74  76]))

I find it pretty weird. why the phrase played later comes first?

if we reverse the order of argument then can take phrase in order without using ->> or if using threading macro is desired, then can use -> macro.

I wonder why it is made like this currently and if you want to change it? I could try to pull off pull request if you want to change it.

Thanks.

ctford commented 5 years ago

Hi,

Sorry for missing your question many moons ago when you posted it.

The reason for the order is, as you deduced, to use the ->> macro. You're right that if the order switched we could use the -> macro instead, but that would break Clojure convention and would get weird when used with where etc.