Content deleted Content added
No edit summary |
Hans Adler (talk | contribs) |
||
Line 137:
:::As for the C case, if you're willing to consider function pointers as functions, then the fact that the only way you can create a function ''constant'' within the language (that is, not unsafely converting an untyped pointer to a function pointer) is by binding it to an identifier is again a trivial syntactic detail. [[Anonymous function]] should be merged into [[First-class function]]. --[[User:Macrakis|macrakis]] ([[User talk:Macrakis|talk]]) 02:16, 21 August 2009 (UTC)
I am not exactly an expert, but I think having first class functions is neither stronger nor weaker than having anonymous functions:
* This is probably a stupid and very atypical example, but if you consider Java's reflection subsystem a core part of the language (this is not usually done), then Java arguably has first-class functions, modulo the kludgey syntax. But I don't think it has anonymous functions, since every function is actually a method in a class and must have a name as such. (There may however be a way to have a free name chosen dynamically.) A more straightforward example would be a programming language with a lambda operator that takes an explicit, non-optional parameter that serves as the name of the function. Of course you could work around this with a factory for unique names. This shows that the line is rather blurry, while the previous example shows that there may be real issues.
* Apparently recent versions of Visual Basic support anonymous functions. If this had been added to an earlier version I would be quite sure that these wouldn't be first class. I am not familiar with the .NET version of VB, though, so it's quite possible that they are first class. It's easy to create an artificial example of such a language. Just take a language with first class anonymous functions and add the restriction that functions may be assigned to parameter variables of functions (when calling the function), but not to ordinary variables.
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)
|