Tonight, I've gotten the kids to sleep, gotten the dishes washed, and did a little amateur skimming of the Romani internet. (Who couldn't love a language that calls a black widow spider

*yalakrĂˇno*, and a pear tree

*ambrolin*?)

Now I am tired, and unable to do anything except ask "what if?"

What if you had a functional programming language where the lambda was implicit, so any expression with an unresolved term was a lambda expression, and the unresolved terms were the parameters?

Obviously, you would need a couple of things to make this work. First, you would need to do away with a lot of syntactic sugar, because your parser needs to be able to operate without necessarily knowing anything about the referents of the symbols it is operating on. Second, you would need to have some way to recognize which input values to a lambda expression match which parameters.

But both of those are just conventional matters, not real theoretical difficulties. Let's say, for the sake of this post, that we have a syntax like Lisp, and parameters are ordered as they appear in the source code.

Now for the second bit: What if you were able to reference a function from within itself using a special term, similar to the way you can use the variable

*this,*

*self*or

*me*in object-oriented languages?

For the sake of this post, let's call this special term

*thus*.

If you had a language with both of these features, you could write a lambda expression for the exponentiation function as follows:

**(if (eq x 1) 1 (multiply x (thus (subtract x 1))))**

We assume the functions

*if*,

*eq*,

*multiply*,

*thus*, 1 and

*subtract*are known, so the unresolved term is

*x*, which is the sole parameter to the expression.

*unresolve*that returns a term of an expression from the known space to the parameter space. So, if you wanted a function like

*factorial*that took the parameter

*x*and also some function to use instead of

*multiply*, you could say:

~~(unresolve factorial multiply)~~

**Then you could substitute a different function, like**

*divide*:

**((**

**unresolve**

**factorial multiply) divide)**

These are the sorts of vapid ideas a tired mind produces.

## No comments:

## Post a Comment