Re: Object recreating itself as a different class type ?




"Rudy Velthuis" <newsgroups@xxxxxxxxxxxx> wrote in message
news:xn0euyz0rvm61vw00y@xxxxxxxxxxxxxxxxx
Skybuck Flying wrote:

Apperently you don't know the answer to my question and instead you
pretend I asked another question.

OK, you are a "help vampire". I guess it is best if I ignore you. You
are just rude and "onbeleerbaar". You made it to my bozo bin extremely
fast, congratulations.

One last reply: all your questions will be answered if you read (and
try to understand) the Language Guide, instead of bothering people here
with questions showing you don't have any interest in actually learning
something the hard and thorough way, or listening to advice from people
who actually do know the language.

No you did not read my question properly.

However you have already answered my questions in another sub thread.

I think I now understand how it works, I have explained it in another sub
thread.

I think the improved code is now bug free.

Please answer there and not anymore in this sub thread about that matter.

I have taken your advice to heart and I downloaded this Delphi Language
Guide:

http://info.borland.com/techpubs/delphi/Delphi2005/Reference.pdf

I searched for the word: "Self"

The language guide does not properly explain what Self really is.

It does not explain that Self does not really exist.

It does not explain that no space is really allocated for it.

It might be allocated on the stack, registers or whatever the calling
convention is !

The only two slighty interesting bits of information were (which might not
be available in delphi's help (?):

"
Declarations
The names of variables, constants, types, fields, properties, procedures,
functions, programs, units, libraries, and
packages are called identifiers. (Numeric constants like 26057 are not
identifiers.) Identifiers must be declared before
you can use them; the only exceptions are a few predefined types, routines,
and constants that the compiler
understands automatically, the variable Result when it occurs inside a
function block, and the variable Self when
it occurs inside a method implementation.
A declaration defines an identifier and, where appropriate, allocates memory
for it. For example,
var Size: Extended;
declares a variable called Size that holds an Extended (real) value
"

And:

"
Handling Method Calls
Methods use the same calling conventions as ordinary procedures and
functions, except that every method has an
additional implicit parameter Self, which is a reference to the instance or
class in which the method is called. The
Self parameter is passed as a 32-bit pointer.
Under the register convention, Self behaves as if it were declared before
all other parameters. It is therefore
always passed in the EAX register.
Under the pascal convention, Self behaves as if it were declared after all
other parameters (including the
additional var parameter sometimes passed for a function result). It is
therefore pushed last, ending up at a
lower address than all other parameters.
Under the cdecl, stdcall, and safecall conventions, Self behaves as if it
were declared before all other
parameters, but after the additional var parameter (if any) passed for a
function result. It is therefore the last to
be pushed, except for the additional var parameter.
Constructors and destructors use the same calling conventions as other
methods, except that an additional Boolean
flag parameter is passed to indicate the context of the constructor or
destructor call.
A value of False in the flag parameter of a constructor call indicates that
the constructor was invoked through an
instance object or using the inheritedinherited keyword. In this case, the
constructor behaves like an ordinary method.
A value of True in the flag parameter of a constructor call indicates that
the constructor was invoked through a class
reference. In this case, the constructor creates an instance of the class
given by Self, and returns a reference to the
newly created object in EAX.
A value of False in the flag parameter of a destructor call indicates that
the destructor was invoked using the inherited
keyword. In this case, the destructor behaves like an ordinary method. A
value of True in the flag parameter of a
destructor call indicates that the destructor was invoked through an
instance object. In this case, the destructor
deallocates the instance given by Self just before returning.
The flag parameter behaves as if it were declared before all other
parameters. Under the register convention, it is
passed in the DL register. Under the pascal convention, it is pushed before
all other parameters. Under the cdecl,
stdcall, and safecall conventions, it is pushed just before the Self
parameter.
Since the DL register indicates whether the constructor or destructor is the
outermost in the call stack, you must
restore the value of DL before exiting so that BeforeDestruction or
AfterConstruction can be called properly.
"

Nowadays the help calls everything a reference. Reference this, reference
that... it creates uncertainty:

It says: "Self references... blablabla"

The question then becomes:

How does it reference ?

Does it do something special ? Like strings ?

Does it use special storage ?

When the help says: "reference" it could mean anything !!

In reality an object reference, or as this guide sometimes calls it: class
type variable... is really just an object pointer.

I would rather call it object pointer.. but Borland would probably not agree
with that because they might change the way objects are referenced in the
future.

Therefore it's always good to make sure how it really works and that's
exactly what I did.

In the end the programmer still has to know how the reference is
implemented.

Simple questions with simple answers like: Is it still only a pointer ? yes
/ no is sufficient.

Might as well called it an object pointer... and keep calling it that until
the fricking implementation changes ;)

^^^ more clear ;)

Bye,
Skybuck.


.



Relevant Pages

  • Re: iexplorer halts on exit when ActiveXObject has been used
    ... >>> The way to dispose of the object is to use its destructor, ... that is a constructor and destructor, ... further reference to the object or any of its properties is intended." ... > global/variable object will remove that reference from the system. ...
    (comp.lang.javascript)
  • Re: iexplorer halts on exit when ActiveXObject has been used
    ... > that is a constructor and destructor, ... > The var 'something' is a reference to the object created by use ... If the property has the DontDelete attribute, ... >> So you might expect that the property of the global/Variable object ...
    (comp.lang.javascript)
  • Re: How to pass information, classes between forms in Windows Application mode
    ... parametricized or parameter constructor, ... Form2: Form1 as you discuss below and as I further comment below. ... You're passing a reference to the object. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: OO problem: How to create a duplicate of a derived class with only a base variable ?
    ... > TBaseString.Create returns a reference to a newly allocated object. ... > and TObject has a static constructor. ... And when you add TDerived4, you don't have to go back and change ... > Duplicate could be introduced in TBase, ...
    (alt.comp.lang.borland-delphi)
  • Re: type checking
    ... Generics are also coming in Java (I've lost track of the # of times ... the destructor is called when it happens to be called, ... > happens immediately when the last reference has gone. ... but I'm not sure if they delay the garbage collection. ...
    (comp.lang.python)

Loading