Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
Proper name for free method in old school objects
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
« previous
next »
Print
Pages: [
1
]
Author
Topic: Proper name for free method in old school objects (Read 948 times)
LemonParty
Hero Member
Posts: 651
Proper name for free method in old school objects
«
on:
August 16, 2026, 07:56:56 pm »
I have an old school object:
Code: Pascal
[Select]
[+]
[-]
type
TMyObject
=
object
{...}
And I need to do a clean up (free some things) when object is not needed anymore. What name should I use for freeing method? .Free?
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
jamie
Hero Member
Posts: 7937
Re: Proper name for free method in old school objects
«
Reply #1 on:
August 16, 2026, 08:02:38 pm »
Not sure about that, it depends if you dynamically create them with Virtual methods?
If they are not that type, then maybe CleanUp, but then again, Advanced records can have constructors so whatever I guess.
Jamie
Logged
The only true wisdom is knowing you know nothing
LemonParty
Hero Member
Posts: 651
Re: Proper name for free method in old school objects
«
Reply #2 on:
August 16, 2026, 08:08:35 pm »
Jamie, do you think advanced records are better choice?
Because I can change objects to advanced records.
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Thausand
Hero Member
Posts: 613
Re: Proper name for free method in old school objects
«
Reply #3 on:
August 16, 2026, 08:36:53 pm »
constructor/destructor can be name any thing that want. It common and use init / done (example Freevision).
documentation (chapter declaration also have init/done example) :
https://www.freepascal.org/docs-html/current/ref/refch5.html#refse28.html
Logged
A docile goblin always follow HERMES.md
cdbc
Hero Member
Posts: 2943
Re: Proper name for free method in old school objects
«
Reply #4 on:
August 16, 2026, 08:42:20 pm »
Hi
Back in the day, we traditionally used 'Init' for the constructor & 'Done' for the destructor, of our Object(s)... You'd often see code like this:
Code: Pascal
[Select]
[+]
[-]
var
myObj
:
PMyObject
;
begin
myObj
:
=
new
(
PMyObject
,
Init
(
42
,
'Life'
)
;
writeln
(
'(i) The meaning of '
,
myObj
^
.
Text
,
' is '
,
myObj
^
.
Value
)
;
dispose
(
myObj
,
Done
)
;
end
;
This all started with Turbo Pascal 5.5 \o/
HTH
Regards Benny
Logged
If it ain't broke, don't fix it
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release & FPC Main -> Lazarus Main
jamie
Hero Member
Posts: 7937
Re: Proper name for free method in old school objects
«
Reply #5 on:
August 16, 2026, 09:54:48 pm »
if you don't have any inheritance in the OBJECT, you can replace it with an advanced Record and use finalize, Initialize, Copy operators to auto initiate it and clean it up in the background when it enters and leaves the Code body.
You can even use the Operator overloads in a record.
It's up to you .
Would be nice if either the object model could do that and still keep its ability to inherit or make the RECORD be able to inherit in which that could look more like a C++ class!
Jamie
Logged
The only true wisdom is knowing you know nothing
Thaddy
Hero Member
Posts: 19805
Glad to be alive.
Re: Proper name for free method in old school objects
«
Reply #6 on:
August 17, 2026, 08:28:56 am »
records with inheritance are called....wait for it... objects.. hence record inheritance will never happen because it is already in the language.
Logged
Any "programmer" that knows only one programming language is not a programmer
LemonParty
Hero Member
Posts: 651
Re: Proper name for free method in old school objects
«
Reply #7 on:
August 17, 2026, 07:38:46 pm »
Thank you for answers. I stoped on advanced records for now.
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Proper name for free method in old school objects
TinyPortal
© 2005-2018