On Tuesday, 27 August 2013 at 21:51:48 UTC, Andrej Mitrovic wrote:
On 8/27/13, <[email protected]>"@puremagic.com <"\"Luís".Marques"> wrote:
     // Not OK
     int foo(int x, int y = x)
     {
         return x*y;
     }

Personally I think a much more useful feature would be (and this
doesn't block this feature but it's related to default arguments):

struct S
{
    void foo(int x = this.y)
    {
    }

    int y;
}

I used to do something similar to that in another language. Something like...

void toggle(bool newState = !this.state) { this.state = newState; }

A function that could set state to a given value, or toggle it if omitted. Then again, that language didn't have overloading at all.

Another example, but with more complex processing.
void speak(string msg, bool bypassMute = this.channel.isAdmin(this.username)) { ... }

Reply via email to