Article View: comp.lang.modula2
Article #1549Re: Oberon parameter passing
From: Larry Smith
Date: Wed, 07 Oct 1992 11:53
Date: Wed, 07 Oct 1992 11:53
27 lines
1890 bytes
1890 bytes
In article <1992Oct5.084755.8205@lhn.gns.cri.nz>, mdlcpgs@lhn.gns.cri.nz (Phil Scadden) writes:
>Returning to your example, I dont see a problem with
> PROCEDURE PrintString(VAR s : ARRAY OF CHAR);
> BEGIN
> (* print string here *)
> END PrintString.
I see a big problem with it, it refuses to accept PrintString("foo") unless
your compiler is willing to break type-checking the way you suggest. It is
furthermore non-portable, except to other Oberon compilers that implement
similar C semantics.
No matter how you cut it, "foo" is a constant and should not be passed to a
VAR parameter - even if it does have some internal address. The correct way
to implement this semantic is to always pass aggregate types as pointers and
to emit code at the begining of each routine to branch to the end, where
the compiler will be after noticing what parameters that were modified during
the compilation. These parameters can be copied onto the stack and the
argument pointer adjusted, and the routine started with a backwards jump to
the real begining of the routine. This allows one-pass compilation, removes
the necessity for aggregate copies where such copies are not needed to enforce
standard semantics.
Larry Smith (smith@ctron.com) No, I don't speak for Cabletron. Need you ask?
-
How about we all do something reasonable? I bet that'll confuse 'em!
Technical Details
Message-ID:
<5430@balrog.ctron.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!gatech!purdue!mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!balrog!ctron.comReferences:
<1992Oct01.203420.3612@bnr.ca> <1992Oct5.084755.8205@lhn.gns.cri.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!purdue!mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!balrog!ctron.com From: smith@ctron.com (Larry Smith) Newsgroups: comp.lang.modula2 Subject: Re: Oberon parameter passing Message-ID: <5430@balrog.ctron.com> Date: 7 Oct 92 11:53:00 GMT References: <1992Oct01.203420.3612@bnr.ca> <1992Oct5.084755.8205@lhn.gns.cri.nz> Sender: usenet@balrog.ctron.com Reply-To: smith@ctron.com Organization: Cabletron Systems, Inc. Lines: 27