Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-06

Object upgrades (new)

15 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

{ I think the old thread “Object upgrades” got broken during the server move so I’ll try to start a new thread and see if this gets posted }

Another question. I’m not sure it’s possible but I did try to add management operators to objects and found that if a initialize operator was declared in a unit which was precompiled and then inherited from an object in another unit which declared another initialize operators, the initialize operator would be called twice.

The issue is that the operator is compiled into some other code which always gets called when the object is used as a var type. Is there any work around to that? The options I’m aware of are:

1) don’t allow management operators in objects (that would be very unfortunate indeed).
2) don’t allow subclasses to redeclare a management operator (that seems ok since the operator can call a virtual method from the base class).
3) allow overriding of operators. I don’t think that would be make sense or perhaps even possible.

Regards,
Ryan Joseph

Reply by email

Sven Barth
to Ryan Joseph
Ryan Joseph wrote 9 lines
{ I think the old thread “Object upgrades” got broken during the server move so I’ll try to start a new thread and see if this gets posted } Another question. I’m not sure it’s possible but I did try to add management operators to objects and found that if a initialize operator was declared in a unit which was precompiled and then inherited from an object in another unit which declared another initialize operators, the initialize operator would be called twice. The issue is that the operator is compiled into some other code which always gets called when the object is used as a var type. Is there any work around to that? The options I’m aware of are: 1) don’t allow management operators in objects (that would be very unfortunate indeed). 2) don’t allow subclasses to redeclare a management operator (that seems ok since the operator can call a virtual method from the base class). 3) allow overriding of operators. I don’t think that would be make sense or perhaps even possible.

I don't see a need to add management operators to objects. Objects have constructors and destructors, so they don't need Initialize and Finalize operators and they have a defined assignment operation. Just leave the poor, old objects alone.

Regards,
Sven

Reply by email

Ryan Joseph
to Sven Barth
On Jun 15, 2019, at 12:50 PM, Sven Barth via fpc-devel wrote: I don't see a need to add management operators to objects. Objects have constructors and destructors, so they don't need Initialize and Finalize operators and they have a defined assignment operation. Just leave the poor, old objects alone.

It’s not about objects as much as record inheritance (which as I was told will not be happening). I don’t see why Pascal got left out of this one particular thing but since we’ve always had objects it only makes sense to keep them up to date. Not sure why there would be any resistance to this. Making a mode switch for “advanced objects” seems sensible enough to me (unless you want to make a whole new keyworld like “struct” or something).

Regards,
Ryan Joseph

Reply by email

Sven Barth
to Ryan Joseph

Ryan Joseph schrieb am Sa., 15. Juni 2019, 20:43:

Show quoted text 17 lines
> On Jun 15, 2019, at 12:50 PM, Sven Barth via fpc-devel < > wrote: > > I don't see a need to add management operators to objects. Objects have constructors and destructors, so they don't need Initialize and Finalize operators and they have a defined assignment operation. Just leave the poor, old objects alone. It’s not about objects as much as record inheritance (which as I was told will not be happening). I don’t see why Pascal got left out of this one particular thing but since we’ve always had objects it only makes sense to keep them up to date. Not sure why there would be any resistance to this. Making a mode switch for “advanced objects” seems sensible enough to me (unless you want to make a whole new keyworld like “struct” or something).

I neither see a reason for record inheritance nor for the objects to be more like records. Pascal doesn't need to replicate each and every feature of other languages. What we need is libraries to help users do their work.

Regards,
Sven

Reply by email

Benito van der Zander
to Sven Barth: I don't see a need to add management operators to objects. Objects have constructors and…

Hi',

I don't see a need to add management operators to objects. Objects have constructors and destructors, so they don't need Initialize and Finalize operators

One need would be to automatically call the destructor

It could make the code much simpler, especially when it also replaces try..finally, and prevent memory leaks

Just leave the poor, old objects alone.

Objects are much more useful than classes or records

Bye,
Benito

