From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Variable list parameters
Date: Mon, 26 Nov 2007 14:00:35 -0500
Date: 2007-11-26T14:00:35-05:00 [thread overview]
Message-ID: <wccprxwsugc.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: w_udnZMiDO0dZNfanZ2dnUVZ_ryqnZ2d@comcast.com
"Steve" <nospam_steved94@comcast.net> writes:
> <shaunpatterson@gmail.com> 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
next prev parent reply other threads:[~2007-11-26 19:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-26 15:44 Variable list parameters shaunpatterson
2007-11-26 16:52 ` Steve
2007-11-26 18:44 ` tmoran
2007-11-26 19:00 ` Robert A Duff [this message]
2007-11-28 8:48 ` axtens
2007-11-28 20:21 ` amado.alves
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox