[fpc-pascal] Variable arguments, different types?

L505 fpc505 at z505.com
Thu Mar 9 17:48:02 CET 2006


----- Original Message -----
From: "Michael Van Canneyt" <michael at freepascal.org>
To: "FPC-Pascal users discussions" <fpc-pascal at lists.freepascal.org>
Sent: Thursday, March 09, 2006 9:36 AM
Subject: Re: [fpc-pascal] Variable arguments, different types?


>
>
> On Thu, 9 Mar 2006, L505 wrote:
>
> >
> >
> >>
> >>> I have also read people stating things like this before:
> >>>
> >>> "you can use array of const but you can't make functions like writeln
> >>> because writeln accepts multiple types".
> >>
> >> Usually the statement is about different _numbers_ of arguments, not
> >> different types. Writing subroutine which accept different types for
> >> their arguments has never been a problem in Pascal.
> >
> > I was talking specifically about array of const, not Pascal in general. The
docs
> > do not make it clear that array of const can accept different types in "one
> > call". We are talking purely about "array of const" here, not the Pascal
> > language in general. Of course I know the Pascal language can accept
multiple
> > types in one call.
> >
> >>
> >>> But in fact, with array of const, you can use multiple types.
> >>
> >> You can, just as you can use different types in record types.
> >> Still, the  actual argument type would be the type of the record or, as in
> >> your case "array of const" then. Don't confuse that.
> >
> > Well you are nitpicking my email :-). I'm not confused at all - the docs
are.
>
> As the author of the docs, I feel compelled to protest:
>
> "This is a special case of the Open array construction, where it is
> allowed to pass any expression in an array to a function or procedure."
>
> The "any expression" is the keyword here...
>
> But, to make it more explicit, I have added
> "Each element of the array can have a different type."
>
> And have added some examples where the elements have different types.


Sorry Michael, my emails sound a bit harsh some times. I was just wondering if
this was actually supposed to be possible? I don't think I've ever seen anyone
use this trick before. It's kind of like Perl. Dangerous, weak typing. I wonder
how slow it is since it is a run time check :-)




More information about the fpc-pascal mailing list