April 09, 2015 Re: Parameter is null by default. No value is given. Code says it is not null. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On Thursday, 9 April 2015 at 14:42:33 UTC, Daniel Kozak wrote: > On Thursday, 9 April 2015 at 14:30:07 UTC, Daniel Kozak wrote: >> On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote: >>> On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote: >>>> By the way, I am using "DMD64 D Compiler v2.067.0" on Ubuntu 14.04. >>> >>> I have Archlinux DMD64 D Compiler v2.067.0 and it works OK for me. >> >> WOW >> >> rdmd app.d(without params): > Ok rdmd and dub works because they are use ldc, but do not me ask how. I always think that dub and rdmd should use dmd compiler until I tell them otherwise I try it with DMD64 D Compiler v2.066 and same problem occured. So probably some backend problem. You should create an issue on https://issues.dlang.org |
April 09, 2015 Re: Parameter is null by default. No value is given. Code says it is not null. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On 4/9/15 9:32 AM, Adam D. Ruppe wrote: > Don't use string == null, it is true for empty strings since null and an > empty string are almost interchangable. I think this is not good advice. Comparing string to null is perfectly fine with ==. It's fine *because* null and empty strings are the same thing, so comparing against null is essentially comparing against an empty string. > You can try if(string is null) - is instead of ==. Though usually in D, > I just if(string.length == 0) and treat empty and null the same way. This is likely not what you want, it's generally not important where a string is located. Note that the "bad" behavior (which was just fixed BTW) is if(somearr), which used to mean if(somearr.ptr), and now it's a compiler error. -Steve |
April 09, 2015 Re: Parameter is null by default. No value is given. Code says it is not null. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Thursday, 9 April 2015 at 15:04:47 UTC, Steven Schveighoffer wrote:
>> You can try if(string is null) - is instead of ==. Though usually in D,
>> I just if(string.length == 0) and treat empty and null the same way.
>
> This is likely not what you want, it's generally not important where a string is located.
I think you were replying to the first sentence, but I recommend the second sentence: just always use `if(string.length)` and forget abotu where it is stored.
|
April 09, 2015 Re: Parameter is null by default. No value is given. Code says it is not null. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Thu, 09 Apr 2015 11:04:47 -0400 Steven Schveighoffer via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > > Note that the "bad" behavior (which was just fixed BTW) is > if(somearr), which used to mean if(somearr.ptr), and now it's a > compiler error. > > -Steve Yeah, because of this I must change almost 1k lines in my codebase :( |
April 09, 2015 Re: Parameter is null by default. No value is given. Code says it is not null. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Thu, 09 Apr 2015 11:04:47 -0400 Steven Schveighoffer via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > > Note that the "bad" behavior (which was just fixed BTW) is > if(somearr), which used to mean if(somearr.ptr), and now it's a > compiler error. > > -Steve Yeah, because of this I must change almost 1k lines in my codebase |
April 09, 2015 Re: Parameter is null by default. No value is given. Code says it is not null. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On Thursday, 9 April 2015 at 14:49:24 UTC, Daniel Kozak wrote: > On Thursday, 9 April 2015 at 14:42:33 UTC, Daniel Kozak wrote: >> On Thursday, 9 April 2015 at 14:30:07 UTC, Daniel Kozak wrote: >>> On Thursday, 9 April 2015 at 14:25:56 UTC, Daniel Kozak wrote: >>>> On Thursday, 9 April 2015 at 14:16:00 UTC, tcak wrote: >>>>> By the way, I am using "DMD64 D Compiler v2.067.0" on Ubuntu 14.04. >>>> >>>> I have Archlinux DMD64 D Compiler v2.067.0 and it works OK for me. >>> >>> WOW >>> >>> rdmd app.d(without params): >> Ok rdmd and dub works because they are use ldc, but do not me ask how. I always think that dub and rdmd should use dmd compiler until I tell them otherwise > > I try it with DMD64 D Compiler v2.066 and same problem occured. So probably some backend problem. You should create an issue on https://issues.dlang.org Reported. I simplified the example as well. Removed a big part of code and used "assert" instead of "writeln". My rdmd generates assertion exception with simplified code. I hope it can be tested later as well. https://issues.dlang.org/show_bug.cgi?id=14430 |
Copyright © 1999-2021 by the D Language Foundation