Re: Very simple null reference escape

2019-06-02 Thread Basile B. via Digitalmars-d-learn
On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; safeAccess from iz does this : https://github.com/Basile-z/iz/blob/master/import/iz/sugar.d#L1666

Re: Very simple null reference escape

2019-06-02 Thread Amex via Digitalmars-d-learn
On Sunday, 2 June 2019 at 14:37:48 UTC, Paul Backus wrote: On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; The "optional" package on dub [1] has a .dispatch

Re: Very simple null reference escape

2019-06-02 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; The "optional" package on dub [1] has a .dispatch method that does this: auto d = some(A()); //

Re: this is null

2019-03-10 Thread ANtlord via Digitalmars-d-learn
On Sunday, 10 March 2019 at 14:25:56 UTC, spir wrote: There is a typo in this instruction: T* ptr = this.list.getFisrtFreeOrAdd(memViewLen).getPtr!T(); ^^ rs (may this explain your null? the compiler should complain) diniz Good catch! But I

Re: this is null

2019-03-10 Thread spir via Digitalmars-d-learn
On 09/03/2019 21:10, ANtlord via Digitalmars-d-learn wrote: On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: You can end up with a null `this` reference if you dereference a null pointer to a struct and then call a method on the result. For example: I can but my reference is

Re: this is null

2019-03-09 Thread ANtlord via Digitalmars-d-learn
On Saturday, 9 March 2019 at 21:00:51 UTC, Ali Çehreli wrote: I haven't run the code but which pointer is null? Try adding I mean `this` by "this" word. You can see that `this` is null if you run gdb and before that line make `p/x this` [0] this check as well: auto node =

Re: this is null

2019-03-09 Thread Ali Çehreli via Digitalmars-d-learn
On 03/09/2019 12:10 PM, ANtlord wrote: On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: You can end up with a null `this` reference if you dereference a null pointer to a struct and then call a method on the result. For example: I can but my reference is not null before

Re: this is null

