[fpc-pascal] Re: Initializing Records Automatically
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Mar 24 12:02:32 CET 2008
On 24 Mar 2008, at 12:53, L wrote:
> So a record with an ansistring and an integer.. for example even
> local scope..
>
> Will be all zeros?
>
> procedure test;
> var somerec: Tsomerec;
> begin
> // these checks are okay?
> if somerec.astring = '' if somerec.someint = 0
>
> end;
>
> i.e. above is not random data?
The ansistring is initialised on entry, the someint is not. The reason
that refcounted fields simply have to be initialised, is that
otherwise you'd get a crash as soon as you'd try to assign something
to them (since an assignment is basically "increfcount(source);
decrefcount(target); pointer(target):=pointer(source)", which would go
horribly wrong if target could contain garbage).
Jonas
More information about the fpc-pascal
mailing list