comp.lang.ada
 help / color / mirror / Atom feed
* Procedure/function parameters
@ 1986-07-15 17:46 andy
  1986-07-19 19:46 ` richw
  0 siblings, 1 reply; 3+ messages in thread
From: andy @ 1986-07-15 17:46 UTC (permalink / raw)


Forgive my pascal-eze, but the following partial program is quite
difficult to implement in Ada(TM) without drastic changes.  Generics
don't work because both top level procedures have state; reinstantiating
either loses that state.  Passing a tag that says which procedure to
call (the enumeration scheme) doesn't work; the procedures being
passed are not visible to the called procedure (and besides, they
refer to variables of private types that the called procedure
shouldn't know about).

Notice how simple the procedure parameter solution is.  (I reused
names to discourage Ada implementations that change the scope of
various names.  A real program might use distinct names but still
want to maintain separate scopes.)

I recently wrote a compiler where I used procedure parameters
extensively because they allowed me to maintain local state.  Without
this local state, the program would not have been understandable.

procedure a (procedure b (procedure c));
type foo : <something>;
var bar : foo;

procedure c;
begin	{c}
<manipulate bar>
end;	{c}

begin	{a}
<init bar>
b(c);
<manipulate bar>
end;	{a}

procedure b;	{intential name reuse throughout}
type foo : <something>;
var bar : foo;

procedure c (procedure a);
begin	{c}
a;
<manipulate bar>
end;	{c}

begin	{b}
<init bar>
a(c);
<manipulate bar>
end;	{b}

-andy
decwrl!glacier!shasta!andy
andy@sushi.stanford.edu

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

end of thread, other threads:[~1986-07-22  0:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1986-07-15 17:46 Procedure/function parameters andy
1986-07-19 19:46 ` richw
1986-07-22  0:31   ` andy

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