Re: how to assign to shared obj.systime?

2020-07-13 Thread Kagamin via Digitalmars-d-learn
--- import std; shared class TimeCount { synchronized void startClock() { auto me = cast()this; me.startTime = Clock.currTime; } synchronized void endClock() { auto me = cast()this; me.endTime = Clock.currTime

Re: how to assign to shared obj.systime?

2020-07-13 Thread Arafel via Digitalmars-d-learn
On 14/7/20 8:05, Kagamin wrote: On Monday, 13 July 2020 at 07:26:06 UTC, Arafel wrote: That's exactly why what I propose is a way to *explicitly* tell the compiler about it, like @system does for safety. With __gshared you can opt out from sharing safety, then you're back to old good C-style

Re: how to assign to shared obj.systime?

2020-07-13 Thread Kagamin via Digitalmars-d-learn
--- import std; shared class TimeCount { void startClock() { auto me = cast()this; me.startTime = Clock.currTime; } void endClock() { auto me = cast()this; me.endTime = Clock.currTime; } void c

Re: how to assign to shared obj.systime?

2020-07-13 Thread Kagamin via Digitalmars-d-learn
On Monday, 13 July 2020 at 07:26:06 UTC, Arafel wrote: That's exactly why what I propose is a way to *explicitly* tell the compiler about it, like @system does for safety. With __gshared you can opt out from sharing safety, then you're back to old good C-style multithreading.

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 13 July 2020 at 16:17:55 UTC, zoujiaqing wrote: On Monday, 13 July 2020 at 12:57:52 UTC, Adam D. Ruppe wrote: On Monday, 13 July 2020 at 09:34:35 UTC, zoujiaqing wrote: # dmd source/main.d Canvas.o -L-lstdc++ && ./main [1]49078 segmentation fault ./main On my computer I got th

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 July 2020 at 09:34:35 UTC, zoujiaqing wrote: I changed string to basic_string. /// source/main.d import std.stdio; import core.stdcpp.string; extern(C++) { class Canvas { @disable this(); static Canvas Create(); basic_string!ubyte Foo();

Re: opApply and attributes

2020-07-13 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 20:53:05 UTC, Ali Çehreli wrote: I am not sure whether I understand it correctly but there has been a request for opApply() to gain the attributes of the delegate (or the range?). In other words, "transfer the attributes to opApply". This is needed because I want opAp

Re: How can I make executeShell ask for Admin Elevation?

2020-07-13 Thread Marcone via Digitalmars-d-learn
On Monday, 13 July 2020 at 12:28:24 UTC, aberba wrote: On Monday, 13 July 2020 at 00:57:02 UTC, Marcone wrote: On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote: I don't want start program with admin elevation, but ask user for admin permission when some function is called. alias runas =

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread zoujiaqing via Digitalmars-d-learn
On Monday, 13 July 2020 at 12:57:52 UTC, Adam D. Ruppe wrote: On Monday, 13 July 2020 at 09:34:35 UTC, zoujiaqing wrote: # dmd source/main.d Canvas.o -L-lstdc++ && ./main [1]49078 segmentation fault ./main On my computer I got this warning out of the compiler: libstdc++ std::__cxx11::bas

Re: how to assign to shared obj.systime?

2020-07-13 Thread Arafel via Digitalmars-d-learn
On 13/7/20 14:18, Steven Schveighoffer wrote: cast() will remove as little as possible, but for most cases, including classes and struts, this means the entire tree referenced is now unshared. Yeah, but the whole lvalue cast looks just non-obvious and ugly to me: ``` cast() foo = bar; ```

Re: What's the point of static arrays ?

2020-07-13 Thread wjoe via Digitalmars-d-learn
On Friday, 10 July 2020 at 21:24:08 UTC, Ali Çehreli wrote: What is important is overhead: That's the major point I took from all this. Thanks for your effort. And thanks everybody else, too, I really appreciate it.

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 13 July 2020 at 09:34:35 UTC, zoujiaqing wrote: # dmd source/main.d Canvas.o -L-lstdc++ && ./main [1]49078 segmentation fault ./main On my computer I got this warning out of the compiler: libstdc++ std::__cxx11::basic_string is not yet supported; the struct contains an interio

Re: Choosing a non-default linker for dmd (via dub)

2020-07-13 Thread WebFreak001 via Digitalmars-d-learn
On Sunday, 12 July 2020 at 16:36:09 UTC, Per Nordlöw wrote: The line dflags "-linker=gold" platform="linux-ldc" # use GNU gold linker in dub.sdl enables me to change linker for LDC. Is it possible to choose a specific linker for DMD aswell in a similar way? I only find the flag `-L` that s

Re: How can I make executeShell ask for Admin Elevation?

2020-07-13 Thread aberba via Digitalmars-d-learn
On Monday, 13 July 2020 at 00:57:02 UTC, Marcone wrote: On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote: I don't want start program with admin elevation, but ask user for admin permission when some function is called. alias runas = compose!(x => to!bool((cast(int) x) > 32), x => ShellE

Re: how to assign to shared obj.systime?

2020-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/13/20 3:26 AM, Arafel wrote: On 13/7/20 3:46, Steven Schveighoffer wrote: On 7/11/20 6:15 AM, Arafel wrote: What I really miss is some way of telling the compiler "OK, I know what I'm doing, I'm already in a critical section, and that all the synchronization issues have been already man

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread zoujiaqing via Digitalmars-d-learn
I changed string to basic_string. /// source/main.d import std.stdio; import core.stdcpp.string; extern(C++) { class Canvas { @disable this(); static Canvas Create(); basic_string!ubyte Foo(); basic_string!ubyte Bar(); }; } void main() { C

Re: how to assign to shared obj.systime?

2020-07-13 Thread Arafel via Digitalmars-d-learn
On 13/7/20 3:46, Steven Schveighoffer wrote: On 7/11/20 6:15 AM, Arafel wrote: What I really miss is some way of telling the compiler "OK, I know what I'm doing, I'm already in a critical section, and that all the synchronization issues have been already managed by me". You do. It's a cast.