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)) { }
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).
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?
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.
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?
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
Can you show me an example of your two options?
I'm not sure what do you exactly mean.
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
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.
Your answers are remarkable elaborated. Thanks for your great effort,
Jonathan!! ;-)
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
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.
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
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
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
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
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,
--
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:
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
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
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
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
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
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
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
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
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
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 ;
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
Hello List:
I am looking for D code using the gmplib: any hint is welcome.
Thanks in advance,
Jerome
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() {
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.
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
... the order of files matters? Yuck.
Yep it's a bug.
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];
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] ) =
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;
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
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 )
39 matches
Mail list logo