[Resent because I forgot to change To: field again. Damn it.]
* [100304 :: 0133] Frank Heckenbach ih8mj@fjf.gnu.de wrote:
I apologize for the vagueness of my original post. It was written at the end of the very tiring day (or the start of one; depends on how you look at it).
I know. :-)
Sometimes I begin to despise my choice to try and become a programmer--or, rather, try to be competent enough in programming to fake being a programmer.
But then I remember that I know nothing else, and would have to feed my family with food bought through the money I'm hoping to earn through coding. :D
inheritance for all the objects that need to be written to and read from a file,
... using a virtual method. That would be the OOP approach.
I opted for a root object that has as a member an object that implements an interface for accessing data streams from a disk.
Sounds more complicated than it is in code. :P
but I'm lazy, and since these functions will be doing basically the same thing (managing binding types, reading to/writing from streams),
Which could be done in a common ancestor's method. (No-one ever said OOP would reduce the number of routines in total ... ;-)
Aye. A teacher of mine tried to argue so; so I slapped him down.
But, like I said, I'm lazy; so I still look for ways to have object orientation with reduced coding. I like having my cake and eating it, too. :)
BTW, if you don't want to be Extended Pascal conformant (and you obviously don't), you can use GPC extensions such as:
While I'll admit to not gunning for conformance, I like to stick to it as much as I can. But when I encounter limitations in the languages I use, I try to find ways that work around them.
If there aren't, I try to make some.
There is no such thing as runtime type information in GPC. What you
Which I sorely miss, coming from a Windows/Delphi background.
[everything else snipped for brevity]
I've been mulling over your suggestions for the past few days--and I must admit ignorance for a lot of the things you've said. Like I said, I'm lazy, and I like having my cake and being able to eat it, as well; so here's what I've done.
I have a root object which implements a several functions that is common for all the Type 1* objects I have, and also has a member object that implements the disk-access functions I need.
Part of the creation of a Type 1 object involves passing the parameters needed by the disk-access object's constructor, all of which are contained in a RRecdStream record.
The RRecdStream record is declared as such:
RRecdStream = record { pointer to the structure to be written } recd_ptr = pointer; { byte; denotes what kind of structure is held by recd_ptr } recd_type = TRecordType; { MAX_PATH_LEN is 2060 bytes; as defined in GPC 20030830. Is there any way to retrieve this at runtime? } file_name = string(MAX_PATH_LEN); end;
And, oh, is there any way to turn a constructor into a function? :P
The disk-interface module is *very* incomplete as of now, but I would gladly send it to anyone who's interested; or, for that matter, a tar-gzip'd file of the whole project.
* A `Type 1' (made up term) object in this context is an object that has a member variable that gets written to/read from a stream.