🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #1486

Re: Array parameter passing

#1486
From: Bill Seurer
Date: Tue, 06 Oct 1992 13:44
28 lines
1974 bytes
In article <1arv24INN3nl@swan.doc.ic.ac.uk>, iwm@doc.ic.ac.uk (Ian W Moor) writes:
|> |> Example:
|> |> 
|> |>     PROCEDURE PrintString(s : ARRAY OF CHAR); (* $CopyArrays- *)
|> |>     
|> |> Another solution would be to make to Compiler intelligent enough to see that
|> |> the ARRAY ist not changed in the procedure and then chose this option 
|> |> automatically.
|> |> 
|> 
|> Getting the compiler to do it right is much the best way ! What happens if
|> you disable array copying and then later by mistake you modify the procedure 
|> to change the string ?

We extended our compiler with a 3rd procedure parameter type, REF.  REF
parameters are pass-by-reference just like VAR except that the value
can't be modified.  For expressions and constants whose address can't be
taken a temporary variable is created and its address is passed.

This makes a tremendous difference in performance for some code and
especially for open arrays.

I have seen similar things in Pascal compilers (often called CONST or
somesuch).
-- 

- Bill Seurer     Language and Compiler Development      IBM Rochester, MN
  Internet: BillSeurer@vnet.ibm.com    America On-Line: BillSeurer@aol.com
Technical Details
Message-ID: <1992Oct06.134428.22883@rchland.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!ukma!gatech!news.ans.net!newsgate.watson.ibm.com!yktnews!admin!nordruth!seurer
References: <1992Oct01.203420.3612@bnr.ca> <1992Oct5.230036.8066@dfv.rwth-aachen.de> <1arv24INN3nl@swan.doc.ic.ac.uk>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!ukma!gatech!news.ans.net!newsgate.watson.ibm.com!yktnews!admin!nordruth!seurer
From: seurer@rchland.vnet.ibm.com (Bill Seurer)
Subject: Re: Array parameter passing
Sender: news@rchland.ibm.com
Message-ID: <1992Oct06.134428.22883@rchland.ibm.com>
Date: Tue, 06 Oct 1992 13:44:28 GMT
Reply-To: BillSeurer@vnet.ibm.com
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
References: <1992Oct01.203420.3612@bnr.ca> <1992Oct5.230036.8066@dfv.rwth-aachen.de> <1arv24INN3nl@swan.doc.ic.ac.uk>
Nntp-Posting-Host: nordruth.rchland.ibm.com
Organization: IBM Rochester
Keywords: Oberon, parameter passing
Lines: 28