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

Daniël Mantione daniel.mantione at freepascal.org
Mon Oct 2 16:28:21 CEST 2006



Op Mon, 2 Oct 2006, schreef ik:

> > > > 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. :(

No, but you can pass a pointer to them. That simply wouldn't fit, i.e. 
blow up the size of the record. You can't pass arrays or records in C 
either, right?

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

Well, you can get it enabled in fpc mode if want. For the rest, it was 
exactly the intention to invent a safe mechanism that doesn't allow you to 
destroy your stack with a simple typo.

If we would code a variable number of parameters, that will only be a 
syntactic alternative for the same construction.

Daniël


More information about the fpc-devel mailing list