[Issue 6930] combined type of immutable(T) and inout(T) should be inout(const(T))

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 10 13:23:08 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6930



--- Comment #11 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-11-10 13:22:28 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > inout's primary focus is transferring the type modifier from the arguments to
> > the return type.  Merging it with a possible external immutable type is
> > secondary.
> > 
> > I think inout(const(T)) should resolve as we've discussed.  The enhancement is
> > that immutable(T) and inout(T) should be implicitly castable to
> > inout(const(T)).  
> 
> See specification of inout:
> http://d-programming-language.org/function.html
> 
> "The inout forms a wildcard that stands in for any of mutable, const or
> immutable. When the function is called, the inout of the return type is changed
> to whatever the mutable, const, or immutable status of the argument type to the
> parameter inout was."
> 
> If inout(const(T)) is parsed as const(T) then the inout does not form a
> wildcard that can stand for immutable. Contradiction with the language
> specification. That is a bug.

You may be misunderstanding me.  I agree this is a bug.  I'll try to be
clearer:

1. inout(const(T)) should resolve to const(T) or immutable(T) upon exit from
inout scope.  That it resolves to const(T) right now is a bug.

2. immutable(T) and inout(T) can legally implicitly cast to inout(const(T)). 
This is an enhancement.

-- 
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