On Fri, 4 Jul 1997 16:27:32 +0200 Frank Heckenbach heckenb@mi.uni-erlangen.de wrote:
Marius Gedminas wrote:
In Delphi you can declare a method 'virtual' or 'dynamic' and when you want to override it in an descendant class, you must do it with 'override' directive.
And what happens if you don't use "override"?
If you don't use "override", then it creates a new method by the same name, which replaces the original one. The full implications of this are not clear to me yet, but they have caused me some grief a few times (things not behaving as you expect).
Peter Gerwinski wrote:
It's "class" = "reference to object". Fortunately, the GCC front-end is able to deal with such things,
Fine! :-) (Front-end? Or back-end?)
so we "only" have to implement the syntax into GPC - and take care that it doesn't break other applications of reference types such as `Var' parameters and procedural variables.
Yes. Are value and reference parameters of class type the same, then (in Delphi)? Or do reference parameters pass a pointer/reference to the reference, i.e. do they allow destroying and recreating the object?
Who knows?
Are pointers to classes allowed in Delphi, and what do they mean?
If you mean this;
Type MyFoo = Class
end;
Type pMyFoo = ^MyFoo;
Var Foo : pMyFoo;
- then the answer is "yes", this will be accepted in the sense that it will compile. However, when you run the program, I cannot tell you what will happen. I have not ever tried it, neither do I have any desire to do so. In fact, there is no point at all in doing something of that nature.
AFAICG, objects in Delphi are typically things like windows, editors, dialogs and such "big things".
Not at all. There are all sorts of classes, including collections, strings, maths, Zip/UnZip, etc.
Delphi also supports both Objects and Classes -
With the differences like I described them?
I am not sure I remember how you described them. However the main difference is that Objects in Delphi are the same as the Objects in BP (and GPC). Classes are different, in the ways which have before been explained.
so it would be nice if we could as well.
gpc will certainly not remove objects when classes are implemented. :-)
[b] the constructor does the heap allocation stuff, e.g., "Foo := MyFoo.Create" *allocates memory for Foo "(New, Foo)" *calls Foo^.Create (constructor)
So it's the same as "Foo := New(MyFoo, Create)" in BP?
More or less.
I'd like to know it exactly. Is there any difference (besides the different syntax, of course)?
given this; "Procedure Foo (Bar:TObject)"
In Delphi, Bar is a pointer (even though it is automatically deferenced). In BP it is not a pointer (you would have to do "Bar: pObject", and then do some magic to dereference it automatically, to achieve the same thing).
Delphi destroys all objects that it creates itself. However, if you manually create an object by calling its constructor, you have to destroy it yourself with a call to "Free".
Sounds logical. But when does Delphi create objects by itself?
When it manages the project, e,g., when you drag objects from the repository onto your form - which is how most Delphi programs are meant to be written.
AFAIK, gpc doesn't do this yet, so we'd have to adopt this as well!?
We would need a Delphi-like IDE.
Like I said, "Create" and "Destroy" are empty in TObject (i.e., they contain just an empty "begin end;" block). "Free" checks whether the pointer is Nil, and if it is not, it calls Destroy.
Nice little "trick", but not very systematic. "Free" is a method of an object, and this object can be "nil^"!? Technically, it works, but "Free" must not be virtual (I guess it isn't in Delphi)! But as a clean way, I'd prefer a procedure... (Or should we regard it as defined behaviour to call a static method of a non-existing object if the method doesn't access any fields of the object?)
Well, "Free" is written in ASM. So, maybe therein lies the magic. I don't understand the ASM code, so I can't really comment on this.
Best regards, The Chief Dr Abimbola A. Olowofoyeku (The African Chief, and the Great Elephant) Author of: Chief's Installer Pro v3.60 for Win16 and Win32. Homepage: http://ourworld.compuserve.com/homepages/African_Chief/ E-mail: laa12@cc.keele.ac.uk