Sven Barth wrote 32 lines
Am 15.06.2019 um 17:17 schrieb Ryan Joseph: > { I think the old thread “Object upgrades” got broken during the > server move so I’ll try to start a new thread and see if this gets > posted } > > Another question. I’m not sure it’s possible but I did try to add > management operators to objects and found that if a initialize > operator was declared in a unit which was precompiled and then > inherited from an object in another unit which declared another > initialize operators, the initialize operator would be called twice. > > The issue is that the operator is compiled into some other code which > always gets called when the object is used as a var type. Is there > any work around to that? The options I’m aware of are: > > 1) don’t allow management operators in objects (that would be very > unfortunate indeed). > 2) don’t allow subclasses to redeclare a management operator (that > seems ok since the operator can call a virtual method from the base > class). > 3) allow overriding of operators. I don’t think that would be make > sense or perhaps even possible. I don't see a need to add management operators to objects. Objects have constructors and destructors, so they don't need Initialize and Finalize operators and they have a defined assignment operation. Just leave the poor, old objects alone. Regards, Sven _______________________________________________ fpc-devel maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Ryan Joseph
to Benito van der Zander
On Jun 16, 2019, at 6:00 PM, Benito van der Zander wrote: Objects are much more useful than classes or records

Now that’s an inflammatory statement! :) But seriously, I do miss record inheritance from C++, C#, Swift when I’m in Pascal.

Regards,
Ryan Joseph

Reply by email

Unknown author
to Ryan Joseph: Now that’s an inflammatory statement! :) But seriously, I do miss record inheritance…
Ryan Joseph wrote 7 lines
> On Jun 16, 2019, at 6:00 PM, Benito van der Zander wrote: > > Objects are much more useful than classes or records Now that’s an inflammatory statement! :) But seriously, I do miss record inheritance from C++, C#, Swift when I’m in Pascal.

what always confused me these days is that records and objects were one thing back in the (TP6) day but today they are something quite different... i had to be very careful when i wrote my satellite TLE management tool because of these differences...

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.*

Reply by email

Sven Barth
to Unknown author

schrieb am Mo., 17. Juni 2019, 02:07:

Show quoted text 20 lines
On 6/16/19 6:44 PM, Ryan Joseph wrote: > > >> On Jun 16, 2019, at 6:00 PM, Benito van der Zander wrote: >> >> Objects are much more useful than classes or records > > Now that’s an inflammatory statement! :) But seriously, I do miss record inheritance from C++, C#, Swift when I’m in Pascal. what always confused me these days is that records and objects were one thing back in the (TP6) day but today they are something quite different... i had to be very careful when i wrote my satellite TLE management tool because of these differences...

Ehm... TP style objects were already quite different to records back in TP days. After all the former supported inheritance and (virtual) methods while the later supported variant parts.

Regards,
Sven

Reply by email

Unknown author
to Sven Barth
Sven Barth wrote 10 lines
schrieb am Mo., 17. Juni 2019, 02:07: what always confused me these days is that records and objects were one thing back in the (TP6) day but today they are something quite different... i had to be very careful when i wrote my satellite TLE management tool because of these differences... Ehm... TP style objects were already quite different to records back in TP days.

yes... what i'm saying is that today's are different and that's what confuses me...

After all the former supported inheritance and (virtual) methods while the later supported variant parts.

in the day that i speak of, records were simple static blocks that contained data in a certain defined order... today's records have methods, too, which are more like objects back then... i forget the difference between yesterday's objects and today's...

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.*

Reply by email

Sven Barth
to Unknown author

schrieb am Mo., 17. Juni 2019, 14:15:

Show quoted text 20 lines
On 6/17/19 1:54 AM, Sven Barth via fpc-devel wrote: > schrieb am Mo., 17. > Juni 2019, 02:07: > > what always confused me these days is that records and objects were one thing > back in the (TP6) day but today they are something quite different... i had to > be very careful when i wrote my satellite TLE management tool because of these > differences... > > > Ehm... TP style objects were already quite different to records back in TP days. yes... what i'm saying is that today's are different and that's what confuses me...

You are talking about classes, aren't you?

Show quoted text 12 lines
> After all the former supported inheritance and (virtual) methods while the later > supported variant parts. in the day that i speak of, records were simple static blocks that contained data in a certain defined order... today's records have methods, too, which are more like objects back then... i forget the difference between yesterday's objects and today's...

But back in the days the objects were already different from records. And yes, both are again different from classes.

Regards,
Sven

Reply by email

