comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Parameters in Sub
Date: Fri, 21 Sep 2001 16:37:19 GMT
Date: 2001-09-21T16:37:19+00:00	[thread overview]
Message-ID: <31Kq7.9078$p77.31214@www.newsranger.com> (raw)

In article <9ofn8h$m0v$1@reader1.fr.uu.net>, Marc says...
>
>Hello,
>I will want to know: modes OUT and IN OUT, in a procedure, show all the 2
>clearly a passage of parameters by " address " (of the variable). I have a
>doubt about what one call the passage " by reference "
>I associated it  IN OUT has this type of passage. Is this well that. Then
>the passage by " value " designe it IN, the passage by " address " designe
>the OUT??? Thank you for your answers.

This is a bit hard to decipher, but it looks like you are asking when/if "OUT"
and "IN OUT" use reference passing, and when they use value. The quick answer is
"it depends".

A slightly more complete answer is that there are some situations where the
language specifies reference passing, but in all other situations it is up to
the compiler. In those cases you can trust that the compiler will do what is
most efficient (eg: reference whenever the value would be too big to fit in a
register), but you *must* not make your code depend on the mode by taking
addresses of parameters or assuming two parameters of the same type are
different objects. 

For a complete answer, I suggest you either read the relevant LRM sections or
get a good Ada book that covers this subject. There are some situations where it
is useful to know which is done. But if you are an Ada beginner, the best rule
is to just assume that the compiler knows what it is doing, and do not write
your code in such a way that proper operation depends on one method or the
other. Whatever you do, do *not* look to pass around addresses with the
misguided assumption that it will be quicker.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



             reply	other threads:[~2001-09-21 16:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-21 16:37 Ted Dennison [this message]
2001-09-21 18:28 ` Parameters in Sub Jeffrey Carter
  -- strict thread matches above, loose matches on Subject: below --
2001-09-21 15:13 Marc
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox