[fpc-pascal] Variable arguments, different types?

Vinzent Hoefler JeLlyFish.software at gmx.net
Thu Mar 9 17:47:54 CET 2006


On Thursday 09 March 2006 16:23, L505 wrote:

> Well you are nitpicking my email :-).

Maybe. I'm known for doing that sometimes. I also even tend to write 
"SizeOf (byte)" instead of "1".

> I'm not confused at all - the docs are.

Are they?

"My" Free Pascal: Reference Guide states:

|10.3.6  Array of const

[...]

|Inside the procedure body, the array of const is equivalent to an open
|array of TVarRec:
|
|Procedure Testit (Args: Array of const);  
| 
|Var I : longint;  
| 
|begin  
[...]
|  For i:=0 to High(Args) do  
|    begin  
|    write ('Argument ',i,' has type ');  
|    case Args[i].vtype of  
|      vtinteger    :  
|        Writeln ('Integer, Value :',args[i].vinteger);  
|      vtboolean    :  
|        Writeln ('Boolean, Value :',args[i].vboolean);  
|      vtchar       :  
|        Writeln ('Char, value : ',args[i].vchar);  
|      vtextended   :  
|        Writeln ('Extended, value : ',args[i].VExtended^);  
|      vtString     :  
|        Writeln ('ShortString, value :',args[i].VString^);  
[...]

> All I was asking was why specifically in array of const's
> case, the docs did not make it clear I could pass multiple types in
> the same call. If you look in the examples in the docs page, all the
> examples show the programmer passing arguments of the same type in
> one call.

That's true. But looking at - for instance - SysUtils.Format should make 
it clear, that an "array of const" is not limited to that.

> They only make it clear that you can pass multiple types in separate
> calls, not in the same call.

So you propose, the examples and maybe the text

|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.
                 ^^^^^^^^^^^^^^

should be changed then? :-)

> > And you still can't just pass two arguments when the subroutine
> > expects only one
>
> Isn't this exactly what array of const is for? It allows you to use
> anywhere from 1 to unlimited parameters.

Yes. Still, it's only one argument. You can't just suddenly pass two 
"array of const", can you?


Vin"Nitpicker"zent.




More information about the fpc-pascal mailing list