[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.
On 17 Mar 2004 at 22:42, Neil Santos wrote: [...]
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.
You are perhaps still trying to reinvent the wheel. You really should have a look at the TStream and TCollection objects in the FreeVision objects unit before putting in more work on this. You should be able to derive descendants from these, and we can all benefit from your efforts.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/
* [180304 :: 0353] Prof A Olowofoyeku (The African Chief) chiefsoft@bigfoot.com wrote:
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.
You are perhaps still trying to reinvent the wheel. You really should have a look at the TStream and TCollection objects in the FreeVision objects unit before putting in more work on this. You should be able to derive descendants from these, and we can all benefit from your efforts.
I believe I am; in a reply to your post (whose To: field I also forget to edit), I mentioned my being dismayed that I had not learned sooner about your work.
I'll be postponing this part of my project until I've looked at your FreeVision port. Thanks, Chief.
Neil Santos wrote:
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;
GPC doesn't declare MAX_PATH_LEN. Perhaps it's a predefined system macro on your system, but it's not recommended to use those.
Usually I'd just use `TString' (which has a reasonably large dimension).
And, oh, is there any way to turn a constructor into a function? :P
You can use any constructor as a Boolean function. It will return False if the constructor calls Fail, otherwise True. Is that what you mean?
Frank
On 17 Mar 2004 at 20:08, Frank Heckenbach wrote:
Neil Santos wrote:
[...]
And, oh, is there any way to turn a constructor into a function? :P
You can use any constructor as a Boolean function. It will return False if the constructor calls Fail, otherwise True. Is that what you mean?
I suspect that what he is referring to is the Delphi class syntax whereby a constructor returns a pointer to the object - e.g., myobj := tMyObj.MyConstructor;
So perhaps whatever magic is responsible for being able to use a constructor as a boolean function may possibly be also used for enabling the use of constructors to return a pointer to the object. I would also find such a thing useful. It would involve some implicit things - e.g.,
Constructor TMyobj.Create; begin blah; blue; blih; end;
would become something like this; Constructor TMyobj.Create; begin New (Result); { implicit "New"; I guess that the "Result" here would be "Self" in Delphi classes } With Result^ do begin { implicit "With" (in Delphi = "With Self"?) } blah; blue; blih; end; end;
I am not sure how feasible (or even desirable) it is to do something like this (especially if not also going thereby down the full Delphi "class" route). Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/
Prof A Olowofoyeku (The African Chief) wrote:
I suspect that what he is referring to is the Delphi class syntax whereby a constructor returns a pointer to the object - e.g., myobj := tMyObj.MyConstructor;
So perhaps whatever magic is responsible for being able to use a constructor as a boolean function may possibly be also used for enabling the use of constructors to return a pointer to the object. I would also find such a thing useful. It would involve some implicit things - e.g.,
[...]
I am not sure how feasible (or even desirable) it is to do something like this (especially if not also going thereby down the full Delphi "class" route).
I think it should be done together with `class'. But currently I'm more busy with other things, so I won't start working on this now ...
Frank