----boundary-LibPST-iamunique-1350785153_-_-
Content-type: text/plain
> -----Original Message-----
> From: Hof, Philipp [mailto:p.hof{([at]})nowhere.xy> Sent: Friday, 1 October 2004 10:38 AM
> To: 'blackbox{([at]})nowhere.xy> Subject: Are local variables initialised?
>
>
> Hi all,
>
> In C local variables are not initialised.
> In C local structs are therefore often initialised with a macro like:
>
> ZeroMemory(&my_struct, sizeof(MY_STRUCT));
>
> How about Component Pascal? Are local variables, records
> (untagged) in Component Pascal initialised to zero by default?
>
Philipp,
The short answer to your question is no - with a couple of exceptions.
The initialisation of variables in Component Pascal is defined in
several sections of the Language Report:
-------------------------------------------------------
6.4 Pointer Types
All fields or elements of a newly allocated record or array are cleared,
which implies that all embedded pointers and procedure variables are
initialized to NIL.
10. Procedure declarations
Local variables whose types are pointer types or procedure types are
initialized to NIL before the body of the procedure is executed.
10.1 Formal Parameters
Like local variables, output parameters of pointer types and procedure
types are initialized to NIL. Other output parameters must be considered
as undefined prior to the first assignment in the procedure.
11. Modules
Variables declared in a module are cleared prior to the execution of the
module body. This implies that all pointer or procedure typed variables
are initialized to NIL.
-------------------------------------------------------
The Miscellaneous section in the What's New in Component Pascal document
specifically answers your question:
"Global variables, including heap variables allocated with NEW, now have
a defined initial value (FALSE, 0X, 0, 0.0, {}, NIL, ""). Local (i.e.,
stack) variables are not initialized, except for pointers and procedure
variables which are set to NIL for safety reasons."
-------------------------------------------------------
Regards,
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp
--------------------------------------------
To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
blackbox-request{([at]})nowhere.xy
To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.
Send any problem reports or questions related to this email list to the list owner at
owner-blackbox{([at]})nowhere.xy
Current posting policy:
a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.
b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.
----boundary-LibPST-iamunique-1350785153_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS1c
cGFyDQo+IEZyb206IEhvZiwgUGhpbGlwcCBbbWFpbHRvOnAuaG9mQGVsZWMuY2FudGVyYnVyeS5h
Yy5uel0gXHBhcg0KPiBTZW50OiBGcmlkYXksIDEgT2N0b2JlciAyMDA0IDEwOjM4IEFNXHBhcg0K
PiBUbzogJ2JsYWNrYm94QG9iZXJvbi5jaCdccGFyDQo+IFN1YmplY3Q6IEFyZSBsb2NhbCB2YXJp
YWJsZXMgaW5pdGlhbGlzZWQ/XHBhcg0KPiBccGFyDQo+IFxwYXINCj4gSGkgYWxsLFxwYXINCj4g
XHBhcg0KPiBJbiBDIGxvY2FsIHZhcmlhYmxlcyBhcmUgbm90IGluaXRpYWxpc2VkLlxwYXINCj4g
SW4gQyBsb2NhbCBzdHJ1Y3RzIGFyZSB0aGVyZWZvcmUgb2Z0ZW4gaW5pdGlhbGlzZWQgd2l0aCBh
IG1hY3JvIGxpa2U6XHBhcg0KPiAgXHBhcg0KPiBaZXJvTWVtb3J5KCZteV9zdHJ1Y3QsIHNpemVv
ZihNWV9TVFJVQ1QpKTtccGF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