Re: [BLACKBOX] Discussing IN is not 'Wasting time'

From: [at]} <CFB>
Date: Tue, 26 Feb 2008 11:55:01 +1030

----boundary-LibPST-iamunique-170808513_-_-
Content-type: text/plain

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Zinn, Helmut
> Sent: Tuesday, 26 February 2008 12:54 AM
> To: BLACKBOX{([at]})nowhere.xy
> Subject: [BLACKBOX] Discussing IN is not 'Wasting time'
>
>
> I apologize the "Wasting Time" and say thank you for your
> create help. I wrote a little test program (see below) and
> have the following comments:
>
> There a 3 different situation about IN
> 1. Using a simple variable as parameter
> 2. Using a record as parameter
> 3. Using a pointer as parameter
>
> In the example below I miss the compiling error inside Sub33
> (topic using a pointer). If there produce an error too then
> your solution is symmetrically and I'm satisfied.
>

Hi Helmut,

Thank you for your feedback. Your Sub33 example illustrates the question
that Aubrey McIntosh asked recently. My view is as follows:

  VAR
    pb: pBlock;

  PROCEDURE Sub33 (IN a: pBlock);
  BEGIN
    NEW(a); (* is a compiling error *)
    a := pb; (* is a compiling error *)
    a.i := 3; (* is not a compiler error - a itself has not changed *)
  END Sub33;

This is consistent (and, admittedly, similarly confusing) with the existing
behaviour of value parameters:
 
  PROCEDURE Sub33 (a: pBlock);
  BEGIN
    a.i := 3
  END Sub33;

In both cases, the change made to the global value of a.i persists after
exit from the procedure.

Unfortunately, IN parameters only make pointers marginally less risky than
they are already. Working with pointers is like working with reals. The
programmer needs to have a real good understanding of what they are doing.

Regards,
Chris

Chris Burrows
CFB Software
http://www.cfbsoftware.com/cp


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-170808513_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXG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.0 : Thu Sep 26 2013 - 06:31:00 UTC