[Home] [By Thread] [By Date] [Recent Entries]
On 3/29/2014 2:18 PM, Michael Kay wrote:
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.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. 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
|

Cart



