Re: Distinguish between a null array and an empty array

2020-05-25 Thread Nathan S. via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:12:31 UTC, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that b is an empty array and a is a null

Re: Dub platform probes

2020-05-25 Thread Anonymouse via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:58:54 UTC, Tim wrote: [...] Same here, but /tmp. $ ls /tmp/dub* | wc -l 174

Dub platform probes

2020-05-25 Thread Tim via Digitalmars-d-learn
Hi all I end up with a directory flooded with platform probes. How can I make sure that old ones are deleted automatically? Thanks

Re: How to get the pointer of "this" ?

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:32:52 UTC, Vinod K Chandran wrote: What is an opCast ? operator overload of the cast function. if you didn't write one, you don't have to worry about this.

Re: How to get the pointer of "this" ?

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:31:00 UTC, Vinod K Chandran wrote: A dword is an unsigned, 32-bit unit of data. We can use uint in D. I have tried that too, but no luck. A DWORD_PTR is *not* the same as a uint. It is more like a size_t or void* depending on context.

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:04:28 UTC, Adam D. Ruppe wrote: On Monday, 25 May 2020 at 21:45:39 UTC, welkam wrote: Where is DWORD_PTR defined? it is a win32 thing. should be able to directly cast to it most the time if there is opCast on the class it needs another layer of helper function

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 21:45:39 UTC, welkam wrote: On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: cast(DWORD_PTR) this); Where is DWORD_PTR defined? I cant find it in docs. If its an alias of long then you have to cast to a pointer like this cast(long*) this; you need to

ModuleInfo and -fno-moduleinfo option

2020-05-25 Thread Marius Cristian Baciu via Digitalmars-d-learn
Hello, As a general question, what is the purpose of ModuleInfo, constructing and deconstructing each of the runtime's modules? In other words, what are the ramifications of using gdc's -fno-moduleinfo option? I am asking this because I found that skipping its generation solves the problems g

Re: How to get the pointer of "this" ?

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 21:45:39 UTC, welkam wrote: Where is DWORD_PTR defined? it is a win32 thing. should be able to directly cast to it most the time if there is opCast on the class it needs another layer of helper function but without opCast it should just work

Re: How to get the pointer of "this" ?

2020-05-25 Thread welkam via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: cast(DWORD_PTR) this); Where is DWORD_PTR defined? I cant find it in docs. If its an alias of long then you have to cast to a pointer like this cast(long*) this; you need to specify that you want to cast to a pointer of type T.

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 18:42:33 UTC, bauss wrote: On Monday, 25 May 2020 at 17:14:13 UTC, Vinod K Chandran wrote: On Monday, 25 May 2020 at 16:54:11 UTC, Mike Parker wrote: [...] Hi @Mike Parker, Thank you for your valuable suggestions. I will sure follow them. Well, the exact line numbe

Re: How to get the pointer of "this" ?

2020-05-25 Thread bauss via Digitalmars-d-learn
On Monday, 25 May 2020 at 17:14:13 UTC, Vinod K Chandran wrote: On Monday, 25 May 2020 at 16:54:11 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: [...] The error has nothing to do with taking a pointer to `this`. It's suggesting that somewhere in you

Re: How to get the pointer of "this" ?

2020-05-25 Thread John Burton via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote: I believe that in D *this* is a reference to the object and not a pointer like in C++. So I think that writing &this might be what you need? No. A class reference is a pointer

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:54:11 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: [...] The error has nothing to do with taking a pointer to `this`. It's suggesting that somewhere in your code you're attempting to use the `this` reference like an lva

Re: Using Vibe.d for not HTTP

2020-05-25 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2020-05-25 at 12:29 +, Panke via Digitalmars-d-learn wrote: > […] > https://vibed.org/api/vibe.core.core/runTask ? > Possibly, it is just that the documentation is sadly lacking in examples of use. -- Russel. === Dr Russel Winder t: +44

Re: How to get the pointer of "this" ?

2020-05-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: Here is my full code. Please take a look. https://pastebin.com/av3nrvtT The error has nothing to do with taking a pointer to `this`. It's suggesting that somewhere in your code you're attempting to use the `this` reference like

Re: How to get the pointer of "this" ?

