state of an object

2012-07-02 Thread Namespace
Is it possible to figure out how is the state of an object at compile time? E.g. if the object is null or not: class Foo { } Foo f; static if (is_null(f)) { }

Re: state of an object

2012-07-02 Thread bearophile
Namespace: Is it possible to figure out how is the state of an object at compile time? E.g. if the object is null or not: class Foo { } Foo f; static if (is_null(f)) { } In general you need a tool that analyzes D code statically (and maybe in some cases doesn't give a certain answer).

Re: state of an object

2012-07-02 Thread Jonathan M Davis
On Monday, July 02, 2012 08:19:52 Namespace wrote: Is it possible to figure out how is the state of an object at compile time? E.g. if the object is null or not: class Foo { } Foo f; static if (is_null(f)) { } What are you trying to test exactly? Whether f default initializes to null?

Re: state of an object

2012-07-02 Thread Namespace
In general you need a tool that analyzes D code statically (and maybe in some cases doesn't give a certain answer). Bye, bearophile Short: not so easy. Too bad.

Re: state of an object

2012-07-02 Thread Namespace
My intention was to avoid something like this: [code] class Foo { } Foo f; // f is null NotNull!(Foo) test = f; // should throw an compiler error, because f is null [/code] I can avoid NotNull!(Foo) test = null; with @disable this(typeof(null)); but how can i avoid null objects?

Re: state of an object

2012-07-02 Thread Jonathan M Davis
On Monday, July 02, 2012 10:41:03 Namespace wrote: My intention was to avoid something like this: [code] class Foo { } Foo f; // f is null NotNull!(Foo) test = f; // should throw an compiler error, because f is null [/code] I can avoid NotNull!(Foo) test = null; with @disable

Re: state of an object

2012-07-02 Thread Namespace
Can you show me an example of your two options? I'm not sure what do you exactly mean.

Re: state of an object

2012-07-02 Thread Namespace
I cannot create the Foo objects _in_ the NotNull struct because i need the reference of an specific object. And if i throw an error if the object paramter is null, it's not a compiler error. So there is no way that a null reference as paramter can be detect at compile time? I tried different

Error: null dereference in function _Dmain

2012-07-02 Thread Namespace
I'm getting this with this code: http://dpaste.dzfl.pl/55f83be6 Can someone explain me, _why_ i get this error? o.O I thought D cannot detect null references by itself.

Re: why is string not implicit convertable to const(char*) ?

2012-07-02 Thread mta`chrono
Your answers are remarkable elaborated. Thanks for your great effort, Jonathan!! ;-)

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Tobias Pankrath
On Monday, 2 July 2012 at 15:55:03 UTC, Namespace wrote: I'm getting this with this code: http://dpaste.dzfl.pl/55f83be6 Can someone explain me, _why_ i get this error? o.O I thought D cannot detect null references by itself. Can't check now. But if you get this during runtime, D does detect

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Namespace
On Monday, 2 July 2012 at 16:19:08 UTC, Tobias Pankrath wrote: On Monday, 2 July 2012 at 15:55:03 UTC, Namespace wrote: I'm getting this with this code: http://dpaste.dzfl.pl/55f83be6 Can someone explain me, _why_ i get this error? o.O I thought D cannot detect null references by itself.

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Jonathan M Davis
On Monday, July 02, 2012 17:55:01 Namespace wrote: I'm getting this with this code: http://dpaste.dzfl.pl/55f83be6 Can someone explain me, _why_ i get this error? o.O I thought D cannot detect null references by itself. You didn't actually list what error you're seeing. The error that I'm

Re: state of an object

2012-07-02 Thread Jonathan M Davis
On Monday, July 02, 2012 17:25:03 Namespace wrote: I cannot create the Foo objects _in_ the NotNull struct because i need the reference of an specific object. And if i throw an error if the object paramter is null, it's not a compiler error. So there is no way that a null reference as

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Namespace
You didn't actually list what error you're seeing. The error that I'm seeing (which may differ from yours' because I'm on the latest master, not 2.059, and you're probably on 2.059) is q.d(87): Error: constructor q.NotNull!(Foo).NotNull.this is not callable because it is annotated with

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Jonathan M Davis
On Monday, July 02, 2012 19:36:21 Namespace wrote: You didn't actually list what error you're seeing. The error that I'm seeing (which may differ from yours' because I'm on the latest master, not 2.059, and you're probably on 2.059) is q.d(87): Error: constructor

Debugging compiler crashes?

2012-07-02 Thread Wouter Verhelst
Hi, I have a body of code which makes the compiler frontend segfault. Is there some automated tool which will help me produce a minimal testcase so I can file a bugreport? The body in question is fairly large, just posting that to a bugreport doesn't sound like a good idea to me. Thanks, --

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Namespace
Well, I'm getting q.d(111): Error: no identifier for declarator t q.d(111): Error: found 'in' when expecting ';' due to your erroneous use of in a foreach loop instead of ;, Sorry, that comes of my little compiler hack, as you can see here:

Re: Debugging compiler crashes?

2012-07-02 Thread Timon Gehr
On 07/02/2012 08:38 PM, Wouter Verhelst wrote: Hi, I have a body of code which makes the compiler frontend segfault. Is there some automated tool which will help me produce a minimal testcase so I can file a bugreport? The body in question is fairly large, just posting that to a bugreport

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Ali Çehreli
On 07/02/2012 11:36 AM, Jonathan M Davis wrote: By the way, it's pointless to compile with both -w and -wi. -wi makes it so that warnings are displayed without stopping compilation. -w makes it so that warnings are displayed and treated as errors (so they stop compilation). Pick one or

Re: Debugging compiler crashes?

2012-07-02 Thread Wouter Verhelst
Timon Gehr timon.g...@gmx.ch writes: On 07/02/2012 08:38 PM, Wouter Verhelst wrote: Hi, I have a body of code which makes the compiler frontend segfault. Is there some automated tool which will help me produce a minimal testcase so I can file a bugreport? The body in question is fairly

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Jonathan M Davis
On Monday, July 02, 2012 20:52:19 Namespace wrote: Well, I'm getting q.d(111): Error: no identifier for declarator t q.d(111): Error: found 'in' when expecting ';' due to your erroneous use of in a foreach loop instead of ;, Sorry, that comes of my little compiler hack, as you can

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Ali Çehreli
On 07/02/2012 11:36 AM, Jonathan M Davis wrote: By the way, it's pointless to compile with both -w and -wi. -wi makes it so that warnings are displayed without stopping compilation. -w makes it so that warnings are displayed and treated as errors (so they stop compilation). Pick one or

Re: Debugging compiler crashes?

2012-07-02 Thread Trass3r
dmd: glue.c:542: virtual void FuncDeclaration::toObjFile(int): Assertion `semanticRun == PASSsemantic3done' failed. Aborted wouter@carillon:~/code/d/DustMite$ ... and I'm not yet that fluent in D to understand what's going on. Any ideas? pass dustmite.d before dsplit.d known problem, but the

Re: Debugging compiler crashes?

2012-07-02 Thread Wouter Verhelst
Trass3r u...@known.com writes: dmd: glue.c:542: virtual void FuncDeclaration::toObjFile(int): Assertion `semanticRun == PASSsemantic3done' failed. Aborted wouter@carillon:~/code/d/DustMite$ ... and I'm not yet that fluent in D to understand what's going on. Any ideas? pass dustmite.d

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Jonathan M Davis
On Monday, July 02, 2012 12:45:16 Ali Çehreli wrote: On 07/02/2012 11:36 AM, Jonathan M Davis wrote: By the way, it's pointless to compile with both -w and -wi. -wi makes it so that warnings are displayed without stopping compilation. -w makes it so that warnings are displayed and

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Namespace
If you want to play around with that, that's fine, but the language is not going to change, so please to post code which uses your changes. If you start making changes to the compiler, you can't really expect other people to help you figure out what's wrong with your code - especially since

rdmd failing to generate init data from dependant file

2012-07-02 Thread Francois Chabot
I'm not 100% sure that rdmd is the culprit here, or if it's something OPTLINK isn't picking up. Given the following modules: module a_pkg.a_module; import std.exception ; immutable class Test { string[string] aa ; this( ) { string[string] tmp ;

Re: Debugging compiler crashes?

2012-07-02 Thread Wouter Verhelst
Wouter Verhelst wou...@grep.be writes: Trass3r u...@known.com writes: dmd: glue.c:542: virtual void FuncDeclaration::toObjFile(int): Assertion `semanticRun == PASSsemantic3done' failed. Aborted wouter@carillon:~/code/d/DustMite$ ... and I'm not yet that fluent in D to understand what's

D and gmp

2012-07-02 Thread Jerome BENOIT
Hello List: I am looking for D code using the gmplib: any hint is welcome. Thanks in advance, Jerome

Re: Error: null dereference in function _Dmain

2012-07-02 Thread Namespace
At last a further Stack overflow, maybe you could explain me why. It comes if i try to outsource the redundant code with a mixin template like this: [code] mixin template TRef(T : Object) { private: NotNull!(T) _nn; public: @property NotNull!(T) GetNN() {

Build WindowsApi bindings with dmd?

2012-07-02 Thread Damian
I was looking through the bindings and only see a makefile for GNU make. Is there a version for dmd? I really wanted to avoid GNU make if possible.

Re: Build WindowsApi bindings with dmd?

2012-07-02 Thread dnewbie
On Monday, 2 July 2012 at 22:10:00 UTC, Damian wrote: I was looking through the bindings and only see a makefile for GNU make. Is there a version for dmd? I really wanted to avoid GNU make if possible. You can try this https://github.com/AndrejMitrovic/WindowsAPI/downloads

Re: Debugging compiler crashes?

2012-07-02 Thread Trass3r
... the order of files matters? Yuck. Yep it's a bug.

popFront causing more memory to be used

2012-07-02 Thread ixid
I'm not sure what's going on here. Using this code to solve a reddit programming challenge to return the Nth term of a Fibonacci-like sequence of arbitrary length: module main; import std.stdio, std.array, std.datetime; ulong f(int k, int n) { ulong[] nums = new ulong[k];

Help translating C/C++ snippet to D

2012-07-02 Thread Dustin
Hello, I'm trying to follow along with a C++ tutorial and translate it to D but I don't know C/C++ well enough to understand this #Define statement: #define ARRAY_COUNT( array ) (sizeof( array ) / (sizeof( array[0] ) * (sizeof( array ) != sizeof(void*) || sizeof( array[0] ) =

Debug output functions

2012-07-02 Thread Wouter Verhelst
So, I wanted to create a number of functions that would call write(), writef(), writefln(), or writeln() with whatever arguments they were given, but only if the user had used a 'enable debugging' command-line option (or some such). What I first did was this: module debugout; int debuglevel;

Re: popFront causing more memory to be used

2012-07-02 Thread Era Scarecrow
On Tuesday, 3 July 2012 at 02:20:23 UTC, ixid wrote: I'm not sure what's going on here. Using this code to solve a reddit programming challenge to return the Nth term of a Fibonacci-like sequence of arbitrary length: module main; import std.stdio, std.array, std.datetime; ulong

Re: Help translating C/C++ snippet to D

2012-07-02 Thread nazriel
On Tuesday, 3 July 2012 at 02:34:04 UTC, Dustin wrote: Hello, I'm trying to follow along with a C++ tutorial and translate it to D but I don't know C/C++ well enough to understand this #Define statement: #define ARRAY_COUNT( array ) (sizeof( array ) / (sizeof( array[0] ) * (sizeof( array )