www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7105] New: relax inout rules

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

           Summary: relax inout rules
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



Currently, DMD requires that the return type of a function that has
inout-qualified parameters is itself qualified with inout. Removing this
restriction would make the type system more expressive.

For example, the following function still requires code duplication to work for
multiple differently qualified parameters:

void copy(int** tgt, int* src){ *tgt = src; }
void copy(immutable(int)** tgt, immutable(int)* src){ *tgt = src; }
void copy(const(int)** tgt, const(int)* src){ *tgt = src; }

With the lifted restriction, these three overloads can be merged:

void copy(inout(int)** tgt, inout(int)* src){ *tgt = src; }


Also see the newsgroup discussion on the topic:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=151839

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 13 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com



Another use case is to support foreach on a container of arbitrary constancy,
by using

    int opApply(int delegate(ref inout(T)) dg) inout;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105




That is an enhancement of what is suggested here. It is not very clear that
inout should behave like that inside delegate/function pointer parameters.
Maybe it is best if you open another enhancement request that discusses your
design and its use cases in detail.

For example, what would be the meaning of the following declarations?

inout(int)[] delegate(inout(int)[] dg;
inout(int)[] foo(inout(int)[]delegate(inout(int)[] dg, inout(int)[] x){ ... }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105





 For example, what would be the meaning of the following declarations?
 
 inout(int)[] delegate(inout(int)[] dg;
 inout(int)[] foo(inout(int)[]delegate(inout(int)[] dg, inout(int)[] x){ ... }
Both of these would be syntax errors, because the brackets aren't matched. But I see the ambiguity now. Does the inout status belong to the delegate itself or to the function of which it is a parameter? If the signature of dg is invalid because it doesn't pass the inout status through, then in principle it could be taken to belong to the outer function. Which would be passing the inout status through to the delegate rather than as a return. I'll think about it and continue the discussion on the newsgroup. Stewart. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/735

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





 Another use case is to support foreach on a container of arbitrary constancy,
 by using
 
     int opApply(int delegate(ref inout(T)) dg) inout;
I think that the inout parameter contravariant (I've filed as issue 7542) is necessary due to enable such signatures. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105






 Another use case is to support foreach on a container of arbitrary constancy,
 by using
 
     int opApply(int delegate(ref inout(T)) dg) inout;
I think that the inout parameter contravariant (I've filed as issue 7542) is necessary due to enable such signatures.
And I've posted issue 7543. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105






 For example, what would be the meaning of the following declarations?
 
 inout(int)[] delegate(inout(int)[] dg;
 inout(int)[] foo(inout(int)[]delegate(inout(int)[] dg, inout(int)[] x){ ... }
Both of these would be syntax errors, because the brackets aren't matched. But I see the ambiguity now. Does the inout status belong to the delegate itself or to the function of which it is a parameter? If the signature of dg is invalid because it doesn't pass the inout status through, then in principle it could be taken to belong to the outer function. Which would be passing the inout status through to the delegate rather than as a return. I'll think about it and continue the discussion on the newsgroup.
digitalmars.D "inout and function/delegate parameters" On web interface: http://forum.dlang.org/thread/jhr0t6$24v6$1 digitalmars.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/98988d685d8fb16ebe05430c1dd8db5f799f1fe8


Issue 7105 - relax inout rules

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105




Commit pushed to master at
https://github.com/D-Programming-Language/d-programming-language.org

https://github.com/D-Programming-Language/d-programming-language.org/commit/ec215c4def669d8e5765328ee16e54eb876c66c3
Relax inout rule

It has been introduced by issue 7105 from 2.059. In current, an inout is not
necessary to appear in the return type.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 29 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7105




Commit pushed to staging at
https://github.com/D-Programming-Language/d-programming-language.org

https://github.com/D-Programming-Language/d-programming-language.org/commit/ec215c4def669d8e5765328ee16e54eb876c66c3
Relax inout rule

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