[BLACKBOX] Variable IN parameters !

From: Campbell, Robert (SELEX GALILEO, UK) <robert.d.campbell{([at]})nowhere.xy>
Date: Mon, 6 Aug 2012 14:04:30 +0000

Hello

After the first line box.k is 17. Then a call to 'Salt' changes it to 5 even though box is
an IN parameter, which I thought meant that it could not be changed.

(If box contained POINTERs I knew that the things pointed to could be changed, but
I thought that the (*direct*) contents of box should be read-only.)

Is this a bug? - or just a trap for the unwary?


Regards

Robert



MODULE RdcTestOne;

IMPORT StdLog;

TYPE
  Box = RECORD
            k : INTEGER
          END;

PROCEDURE (VAR box : Box) Pepper, NEW;
  BEGIN
    box.k := 5
  END Pepper;

PROCEDURE (IN box : Box) Salt, NEW;
  BEGIN
    box.Pepper
  END Salt;

PROCEDURE Do*;
  VAR
    box : Box;
  BEGIN
    box.k := 17; StdLog.Int (box.k); StdLog.Ln;
    box.Salt; StdLog.Int (box.k); StdLog.Ln
   END Do;

END RdcTestOne.

SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy




Received on Mon Aug 06 2012 - 16:04:30 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:00 UTC