Follow

I don't know if you had or have this problem, but I used to be paralysed about choosing the order of variables for my functions.

But then I came up with a heuristic that helps me to spend no time on this. Here it is:

"The arguments that are less likely to change should go to the left, so that you get nice higher order functions via currying".

For example, a function that takes encoding table and needle (search item) will take "table, needle" because the same table can have differnt needles.

A function that takes a public key and a signature to check its validity will take "pk, sig" because we can try a lot of different signatures for a given key.

When it's not obvious what's more parametric, what's less parametric, I just yeet args in random order. But it's very *very* rarely the case.

Sign in to participate in the conversation
Doma Social

Mastodon server of https://doma.dev.