What about old borland objects (heap and stack initialization) process?
I am guessing they are more like records... or do heap objects act like
classes in that they are filled with zeros?
p.s. I think the inconsistent behavior between local scope records and
global scope records is kind of a
On 25 Mar 2008, at 13:40, L wrote:
What about old borland objects (heap and stack initialization)
process?
I am guessing they are more like records...
They are exactly like records.
or do heap objects act like classes in that they are filled with
zeros?
Unlike classes, objects have
I wrote:
What about old borland objects (heap and stack initialization) process?
program test1;
type
trec = record i: integer; end;
tclass = class i: integer; end;
tobj = object i: integer; end;
pobj = ^Tobj;
procedure show;
var rec: trec; c: tclass; o: tobj; po: pobj;
begin
p.s. I think the inconsistent behavior between local scope records
and global scope records is kind of a flaw/danger in modern
pascal.. as the bugs may not be caught until someone builds a
program with local scope var..
Using uninitialised variables is virtually always bad, regardless
On 25 Mar 2008, at 14:40, L wrote:
Not a fool proof test since random values have a chance of being
zero, but it basically shows:
1. global old heap object NOT zeroed
2. local old heap object NOT zeroed
3. local class zeroed
4. global class zeroed
The above terminology is wrong. Given your
Jonas Maebe wrote:
Using uninitialised variables is virtually always bad, regardless of the
scope. And the fact that global variables are zeroed at the program
start is afaik not defined by the Pascal standard. It's just a side
effect of the way most operating systems work.
I think I didn't
On 25 Mar 2008, at 14:21, Joao Morais wrote:
Jonas Maebe wrote:
Using uninitialised variables is virtually always bad, regardless
of the scope. And the fact that global variables are zeroed at the
program start is afaik not defined by the Pascal standard. It's
just a side effect of the
Using uninitialised variables is virtually always bad, regardless of the
scope. And the fact that
global variables are zeroed at the program start is afaik not defined
by the Pascal standard. It's
just a side effect of the way most operating systems work.
I think something like:
procedure
I wrote:
I think something like:
procedure test;
var blah: integer = 0;
begin
end;
Is useful.. i.e. initialized variables that are done on the spot.
To expand on this.. not only local scope vars, but global..
var
global: integer = 0;
I agree is much clearer than leaving it to the
I wrote:
3. local class zeroed
4. global class zeroed
I meant class instance zeroed
(Regarding Jonas' nitpick ;-)
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Joao Morais replied to Jonas with:
I think I didn't get your point. What about this piece of code:
interface
function foo: tfoo;
implementation
var
_foo: tfoo;
function foo: tfoo;
begin
if not assigned(_foo) then
_foo := tfoo.create;
result := _foo;
end;
Is it safe?
What about this:
Pascal does not define any variable initialization itself - one should
always init all Pascal vars of any type. Doing so is an excellent
coding habit also portable to any other language/OS - protects against
low-level implementation changes.
I never trust a side effect I didn't code
12 matches
Mail list logo