[fpc-devel] va(r)_arg vs open array

ik idokan at gmail.com
Mon Oct 2 15:57:15 CEST 2006


On 10/2/06, Daniël Mantione <daniel.mantione at freepascal.org> wrote:
>
>
> Op Mon, 2 Oct 2006, schreef ik:
>
> > Hi,
> >
> > I'm wondering why Pascal as a language (and FPC with it's extensions)
> > does not support va_args (or var_args in the java language).
>
> It does: array of const. If you declare a procedure cdecl it is even
> binary compatible with a C varargs.
>
> > Now we have open array, that's a really cool thing, but I can't
> > understand why I can't have a feature such as the compiler voodoo
> > magic of the "write" procedure.
>
> Syntactically you cannot. However, the array of const is just as powerfull
> (actually more powerfull, since you can pass multiple arrays). We consider
> adding a trick to make it syntactically behave like writeln unnecessary.

But in vtype I can't know if I got array or not, and I can't know if
that's a record. :(

>
> > At the moment, I try to create an OS (it's hard to even think of it as
> > one at the moment, it will take a lot of time until it will be
> > something close to an OS) with FPC, and when compiling the system unit
> > again, I really missing it, and open arrays are just not "that" ...
> >
> > I can give a list of pros about it, but I rather hear the pros and the
> > cons from other first (maybe me and others will accept it) so what are
> > the cons you see about it, and are there any pros that might be able
> > to make it possible to add such feature to FPC ?
>
> Show the problem with array if const first :)

Lets start from the pity ones to the real problems :)

1. It's not a va_args.
2. The usage of [].
3. Even empty parameter must have [] instead of not calling it. It's
like C that must have empty () when calling a function ...
4. I can't add default values to that type of parameter.
5. Feel like an hack.
6. Try to explain that to a C developer... it easier to bash your head
against the wall
7. Require delphi/objfpc modes.
8. Have a record inside that tells you the type of the parameter (that
is also a pro as much as it con)
9. I feel like it limiting the type of usage I can do with it because
it support only "basic" types of parameters (according to the example
in the documentation:
http://www.freepascal.org/docs-html/ref/refsu47.html#x113-12000010.3.6).
10. I feel that there is not enough documentation about it.

(Hey I promised some pity reasons ;))

There might be probably more reasons why not to use open arrays, but I
can't think on more at the moment.

>
> Daniël
>

Ido


More information about the fpc-devel mailing list