Unknown author
to Sven Barth
Sven Barth wrote 21 lines
schrieb am Mo., 17. Juni 2019, 14:15: On 6/17/19 1:54 AM, Sven Barth via fpc-devel wrote: > schrieb am Mo., 17. Juni 2019, 02:07: > >     what always confused me these days is that records and objects were one thing >     back in the (TP6) day but today they are something quite different... i had to >     be very careful when i wrote my satellite TLE management tool because of these >     differences... > > > Ehm... TP style objects were already quite different to records back in TP days. yes... what i'm saying is that today's are different and that's what confuses me... You are talking about classes, aren't you?

maybe... that's part of the confusion... i'm self taught from TP2... never took any classes for anything computer at all... started with B.A.S.I.C. and a friend showed me asm and pascal... i dropped basic like a hot potato and went all out with asm and pascal... had a nice library of routines in asm but as each new TP came out, fewer and fewer of my homegrown asm routines were needed... eventually i was doing asm blocks in my pascal sources instead of compiling .obj files and linking them in...

Show quoted text 7 lines
in the day that i speak of, records were simple static blocks that contained data in a certain defined order... today's records have methods, too, which are more like objects back then... i forget the difference between yesterday's objects and today's... But back in the days the objects were already different from records.

right... i wrote my own objects when they were introduced and later extensively used message base objects from Mark May when writing BBS message base tools... some objects had (traditional) records* within them...

mksm106.zip 215k
MK Source for Msg Access v1.06 - Mark May's
Pascal OOP source code to access Squish,
Jam, Hudson, *.Msg, and Ezycom message
bases. Great for developing BBS utilities.
(FW)
ftp://sestar.synchro.net/main/PROG/mksm106.zip

i started, some time back, to convert the code to FPC but RL and other shite got in the way...

And yes, both are again different from classes.

yeah, i'll have to see if i can figure out what classes are and if they are one of the old-school objects or records... yeah, i'm getting old and rarely dabble in pascal code any more but i still read the mailing lists :)

*this is an example of a traditional record and a traditional object as i think of them...

Type JamHdrType = Record
   Signature: Array[1..4] of Char;
   Created: LongInt;
   ModCounter: LongInt;
   ActiveMsgs: LongInt;
   PwdCRC: LongInt;
   BaseMsgNum: LongInt;
   Extra: Array[1..1000] of Char;
End;
Const JamSubBufSize = 4000;
Type JamSubBuffer = Array[1..JamSubBufSize] of Char;
Type HdrType = Record
   JamHdr: JamMsgHdrType;
   SubBuf: JamSubBuffer;
