comp.lang.ada
 help / color / mirror / Atom feed
* parameter passing
@ 1990-06-29 15:32 David Guaspari
  0 siblings, 0 replies; 11+ messages in thread
From: David Guaspari @ 1990-06-29 15:32 UTC (permalink / raw)


Here's why I asked whether it would be reasonable to assume that
parameters of the same type are passed in the same way.  My problem is
reasoning about the values of out or inout parameters of composite
types after exceptional exit.

There are useful, simple cases in which we know how to write the
intended programs (in a natural way) and convince ourselves that
they're correct.

1. Example: Consider 

  procedure add_item(comp: in out composite_type, i: item_type)

part of whose specification is

  If i is an inappropriate item, then raise the exception
  INAPPROPRIATE_ITEM and leave comp unchanged.

If comp is passed by copy, then this part of the specification is
satisfied free of charge, so (at least as far as the given spec is
concerned) we can safely reason about add_item under the assumption
that comp is passed by reference.

2. Generalizing the example: 

What the example really shows is that it's possible to reason easily
about *invariant properties* of writable composite parameters -- i.e.,
about specifications like

  (*)  If some_exception is raised then (in the resulting exit state) 
       comp still satisfies some_property_it_satisfied_on_entry

It takes modest care to formulate "comp still satisfies ..." correctly. 

3. Generalizing too far: 

I'm involved in designing a specification language for Ada programs.
It permits you to say things like (*), but not to state any other
kinds properties of the value of comp upon exceptional exit.
Naturally, we want the class of permitted invariant properties to be
as general as possible (so long as we can still reason about them
easily).  Under Ada's rules, we're going too far if we permit the
invariant to be a joint property of two writable parameters, e.g. (for
the case in which composite_type is an array type (or, in the second
case, an array type with discrete components))

    if comp1 and comp2 are permutations of one another upon entry,
    then they are still permutations of one another upon exceptional
    exit

or

    the lexicographic ordering of comp1 and comp2 is the same on
    exceptional exit as it was on entry

For specifications like these, we can safely pretend that comp1 and
comp2 are passed by reference only if we are entitled to assume that
they're passed by the same mechanism.  

Hence my question.


David Guaspari
oravax!davidg@cu-arpa.cs.cornell.edu
davidg%oravax.uucp@cu-arpa.cs.cornell

^ permalink raw reply	[flat|nested] 11+ messages in thread
* parameter passing
@ 2000-02-17  0:00 Riyaz Mansoor
  2000-02-18  0:00 ` Richard D Riehle
  2000-02-19  0:00 ` Ehud Lamm
  0 siblings, 2 replies; 11+ messages in thread
From: Riyaz Mansoor @ 2000-02-17  0:00 UTC (permalink / raw)




i want to pass a generic package as a parameter to another genric package.

eg:

with gen1_pack;
with gen2_pack;

procedure main is
    package gen1 is new gen1_pack;
    --how do i declare the gen2_pack with gen1 as a parameter?
begin
end;

also how would the code look like in gen2_pack which actually accepts the
gen1 package as a generic "paramter" ?

thanks


----------------------------------------------------







^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <1569@oravax.UUCP>]
* Parameter Passing
@ 1989-06-21 13:16 Jon Humphreys
  1989-06-21 17:23 ` William Thomas Wolfe,2847,
  0 siblings, 1 reply; 11+ messages in thread
From: Jon Humphreys @ 1989-06-21 13:16 UTC (permalink / raw)


I'm currently trying to learn Ada by translating a program written
in BASIC (my employer's choice, not mine), and I've got a fairly
fundamental question: when passing parameters from one package
to another, is it possible to simulate something like a FORTRAN
common block by placing variables in a package and then 
using the package whenever I need to access/modify the variables? For
example, consider the following hierarchy:

				main
				 | 
			--------------------
			|  		   |
			A		   B
					---|---
					|     |
(B, C, and D are a package)		C     D

If a set of variables were used in procedures A and D, would it
be possible to create a package containing these variables and 
then include them in procedure A and D? Or should all the variables
be declared in main and then passed as parameters to A and B, and then
from B to D (this seems inefficient)? I guess what I'm asking is, which 
way would be considered correct in Ada? (Currently, we don't even have a 
compiler, so there isn't any way for me to test this kind of thing.)

Thanks for any help, 

jon

^ permalink raw reply	[flat|nested] 11+ messages in thread
* parameter passing
@ 1986-10-08 18:56 Eric Marshall
  1986-10-10 16:46 ` Geoff Mendal
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Marshall @ 1986-10-08 18:56 UTC (permalink / raw)



	The LRM 6.2:6 says that access variables have to be
passed via copy-in. What benefit does this have for IN parameters?
How could a user detect if a compiler did not do this?

Thanks in advance.


Eric Marshall
System Development Corporation, a Burroughs Company
P.O. Box 517
Paoli, PA. 19301
(215) 648-7223

USENET: sdcrdcf!burdvax!eric
        {sjuvax,ihnp4,akgua,cadre}psuvax1!burdvax!eric
ARPANET: PAYTON@BBNG

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2000-02-19  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-06-29 15:32 parameter passing David Guaspari
  -- strict thread matches above, loose matches on Subject: below --
2000-02-17  0:00 Riyaz Mansoor
2000-02-18  0:00 ` Richard D Riehle
2000-02-19  0:00 ` Ehud Lamm
     [not found] <1569@oravax.UUCP>
1990-06-27 15:32 ` stt
1990-06-27 17:15 ` Michael Feldman
1989-06-21 13:16 Parameter Passing Jon Humphreys
1989-06-21 17:23 ` William Thomas Wolfe,2847,
1986-10-08 18:56 parameter passing Eric Marshall
1986-10-10 16:46 ` Geoff Mendal
1986-10-30 23:08   ` Mats_Ohlin_FOA2

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