Error: incompatible types for 'shared(SysTime)' and 'shared(SysTime)'

Arafel er.krali at gmail.com
Fri Sep 14 09:15:45 UTC 2018


On 09/13/2018 06:59 PM, ag0aep6g wrote:
> On 09/13/2018 03:25 PM, Arafel wrote:
>>          // How can we update the timestamp? Neither of those work
>>          timestamp = Clock.currTime;
>>          timestamp = cast(shared) Clock.currTime;
> 
> cast() timestamp = Clock.currTime;

Still not there... it doesn't work with ref parameters (and probably 
other things, like AAs, or at least nested AAs / arrays):

```
import std.stdio;
import std.datetime.systime;
import core.time;

void foo(ref SysTime t) {
     t += 1.dur!"minutes";
}

shared synchronized class A {
     private SysTime s;

     this() {
         cast ()s = Clock.currTime; // OK, This works
     }

     void foo() {
         writeln("A.foo - Before: ", cast() s);

         // But how to do this??
         //(cast () s).foo;
         //s.foo;

         writeln("A.foo - After: ", cast() s);
     }
}

void main() {

     SysTime s = Clock.currTime;
     writeln("main - Before: ", s);
     s.foo;
     writeln("main - After: ", s);

     shared A a = new shared A;
     a.foo;
}
```

That makes me wonder if casting a lvalue makes sense at all, and how 
come that the result is not another lvalue... what it is, I don't know, 
because you can assign to it, but not take a reference.


More information about the Digitalmars-d-learn mailing list