Re: static alias this and if/do/while/for

2020-10-26 Thread Q. Schroll via Digitalmars-d-learn
On Thursday, 22 October 2020 at 21:55:59 UTC, Jack Applegame wrote: There is a funny feature (or bug) in the D language: static alias this and static operator overloading. For example interface Foo { static { int value; void opAssign(int v) { value = v; } int get

Re: static alias this and if/do/while/for

2020-10-26 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Thursday, 22 October 2020 at 21:55:59 UTC, Jack Applegame wrote: Now we can use type Foo as if it were an lvalue/rvalue: Foo = 5; int a = Foo; int b = Foo + a; Haha, that's pretty neat!

static alias this and if/do/while/for

2020-10-22 Thread Jack Applegame via Digitalmars-d-learn
There is a funny feature (or bug) in the D language: static alias this and static operator overloading. For example interface Foo { static { int value; void opAssign(int v) { value = v; } int get() { return value; } alias get this; } } Now we can use

Re: static alias this

2015-02-07 Thread Ali Çehreli via Digitalmars-d-learn
On 02/07/2015 04:46 AM, Mike wrote: > B)- > struct StaticRegister { > static private uint _value; > @property static uint value() { return _value; } > @property static void value(uint v) { _value = v; } > > alias value this; > } > > void

Re: static alias this

2015-02-07 Thread jkpl via Digitalmars-d-learn
Another try E)--- struct StaticRegister { static private uint _value; @property static uint value() { return _value; } @property static void value(uint v) { _value = v; } static uint opCall(){return _value;} alias _value this; } void ma

static alias this

2015-02-07 Thread Mike via Digitalmars-d-learn
Consider this simple example A)- struct StaticRegister { static private uint _value; @property static uint value() { return _value; } @property static void value(uint v) { _value = v; } } void main(string[] s) { StaticRegister = 1; asser