<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 09/22/2014 08:28 PM, Boian Mitov wrote:
<blockquote cite="mid:3452E3B724C34DB3AA60F27E8C3CA843@mpc1"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div dir="ltr">
<div style="font-size: 10pt; font-family: 'Arial'; color: rgb(0,
0, 0);">
<div>In general, records and classes are inherently the same
thing (and in C++ are indeed practically interchangeable).
The only real difference in Delphi/FPC is that records are
instantiated in the stack, </div>
</div>
</div>
</blockquote>
<br>
Or on the heap:<br>
==========<br>
Type<br>
TMyRecord = Record<br>
End;<br>
<br>
PMyRecord = ^TMyRecord;<br>
<br>
Var<br>
a: PMyRecord;<br>
Begin<br>
a:= GetMem(SizeOf(TMyRecord));<br>
End;<br>
==========<br>
<br>
<blockquote cite="mid:3452E3B724C34DB3AA60F27E8C3CA843@mpc1"
type="cite">
<div dir="ltr">
<div style="font-size: 10pt; font-family: 'Arial'; color: rgb(0,
0, 0);">
<div>the objects in the heap,</div>
</div>
</div>
</blockquote>
If you alocate them like<br>
==========<br>
Type<br>
TMyObject = Object<br>
End;<br>
<br>
Var<br>
a: TMyObject;<br>
==========<br>
<br>
`a` will be on the stack, not on the heap. I you allocate them using
`New`, they will be on the heap.<br>
<br>
See, that is what I love about this language and this compiler: you
can do whatever you want! You want to write assembly: go ahead,
wanna think higher level: you get a wonderful assortment of
available primitives:<br>
- Dynamic arrays/strings<br>
- Static arrays/strings<br>
- Records<br>
- Objects<br>
- Classes<br>
- Interfaces<br>
<br>
Al with their own unique flavour. It is a bit like two programmer
programming assembly:<br>
- One prefers a RISC style instruction set because it is
composed of a set of primitive instructions that are easy to
comprehend, the CISC instructions are complex and have many pitfalls
is what he/she says.<br>
- The other programmer says programming RISC is a drudgery:
constantly writing the same instructions that do nearly nothing,
have no special side effects, all the fun is gone.<br>
<br>
As a programmer, pick the patterns you like, use them as much as you
think is appropriate and know when they are not. In pascal you can
do that because of the above.<br>
<br>
So much for my little praise to pascal :-)<br>
<br>
<blockquote cite="mid:3452E3B724C34DB3AA60F27E8C3CA843@mpc1"
type="cite">
<div dir="ltr">
<div style="font-size: 10pt; font-family: 'Arial'; color: rgb(0,
0, 0);">
<div> and the artificial restriction on record inheritance.</div>
</div>
</div>
</blockquote>
If you want a record with inheritance, use object.<br>
<br>
<pre class="moz-signature" cols="72">--
Ewald</pre>
</body>
</html>