October 13, 2008 Re: equivariant functions | ||||
|---|---|---|---|---|
| ||||
Andrei Alexandrescu Wrote:
> Denis Koroskin wrote:
> > class Storage
> > {
> > sameconst(Foo) foo() sameconst(this) // const, invariant or none
> > {
> > return _foo;
> > }
> >
> > private Foo _foo;
> > }
> >
> > Your version?
>
> class Storage
> {
> typeof(this._foo) foo() const { return _foo; }
> }
>
In this example signature (interface) explicitly depends on private field (implementation). I just tried to imagine how to document its return type.
| ||||
October 13, 2008 Re: equivariant functions | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ore-sama | ore-sama wrote:
> Andrei Alexandrescu Wrote:
>
>> Denis Koroskin wrote:
>>> class Storage { sameconst(Foo) foo() sameconst(this) // const,
>>> invariant or none { return _foo; }
>>>
>>> private Foo _foo; }
>>>
>>> Your version?
>> class Storage { typeof(this._foo) foo() const { return _foo; } }
>>
>
> In this example signature (interface) explicitly depends on private
> field (implementation). I just tried to imagine how to document its
> return type.
That's a good point.
Andrei
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply