Page 2 of 2
Re: what is a class?
Posted: Fri May 06, 2016 9:39 am
by onlyonemac
Think of classes and types like this: classes are a "template" for an object, whereas types are a "template" for a piece of data. So "vehicle" might be the class of an object "car", but "integer" might be the type of an attribute "number_of_doors". (Note that, as aforedescribed, types can also be subdivided into base types and user-defined types which are built from those base types. Some languages, such as Java, may also blur the lines between classes and types at times, but they are still different concepts.)
Re: what is a class?
Posted: Fri May 06, 2016 9:58 am
by iansjack
In a pure object-oriented language (such as SmallTalk) everything is an instance of a class, even classes. The distinction between classes and types is an arbitrary one made by hybrid monsters such as C++.
Re: what is a class?
Posted: Fri May 06, 2016 12:22 pm
by Schol-R-LEA
The real problem is that there are several models of how to map a conceptual category to a concrete datum, and the terminology varies depending on the model - there are several competing or at least contradictory definitions of what words like 'class', 'type', 'domain', 'value', 'object', 'reference' and so forth mean. Most books or papers approaching this from a formal position - such as
Data Structures + Algorithms = Programs by Wirth,
A Discipline of Programming by Dijkstra,
Elements of Programming by Stepanov and McJones (I am currently reading this, and it's... well, I'm reserving judgement), or
The Science of Programming by Gries - define the meanings used in them, but informal works by their nature generally don't.
Most of the confusion we're having in this thread seems to come from contradictory definitions of common but loosely used terms.
Re: what is a class?
Posted: Fri May 06, 2016 1:58 pm
by cxzuk
iansjack wrote:In a pure object-oriented language (such as SmallTalk) everything is an instance of a class, even classes. The distinction between classes and types is an arbitrary one made by hybrid monsters such as C++.
Yes, well slightly different in my language. ive gone for; A 'class' is an object (you can send it messages, add method etc and all constructors). But I didn't like the metaclass idea so have it as a primitive object defined by the language and provided by the environment.
Re: what is a class?
Posted: Fri May 06, 2016 2:01 pm
by cxzuk
I currently think a 'type' is a label thats meaning is the interfaces and invariants of some concept.
I'm happy with my current dynamic typing and 'standardisation' (to keep the types label meaning the same) and want to stay away from typing for the time being
having said that I also wanted to avoid inheritance and look where that got me!
Re: what is a class?
Posted: Fri May 06, 2016 7:25 pm
by Schol-R-LEA
Shall we define some terms, then, so we're all saying the same things when we are using a given term? I'll start by proposing something, and then let others either propose their own definitions or indicate that they agree with one someone else proposed, and we'll see if we can come to a consensus. My first four are basically rewordings of Stepanov and McJones's terms:
- entity - any thing or concept that can be treated as a unit. A abstract entity are a sort of Platonic ideal of a given entity, and does not change; a concrete entity is one which has a creation point in time and space, can be altered over time, and eventually ceases to exist in some point in time and space.
- attribute - a property of an entity. An abstract attribute is one which is describes an abstract entity; a concrete attribute is a correspondence between the actual state of a concrete entity and the abstract attributes of it's matching abstract entity. While abstract entities can only exist as concepts, concrete entities can exist either as physical objects, organizational units (e.g., a government, a legal contract, an intellectual property when considered independent of the specific medium it is stored in) or structural units (e.g., a city, an island, a building, a disk driver).
- Identity - the general concept of the 'sameness' of a concrete entity as it changes over time. This is a problematic concept, as it can't really even proven to mean much of anything, so several other indicators have to be used when working with concrete entities. Generally speaking, the identity of an abstract entity is its definition or description, which is somewhat tautological.
- snapshot - a description of all the defined attributes of a concrete entity at a given instantaneous point in time (I'll leave the definition of 'instantaneous' to whatever future philosopher who manages to do so without self-contradiction).
- value - an abstract entity representing some concept.
- species - an identity naming a group of entities with the same set of abstract attributes, such that they can be substituted for each other under given circumstances (e.g., human beings, laws, integers).
- genus - an identity naming a set of related species that have one or more subsets of their attributes in common.
- datum - a concrete entity consisting of some unit of information.
- signal - a concrete entity carrying a datum representing a value.
- value type - an interpretation of a datum as a representation of a value.
This is a starting point, but probably too abstract so far. I will try to get back to this later.
Re: what is a class?
Posted: Sun May 15, 2016 6:41 am
by embryo2
cxzuk wrote:What i think i want is to extend the superclass with each subclass definition (like a partial class with a label), this would mean an instance of NUMBER would contain all the code from class INTEGER.
Then you'll be unable to separate your classes. Usually a class hierarchy is extended during a long period of time and it means every new class you write will always trigger recompilation of all base classes, even if your project is working somewhere on a server that serves user requests. So, the server needs a compiler and an infrastructure that helps it to survive the recompilation process. Isn't it too limiting requirement?