문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top