2 ms·
So would you consider a pointer to a memory location to be an object?
by weavejester 12y ago
So would you consider a pointer to a memory location to be an object?
- seanmcdirmid 12y agoUse the wiki [1]: > In computer science, an object is a location in memory having a value and possibly referenced by an identifier. Not useful huh? I would say, if the memory location is heap allocated and has mutable fields, then it is probably acting like an object (it could also be a value, it depends if its identity is important or not). [1] http://en.wikipedia.org/wiki/Object_(computer_science) http://en.wikipedia.org/wiki/Object_(computer_science)
- weavejester 12y agoWikipedia appears to distinguish between "object-based" languages and "object-orientated" languages. On the subject of object orientated languages, it says: > An object has state (data) and behavior (code). Which is the definition I'm most familiar with. I wouldn't class a Clojure reference as an "object", as it has state but no inherent behavior. > I would say, if the memory location is heap allocated and has mutable fields, then it is probably acting like an object So a reference to an immutable map wouldn't count as an object for you, because there are no mutable fields?
- seanmcdirmid 12y agoThe reference to the immutable map doesn't count (a immutable map is just a value), but keys into the map can form objects (in that they represent "object" properties). Actually, that is how you get objects without first class mutability (identities must still be generated, of course, which is the same thing). Ya, the wiki article makes a distinction between programming and designing with objects, and object-oriented programming. It really. All my arguments are about designing and programming with objects vs. designing and programming with values, call it "programming with objects" if you must.