According to Pierre Phaneuf:
According to myself (Peter Gerwinski):
I don't like that solution either. It makes units compiled with different options *really* incompatible with each other. (Programs using `ClassName' will rely on the function returning the correct result.)
Ok, then make it a program level switch, that doesn't have any effect in units... But then, do we need it?
I suggest to forget about the switch and just store a pointer to a string constant holding the name of the object in the VMT. Since we don't need to care about a 64k data segment (4GB will be enough for a while), these few extra bytes are harmless.
Its the explicit part I'm trying to avoid... I guess this part will be compiler dependent, but should be among very few (with the TObject.Init constructor).
Whatever we do here, it will be compiler dependent. If we implement some feature into GPC to select a constructor through a VmtLink, we can be sure that no other compiler has this.
I do not worry about compiler dependence since all of this is written especially for GPC - and other compilers which claim to be compatible to GPC do not exist yet. I *do* worry about portability between the various platforms GPC runs on.
[...] something like SetTypeOf(P, VMTLink)? ;-)
PtrToMyObj^.TypeOf:= TypeOf ( SomeObjectType );
Maybe this would be better... But I don't like this very much either...
What about
AssignType ( MyObj, MyVmtLink );
where MyObj is an object variable (usually a pointer dereference) and MyVmtLink points to the VMT?
[...] In general, I'm against "magic" things, like the New() function, or the Write()/WriteLn() functions (in BP at least, they cannot be implemented using the language!).
So am I. That's one beauty of C: Everything, including `printf' and such, is user-definable. (Said by someone who is hacking a Pascal compiler because he cannot stand the ugly syntax of C/C++ ... ;-)
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal [970510] - http://home.pages.de/~gnu-pascal/ [970125]
On Thu, 29 May 1997, Peter Gerwinski wrote:
Ok, then make it a program level switch, that doesn't have any effect in units... But then, do we need it?
I suggest to forget about the switch and just store a pointer to a string constant holding the name of the object in the VMT. Since we don't need to care about a 64k data segment (4GB will be enough for a while), these few extra bytes are harmless.
Yes, but like Frank said, I don't think people making commercial programs without sources would appreciate having their identifiers in the binary... Anyway, I think we should drop this idea, unless somebody comes up with a good idea for a use of this feature... ;-)
Its the explicit part I'm trying to avoid... I guess this part will be compiler dependent, but should be among very few (with the TObject.Init constructor).
Whatever we do here, it will be compiler dependent. If we implement some feature into GPC to select a constructor through a VmtLink, we can be sure that no other compiler has this.
Yes, I understand that we can code specifically for GPC, but what I mean is that if the implicit parameters changes (since they are compiler implementation dependent), we won't be able to recompile the library with the newer GPC (with possibly different implicit parameters). I'd rather see an GPC-specific command to spawn an object using a specific VMT link, doing the constructor invocation, so that if the constructor invocation changes, it you could recompile the library without any problem...
I do not worry about compiler dependence since all of this is written especially for GPC - and other compilers which claim to be compatible to GPC do not exist yet. I *do* worry about portability between the various platforms GPC runs on.
Of course!
PtrToMyObj^.TypeOf:= TypeOf ( SomeObjectType );
Maybe this would be better... But I don't like this very much either...
What about
AssignType ( MyObj, MyVmtLink );
where MyObj is an object variable (usually a pointer dereference) and MyVmtLink points to the VMT?
Sold. This one I like! :-)
So am I. That's one beauty of C: Everything, including `printf' and such, is user-definable. (Said by someone who is hacking a Pascal compiler because he cannot stand the ugly syntax of C/C++ ... ;-)
Yes, it's one of the very few beauties of C... Note that Frank Heckenbach has a differing opinion on this, which is also quite valid...
Pierre Phaneuf
"The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense." - Edsger W. Dijkstra.