September 02, 2006 Re: Some more template syntax sugar | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> 2) Nameless parameters come up an awful lot in C/C++ header files - I think they're expected.
I thought of that one, and since you want D to work in the same way as C and C++ when the syntax is the same, I figure you must keep nameless parameters working in the way they do.
That means that we need a modified typeless parameter syntax. I'm not sure which keywords and operators are available, but I think that @ isn't used. How about just sticking a @ into the syntax for typeless parameters to make it unambiguous.
auto foo(@x, @y, int) // x and y are typeless parameters, and the third paremeter is nameless.
Cheers,
Reiner
|
September 02, 2006 Re: Some more template syntax sugar | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Sat, 02 Sep 2006 13:14:31 -0700, Walter Bright wrote: > Reiner Pope wrote: >> Thoughts, anyone? > > 1) Lots of people like nameless parameters to implicitly document that the parameter isn't used. And lots of people like named parameters to explicitly document the meaning of the parameters. > 2) Nameless parameters come up an awful lot in C/C++ header files - I think they're expected. So what? This is D and not C/C++. If one is going to use a new language then one should be prepared to learn a few new things too. -- Derek Parnell Melbourne, Australia "Down with mediocrity!" |
September 04, 2006 Re: Some more template syntax sugar | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > On Sat, 02 Sep 2006 13:14:31 -0700, Walter Bright wrote: > >> Reiner Pope wrote: >>> Thoughts, anyone? >> 1) Lots of people like nameless parameters to implicitly document that the parameter isn't used. > > And lots of people like named parameters to explicitly document the meaning > of the parameters. It would be better to be able to explicitly document that the parameter isn't used. Maybe by reusing the 'null' keyword. int somefunc(int x, uint null) { } > >> 2) Nameless parameters come up an awful lot in C/C++ header files - I think they're expected. > > So what? This is D and not C/C++. If one is going to use a new language > then one should be prepared to learn a few new things too. It would add a lot more pain to converting C header files to D. For example, the Win32 API project, would require over ten thousand changes. |
Copyright © 1999-2021 by the D Language Foundation