End;
Type JamMsgObj = Object (AbsMsgObj)
   JM: ^JamMsgType;
   MsgHdr: ^HdrType;
   JamIdx: ^JamIdxArrayType;
   TxtBuf: ^JamTxtBufType;
   Error: Longint;
   Constructor Init;                      {Initialize}
   Destructor Done; Virtual; {Done}
   Procedure SetMsgPath(St: String); Virtual; {Set netmail path}
   Function  GetHighMsgNum: LongInt; Virtual; {Get highest netmail msg number in
area}
   Function  LockMsgBase: Boolean; Virtual; {Lock the message base}
   Function  UnLockMsgBase: Boolean; Virtual; {Unlock the message base}
   Function  WriteMailIdx(FN: String; MsgPos: Word): Word; Virtual; {Write
Netmail or EchoMail.jam}
   Procedure SetDest(Var Addr: AddrType); Virtual; {Set Zone/Net/Node/Point for
Dest}
   Procedure SetOrig(Var Addr: AddrType); Virtual; {Set Zone/Net/Node/Point for
Orig}
   Procedure SetFrom(Name: String); Virtual; {Set message from}
   Procedure SetTo(Name: String); Virtual; {Set message to}
   Procedure SetSubj(Str: String); Virtual; {Set message subject}
   Procedure SetCost(SCost: Word); Virtual; {Set message cost}
   Procedure SetRefer(SRefer: LongInt); Virtual; {Set message reference}
   Procedure SetSeeAlso(SAlso: LongInt); Virtual; {Set message see also}
   Function  GetNextSeeAlso: LongInt; Virtual;
   Procedure SetNextSeeAlso(SAlso: LongInt); Virtual;
   Procedure SetDate(SDate: String); Virtual; {Set message date}
   Procedure SetTime(STime: String); Virtual; {Set message time}
   Procedure SetLocal(LS: Boolean); Virtual; {Set local status}
   Procedure SetRcvd(RS: Boolean); Virtual; {Set received status}
   Procedure SetPriv(PS: Boolean); Virtual; {Set priveledge vs public status}
   Procedure SetCrash(SS: Boolean); Virtual; {Set crash netmail status}
   Procedure SetKillSent(SS: Boolean); Virtual; {Set kill/sent netmail status}
   Procedure SetSent(SS: Boolean); Virtual; {Set sent netmail status}
   Procedure SetFAttach(SS: Boolean); Virtual; {Set file attach status}
   Procedure SetReqRct(SS: Boolean); Virtual; {Set request receipt status}
   Procedure SetReqAud(SS: Boolean); Virtual; {Set request audit status}
   Procedure SetRetRct(SS: Boolean); Virtual; {Set return receipt status}
   Procedure SetFileReq(SS: Boolean); Virtual; {Set file request status}
   Procedure DoString(Str: String); Virtual; {Add string to message text}
   Procedure DoChar(Ch: Char); Virtual; {Add character to message text}
   Procedure DoStringLn(Str: String); Virtual; {Add string and newline to msg text}
   Procedure DoKludgeLn(Str: String); Virtual; {Add ^AKludge line to msg}
   Function  WriteMsg: Word; Virtual;
   Function  GetChar: Char; Virtual;
   Procedure AddTxtSub(St: String);
   Procedure MsgStartUp; Virtual; {set up msg for reading}
   Function  EOM: Boolean; Virtual; {No more msg text}
   Function  GetString(MaxLen: Word): ShortString; Virtual; {Get wordwrapped string}
   Function  WasWrap: Boolean; Virtual; {Last line was soft wrapped no CR}
   Procedure SeekFirst(MsgNum: LongInt); Virtual; {Seek msg number}
   Procedure SeekNext; Virtual; {Find next matching msg}
   Procedure SeekPrior; Virtual; {Seek prior matching msg}
   Function  GetFrom: String; Virtual; {Get from name on current msg}
   Function  GetTo: String; Virtual; {Get to name on current msg}
   Function  GetSubj: String; Virtual; {Get subject on current msg}
   Function  GetCost: Word; Virtual; {Get cost of current msg}
   Function  GetDate: String; Virtual; {Get date of current msg}
   Function  GetTime: String; Virtual; {Get time of current msg}
   Function  GetRefer: LongInt; Virtual; {Get reply to of current msg}
   Function  GetSeeAlso: LongInt; Virtual; {Get see also of current msg}
   Function  GetMsgNum: LongInt; Virtual; {Get message number}
   Procedure GetOrig(Var Addr: AddrType); Virtual; {Get origin address}
   Procedure GetDest(Var Addr: AddrType); Virtual; {Get destination address}
   Function  IsLocal: Boolean; Virtual; {Is current msg local}
   Function  IsCrash: Boolean; Virtual; {Is current msg crash}
   Function  IsKillSent: Boolean; Virtual; {Is current msg kill sent}
   Function  IsSent: Boolean; Virtual; {Is current msg sent}
   Function  IsFAttach: Boolean; Virtual; {Is current msg file attach}
   Function  IsReqRct: Boolean; Virtual; {Is current msg request receipt}
   Function  IsReqAud: Boolean; Virtual; {Is current msg request audit}
   Function  IsRetRct: Boolean; Virtual; {Is current msg a return receipt}
   Function  IsFileReq: Boolean; Virtual; {Is current msg a file request}
   Function  IsRcvd: Boolean; Virtual; {Is current msg received}
   Function  IsPriv: Boolean; Virtual; {Is current msg priviledged/private}
   Function  IsDeleted: Boolean; Virtual; {Is current msg deleted}
   Function  IsEchoed: Boolean; Virtual; {Msg should be echoed}
   Function  GetMsgLoc: LongInt; Virtual; {Msg location}
   Procedure SetMsgLoc(ML: LongInt); Virtual; {Msg location}
   Procedure YoursFirst(Name: String; Handle: String); Virtual; {Seek your mail}
   Procedure YoursNext; Virtual; {Seek next your mail}
   Function  YoursFound: Boolean; Virtual; {Message found}
   Procedure StartNewMsg; Virtual;
   Function  OpenMsgBase: Word; Virtual;
   Function  CloseMsgBase: Word; Virtual;
   Function  MsgBaseExists: Boolean; Virtual; {Does msg base exist}
   Function  CreateMsgBase(MaxMsg: Word; MaxDays: Word): Word; Virtual;
   Function  SeekFound: Boolean; Virtual;
   Procedure SetMailType(MT: MsgMailType); Virtual; {Set message base type}
   Function  GetSubArea: Word; Virtual; {Get sub area number}
   Procedure ReWriteHdr; Virtual; {Rewrite msg header after changes}
   Procedure DeleteMsg; Virtual; {Delete current message}
   Function  NumberOfMsgs: LongInt; Virtual; {Number of messages}
   Function  GetLastRead(UNum, UCRC: LongInt): LongInt; Virtual; {Get last read
for user num}
   Procedure SetLastRead(UNum: LongInt; LR, UCRC: LongInt); Virtual; {Set last read}
   Procedure MsgTxtStartUp; Virtual; {Do message text start up tasks}
   Function  GetTxtPos: LongInt; Virtual; {Get indicator of msg text position}
   Procedure SetTxtPos(TP: LongInt); Virtual; {Set text position}
   Procedure SetAttr1(Mask: LongInt; St: Boolean); {Set attribute 1}
   Function  ReadIdx: NumReadType;
   Function  WriteIdx: NumReadType;
   Procedure AddSubField(id: SmallWord; Data: String);
   Function  FindLastRead(Var LastFile: pFileOBj; UNum, UCRC: LongInt): LongInt;
   Function  ReReadIdx(Var IdxLoc : LongInt) : Word;
   Function  IsNetMail: Boolean; virtual;
   Procedure SetNetMail(SN: Boolean); virtual;
   procedure ClearMsgText; virtual;
   procedure UpdateMsgText(var WriteError: Word); virtual;
   procedure SetDateTime;
   {$IFNDEF MSDOS}
   function GetMsgBuffer: AnsiString; virtual;
   {$ENDIF}
