No it's not. What makes a language functional is its ability to eliminate tail recursion.
Hey, C Is a Functional Language Too
31–40 of 78 posts
Re: Hey, C Is a Functional Language Too
#32In embedded systems (non-MMU ones) you generally want to avoid repeated dynamic runtime allocation to prevent memory fragmentation.
It's a cute example, but I can't see any scenario where its better or safer than heap use.
Re: Hey, C Is a Functional Language Too
#33...and pigs can fly, if you throw them fast enough. This is just an encoding of a Turing-complete language into another, I don't see what's been demonstrated here.
I'm not sure this is even Turing complete considering the limitation he mentions: >The main limitation is that you need to know the size of the return value.
Re: Hey, C Is a Functional Language Too
#34At some point the stack is going to grow which will cause allocation at the OS level. And if we're discussing small embedded systems with fixed stacks, this code is entirely unsafe (non deterministic stack usage may cause stack overruns). In embedded systems (non-MMU ones) you generally want to avoid repeated dynamic runtime allocation to prevent memory fragmentation. It's a cute example, but I can't see any scenario…
The author does explicitly point this out: "While I find this style strangely addictive, I don’t think I would advocate its general use."
Re: Hey, C Is a Functional Language Too
#35Earlier quoted context omitted.
I'm not that old but I remember that, back in the days, functional meant just that you are able to use plain functions (without objects) and pass them around. By that definition, C is functional language, as scheme or lisp or javascript and many others. I don't know why, but some years ago, "functional programmers" started to change and twist the definition of functional language step by step, until all those languag…
I don't see much use in a definition of "functional language" that includes nearly every computer language. We already have a term for that.
Re: Hey, C Is a Functional Language Too
#36...and pigs can fly, if you throw them fast enough. This is just an encoding of a Turing-complete language into another, I don't see what's been demonstrated here.
This article is clearly someone having fun with their language. It isn't a serious claim about C being functional, something which the author states explicitly if you read to the end.
Re: Hey, C Is a Functional Language Too
#37Earlier quoted context omitted.
Doesn't function pointers enable passing functions around in C?
Yes, but functions aren't truly first-class values; you cannot create new ones on-the-fly (proprietary extensions notwithstanding).
Re: Hey, C Is a Functional Language Too
#38"So my title is misleading. I don’t think C is a functional language. But it’s an awful lot of fun (and sometimes very useful) to use C’s functional subset."
Re: Hey, C Is a Functional Language Too
#39No it's not. What makes a language functional is its ability to eliminate tail recursion.
Tail-call elimination is a feature of the language environment, not of the language itself.
Re: Hey, C Is a Functional Language Too
#40Quick question: why does he do this? int main(int argc, char * argv[]) { (void)argc; (void)argv; I've programmed C while in school, but I don't remember ever seeing this and I'm not sure how to google it.