Skip to main content
29 events
when toggle format what by license comment
Oct 7, 2022 at 6:00 history tweeted twitter.com/StackSoftEng/status/1578263854500515840
Oct 6, 2022 at 20:39 comment added T. Sar I don't understand why you're dismissing delegates as function pointers. Can you elaborate why they don't meet your criteria?
Oct 6, 2022 at 14:32 answer added Chris Schaller timeline score: -1
Oct 4, 2022 at 18:06 vote accept J. Mini
Oct 4, 2022 at 18:00 comment added Fattie @J.Mini c# and java are not OO. the question is confusing.
Oct 4, 2022 at 10:46 answer added gnasher729 timeline score: 0
Oct 4, 2022 at 10:24 answer added AnoE timeline score: 2
Oct 4, 2022 at 10:21 answer added S.D. timeline score: 4
Oct 4, 2022 at 6:26 comment added ojs Should we call Java and C# class-oriented languages instead of object-oriented? I think the question would describe these languages better if you just replace the word “object” with “class”.
Oct 3, 2022 at 17:51 answer added supercat timeline score: 0
Oct 3, 2022 at 13:07 comment added JimmyJames In Java, a 'Runnable' is something that can be used to define a new thread. It is not the right abstraction for what you are asking. Prior to version 1.8, the closest thing to a function reference was an 'anonymous inner class' which could be used as a delegate. In versions 1.8+ there's are a set of abstractions, function references, and lambdas. I presume you are referring to the pre-1.8 Java here but it would be good for you to clarify, I think.
Oct 3, 2022 at 9:33 comment added Tomáš Zato I am not aware of any mainstream language where functions are a primitive type. The only way to have that option is when the function has no capture context - such as function pointers in C/C++. But is that really a primitive type?
Oct 3, 2022 at 7:42 answer added Schwern timeline score: 30
Oct 3, 2022 at 3:33 history became hot network question
Oct 2, 2022 at 23:41 answer added Mike Robinson timeline score: -2
Oct 2, 2022 at 21:53 answer added amon timeline score: 11
Oct 2, 2022 at 20:54 answer added Telastyn timeline score: 26
Oct 2, 2022 at 20:38 answer added Martin Maat timeline score: 4
Oct 2, 2022 at 20:23 comment added Jörg W Mittag @Alexander: Indeed. A function is isomorphic to an object with a single method, a closure is isomorphic to an object with a single method and private state, an object is isomorphic to a closure taking a message name as an argument and returning a function. Interestingly, the OP mentions Scheme, which was explicitly designed to study object-orientation, and among all the languages listed by the OP is arguably the "most heavily object-oriented".
Oct 2, 2022 at 20:21 comment added Alexander I think it might be useful to look at this coming from the other side: Even in languages with first-class functions, there are essentially objects accompanying them. If they capture ("close over") any values, they need to store that in a heap-allocating object, alongside a pointer to the function that actually contains the instructions to execute. They're really quite the same.
Oct 2, 2022 at 20:20 review Close votes
Oct 8, 2022 at 3:05
Oct 2, 2022 at 20:16 comment added Jörg W Mittag I still don't understand. E.g. if I pass a function to Collections.sort, there is no Runnable in sight. And there is certainly no "companion object", at least not how I understand the term.
Oct 2, 2022 at 20:14 comment added J. Mini @JörgWMittag I'm talking about the cases where you want to pass a function from one place to another. That's where you need runnables and delegates.
Oct 2, 2022 at 19:57 comment added Jörg W Mittag In Clojure, any object which implements IFn is a function. For example, vectors, maps. keywords, and sets, are functions. I still don't get what the distinction is that you are making, or what a "companion object" is. Scala has a concept of "companion object", but you don't need one for a function. And neither Java nor C# have a concept of "companion object". And I would bet that the vast majority of functions in Java code are not Runnables.
Oct 2, 2022 at 19:50 history edited J. Mini CC BY-SA 4.0
added 2 characters in body
Oct 2, 2022 at 19:50 comment added J. Mini @JörgWMittag I may simply be confused about Scala. I'll change that bit.
Oct 2, 2022 at 19:48 comment added Jörg W Mittag … has a single method that is abstract is for all intents and purposes a function type.
Oct 2, 2022 at 19:48 comment added Jörg W Mittag I am somewhat confused by your question. First off, I would not characterize either Java or C# as "heavily object-oriented". Smalltalk or Self, yes, but Java and C#? No way. Secondly, you mention Scala, and in Scala, functions are very much not primitive types. Scala has no primitive types in the sense of Java (neither does C#, by the way). You can say that the only primitive type in Scala is objects. And functions are objects in Scala, in fact, in Scala any object which has a method called apply is essentially a function. Which is pretty much how functions in Java work: any type which …
Oct 2, 2022 at 19:33 history asked J. Mini CC BY-SA 4.0