transporting qualifier from parameter to the return value
Kagamin
spam at here.lot
Wed Dec 16 04:40:38 PST 2009
Walter Bright Wrote:
> Unmentioned in the proposal is is inout a type constructor or a storage
> class? For example,
>
> U[inout(T)]* foo(inout(X)*** p) { ... }
>
> This is much more complex to implement than only allowing inout at the
> top level, i.e. as a storage class.
It's a type constructor just like const and immutable. As to your example, imagine inout expands as follows
U[T]* foo(X*** p) { ... }
U[const(T)]* foo(const(X)*** p) { ... }
U[immutable(T)]* foo(immutable(X)*** p) { ... }
If this works, then it's ok.
Giving it a quick thought, it should work.
> I also prefer the idea of inout on the return type being assumed, rather
> than explicit:
>
> T foo(inout U p) { ... }
Given inout is a type constructor, it's critical for type safety to properly decorate return type: T is mutable and can't play role of inout-qualified type.
More information about the Digitalmars-d
mailing list