Talk:First-class function: Difference between revisions

Content deleted Content added
Line 144:
 
Since the two concepts are closely related it may in fact be best to discuss them in a single article. But it would take a serious effort to get the details right, and we would need really good sources. It's probably easier to keep the articles separate but keep them synchronised. (Basically they should use the same languages as examples, unless a language has one of the properties but not the other, which should then be stated clearly.) [[User:Hans Adler|Hans]] [[User talk:Hans Adler|Adler]] 09:06, 21 August 2009 (UTC)
: Java is not the best example, but in C++ you can use [[function objects]], which overload the function call operator, <code>()</code>, to simulate first-class functions; you can even implement a [[fixed point combinator]] that way in C++ (there's a link on that page). In Java you only get [[anonymous inner class]]es, which give you closures, but you have to syntactically invoke a method thereof. Still you can implement a fixed point combinator in Java, with [http://arcfn.com/2009/03/y-combinator-in-arc-and-java.html really awful syntax]. But you don't need reflection, and if you have reflection but no inner classes to work as closures, you still can implement a fixed point combinator (try). Basically a fixed point combinator is an essential test of first-classness because it needs to return a function that's not "written" anywhere; well, it is defined implicitly. Since you mentioned Java, dynamic [[class loading]] is a different concept however, orthogonal to the idea of first-class functions; it's more like an eval as mentioned in this article.
 
Having said all that, we're not lacking concrete examples here, but rather some non [[WP:OR]] definitions of these concepts.
I'll try to find some authoritative references (as in not some text on language X, but more principles/theory kinda book). [[User:Pohta ce-am pohtit|Pcap]] [[User_talk:Pohta ce-am pohtit|<small>ping</small>]] 10:42, 21 August 2009 (UTC)