Re: Reflection

2012-02-28 Thread Timon Gehr
On 02/28/2012 07:27 AM, Joshua Niehus wrote: On Tuesday, 28 February 2012 at 06:10:11 UTC, Jesse Phillips wrote: It is a template. I see, thanks. And I bet its not possible to figure out if a template is a function template or a class template etc... You can trivially test whether the

Re: Is empty array null?

2012-02-28 Thread Mikael Lindsten
2012/2/28 Pedro Lacerda pslace...@gmail.com So are a newly allocated array and a null one just the same thing? int[] a = [], b = null; assert(a == b); assert(a.length == b.length); assert(a.ptr == a.ptr); Hi all, Sorry if this is a stupid question - I'm new to D but I've

Re: Is empty array null?

2012-02-28 Thread bearophile
Mikael Lindsten: Coming from the Java/C# world, not distinguishing between an empty array and null feels strange to me. Is this so for strings as well? ...and in Pedros example, if you assign null to b and then try to access b.length, don't you get a NullPointerException? What am I missing?

Re: class templates and static if

2012-02-28 Thread Dmitry Olshansky
On 28.02.2012 2:17, Ali Çehreli wrote: On 02/27/2012 02:06 PM, Jonathan M Davis wrote: I'm not saying that dmd doesn't ever optimize switch statements. I'm just saying that as I understand it, it doesn't always do so (its performance with ranged case statements isn't great for instance).

Re: Is empty array null?

2012-02-28 Thread Jesse Phillips
On Tuesday, 28 February 2012 at 08:38:10 UTC, Mikael Lindsten wrote: Coming from the Java/C# world, not distinguishing between an empty array and null feels strange to me. Is this so for strings as well? ...and in Pedros example, if you assign null to b and then try to access b.length, don't

Re: Is empty array null?

2012-02-28 Thread Mikael Lindsten
2012/2/28 Jesse Phillips jessekphillip...@gmail.com string is an array, alias immutable(char)[], so the same rules apply. I know about string being an alias, hence the question. This means that I can doif (someString.length) { ... }without worrying about the null case (?). That's

Random behavior using a wrapped C library

2012-02-28 Thread simendsjo
I'm getting some unexpected results (crashes or random behavior) when using a wrapped C struct in a library. I have no idea why this is happening as everything else (including other wrapped structs) seems to work just fine. Could it be some alignment issues..? extern(C): //typedef

Re: Is empty array null?

2012-02-28 Thread Ellery Newcomer
On 02/28/2012 05:25 AM, Mikael Lindsten wrote: This means that I can doif (someString.length) { ... }without worrying about the null case (?). That's great! Correct

Re: Random behavior using a wrapped C library

2012-02-28 Thread Trass3r
http://d.puremagic.com/issues/show_bug.cgi?id=5570

Re: Random behavior using a wrapped C library

2012-02-28 Thread simendsjo
On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote: http://d.puremagic.com/issues/show_bug.cgi?id=5570 Thanks. I've literally spent hours testing various things without any luck - would have been simpler if I knew asm :/ A blocker for using x64 on linux then.

Comparison of TickDuration and StopWatch.peek

2012-02-28 Thread Matej Nanut
Hello everyone, I have the following code snippet: import core.time:TickDuration; import std.datetime: StopWatch, AutoStart; void main() { auto wait = TickDuration.from!`msecs`(1000); auto timer = StopWatch(AutoStart.yes); while (timer.peek wait) // Okay. { } while

Re: Comparison of TickDuration and StopWatch.peek

2012-02-28 Thread Jonathan M Davis
On Tuesday, February 28, 2012 19:15:01 Matej Nanut wrote: Hello everyone, I have the following code snippet: import core.time: TickDuration; import std.datetime: StopWatch, AutoStart; void main() { auto wait = TickDuration.from!`msecs`(1000); auto timer =

Re: Comparison of TickDuration and StopWatch.peek

2012-02-28 Thread Andrej Mitrovic
Also you can force property calls in your code if you compile with -property. Property notation has not been enforced so far, but might be in the future afaik.

Re: Comparison of TickDuration and StopWatch.peek

2012-02-28 Thread Matej Nanut
So I can call any (void) method without parenthesis without -property? I guess I'll just add -property to all my programs from now on. But why isn't .peek() a property? In std.container, for example, the BinaryHeap has a .front property (even though it isn't declared as such on dlang.org, but the

Re: Reflection

2012-02-28 Thread Jonathan M Davis
On Tuesday, February 28, 2012 06:56:10 Joshua Niehus wrote: Hello, I dont understand the following snippet's output: import std.stdio, std.traits; void main() { writeln(isSomeFunction!(writeln)); writeln(isCallable!(writeln)); writeln(Yes I am...); } /* OUTPUT */ false false Yes

Re: Comparison of TickDuration and StopWatch.peek

2012-02-28 Thread Jonathan M Davis
On Tuesday, February 28, 2012 20:14:14 Matej Nanut wrote: So I can call any (void) method without parenthesis without -property? I guess I'll just add -property to all my programs from now on. But why isn't .peek() a property? In std.container, for example, the BinaryHeap has a .front property

Re: Random behavior using a wrapped C library

2012-02-28 Thread Trass3r
A blocker for using x64 on linux then. Use gdc. Better codegen anyway.

Re: Random behavior using a wrapped C library

2012-02-28 Thread Mike Parker
On 2/29/2012 1:10 AM, simendsjo wrote: On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote: http://d.puremagic.com/issues/show_bug.cgi?id=5570 Thanks. I've literally spent hours testing various things without any luck - would have been simpler if I knew asm :/ A blocker for

passing a string with the character as an argument

2012-02-28 Thread jic
Greetings! I have this program, import std.process : system; import std.stdio; int main(char[][] args) { char[] cmd; for (int i=1;iargs.length;i++) { cmd ~= args[i] ~ ; } writefln(cmd); return(1); } if I compile it and run it this way, test 1! 2@ 3 4# the result is 1! 2@ 3

Re: passing a string with the character as an argument

2012-02-28 Thread James Miller
On 29 February 2012 18:51, jic cabr...@wrc.xerox.com wrote: Greetings! I have this program, import std.process : system; import std.stdio; int main(char[][] args) {  char[] cmd;  for (int i=1;iargs.length;i++)  {    cmd ~= args[i] ~ ;  }  writefln(cmd);  return(1); } if I

Re: Random behavior using a wrapped C library

2012-02-28 Thread simendsjo
On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker aldac...@gmail.com wrote: On 2/29/2012 1:10 AM, simendsjo wrote: On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote: http://d.puremagic.com/issues/show_bug.cgi?id=5570 Thanks. I've literally spent hours testing various things

Re: Random behavior using a wrapped C library

2012-02-28 Thread James Miller
On 29 February 2012 19:30, simendsjo simend...@gmail.com wrote: On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker aldac...@gmail.com wrote: On 2/29/2012 1:10 AM, simendsjo wrote: On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote:

Re: passing a string with the character as an argument

2012-02-28 Thread Jos van Uden
On 29-2-2012 7:06, James Miller wrote: On 29 February 2012 18:51, jiccabr...@wrc.xerox.com wrote: Greetings! I have this program, import std.process : system; import std.stdio; int main(char[][] args) { char[] cmd; for (int i=1;iargs.length;i++) { cmd ~= args[i] ~ ; }

Re: Random behavior using a wrapped C library

2012-02-28 Thread Kagamin
On Wednesday, 29 February 2012 at 06:30:27 UTC, simendsjo wrote: A strange thing is that memory consumption went _up_ when everything was compiled as x32. Data/code/symbols size?

Re: passing a string with the character as an argument

2012-02-28 Thread James Miller
On 29 February 2012 20:21, Jos van Uden user@domain.invalid wrote: On 29-2-2012 7:06, James Miller wrote: On 29 February 2012 18:51, jiccabr...@wrc.xerox.com  wrote: Greetings! I have this program, import std.process : system; import std.stdio; int main(char[][] args) {  char[] cmd;