News for hackers. Stuff that matters.
Re:Why functional programming? Why Haskell? by _pmf_ on Saturday August 10, 2013 @08:17AM (#6190828)
GCC's pure and const function attributes pretty much allow for these optimizations.
Re:Why functional programming? Why Haskell? by _delirium on Saturday August 10, 2013 @09:14AM (#6190985)
For scalar types I agree, but now that I think of it, I'm not sure it's even possible to write array code using them, unless I'm missing something. If you can't modify the array in-place or write to a provided "output" parameter, and you can't malloc a fresh array to return (because that's a side effect), how do you write a pure function of type int[] -> int[] at all?

The nice thing about Haskell is that it conceptually mallocs a fresh array to return, but then optimizes away the intermediate array in a lot of cases.

Re:Why functional programming? Why Haskell? by cpeterso on Saturday August 10, 2013 @03:21PM (#6192303)
I believe GCC's pure and const function attributes, like the restrict keyword, are only advisory and have no extra compile-time checks that your functions are actually pure or const.