WHY PARAMETER ORDER MATTERS

There is a simple reason why parameter order matters when the techniques of currying and partial application are used: it is only possible to partially apply from the start of the parameter list. When a function has three parameters — x, y, and z, in that order — it can be partially applied by passing x, or x and y, but not just y, or z, or y and z.

As a result, when writing functions for use in functional scenarios, where it is likely that partial application will be used on them, it is a good idea to consider parameter order from that point of view. This applies to “normal,” multi-parameter functions as well as those that are written in curried format from the start.

The important thing to decide about parameter order is which parameter in your function is most likely to be partially applied. In simple cases like those add and mult functions demonstrated earlier, it might not matter at all. But in the case of that ADO.NET helper function from the practical use case, it matters a lot — if the helper function ExecuteModification had the command as the first parameter, partial application couldn’t be readily used. It is much more likely that a caller to this function would want to fix the first parameter, the connection object, than the second one, the SQL command. As it is in most such cases, it is certainly possible that somebody would have a different point of view — a replication scenario where the same statements need to be executed through different ...

Get Functional Programming in C#: Classic Programming Techniques for Modern Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.