I would say the aspect that defines a functional programming language is the support of higher order functions. I.e. functions that can take functions as arguments and more importantly can return functions as return value.
Hey, C Is a Functional Language Too
11–20 of 78 posts
Re: Hey, C Is a Functional Language Too
#12Earlier quoted context omitted.
That's not a very good definition. It means that GHC-flavoured Haskell isn't functional: http://www.haskell.org/haskellwiki/Tail_recursion
I think you might have misinterpreted the contents of that page. As someone who has worked on GHC, I can assure you that it does perform tail call optimisation.
Re: Hey, C Is a Functional Language Too
#13http://en.wikipedia.org/wiki/Chicken_(Scheme_implementation)...
Re: Hey, C Is a Functional Language Too
#14http://conal.net/blog/posts/the-c-language-is-purely-functio...
Re: Hey, C Is a Functional Language Too
#15Re: Hey, C Is a Functional Language Too
#16I would say the aspect that defines a functional programming language is the support of higher order functions. I.e. functions that can take functions as arguments and more importantly can return functions as return value.
Doesn't function pointers enable passing functions around in C?
Re: Hey, C Is a Functional Language Too
#17I would say the aspect that defines a functional programming language is the support of higher order functions. I.e. functions that can take functions as arguments and more importantly can return functions as return value.
Re: Hey, C Is a Functional Language Too
#18I would say the aspect that defines a functional programming language is the support of higher order functions. I.e. functions that can take functions as arguments and more importantly can return functions as return value.
Doesn't function pointers enable passing functions around in C?
Re: Hey, C Is a Functional Language Too
#19No it's not. What makes a language functional is its ability to eliminate tail recursion.
GCC can eliminate tail recursion, so does that make C functional? I don't think the author is seriously of the belief that C is a functional language. This is just a fun little example of writing C in a functional style.
int factorial(int x) {
if (x > 1) return x * factorial(x-1);
else return 1;
}
will be optimized by GCC to int factorial(int x) {
int result = 1;
while (x > 1) result *= x--;
return result;
}
(http://ridiculousfish.com/blog/posts/will-it-optimize.html)