On Monday, 20 June 2022 at 19:08:32 UTC, max haughton wrote:
On Monday, 20 June 2022 at 17:48:48 UTC, Antonio wrote:
Is there any way to specify that a variable, member or
parameter can't be null?
You can use an invariant if it's a member of an aggregate but
be warned that these are only
On Monday, 20 June 2022 at 17:48:48 UTC, Antonio wrote:
Is there any way to specify that a variable, member or
parameter can't be null?
You can use an invariant if it's a member of an aggregate but be
warned that these are only checked at the boundaries of public
member functions.
On Monday, 20 June 2022 at 17:48:48 UTC, Antonio wrote:
Is there any way to specify that a variable, member or
parameter can't be null?
Depends on the type. Basic types can't be null. Pointers and
classes can always be `null`, though you could wrap them in a
custom library type that doesn't
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
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
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());
//
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
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
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 =
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
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
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
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)
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
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
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
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
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
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)
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
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?
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
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
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.
p.s. that is the reason it is not turned on by default, btw.
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".
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
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.
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
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.
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,
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
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 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,
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
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
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
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
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
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:
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
By the way, I am using DMD64 D Compiler v2.067.0 on Ubuntu
14.04.
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.
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
{
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
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
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
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
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
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,
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:
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
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
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
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:
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
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
since null is a value maybe you want
enum blah = null;
you may also give it a type after the enum word
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
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);
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
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
DO YOU PREFER A LANGUAGE ALL IN UPPERCASE?
Hahahaha! I find it ugly too. I prefer lowercaps null, as in Java.
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
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
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
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
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
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
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
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.
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
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
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
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
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
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)
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
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
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;
Ok thanks, My fault ;p
-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:
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
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
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
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
-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
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
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.
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
-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:
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)
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);
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[]
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
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:
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
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
98 matches
Mail list logo