From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!mnetor!seismo!caip!nike!oliveb!glacier!Shasta!andy From: andy@Shasta.UUCP Newsgroups: net.lang.ada Subject: Procedure/function parameters Message-ID: <679@Shasta.STANFORD.EDU> Date: Tue, 15-Jul-86 13:46:40 EDT Article-I.D.: Shasta.679 Posted: Tue Jul 15 13:46:40 1986 Date-Received: Wed, 16-Jul-86 08:55:09 EDT Reply-To: andy@Shasta.UUCP (Andy Freeman) Organization: Stanford University List-Id: 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 : ; var bar : foo; procedure c; begin {c} end; {c} begin {a} b(c); end; {a} procedure b; {intential name reuse throughout} type foo : ; var bar : foo; procedure c (procedure a); begin {c} a; end; {c} begin {b} a(c); end; {b} -andy decwrl!glacier!shasta!andy andy@sushi.stanford.edu