- Hardware and DLL interfacing in BlackBox
----boundary-LibPST-iamunique-903506249_-_-
Content-type: text/plain
On Mon, 21 Feb 2005, CFB Software wrote:
> An excellent presentation!
Thank you, I appreciate. I will keep adding to it ;-)
> I don't believe that this (i.e. ".NET is beta") was true even back in
> February 2004. It certainly is not true now.
I stand corrected. I will change the slide accordingly.
> 2. Slide 44 of 90:
>
> I believe the advice to use the statement
>
> arr := NIL;
>
> is misguided and the results are potentially dangerous.
Not sure why misguided? I do not see how it is dangerous.
Please tell me me why it is dangerous?
> The whole point
> of garbage collection is to let the system, rather than the programmer,
> decide when it is safe to reclaim memory.
I definitely agree....
> Assigning NIL to pointers is
> essentially the same as "de-allocating by hand" and as unsafe as using
> Dispose (or its equivalent) always was.
I agree on one and disagree on the other account.
(1) Assigning a NIL to a pointer is indeed "essentially the same as
de-allocation by hand", in the sense that it make the variable
inaccessible and thus disappear from the sight (if that was the last
reference to that variable). This will eventually trigger garbage
collection, though exact point in time when the GC is called is
not exactly specified.
(2) Assigning a NIL to a pointer is "not as unsafe as using Dispose".
Au contraire, it is safe.
The language report says in appendix D "Memory cannot be deallocated
manually", but it does not say that one cannot or should not assign
NIL to a pointer.
The run-time intergrity rests on the following invariant: either the
variable "arr" is pointing to a variable of a proper type, in which case
it can be dererenced and used, or it points to NIL, in which case it
also can be dereferenced, what however will trigger a TRAP. We need
to agree that a TRAP is permissible, though not pleasant. The run-tme
integrity is not compromised by TRAPs. In other words, TRAPs are safe
for the run-time system, though not necessarily safe for your accounts
receivable. (BlackBox only guarantees the first kind of safety.)
The variable "arr" can thus transition between two states, both of
which are safe and legal: state #1 in which it points to NIL,
and a state #2 in which it points to a variable of a proper type,
operations on which are programmatically safe.
The integrity of the run-time is guaranteed by the semantics of the
assignment operator ":=" or a NEW operator (NEW is a special case
of ":=") that both perform transitions from one safe state
to another safe state of the variable.
The run-time inegrity is potentially compromised by SYSTEM-level
assignments to "arr". One can do such unsafe assignments with SYSTEM.VAL
and SYSTEM.ADR. After using the SYSTEM the state of "adr" may no longer be
legal, and the run-time may crash. The SYSTEM-level programming is as
unsafe as C/C++, what is clearly stated in the documentation.
However, as long as we we do not use SYSTEM, the CPascal syntax and
compiler guarantee that we only transition between legal and safe states.
The assignment "arr := NIL" is therefore safe and cannot lead to system
instability down the road, though it may lead to TRAPs.
W.
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-903506249_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIE9uIE1vbiwgMjEgRmViIDIwMDUsIENGQiBTb2Z0
d2FyZSB3cm90ZTpccGFyDQpccGFyDQo+IEFuIGV4Y2VsbGVudCBwcmVzZW50YXRpb24hXHBhcg0K
XHBhcg0KVGhhbmsgeW91LCBJIGFwcHJlY2lhdGUuIEkgd2lsbCBrZWVwIGFkZGluZyB0byBpdCA7
LSlccGFyDQpccGFyDQo+IEkgZG9uJ3QgYmVsaWV2ZSB0aGF0IHRoaXMgKGkuZS4gIi5ORVQgaXMg
YmV0YSIpIHdhcyB0cnVlIGV2ZW4gYmFjayBpblxwYXINCj4gRmVicnVhcnkgMjAwNC4gSXQgY2Vy
dGFpbmx5IGlzIG5vdCB0cnVlIG5vdy5ccGFyDQpccGFyDQpJIHN0YW5kIGNvcnJl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MgdGhlcmVm
b3JlIHNhZmUgYW5kIGNhbm5vdCBsZWFkIHRvIHN5c3RlbVxwYXINCmluc3RhYmlsaXR5IGRvd24g
dGhlIHJvYWQsIHRob3VnaCBpdCBtYXkgbGVhZCB0byBUUkFQcy5ccGFyDQpccGFyDQpXLlxwYXIN
ClxwYXINCi0tLSBCbGFja0JveFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlND
UklCRSB0byBibGFja2JveEBvYmVyb24uY2h9fQAuY2gNClNlbmRl
----boundary-LibPST-iamunique-903506249_-_---
Received on Mon Feb 21 2005 - 22:08:26 UTC
This archive was generated by hypermail 2.3.0
: Thu Sep 26 2013 - 06:28:23 UTC