Recent

Author Topic: Compile Photoshop Pascal Code  (Read 8950 times)

ASerge

  • Hero Member
  • *****
  • Posts: 2222
Re: Compile Photoshop Pascal Code
« Reply #15 on: June 24, 2018, 09:30:04 pm »
Compare advanced records and objects:
1. Advanced records support type helper (static polymorphism).
2. Objects support virtual function (dynamic polymorphism) and inheritance (static polymorphism).
All other properties are the same.

Nitorami

  • Sr. Member
  • ****
  • Posts: 481
Re: Compile Photoshop Pascal Code
« Reply #16 on: June 24, 2018, 09:51:21 pm »
Why would you need a constructor ? It is only required to build the VMT which is necessary for inheritance & virtual methods which advanced records don't support.

Objects are really like Classes, except they are static and need not be allocated, hence it is not necessary to "create" them. Only if you are using inheritance, then you need a constructor. That is my understanding. I don't know about type helpers.

I had started my own program based on objects, but came to a point where things went wrong. I don't know whether "Delphi broke objects", but have the feeling the developers neglected them, once Classes had been implemented. So I changed to Classes, but still use simple objects to capsule simple data and methods. But I don't use constructors / inheritance on objects anymore, neither properties... I remember they seemed to be buggy.
The advantage of objects is that access to their fields may be a little bit faster than for Classes, although that only matters in tight loops.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Compile Photoshop Pascal Code
« Reply #17 on: June 24, 2018, 11:34:58 pm »
Thanks guys, I appreciate the responses.

A few years ago I started writing a vector library using TVector and TMatrix objects (I write scientific software at a university). At some point I encountered some unexpected behavior. I inquired here, and learned that objects were deprecated, or at least not maintained. It sounds like you (Nitorami)  may have encountered the same issue. Despite the error in my earlier post, I was using object constructors, which I forgot. (I have long since rewritten the library using dynamic arrays and operator overloading).

I do use advanced records extensively, often to set and get options for a complex procedure which are logically grouped together. These are typically set in a dialog box, and then saved to a preferences dictionary in memory, which can be written to a file and reloaded when the program is restarted. Each such record must have default values, which I set in an Init method. It is not such a big deal, but it would be nice to have a constructor to do that automatically. 

So at least one other person has had issues, at least with object constructors or inheritance. I suppose I could use objects and not use constructors or inheritance, but advanced records seem to work well.

« Last Edit: June 24, 2018, 11:44:56 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018