🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #1482

Re: Oberon parameter passing

#1482
From: Martin Horneffer
Date: Mon, 05 Oct 1992 23:00
36 lines
1910 bytes
minyard@crchh453.bnr.ca (Corey Minyard) writes:

>However; will "Hello" be copied onto the stack?

Usually the string will have to be copied on the stack.
(Or, even worse, copied to a temporary object on the heap.)

>That seems very wasteful,
>but I don't see any other way around it.  I am writing an Oberon-2
>interpreter and I can't take this level of inefficiency.

This *really* is nasty.
Here come how the Oberon(-2)-compiler I use (Amiga-Oberon) solves the
problem:
there are Compiler-options that have a certain syntax and are put into
comments. This options allows to influence the creation of code in different
ways. One is to avoid the copying of ARRAY-parameters. If this is used in
a certain procedure, this procedure, of course, may not change this parameter.

Example:

    PROCEDURE PrintString(s : ARRAY OF CHAR); (* $CopyArrays- *)
    
This does exactly what you want and is still portable Oberon.
(I still think it's a bit ugly, since it somehow reminds me
of Turbo-Pascal...)

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.

Martin
-- 
  Martin Horneffer - maho@dfv.rwth-aachen.de;
      ECG 148        Fido: 2:242/7.9; Martin_Horneffer@mowgli.fido.de;
                     Maus: AC, AC2; Martin_Horneffer@ac.maus.de
Technical Details
Message-ID: <1992Oct5.230036.8066@dfv.rwth-aachen.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!know!cass.ma02.bull.com!think.com!sdd.hp.com!nigel.msen.com!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!dfv.rwth-aachen.de!maho
References: <1992Oct01.203420.3612@bnr.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!know!cass.ma02.bull.com!think.com!sdd.hp.com!nigel.msen.com!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!dfv.rwth-aachen.de!maho
From: maho@dfv.rwth-aachen.de (Martin Horneffer)
Newsgroups: comp.lang.modula2
Subject: Re: Oberon parameter passing
Keywords: Oberon, parameter passing
Message-ID: <1992Oct5.230036.8066@dfv.rwth-aachen.de>
Date: 5 Oct 92 23:00:36 GMT
References: <1992Oct01.203420.3612@bnr.ca>
Organization: Communication Networks
Lines: 36