www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12189] New: "out" parameters should be allowed to modify immutable values in ctors

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12189

           Summary: "out" parameters should be allowed to modify immutable
                    values in ctors
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com


--- Comment #0 from Vladimir Panteleev <thecybershadow gmail.com> 2014-02-18
03:56:13 EET ---
void initialize(out string[] v) { v = ["Hi!"]; }

immutable string[] s;

shared static this()
{
    s = ["Hi!"];   // OK
    initialize(s); // NG
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12189


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr gmx.ch


--- Comment #1 from timon.gehr gmx.ch 2014-02-18 04:08:29 PST ---
string[]* ms;

void initialize(out string[] v){
    v = ["Hi!"];
    ms = &v; // oops
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12189


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2014-02-18 20:10:06 PST ---
As Timon shows, accepting variable initialization via out parameter will make a
hole in type system, because out parameter should have mutable type.

So this is impossible enhancement.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12189



--- Comment #3 from Vladimir Panteleev <thecybershadow gmail.com> 2014-02-19
06:46:46 EET ---
Thanks, I didn't think about that.

If "out" did not allow escaping references then I guess it would be different.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12189


bearophile_hugs eml.cc changed:

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


--- Comment #4 from bearophile_hugs eml.cc 2014-02-19 01:10:59 PST ---
(In reply to comment #3)

 If "out" did not allow escaping references then I guess it would be different.

"scope out"? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 19 2014