2020-05-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote: I believe that in D *this* is a reference to the object and not a pointer like in C++. So I think that writing &this might be what you need? No. A class reference is a pointer under the hood. Getting its address will result in a point

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:40:10 UTC, bauss wrote: On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: [...] I think your issue might be elsewhere because casting this should be fine and it should not complain about that in your given code. At least you should be able to pass

Re: RtlAdjustPrivilege and NtRaiseHardError

2020-05-25 Thread Arsium via Digitalmars-d-learn
On Sunday, 24 May 2020 at 20:35:58 UTC, novice2 wrote: "doesn't work" isn't very helpful. Are you seeing compiler errors? Linker errors? Runtime errors? Please describe your problem. Solved my problem alone : wrong signatures with functions ;) and this reply isn't very helpful. what is right

Re: alias this and initialisation

2020-05-25 Thread lalit.singhh via Digitalmars-d-learn
On Monday, 25 May 2020 at 01:35:47 UTC, Danni Coy wrote: can anybody tell me why struct S { int x; alias x this; } void test() { S s; s = 8; // this works S s = 8 // but this does not? }

Re: alias this and initialisation

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 01:35:47 UTC, Danni Coy wrote: s = 8; // this works S s = 8 // but this does not? } alias this only applies if you already have an object. Construction is too soon. You can add a constructor to make that work though.

Re: Using Vibe.d for not HTTP

2020-05-25 Thread Panke via Digitalmars-d-learn
On Monday, 25 May 2020 at 12:04:12 UTC, Russel Winder wrote: Now I need to find out how to spawn a task that can send out data even when the connection handler is blocked awaiting something to read. https://vibed.org/api/vibe.core.core/runTask ?

Re: Using Vibe.d for not HTTP

2020-05-25 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2020-05-25 at 11:55 +0200, Daniel Kozak via Digitalmars-d-learn wrote: […] > > https://run.dlang.io/is/SMLuA2 Thanks for this pointer. It was very helpful to read it as it confirmed that I was going doing the right thing in my code. That you have two sources adding some interleaving is mo

Re: Using Vibe.d for not HTTP

2020-05-25 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, May 24, 2020 at 10:10 AM Russel Winder via Digitalmars-d-learn wrote: > > Hi, > > Clearly Vibe.d is mostly for people doing HTTP and HTTPS stuff. Yet it claims > to be able to support TCP and UDP working with other protocols. However, all > the serious examples are HTTP/HTTPS related. All

Re: Learning Vibe.d

2020-05-25 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, May 24, 2020 at 10:06 AM Russel Winder via Digitalmars-d-learn wrote: > > For my purposes switching to using SIGKILL rather than SIGTERM in my tests > seems to work with 1.9.1, so I'll go with that till 1.9.2 or 1.10.0 produces a > fix rather than revert to 1.8.1. > You can use VibeHighEv

Re: How to get the pointer of "this" ?

2020-05-25 Thread John Burton via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:40:10 UTC, bauss wrote: On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: [...] I think your issue might be elsewhere because casting this should be fine and it should not complain about that in your given code. At least you should be able to pass

Re: Overload function template for rectangular array

2020-05-25 Thread Ali Çehreli via Digitalmars-d-learn
On 5/25/20 1:20 AM, John Chapman wrote: void foo(T)(T[] a) {} void foo(T)(T[][] a) {} auto ra = new int[][](5, 5); ra.foo(); // matches both import std.traits; void foo(T)(T[] a) if (!isArray!T) {} void foo(T)(T[] a) if (isArray!T) {} Or you can take T as parameter and check ElementType!T:

Overload function template for rectangular array

2020-05-25 Thread John Chapman via Digitalmars-d-learn
Is it possible to overload a function template for rectangular arrays? Is there any way to tell them apart from normal ones? void foo(T)(T[] a) {} void foo(T)(T[][] a) {} auto ra = new int[][](5, 5); ra.foo(); // matches both Thanks for any hints.

Re: alias this and initialisation

2020-05-25 Thread Ali Çehreli via Digitalmars-d-learn
On 5/24/20 6:35 PM, Danni Coy wrote:> can anybody tell me why > > struct S > { > int x; > alias x this; > } > > void test() > { > S s; > s = 8; // this works > S s = 8 // but this does not? > } alias this is for implicit conversion, which requires an object to convert fr