comp.lang.ada
 help / color / mirror / Atom feed
From: andy@Shasta.UUCP
Subject: Procedure/function parameters
Date: Tue, 15-Jul-86 13:46:40 EDT	[thread overview]
Date: Tue Jul 15 13:46:40 1986
Message-ID: <679@Shasta.STANFORD.EDU> (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

             reply	other threads:[~1986-07-15 17:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1986-07-15 17:46 andy [this message]
1986-07-19 19:46 ` Procedure/function parameters richw
1986-07-22  0:31   ` andy
replies disabled

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