Re: is ==

2018-05-19 Thread IntegratedDimensions via Digitalmars-d-learn
Furthermore: https://issues.dlang.org/show_bug.cgi?id=3889 Shows real problems. You argue from the side that the bug already exists so we must work around it because we can't go back and "fix things". Who says? D has had breaking changes in the past so it is not a deal breaker. It is also a

Re: Can I infer the type from this?

2018-05-19 Thread Dr.No via Digitalmars-d-learn
On Sunday, 20 May 2018 at 02:01:20 UTC, Alex wrote: On Sunday, 20 May 2018 at 01:41:03 UTC, Dr.No wrote: I'd like to pass a symbol as paramater (class static member0 and at same time get the type of this, something like this: template myTemp(alias s) { enum myTemp =

Re: is ==

2018-05-19 Thread IntegratedDimensions via Digitalmars-d-learn
On Sunday, 20 May 2018 at 02:09:47 UTC, Jonathan M Davis wrote: On Sunday, May 20, 2018 01:51:50 IntegratedDimensions via Digitalmars-d- learn wrote: Simply require == null as is null and be done with it. That would be flat out wrong for dynamic arrays, because then auto result = arr == null

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 20, 2018 01:51:50 IntegratedDimensions via Digitalmars-d- learn wrote: > Simply require == null as is null and be done with it. That would be flat out wrong for dynamic arrays, because then auto result = arr == null and int[] nullArr; auto result = arr == nullArr; would have

Re: Can I infer the type from this?

2018-05-19 Thread Alex via Digitalmars-d-learn
On Sunday, 20 May 2018 at 01:41:03 UTC, Dr.No wrote: I'd like to pass a symbol as paramater (class static member0 and at same time get the type of this, something like this: template myTemp(alias s) { enum myTemp = templateFunction!(??)(s.stringof); } the templateFunction has this

Re: is ==

2018-05-19 Thread IntegratedDimensions via Digitalmars-d-learn
On Sunday, 20 May 2018 at 00:19:28 UTC, Jonathan M Davis wrote: On Saturday, May 19, 2018 17:50:50 IntegratedDimensions via Digitalmars-d- learn wrote: So, ultimately what I feels like is that you are actually arguing for == null to be interpreted as is null but you don't realize it yet. Not

Can I infer the type from this?

2018-05-19 Thread Dr.No via Digitalmars-d-learn
I'd like to pass a symbol as paramater (class static member0 and at same time get the type of this, something like this: template myTemp(alias s) { enum myTemp = templateFunction!(??)(s.stringof); } the templateFunction has this signature: int templateFunction(T)(string

Re: How is == operator implemented for string type?

2018-05-19 Thread Dr.No via Digitalmars-d-learn
On Wednesday, 16 May 2018 at 18:56:26 UTC, Steven Schveighoffer wrote: On 5/16/18 2:45 PM, Dr.No wrote: where is the actual source code implementation? https://github.com/dlang/druntime/blob/7e3b4086fee8f2e2a6882942c677acc28df527ee/src/object.d#L3479 -Steve thanks

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 17:13:36 Neia Neutuladh via Digitalmars-d-learn wrote: > I don't think I've ever wanted to distinguish a zero-length slice > of an array from a null array. It's safer if you don't, because it's so easy to end up with a dynamic array that is empty instead of null, and

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 17:50:50 IntegratedDimensions via Digitalmars-d- learn wrote: > So, ultimately what I feels like is that you are actually arguing > for == null to be interpreted as is null but you don't realize it > yet. Not really, no. Having foo == null be rewritten to foo is null

C style callbacks fix for member callbacks

2018-05-19 Thread IntegratedDimensions via Digitalmars-d-learn
I have a member callback that I want to use as a C callback. This is impossible due to the `hidden this` passed as the "first" parameter. The callback already makes it's last value a user pointer which I use as a "this". If I make my method static extern(C) then there is no crash and

Re: Real Int24

2018-05-19 Thread IntegratedDimensions via Digitalmars-d-learn
On Saturday, 19 May 2018 at 18:19:35 UTC, IntegratedDimensions wrote: Is there any way to create an int24 type that behaves just like any other built in type without having to reimplement everything? In fact, what I'd like to do is create an arbitrary type: struct atype(T) { } where

Real Int24

2018-05-19 Thread IntegratedDimensions via Digitalmars-d-learn
Is there any way to create an int24 type that behaves just like any other built in type without having to reimplement everything?

Re: is ==

2018-05-19 Thread IntegratedDimensions via Digitalmars-d-learn
On Saturday, 19 May 2018 at 01:31:38 UTC, Jonathan M Davis wrote: On Friday, May 18, 2018 23:53:12 IntegratedDimensions via Digitalmars-d- learn wrote: Why does D complain when using == to compare with null? Is there really any technical reason? if one just defines == null to is null then

Re: C API / const char *text / std.string.toStringz pointer is always NULL on C side

2018-05-19 Thread kinke via Digitalmars-d-learn
On Saturday, 19 May 2018 at 17:33:08 UTC, Robert M. Münch wrote: On 2018-05-18 14:42:17 +, Adam D. Ruppe said: A value struct return is actually done via a hidden pointer parameter (so the function can construct it in-place for the caller, a standard optimization), so it just shifted all

Re: C API / const char *text / std.string.toStringz pointer is always NULL on C side

2018-05-19 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-18 14:42:17 +, Adam D. Ruppe said: On Friday, 18 May 2018 at 14:06:11 UTC, Robert M. Münch wrote: So, having a wrong return-type here, resulted in the const char *text parameter always being NULL. Not sure I understand the relation but looks strange to me... at least not very

Re: is ==

2018-05-19 Thread Neia Neutuladh via Digitalmars-d-learn
On Saturday, 19 May 2018 at 04:30:24 UTC, Jonathan M Davis wrote: On Saturday, May 19, 2018 03:32:53 Neia Neutuladh via Digitalmars-d-learn wrote: > Of course, the most notable case where using == with null is > a terrible idea is dynamic arrays, and that's the case where > the compiler