[fpc-pascal] Variable of class method type of function

Bernd K. prof7bit at gmail.com
Tue Jul 17 11:56:01 CEST 2012

On 17.07.2012 01:09, waldo kitty wrote:

> now we need to remember to use "of object" when we are working with nothing but 
> classes?

Imagine for a moment (in a parallel universe) there exists no keyword
"object" and never has. All there has ever been was the keyword "class".

now you have

  TFoo = class

  Foo : TFoo;
  Bar : TFoo;

  Foo := TFoo.Create;
  Bar := TFoo.Create;

TFoo is a class
Foo and Bar are objects

They are objects in the original OOP sense of the word without having to
worry about any other conflicting meaning of the word "object" and then
it makes perfect sense.

IMHO it was the old keyword "object" that was confusing and misplaced
from the beginning on, it should have never existed. If there are two
categories: "data" and "structure of data" then "object" belongs into
"data" (the var section) and "class" belongs into "structure of data"
(the type section).

But "object" in the TurboPascal sense of the word is confusing, a badly
chosen name for something else. Actually it is a type, it describes
structure of data, type of data and not what one would intuitively
expect the data itself, they shouldn't have called it "object".

When mixing the OOP terminology and TurboPascal terminology you can end
up having an object whose type is "object". This is the source of your
confusion. It is best to completely ignore the existence of the old
object keyword while pondering about OOP problems and when you need to
use it then pretend to yourself that the keyword "object" does not mean
what it says at all, that its just a badly chosen type name but it
doesn't matter because you know what it really is.

"procedure of object" on the other hand refers to the real (oop) meaning
of "object" (instance of a class) and It would not hurt to also have its
counterpart "procedure of class" to achieve the perfect symmetry as far
as I'm concerned.

More information about the fpc-pascal mailing list