Abstraction Algorithm : From Named Parameters to Point Free Form

I haven’t encountered many people who really enjoy writing code in point-free form (e.g. no named parameters). This is one of the big criticisms of stack-based functional languages like Joy and Cat. However writing a variant of a stack-based functional langauge with named parameters is a relatively straightforward thing to do (see Theory of Concatenative Combinators by Brent Kerby for a naive algorithm). This approach involves rewriting the algorithm using combinators.

The approach I am considering is to package all arguments to a function in an associative list. This is a more high-level approach, and has several advantages. For example it makes it easier to map from dynamic languages that implement named parameters and argument reflection to Cat. Another advantage is that it is slightly easier to implement. The downside is that it has a potentially big performance hit, if implemented naively.

At this point I think it is smartest to go with a simple implementation.

One Response to “Abstraction Algorithm : From Named Parameters to Point Free Form”

  1. Max Lybbert Says:

    As you know from recent email exchanges, I’ve just finished reading “Design and Evolution of C++.” There is a lot of interesting material in there, even for people who don’t like C++.

    Interestingly, the C++ committee once considered adding named parameter passing to the language, and decided a halfway intelligent implementation could simply transform the argument list into a “pass by position” system during parsing. That is, the actual function call system would stay the same, but the parser would simply be smarter and translate from the pass by name into pass by position.

    However, because C++ allows you to name parameters differently in the header and the implementation (precisely because of the way parameters are usually passed by position), the committee couldn’t decide *which* names to use (the ones in the header, or the ones in the implementation, or both, …).

    Anyhow, turns out this is one of those nice features you need to add early if you hope to avoid meeting the devil in the details.

Leave a Reply

You must be logged in to post a comment.