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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,15ce2ff6360d2b58 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-15 16:22:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread1.news.atl.earthlink.net.POSTED!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Newbie question:procedural variables(call by reference)? References: <3F65EBF4.7CF3@mail.ru> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 15 Sep 2003 23:22:29 GMT NNTP-Posting-Host: 65.110.133.134 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.atl.earthlink.net 1063668149 65.110.133.134 (Mon, 15 Sep 2003 16:22:29 PDT) NNTP-Posting-Date: Mon, 15 Sep 2003 16:22:29 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:42547 Date: 2003-09-15T23:22:29+00:00 List-Id: Dmytry Lavrov writes: > There are no procedural variables(calls by reference) in Ada,right? > (or I missed something...) Yes, there are procedure variables in Ada95: type Procedure_Access is access procedure (I : Integer); type Function_Access is access function (I : Integer) return Float; > How to live without 'em? (i guess , 'like in java' ;-) You don't have to, but you have procedure pointers in Ada95. However, you probably don't need them. Instead, you'll probably want to use a "generic formal subprogram," like this: generic with procedure Process (I : Integer) is <>; procedure Generic_Op; To call Op, you must "instantiate" it, and supply the procedure a the "generic actual argument," like this: procedure Process (I : Integer) is ...; procedure Op is new Generic_Op (Process); Now you can call Op, and it will call Process. > What for example if I have wrote, say.... expression evaluator. In > Pascal(bit extended), and with way to add custom functions, like > > procedure AddFunc > (name:string; > numparams:integer; > additionalparam:machine_word; > fn:CustomFunction); You could use a function pointer here, but you probably don't want to. To convert this to Ada95, to this: generic with procedure Custom_Function (O : T) is <>; procedure Generic_AddFunc (Name : String; NumParams : Integer; AdditionalParam : Integer_32); You first have to instantiate Generic_AddFunc, and supply an actual Custom_Function. Something like: procedure Do_Something (O : T); procedure AddFunc is new Generic_AddFunc (Do_Something); > How I can move it to Ada....(of course I know that it's sometimes > better to do all with OOP, but here is much simpler to have array with > references, than doing crazy extensible objects). See above. > Why peoples sometime talking about OS in ada?...it's inpossible w/o call > by reference,OOP is based on call by reference,right?. Yes, OOP is done with call-by-reference. Tagged types in Ada95 are passed by reference, so dispatching works.