stefan.kruger
2019-11-7 13:09:04

Why does for-each and set-for-each have a different parameter order?


soegaard2
2019-11-7 13:12:26

Well, for-each is from Scheme. The call is (for-each f a-list). This order is the same as map, which makes it easy to remember. The advantage of having the list last, is that the list argument usually leads to a larger expression (and it makes it easier to spot f, when it is first.


soegaard2
2019-11-7 13:13:13

It would be natural to use the same order in set-for-each, but I bet the reason is that all the other set-functions all have the set as the first argument.


rokitna
2019-11-7 22:07:47

Interesting, the short-arguments-come-first principle is the very reason I prefer for the list to come first. The function argument is virtually always a lambda for me.


notjack
2019-11-7 22:24:13

IMO, the scheme order isn’t natural at all. I’ve had actual bugs caused by the argument order of sequence-map: https://github.com/jackfirth/rebellion/issues/299


notjack
2019-11-7 22:25:29

(….but in a language with currying, this all goes out the window)