Re: [xsl] Things that make you go Hmmmm!

Subject: Re: [xsl] Things that make you go Hmmmm!
From: Michael Sokolov <msokolov@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 29 Mar 2014 14:34:10 -0400
On 3/29/2014 2:18 PM, Michael Kay wrote:
Functional programming is based on functions as first class values. A
function can appear anywhere that any other atomic value can appear.
Whether it is on the end of a print statement, as the object of a
return statement, as a member of a sequence, in a comparison. You
don't stop and say well I don't see what sense it would make for min
or gt to compare two functions or a function so I won't allow it.

Strong typing is not incompatible with orthogonal language design. Orthogonality doesn't mean that all operators have to apply to all data values. (Regarding your example, I'm not sure I have come across a language that allows one to ask whether one function is greater than another, and if this operation were offered, I have no idea what it would do.)
C and C++ certainly allow you to do that, at least to compare pointers to functions. It has some limited meaning. At the very least it allows sorting functions consistently, if somewhat arbitrarily.

The orthogonality rule that "a function can appear anywhere that an atomic value can appear" is a rule about syntax, not about typing. It doesn't mean that you can divide one function by another.
Division of functions seems less useful. Certainly a possible, and consistent, rule for applying arithmetic operators such as this to functions is to compose them:

(f / g)(x) := f(x) / g(x)

But I'm not sure that's really orthogonal in the sense that other operators may apply to the functions themselves though rather than their results. It's certainly not likely something anybody would expect or welcome.

I do agree that just because it's possible to express something in a language doesn't imply that it must be meaningful. Languages by their nature admit nonsensical statements. It's futile to attempt to eradicate them completely. Issuing warnings and errors in well-known useless cases is one helpful approach - something I think you've done a bunch of in XSLT, which admits a certain number of valid but vapid statements.

-Mike Sokolov

Current Thread