Skip to main content

Timeline for class in OOP language and type

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
Jan 27, 2015 at 10:25 comment added Den @Doval 1) you can pass methods around AFAIK, so they are first-class values; 2) it does make sense to compare functions for equality, JS people do it all the time.
Jan 22, 2015 at 12:46 comment added Doval @ruakh A method can't without its object. The closest analog is static methods, except they're still not first-class values. The thing about most OO languages is that they take objects as the smallest building block, so if you want anything smaller you have to fake it with objects, and you still end up dragging in a bunch of semantics functions shouldn't have. E.g. it doesn't make sense to compare functions for equality, but you can still compare two faux-function objects.
Jan 22, 2015 at 12:41 history edited leftaroundabout CC BY-SA 3.0
added 89 characters in body
Jan 22, 2015 at 12:37 comment added leftaroundabout ...more importantly, my anwer does consider behaviour. Indeed behaviour is usually the reason why you use inheritance, and the unification of different possible behaviours precisely captures the sum-type aspect of OO classes.
Jan 22, 2015 at 12:34 comment added leftaroundabout @ruakh: no. You can of course implement functions in OO, but in general, methods are not functions (because they modify state etc.). Nor are "functions" in procedural languages functions, for that matter. Indeed, single-static-method interfaces come closest to function/exponential-types, but I hoped to avoid the discussion of that because it has no relevance for this question.
Jan 22, 2015 at 12:31 history edited leftaroundabout CC BY-SA 3.0
Typos in footnote
Jan 22, 2015 at 6:35 comment added ruakh Sorry, but I think this is a very poor answer. Functions do have a clear OO analogue, namely methods (and single-method interface types). The basic definition of an object is that it has both state (fields/data members) and behavior (methods/member functions); your answer ignores the latter.
Jan 22, 2015 at 2:08 history answered leftaroundabout CC BY-SA 3.0