Talk:First-class functions: Difference between revisions

Line 44:
:Some notes to the list. The list rather refers to operations on functional types. Neither of is actually required to make functions first-class. What is required is that a function were a type and there existed objects of this type, with '''some''' operations defined on this type. Whether these operations include any concrete operation beyond "call me," is up to the language. Only "call me" is essential (that makes the object a function). Granted, almost certainly a reasonable implementation will provide operations from the list. --[[User:Dmitry-kazakov|Dmitry-kazakov]] 17:57, 24 February 2009 (UTC)
::: Chance there are that many languages at the end manipulate pointers to code; but this is hidden. In C, it is not so hidden, but I can feel it like a syntax oddness: a function ''is'' ''de facto'' a pointer to a function ---or the first-class implies also an uniform syntax to manipulate/use/refer to objects? If it is so, Python (and many more, and likely all!) could be out because e.g. <tt>sin</tt> means ''the function sin'', but to "use" it I need the syntax <tt>sin(x)</tt>... Compilers/interpreters of languages that have first-class functions, must implement it someway, e.g. having something like a hash-table that "links" between names and pointers to ''object'' (which could be directly code or more complex data structure, depending on the context the language need to make its thing works)... So again the question: first-class functions is not about what you can do with the language, but about the syntax and what is ''already'' implemented? --[[User:ShinTakezou|ShinTakezou]] 21:33, 24 February 2009 (UTC)
 
::::It is about the syntax (i.e. the language), not about what is going on under the cover. To be first-class is a language property. So it obviously cannot be changed by means of writing a program. You must modify the language in order to make first-class things that are initially non-first-class. Regarding C++, I think it is quite close to have first-class functions because of <lang cpp>operator ()</lang>That does not give you [[closure]] or composition of functions, but as I said before that is unimportant. A first-class static functional object is still first-class object. We could compare it with a language that would not have no integers, only integer constants. In that language integer would be first-class, because you could have a constant '''integer object'''. Lacking integer assignment is nasty, but irrelevant. A bigger problem with C++ is that not all kinds of its functions can be implemented this way. For example, methods cannot be, only free functions. IMO, this qualifies C++ functions as non-first-class, not that they are static, not nested etc. --[[User:Dmitry-kazakov|Dmitry-kazakov]] 08:42, 25 February 2009 (UTC)
 
::Thanks Dmitry. That is a valid point. I guess if a language has problems with the example but can reason, (making a better case than C), why it has first class functions, then they should make their case too. Maybe they could cover the four points by other means. --[[User:Paddy3118|Paddy3118]] 18:25, 24 February 2009 (UTC)