[Issue 7198] Delegate literals with nameless arguments fail to infer a type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 2 09:09:08 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7198
--- Comment #7 from Jacob Carlborg <doob at me.com> 2012-01-02 09:09:00 PST ---
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > (I don't actually know why we have unnamed parameters at all; most modern
> > > languages simply don't allow this. In addition, unused parameters in
> > > delegate/function literals/lambdas sort of seems to go against the entire idea
> > > with lambda functions, in the general case.)
> >
> > Useful situations for unnamed parameters:
> >
> > * Declaring a delegate type
> >
> > void delegate (int) dg;
>
> But that's a type signature, not a literal.
Oh, yeah, right.
> >
> > * Declaring a function/method without implementation
> >
> > void foo (int);
>
> This, on the other hand, I do not like. Without a parameter name, you have to
> look at the implementation to have a clue what it means. That makes the
> declaration (more or less) useless.
I've seen it a lot when declaring C functions. There won't be an implementation
(at least not in your code) and you're relying on the documentation for the C
library.
> >
> > * Overriding/implementing a method where a parameter isn't needed
> >
> > class Foo {
> > abstract void foo (int a);
> > }
> >
> > class Bar : Foo {
> > void foo (int) {}
> > }
> >
>
> Point taken, though naming it _ or similar usually works.
That will only work for one argument.
> >
> > These are the situations I see it as might being useful but I would say that
> > adding names to the parameters adds documentation and that's always a good
> > thing.
>
> Agreed.
Note that I'm not against this idea. Just pointing out how/when it can be used.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list