2019-03-09 Thread ANtlord via Digitalmars-d-learn
On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: struct S { bool isThisNull() { return is null; } } void main() { import.std.stdio; S* p = null; writeln((*p).isThisNull); // true } Interactive version: https://run.dlang.io/is/fgT2rS Anyway, thank you! I didn't

Re: this is null

2019-03-09 Thread ANtlord via Digitalmars-d-learn
On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: You can end up with a null `this` reference if you dereference a null pointer to a struct and then call a method on the result. For example: I can but my reference is not null before calling. Take a look at the line of code

Re: this is null

2019-03-09 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 9 March 2019 at 19:18:38 UTC, ANtlord wrote: Hello everyone! I've encountered the problem which I already encountered before. Unfortunately, I had no time in the previous time to report and to talk about it. So I decided to play making my own "malloc" function in pure D (betterC)

Re: assigment to null class object member compiled? is this a bug?

2018-10-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 October 2018 at 06:53:32 UTC, dangbinghoo wrote: why the code bellow compiles? D compilers are allowed to make that an error, but it might not. With the current implementation, dmd that.d will compile, but dmd -O that.d will fail with an error. Yes, turning on optimizations

Re: assigment to null class object member compiled? is this a bug?

2018-10-22 Thread Alex via Digitalmars-d-learn
On Monday, 22 October 2018 at 01:39:48 UTC, dangbinghoo wrote: On Friday, 19 October 2018 at 09:08:32 UTC, Vijay Nayar wrote: Technically the code you have is syntactically correct. You are permitted to create a class variable without assigning it to a class object. (Assigning it to a class

Re: assigment to null class object member compiled? is this a bug?

2018-10-21 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 19 October 2018 at 09:08:32 UTC, Vijay Nayar wrote: Technically the code you have is syntactically correct. You are permitted to create a class variable without assigning it to a class object. (Assigning it to a class object would look like "A a = new A();") Which section of The

Re: assigment to null class object member compiled? is this a bug?

2018-10-19 Thread Vijay Nayar via Digitalmars-d-learn
On Friday, 19 October 2018 at 06:53:32 UTC, dangbinghoo wrote: hi, why the code bellow compiles? --- import std.stdio; class A { int m; } void main() { A a; a.m = 1; } --- and running this code get: `segmentation fault (core dumped) ./test` I consider this couldn't be compiled

Re: toString contains null for struct with function/method

2018-04-09 Thread number via Digitalmars-d-learn
On Sunday, 8 April 2018 at 15:51:05 UTC, Paul Backus wrote: On Sunday, 8 April 2018 at 15:04:49 UTC, number wrote: writeln(s2);// S2(0, null) S2 is a nested struct [1], which means it has a hidden pointer field that's used to access its enclosing scope. If you change

Re: toString contains null for struct with function/method

2018-04-08 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 8 April 2018 at 15:04:49 UTC, number wrote: the write() shows a 'null' if the struct has a function/method. why is that? ``` import std.stdio; void main() { struct S { int i; } S s; writeln(s);// S(0)

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-08 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 8 March 2018 at 08:04:54 UTC, Nick Sabalausky (Abscissa) wrote: Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't appear to work on run.dlang.io). But it does seem to work for me if I use 'v0.8.3-alpha.1'. I wonder what could have changed to result in this? It's a

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-08 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 03:04 AM, Nick Sabalausky (Abscissa) wrote: Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't appear to work on run.dlang.io). But it does seem to work for me if I use 'v0.8.3-alpha.1'. I wonder what could have changed to result in this?

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-08 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 01:13 AM, Nicholas Wilson wrote: That does seem odd. --- /+dub.sdl: dependency "vibe-d" version="~>0.8.3-alpha.1" +/ import vibe.core.net; import std.stdio; TCPConnection mySocket; void main() {     auto b = mySocket is null;     writeln(b); } --- works fine on run.dlang.io

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 March 2018 at 04:48:08 UTC, Nick Sabalausky (Abscissa) wrote: - import vibe.core.net; TCPConnection mySocket; void main() { auto b = mySocket is null; } - That's giving me: - Error: incompatible types for

Re: Stacktrace on Null Pointer Derefence

2016-09-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 22 September 2016 at 19:51:31 UTC, Nordlöw wrote: A known bug? Yeah, it shows the line before instead of the line of. But it still shows basically where you are.

Re: Stacktrace on Null Pointer Derefence

2016-09-22 Thread ketmar via Digitalmars-d-learn
p.s. that is the reason it is not turned on by default, btw.

Re: Stacktrace on Null Pointer Derefence

2016-09-22 Thread ketmar via Digitalmars-d-learn
On Thursday, 22 September 2016 at 19:51:31 UTC, Nordlöw wrote: A known bug? prolly. segfault handler is highly non-standard hack, it may miss exact position or something. as is "it is not guaranteed to work, and if it will work, it is not guaranteed to work correctly".

Re: Stacktrace on Null Pointer Derefence

2016-09-22 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 22 September 2016 at 00:46:19 UTC, ketmar wrote: { import etc.linux.memoryerror; registerMemoryErrorHandler(); } Thx! That at least triggered an exception. However the line number for the innermost function is wrong. For instance 1 void boom() 2 { 3 int* y = null; 4

Re: Stacktrace on Null Pointer Derefence

2016-09-21 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 23:36:08 UTC, Nordlöw wrote: Doing a null deref such as int* y = null; *y = 42;// boom [...] Can you include compiler command line? I use -g -gs -debug to get stack traces on windows.

Re: Stacktrace on Null Pointer Derefence

2016-09-21 Thread ketmar via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 23:36:08 UTC, Nordlöw wrote: Is there a way to get a stacktrace instead? { import etc.linux.memoryerror; registerMemoryErrorHandler(); } warning: this is hightly system-specific, and may work or not work depending of the moon phase, and may broke on any

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Adam D. Ruppe via Digitalmars-d-learn
Don't use string == null, it is true for empty strings since null and an empty string are almost interchangable. 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.

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread tcak via Digitalmars-d-learn
On Thursday, 9 April 2015 at 11:45:31 UTC, tcak wrote: I have written a function as follows: public bool setCookie( string name, string value, long maxAgeInSeconds = long.min, string expiresOnGMTDate=null, string path=null, string domain=null,

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread tcak via Digitalmars-d-learn
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

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
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

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 09 Apr 2015 11:45:30 + tcak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have written a function as follows: public bool setCookie( string name, string value, long maxAgeInSeconds = long.min, string expiresOnGMTDate=null,

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozák via Digitalmars-d-learn
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

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozák via Digitalmars-d-learn
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

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
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

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread tcak via Digitalmars-d-learn
On Thursday, 9 April 2015 at 13:32:38 UTC, Adam D. Ruppe wrote: Don't use string == null, it is true for empty strings since null and an empty string are almost interchangable. You can try if(string is null) - is instead of ==. Though usually in D, I just if(string.length == 0) and treat

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Steven Schveighoffer via Digitalmars-d-learn
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

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
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): Name:

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Adam D. Ruppe via Digitalmars-d-learn
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

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread tcak via Digitalmars-d-learn
By the way, I am using DMD64 D Compiler v2.067.0 on Ubuntu 14.04.

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Daniel Kozak via Digitalmars-d-learn
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.

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread tcak via Digitalmars-d-learn
On Thursday, 9 April 2015 at 12:06:49 UTC, Daniel Kozák wrote: On Thu, 09 Apr 2015 11:45:30 + tcak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Can you post full example somewhere, this code works ok for me: import std.stdio; import std.datetime; class Response {

Re: Cannot alias null

2014-06-13 Thread via Digitalmars-d-learn
On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via Digitalmars-d-learn wrote: What I was really trying to do was D'ify C expressions like this: typedef ((struct t*)0) blah; This doesn't compile for me with GCC, and I don't know what it's supposed to mean. ((struct t*) 0) is a

Re: Cannot alias null

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 12 June 2014 at 22:54:20 UTC, Ali Çehreli wrote: On 06/12/2014 03:38 PM, monarch_dodra wrote: So there's something special about null. The difference is that null is an expression. It is the same limitation as not being able to alias a literal. alias zero = 0; alias

Re: Cannot alias null

2014-06-13 Thread Tom Browder via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 7:59 AM, via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via Digitalmars-d-learn wrote: What I was really trying to do was D'ify C expressions like this: typedef ((struct t*)0) blah; This

Re: Cannot alias null

2014-06-13 Thread Philpax via Digitalmars-d-learn
On Friday, 13 June 2014 at 15:05:49 UTC, Tom Browder via Digitalmars-d-learn wrote: On Fri, Jun 13, 2014 at 7:59 AM, via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via Digitalmars-d-learn wrote: What I was really trying

Re: Cannot alias null

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 15:05:49 UTC, Tom Browder via Digitalmars-d-learn wrote: So I'm not sure how to translate that into D. I do know my first attempt here doesn't work, even with it being surrounded by extern (C) {}: $ cat chdr.d struct t; struct t* t_ptr = null; This seems to work

Re: Cannot alias null

2014-06-13 Thread Tom Browder via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 10:15 AM, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 13 June 2014 at 15:05:49 UTC, Tom Browder via Digitalmars-d-learn wrote: So I'm not sure how to translate that into D. I do know my first attempt here doesn't work,

Re: Cannot alias null

2014-06-12 Thread Ali Çehreli via Digitalmars-d-learn
On 06/12/2014 01:26 PM, Tom Browder via Digitalmars-d-learn wrote: This will not compile: alias blah = null; The dmd message are: di/test_hdr.d(10): Error: basic type expected, not null di/test_hdr.d(10): Error: semicolon expected to close alias declaration di/test_hdr.d(10): Error:

Re: Cannot alias null

2014-06-12 Thread Andrew Edwards via Digitalmars-d-learn
On 6/12/14, 4:29 PM, Ali Çehreli wrote: On 06/12/2014 01:26 PM, Tom Browder via Digitalmars-d-learn wrote: This will not compile: alias blah = null; The dmd message are: di/test_hdr.d(10): Error: basic type expected, not null di/test_hdr.d(10): Error: semicolon expected to

Re: Cannot alias null

2014-06-12 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 12, 2014 at 03:26:13PM -0500, Tom Browder via Digitalmars-d-learn wrote: This will not compile: alias blah = null; [...] 'null' is a value, not a type. Try: alias blah = typeof(null); T -- If it's green, it's biology, If it stinks, it's chemistry, If it has numbers

Re: Cannot alias null

2014-06-12 Thread Ali Çehreli via Digitalmars-d-learn
On 06/12/2014 01:36 PM, Andrew Edwards wrote: void foo() {} alias bar = foo(); Am I just misunderstanding what is meant by types? Seems to be an old behavior. That does not compile with 2.066: Error: function declaration without return type. (Note that constructors are always named

Re: Cannot alias null

2014-06-12 Thread Tom Browder via Digitalmars-d-learn
On Thu, Jun 12, 2014 at 3:42 PM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thu, Jun 12, 2014 at 03:26:13PM -0500, Tom Browder via Digitalmars-d-learn wrote: This will not compile: alias blah = null; [...] 'null' is a value, not a type. Try:

Re: Cannot alias null

2014-06-12 Thread Ali Çehreli via Digitalmars-d-learn
On 06/12/2014 02:06 PM, Tom Browder via Digitalmars-d-learn wrote: What I was really trying to do was D'ify C expressions like this: typedef ((struct t*)0) blah; Is that actually a function pointer typedef? I can't parse that line. :) So, taking your advice, I found this to work (at

Re: Cannot alias null

2014-06-12 Thread Tom Browder via Digitalmars-d-learn
On Thu, Jun 12, 2014 at 4:17 PM, Ali Çehreli digitalmars-d-learn@puremagic.com wrote: On 06/12/2014 02:06 PM, Tom Browder via Digitalmars-d-learn wrote: ... What I was really trying to do was D'ify C expressions like this: typedef ((struct t*)0) blah; ... So, taking your advice, I found

Re: Cannot alias null

2014-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
since null is a value maybe you want enum blah = null; you may also give it a type after the enum word

Re: Cannot alias null

2014-06-12 Thread Tom Browder via Digitalmars-d-learn
On Thu, Jun 12, 2014 at 4:58 PM, Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: since null is a value maybe you want enum blah = null; That works. you may also give it a type after the enum word But I can't get any other variant to work so far. -Tom

Re: Cannot alias null

2014-06-12 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 12 June 2014 at 20:44:16 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jun 12, 2014 at 03:26:13PM -0500, Tom Browder via Digitalmars-d-learn wrote: This will not compile: alias blah = null; [...] 'null' is a value, not a type. Try: alias blah = typeof(null);

Re: Cannot alias null

2014-06-12 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 12 June 2014 at 21:58:32 UTC, Adam D. Ruppe wrote: since null is a value maybe you want enum blah = null; you may also give it a type after the enum word I *think* the issue might be that null is an rvalue? Because you can alias variable names all you want. I do it all the time

Re: Cannot alias null

2014-06-12 Thread Ali Çehreli via Digitalmars-d-learn
On 06/12/2014 03:38 PM, monarch_dodra wrote: Yet you can alias variables... int i; alias j = i; Initially I forgot about the fact that symbols can be alias'ed as well. So that's fine. So there's something special about null. The difference is that null is an expression. It is the same

Re: Why is null lowercase?

2013-01-27 Thread Phil Lavoie
DO YOU PREFER A LANGUAGE ALL IN UPPERCASE? Hahahaha! I find it ugly too. I prefer lowercaps null, as in Java.

Re: Why is null lowercase?

2013-01-27 Thread Phil Lavoie
On Friday, 25 January 2013 at 16:11:57 UTC, Maxim Fomin wrote: On Friday, 25 January 2013 at 14:22:20 UTC, Don wrote: On Friday, 25 January 2013 at 01:17:44 UTC, Ali Çehreli wrote: On 01/24/2013 12:42 PM, Matthew Caron wrote: for not null checks if ( ptr !is null) ... And too much perl

Re: Why is null lowercase?

2013-01-25 Thread Don
On Friday, 25 January 2013 at 01:17:44 UTC, Ali Çehreli wrote: On 01/24/2013 12:42 PM, Matthew Caron wrote: for not null checks if ( ptr !is null) ... And too much perl has me wanting to write: if (ptr is not null) IIRC, the !is operator is thanks to bearophile. No, it's from 2002

Re: Why is null lowercase?

2013-01-25 Thread Ali Çehreli
On 01/25/2013 06:22 AM, Don wrote: IIRC, the !is operator is thanks to bearophile. No, it's from 2002 (well, it was !==, renamed to !is in 2005). Bearophile only joined us about the time D2 began, in late 2007. Ok. How about !in then? Did he lobby for that one? :) Ali

Re: Why is null lowercase?

2013-01-25 Thread Maxim Fomin
On Friday, 25 January 2013 at 14:22:20 UTC, Don wrote: On Friday, 25 January 2013 at 01:17:44 UTC, Ali Çehreli wrote: On 01/24/2013 12:42 PM, Matthew Caron wrote: for not null checks if ( ptr !is null) ... And too much perl has me wanting to write: if (ptr is not null) IIRC, the !is

Re: Why is null lowercase?

2013-01-25 Thread Era Scarecrow
On Friday, 25 January 2013 at 14:43:01 UTC, Ali Çehreli wrote: On 01/25/2013 06:22 AM, Don wrote: No, it's from 2002 (well, it was !==, renamed to !is in 2005). Bearophile only joined us about the time D2 began, in late 2007. Ok. How about !in then? Did he lobby for that one? :) //hmmm

Re: Why is null lowercase?

2013-01-25 Thread Ali Çehreli
On 01/25/2013 10:31 AM, Era Scarecrow wrote: On Friday, 25 January 2013 at 14:43:01 UTC, Ali Çehreli wrote: On 01/25/2013 06:22 AM, Don wrote: No, it's from 2002 (well, it was !==, renamed to !is in 2005). Bearophile only joined us about the time D2 began, in late 2007. Ok. How about !in

Re: Why is null lowercase?

2013-01-25 Thread Era Scarecrow
On Friday, 25 January 2013 at 18:57:06 UTC, Ali Çehreli wrote: On 01/25/2013 10:31 AM, Era Scarecrow wrote: After looking at all these 'in' should be reserved for array searching, not pointer checking. It makes more sense to me that way. Sorry if I implied otherwise. Yes, 'in' should be for

Re: Why is null lowercase?

2013-01-24 Thread bearophile
Matthew Caron: Of all of the differences between C and D, the one which I have the most difficulty adapting to is null being lowercase. Does anyone know why this decision was made? Probably because writing all in uppercase ugly. null is a keyword like the others, and they are in lowercase.

Re: Why is null lowercase?

2013-01-24 Thread Mike Parker
On Thursday, 24 January 2013 at 12:56:03 UTC, Matthew Caron wrote: This is probably a question for Walter, but maybe others know. Of all of the differences between C and D, the one which I have the most difficulty adapting to is null being lowercase. Does anyone know why this decision was

Re: Why is null lowercase?

2013-01-24 Thread monarch_dodra
On Thursday, 24 January 2013 at 12:56:03 UTC, Matthew Caron wrote: This is probably a question for Walter, but maybe others know. Of all of the differences between C and D, the one which I have the most difficulty adapting to is null being lowercase. Does anyone know why this decision was

Re: Why is null lowercase?

2013-01-24 Thread Leandro Motta Barros
Hi, In C, NULL is a #define, and #defines are typically all-caps. In D, null is real keyword recognized by the compiler, and those are typically lowercase. I am just guessing here, but I'd say the choice for 'null' instead of 'NULL' is just to be coherent with this. Personally, I kinda like

Re: Why is null lowercase?

2013-01-24 Thread Rob T
On Thursday, 24 January 2013 at 12:56:03 UTC, Matthew Caron wrote: This is probably a question for Walter, but maybe others know. Of all of the differences between C and D, the one which I have the most difficulty adapting to is null being lowercase. Does anyone know why this decision was

Re: Why is null lowercase?

2013-01-24 Thread Ali Çehreli
On 01/24/2013 04:56 AM, Matthew Caron wrote: This is probably a question for Walter, but maybe others know. Of all of the differences between C and D, the one which I have the most difficulty adapting to is null being lowercase. Does anyone know why this decision was made? Similarly, the

Re: Why is null lowercase?

2013-01-24 Thread Matthew Caron
On 01/24/2013 12:50 PM, Ali Çehreli wrote: Similarly, the common macros TRUE and FALSE are replaced by the 'true' and 'false' keywords. Ironically, those don't bother me because I never used them. -- Matthew Caron, Software Build Engineer Sixnet, a Red Lion business | www.sixnet.com +1 (518)

Re: Why is null lowercase?

2013-01-24 Thread Matthew Caron
On 01/24/2013 12:04 PM, Rob T wrote: You'll get used to it, it's actually much better than typing in NULL, and it's a real type instead on an int, which never worked well in C. Just be warned that when checking for null *do not* use equality operator Yeah, the compiler helped me find that one

Re: Why is null lowercase?

2013-01-24 Thread Ali Çehreli
On 01/24/2013 12:42 PM, Matthew Caron wrote: for not null checks if ( ptr !is null) ... And too much perl has me wanting to write: if (ptr is not null) IIRC, the !is operator is thanks to bearophile. We would have to reverse the logic before he insisted on !is: :) if (!(ptr is

Re: HWND is NULL but GetLastError returns 0x00

2009-10-17 Thread Zarathustra
I filled out all fields of wndclassex and operands of createWindowEx exactly the same like in identical (working) C program, and there are still the same problem. // void main(){ try{ ptr handle; //Window wnd = new Window(); WndClassEx wndClass;

Re: HWND is NULL but GetLastError returns 0x00

2009-10-17 Thread Zarathustra
Ok thanks, My fault ;p

Re: HWND is NULL but GetLastError returns 0x00

2009-10-16 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Zarathustra wrote: I have the problem with the following code in D2: CreateWindowEx returns NULL but I haven't got idea why? snip That's because your are not properly processing all of the messages that are involved in window creation. See:

Re: delegate !is null

2009-09-10 Thread Steven Schveighoffer
On Tue, 08 Sep 2009 18:13:56 -0400, Saaa em...@needmail.com wrote: Hope this one makes any sense :) C c = new C; C mouseOverObject = c; int delegate() deleg = mouseOverObject.getSomeVariable; mouseOverObject = null; int value; void write() { if(deleg !is null) //how do I make this check for

Re: delegate !is null

2009-09-08 Thread Saaa
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.uzxs4wyreav...@localhost.localdomain... On Sun, 06 Sep 2009 18:54:47 -0400, Saaa em...@needmail.com wrote: I'd like to set D's delegate to a method which is not yet available (like c.method). I solved this by encapsulating

Re: delegate !is null

2009-09-08 Thread Steven Schveighoffer
On Tue, 08 Sep 2009 09:22:30 -0400, Saaa em...@needmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.uzxs4wyreav...@localhost.localdomain... On Sun, 06 Sep 2009 18:54:47 -0400, Saaa em...@needmail.com wrote: I'd like to set D's delegate to a method which is

Re: delegate !is null

2009-09-08 Thread Saaa
The problem lies more in that I'd like to point to something which is not there yet. In the code 'c.method()' is not there yet, as c is null. Maybe I should create a dummy object for c to point to in stead of null ? That way I point the delegate to the dummy method and ignore it as long as

Re: delegate !is null

2009-09-08 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Saaa wrote: The problem lies more in that I'd like to point to something which is not there yet. In the code 'c.method()' is not there yet, as c is null. Maybe I should create a dummy object for c to point to in stead of null ? That way I point

Re: delegate !is null

2009-09-08 Thread Steven Schveighoffer
On Tue, 08 Sep 2009 12:40:13 -0400, Saaa em...@needmail.com wrote: Hm... I'm still confused. Why not just set the delegate to null? Why do you need to have the delegate set to something? It is for the gui. I give it a list of things to display. And some of these things don't yet exist or

Re: delegate !is null

2009-09-08 Thread Steven Schveighoffer
On Tue, 08 Sep 2009 16:15:49 -0400, Saaa em...@needmail.com wrote: // dg is now a instanceless delegate to C.method. dg.ptr = new C; So, nothing special under the hood, this would also work? C c= new C; dg.ptr = c; Yes, same thing. I also don't know how well it will work on interfaces.

Re: delegate !is null

2009-09-08 Thread Saaa
Hm... I'm still confused. Why not just set the delegate to null? Why do you need to have the delegate set to something? It is for the gui. I give it a list of things to display. And some of these things don't yet exist or can be deleted at any time. I'd like it to display the last valid

Re: delegate !is null

2009-09-08 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Saaa wrote: The only way I've found so far to do static binding like you are talking about is using string mixins. I need to rethink stuff a bit, but mixins might be the solution. My port of Atl's window classes uses a MFC like message map:

Re: delegate !is null

2009-09-06 Thread Saaa
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.uzqxxo1neav...@localhost.localdomain... On Fri, 04 Sep 2009 14:33:12 -0400, Saaa em...@needmail.com wrote: class C { private int i; int method() { return i; } } class D { private int delegate(void)

Re: .dup is null

2009-05-04 Thread Qian Xu
Steven Schveighoffer wrote: I think you might have a bug? .dup is the same as s.dup, not sure why you would expect it to be not-null. -Steve If I have not explained clearly. Here is the full code: char[] s; assert(s is null); assert(s.dup is null); assert( !is null);

Re: .dup is null

2009-05-04 Thread Steven Schveighoffer
On Mon, 04 May 2009 10:22:49 -0400, Qian Xu quian...@stud.tu-ilmenau.de wrote: Steven Schveighoffer wrote: I think you might have a bug? .dup is the same as s.dup, not sure why you would expect it to be not-null. -Steve If I have not explained clearly. Here is the full code: char[]

Re: .dup is null

2009-05-04 Thread Steven Schveighoffer
On Mon, 04 May 2009 12:09:09 -0400, Georg Wrede georg.wr...@iki.fi wrote: If I remember correctly, string literals are stored with a null appended, so as to make them easier to use with OS calls, etc. Could it be that stores a 1-byte string, consisting with just this null? Then this

Re: No segfault - null ==

2009-03-31 Thread Unknown W. Brackets
Please remember, strings are not objects. Therefore, a comparison against null does not cause a segfault, as it might with an object. In the case of arrays, test == null and test is null should be the same operation. In contrast, if you had null == new Object(), you would've seen:

Re: No segfault - null ==

2009-03-31 Thread Frits van Bommel
Unknown W. Brackets wrote: In the case of arrays, test == null and test is null should be the same operation. They're not the same operation. (Though there was quite a large debate on these newsgroups a while back because a lot of people thought they *should* be, as you said) The

Re: No segfault - null ==

2009-03-31 Thread Sergey Gromov
Tue, 31 Mar 2009 16:29:30 +0200, Qian Xu wrote: When I was trying to learn how char-array works, I found something unexpected. -- code -- module string_test; void main() { // test 1 assert(null == , null is empty); // No segfault