End;
NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.*

Reply by email

Sven Barth
to Unknown author

Am 17.06.2019 um 19:56 schrieb

Show quoted text 8 lines
> And yes, both are again different from classes. yeah, i'll have to see if i can figure out what classes are and if they are one of the old-school objects or records... yeah, i'm getting old and rarely dabble in pascal code any more but i still read the mailing lists :)

I suggest you to take a look at this:
https://wiki.freepascal.org/Object_Oriented_Programming_with_Free_Pascal_and_Lazarus#Free_Pascal_Language_Extensions

*this is an example of a traditional record and a traditional object as i think of them...

[snip]

These would still work as is in FPC.

Regards,
Sven

Reply by email

Unknown author
to Sven Barth
Sven Barth wrote 9 lines
Am 17.06.2019 um 19:56 schrieb > >> And yes, both are again different from classes. > > yeah, i'll have to see if i can figure out what classes are and if they are > one of the old-school objects or records... yeah, i'm getting old and rarely > dabble in pascal code any more but i still read the mailing lists :) I suggest you to take a look at this: https://wiki.freepascal.org/Object_Oriented_Programming_with_Free_Pascal_and_Lazarus#Free_Pascal_Language_Extensions

thanks... i'll try to get by there soon-ish...

Show quoted text 5 lines
> *this is an example of a traditional record and a traditional object as i > think of them... [snip] These would still work as is in FPC.

right but are they objects, classes or advanced records?

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.*

Reply by email

Sven Barth
to Unknown author

schrieb am Di., 18. Juni 2019, 03:27:

Show quoted text 10 lines
>> *this is an example of a traditional record and a traditional object as i >> think of them... > [snip] > > These would still work as is in FPC. right but are they objects, classes or advanced records?

Your example showed a couple of records and an object. The later is often also called TP-style object for better distinction to Delphi-style objects also known as "classes" (due to their use of the "class" keyword instead of the "object" keyword).

Regards,
Sven

Reply by email