Thread overview
[Issue 9992] Default argument from member variable
Nov 21, 2013
yebblies
Nov 21, 2013
yebblies
November 21, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=9992


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com


--- Comment #1 from yebblies <yebblies@gmail.com> 2013-11-22 03:24:51 EST ---
Default arguments are evaluated at the call site... so I don't think this is necessarily wrong.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 21, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=9992


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #2 from bearophile_hugs@eml.cc 2013-11-21 08:31:01 PST ---
(In reply to comment #1)
> Default arguments are evaluated at the call site... so I don't think this is necessarily wrong.

I think the compiler should give errors for wrong code, even if the function is not yet called.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 21, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=9992



--- Comment #3 from yebblies <yebblies@gmail.com> 2013-11-22 03:43:23 EST ---
Hmm, this doesn't work either.

class Foo
{
    int a = 0;

    void bar(int x = a)
    {
    }
    void baz()
    {
        bar();
    }
}

void main()
{
    Foo f = new Foo();
    //f.bar();   -> does not complain with this commented out
}

They probably should be banned.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------