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-Thread: 103376,b98c6267042b1e47 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Variable list parameters Date: Mon, 26 Nov 2007 14:00:35 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <9e4ce016-d6ab-49de-b6f7-e46c59e047b1@t47g2000hsc.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1196103639 28615 192.74.137.71 (26 Nov 2007 19:00:39 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 26 Nov 2007 19:00:39 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:s5dadyRDgbApBGpEYDmziXUcdrk= Xref: g2news1.google.com comp.lang.ada:18637 Date: 2007-11-26T14:00:35-05:00 List-Id: "Steve" writes: > wrote in message > news:9e4ce016-d6ab-49de-b6f7-e46c59e047b1@t47g2000hsc.googlegroups.com... >> Does Ada have variable length parameter lists? >> >> i.e void printf (char *, ...) > > No. > > You can achieve similar results by making a variable length array and > passing the array as an parameter: > > type arg_array is array( Positive range <> ) of integer; > > procedure process_args( args : arg_array ) is > begin > null; > end process_args; > > ... > > process_args( ( 1, 2, 3 ) ); That works fine for integers, but if you want to pass Strings (a common case), it gets rather ugly! > If you need to have different argument types you can either make the > elements of the array tagged or variant types. An array of variant records works, so long as the discriminant has a default value. As for array of tagged, well, it has to be class-wide, and array-of-class-wide is illegal, so it has to be array-of-pointer-to-class-wide. - Bob