Make dur a property?

anonymous anonymous at example.com
Wed Jan 23 15:11:14 PST 2013


On Wednesday, 23 January 2013 at 22:07:20 UTC, anonymous wrote:
> alias int delegate() C;
> C c;
> auto noprop() {return c;}
> void noprop(C v) {c = v;}
> @property auto prop() {return c;}
> @property void prop(C v) {c = v;}

> && is(typeof( {return noprop;}() ) == C) /* fails with 
> -property. that's goofy */
Actually, this may be alright; have to be explicit with 
non-properties. Just don't apply that rule to UFCS.

Some more:

static assert(
    is(typeof( noprop(c)          )) /* of course */
&& is(typeof( prop(c)            )) /* should error */
);

void noprop(C, int);
@property void prop(C, int);

static assert(
    is(typeof( {c.noprop;}        )) /* fails with -property, 
should work, is explicit enough */
&& is(typeof( {c.prop;}          )) /* should error */

&& is(typeof( {c.noprop();}      )) /* ok */
&& is(typeof( {c.prop();}        )) /* should error */

&& is(typeof( {c.noprop(0);}     )) /* ok */
&& is(typeof( {c.prop(0);}       )) /* should error */

&& is(typeof( {c.noprop = 0;}    )) /* fails with -property, 
alright */
&& is(typeof( {c.prop = 0;}      )) /* ok */
);


More information about the Digitalmars-d mailing list