1

Possible Duplicate:
What are advantages and disadvantages of “point free” style in functional programming?

When I was in university I had to learn haskell. In one of my classes we learned how to use point free functions. Besides the academic point of view is there any advantage of programming in a point free style?

In terms of efficiency is there any difference? Isn't point free more hard to understand in applications with a lot lines of code?

Community
  • 1
  • 1
dreamcrash
  • 47,137
  • 25
  • 94
  • 117
  • 1
    "Isn't point free more hard to understand in applications with a lot lines of code" - you don't apply point-free style blindly to your entire program, so the number of lines of code is irrelevant. The point is that once you're used to point-free style, *some* things can be much clearer in that style. So you use it when it helps, and you don't use it when it doesn't help, same as any other technique. The number of programming techniques that **always** help no matter the circumstances is approximately zero. – Ben Nov 14 '12 at 01:53

2 Answers2

12

Once you're used to it, it's clearer and cleaner, as long as you don't take it too far.

Perhaps ((not.).) isn't as clear as \f x y = not (f x y) to you, but

munge = this . that . other

should be clearer than

munge x = this (that (other x)))

Your lecturers taught you pointfree to make you a better programmer, not because it's best to obfuscate your code, so you should use it when it helps.

The motivation isn't efficiency, it's clarity of thought, purpose and expression.

AndrewC
  • 32,300
  • 7
  • 79
  • 115
7

It can be easier, or harder, to read. Thus it can have an impact on code maintainability, depending how you use it. It won't have an effect on performance (except in very unusual circumstances).

It is just another idiom.

Don Stewart
  • 137,316
  • 36
  • 365
  • 468