OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 2:48 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: what is a class?
PostPosted: Fri May 06, 2016 9:39 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
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.)

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: what is a class?
PostPosted: Fri May 06, 2016 9:58 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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++.


Top
 Profile  
 
 Post subject: Re: what is a class?
PostPosted: Fri May 06, 2016 12:22 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
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.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: what is a class?
PostPosted: Fri May 06, 2016 1:58 pm 
Offline
Member
Member

Joined: Mon Dec 21, 2009 6:03 pm
Posts: 164
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.


Top
 Profile  
 
 Post subject: Re: what is a class?
PostPosted: Fri May 06, 2016 2:01 pm 
Offline
Member
Member

Joined: Mon Dec 21, 2009 6:03 pm
Posts: 164
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!


Top
 Profile  
 
 Post subject: Re: what is a class?
PostPosted: Fri May 06, 2016 7:25 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
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.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: what is a class?
PostPosted: Sun May 15, 2016 6:41 am 
Offline
Member
Member

Joined: Wed Jun 03, 2015 5:03 am
Posts: 397
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?

_________________
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group