Structs and Variadic Functions
Kristian Kilpi
kjkilpi at gmail.com
Thu Dec 21 00:49:00 PST 2006
On Thu, 21 Dec 2006 07:46:14 +0200, Reiner Pope <xxxxxx at xxx.xx> wrote:
[snip]
> Unless I misunderstand you, it seems you are suggesting named
> parameters. Some other languages have this already (for example, OCaml),
> but it doesn't require structs to do this. You can pick up the names of
> parameters from the prototype, and we already have support for default
> parameters. All you need now is support for naming parameters at the
> call-site, for which your syntax seems perfectly suitable. Then, you
> could avoid variadic functions and structs and just write:
>
> FilePtr openFile(char[] filename, bool read=true, bool write=true,
> bool append=false, bool anotherParam=false) {...}
>
> int main(){
> openFile(filename : "asdf.txt", append : true);
> // Equivalent to openFile("asdf.txt", true, true, true, false);
> }
>
> Which is certainly a nice syntax feature to have.
>
> Cheers,
>
> Reiner
Yes, indeed. I guess named parameters have been suggested before (in this
NG)? Does Walter see it as a potential 2.0+ feature?
More information about the Digitalmars-d
mailing list