Re: Physics libraries in D

2013-05-09 Thread Andrea Fontana
On Wednesday, 8 May 2013 at 09:43:43 UTC, Mike Parker wrote: Last I checked, Bullet doesn't have a C interface. That means it's unlikely you'll find a D binding. And I haven't heard of any. If it has a c++ interface probably you can bind it using swig.

Re: Scoped import bug?

2013-05-09 Thread Kenji Hara
On Thursday, 9 May 2013 at 05:01:15 UTC, Mike Linford wrote: I'm not sure whether or not I've encountered a bug or whether my understanding of scoped imports is just faulty. blah.d: 1 module blah; 2 3 version(A) 4 { 5import std.range; 6 } 7 8 struct Blah(R) 9 { 10

Template alias parameter does not accept types

2013-05-09 Thread ref2401
Version D 2.062 http://dlang.org/template.html#TemplateAliasParameter Is is said in the documentation that is's possible but i get compile time error. template GetString(alias Arg) { enum string GetString = Arg.stringof; } void main(string[] argv) { writeln(GetString!1234);

Re: Template alias parameter does not accept types

2013-05-09 Thread bearophile
ref2401: template GetString(alias Arg) { enum string GetString = Arg.stringof; } ... writeln(GetString!int); // Error: template instance Template alias arguments don't yet accept built-in types as int. It will be fixed. Bye, bearophile

Tricky code with exceptions

2013-05-09 Thread bearophile
A little Java program I've just found in a blog post: class Flow { static public void main(String[] args) { for (int i = 0; i 6; ++i) { System.out.println(Loop: + i); try { try { if (i == 3)

Re: Template alias parameter does not accept types

2013-05-09 Thread Anonimous
On Thursday, 9 May 2013 at 10:59:02 UTC, ref2401 wrote: Version D 2.062 http://dlang.org/template.html#TemplateAliasParameter Is is said in the documentation that is's possible but i get compile time error. template GetString(alias Arg) { enum string GetString = Arg.stringof; } void

Re: Template alias parameter does not accept types

2013-05-09 Thread Dicebot
On Thursday, 9 May 2013 at 11:19:38 UTC, bearophile wrote: It will be fixed. Ugh, proof-link? I have always thought it is by design and that actually makes sense.

Re: Argument S to typeof is not an expression

2013-05-09 Thread Dicebot
On Thursday, 9 May 2013 at 01:08:28 UTC, Meta wrote: I can't get the structs to be evaluated at compile time, so I guess that's a lost cause. Well, structs can be evaluated at compile-time but can't be value template parameters. You can do a small trick in this case though:

Re: Tricky code with exceptions

2013-05-09 Thread Mike James
bearophile bearophileh...@lycos.com wrote in message news:pnwldlckpgrjvvuje...@forum.dlang.org... SNIP My D translation: import std.stdio; void main() { foreach (i; 0 .. 6) { writeln(Loop: , i); try { try { if (i == 3)

Re: Argument S to typeof is not an expression

2013-05-09 Thread Meta
then add if (!__ctfe) assert(0); to guarantee it will never be used in real run-time. I don't think I've ever seen __ctfe before. Is it specific to DMD?

Re: Tricky code with exceptions

2013-05-09 Thread Maxim Fomin
It works on dpaste http://dpaste.dzfl.pl/fcd2f2b5 which seems to be based on linux 2.62. Which platform do you use? P.S. Seems we can define new kind of forum contribution - some code works as expected in language X, but equivalent code in D goes ballistic. This is very sad.

Re: Argument S to typeof is not an expression

2013-05-09 Thread Dicebot
On Thursday, 9 May 2013 at 12:35:29 UTC, Meta wrote: then add if (!__ctfe) assert(0); to guarantee it will never be used in real run-time. I don't think I've ever seen __ctfe before. Is it specific to DMD? It is documented here : http://dlang.org/function.html The __ctfe boolean

Re: Template alias parameter does not accept types

2013-05-09 Thread Steven Schveighoffer
On Thu, 09 May 2013 06:58:57 -0400, ref2401 refacto...@gmail.com wrote: Version D 2.062 http://dlang.org/template.html#TemplateAliasParameter Is is said in the documentation that is's possible but i get compile time error. template GetString(alias Arg) { enum string GetString =

Re: Template alias parameter does not accept types

2013-05-09 Thread Kenji Hara
On Thursday, 9 May 2013 at 12:09:03 UTC, Dicebot wrote: On Thursday, 9 May 2013 at 11:19:38 UTC, bearophile wrote: It will be fixed. Ugh, proof-link? I have always thought it is by design and that actually makes sense. AFAIK, there is no plan for fix. The behavior is currently a part of

Re: Template alias parameter does not accept types

2013-05-09 Thread bearophile
Steven Schveighoffer: Do you have evidence of an official statement to the contrary? Here I don't have evidence, just faith :-) Bye, bearophile

Re: Template alias parameter does not accept types

2013-05-09 Thread Dicebot
On Thursday, 9 May 2013 at 13:27:35 UTC, Steven Schveighoffer wrote: template GetString(T) if (is(T == int) || is(T == float) || ...) { enum string GetString = T.stringof; } Current idiomatic D way to handle both built-in types and symbols looks like this: template Hello(T...) if

Re: Tricky code with exceptions

2013-05-09 Thread bearophile
Maxim Fomin: It works on dpaste http://dpaste.dzfl.pl/fcd2f2b5 which seems to be based on linux 2.62. On dpaste it also works on gdc2.060 and ldc2.060, both 64 bit. Which platform do you use? Vista 32. Probably I will add it to Bugzilla. P.S. Seems we can define new kind of forum

Re: Template alias parameter does not accept types

2013-05-09 Thread bearophile
Kenji Hara: AFAIK, there is no plan for fix. The behavior is currently a part of language design. Considering matters of D semantic uniformity, and the code shown by Dicebot: template Hello(T...) if (T.length == 1) { static if (is(T[0])) // ... else // ... }

Re: Template alias parameter does not accept types

2013-05-09 Thread Steven Schveighoffer
On Thu, 09 May 2013 09:38:29 -0400, Dicebot m.stras...@gmail.com wrote: On Thursday, 9 May 2013 at 13:27:35 UTC, Steven Schveighoffer wrote: template GetString(T) if (is(T == int) || is(T == float) || ...) { enum string GetString = T.stringof; } Current idiomatic D way to handle both

Re: Template alias parameter does not accept types

2013-05-09 Thread Dicebot
Feels like I am the only one who wants to restrict rules, not relax them =/ But, erm, you don't need alias accepting literals for old syntax! Strings are valid as template value parameters: http://dpaste.1azy.net/54e5d3f2

Re: Template alias parameter does not accept types

2013-05-09 Thread Steven Schveighoffer
On Thu, 09 May 2013 10:00:45 -0400, Dicebot m.stras...@gmail.com wrote: Feels like I am the only one who wants to restrict rules, not relax them =/ But, erm, you don't need alias accepting literals for old syntax! Strings are valid as template value parameters:

Re: Tricky code with exceptions

2013-05-09 Thread Sean Kelly
For what it's worth, this runs fine on 64-bit OSX.

Re: Tricky code with exceptions

2013-05-09 Thread Brad Anderson
On Thursday, 9 May 2013 at 11:24:03 UTC, bearophile wrote: A little Java program I've just found in a blog post: class Flow { static public void main(String[] args) { for (int i = 0; i 6; ++i) { System.out.println(Loop: + i); try { try {

Re: Tricky code with exceptions

2013-05-09 Thread Brad Anderson
On Thursday, 9 May 2013 at 18:24:46 UTC, Brad Anderson wrote: I just tested this for you when you hopped in IRC but you left before I could tell you that a 64-bit Windows dmd build did not crash and here is the output. Oh, and this was dmd 2.062 (just -m64).

Re: Scoped import bug?

2013-05-09 Thread Mike Linford
On Thursday, 9 May 2013 at 09:52:12 UTC, Kenji Hara wrote: On Thursday, 9 May 2013 at 05:01:15 UTC, Mike Linford wrote: I'm not sure whether or not I've encountered a bug or whether my understanding of scoped imports is just faulty. blah.d: 1 module blah; 2 3 version(A) 4 { 5import

Re: Variant associative arrays

2013-05-09 Thread Byron Heads
On Thu, 09 May 2013 03:29:06 +0200, evilrat wrote: first doesn't compile with DMD 2.062 as int implicitly not converted to long. foo func takes associative array, within this example you can use type Variant[string] to make life a bit easier(but i can't recommend it for ur real code cause

Re: Variant associative arrays

2013-05-09 Thread Byron Heads
On Thu, 09 May 2013 02:33:08 +0200, bearophile wrote: Byron Heads: I have a variant associative array. In the example below I am wondering if there is a way to create the array without having to indicate the variant type on all of the values. Would like to be able to write code like #2,

kxml help.

2013-05-09 Thread Zz
Hi, I decided to try out kxml and I have the following error. test.d(10): Error: found '.' when expecting ',' test.d(11): Error: found '.' when expecting ',' when the following is compiled. module test; import kxml.xml; private import std.string; private import std.stdio; void main() {

Re: kxml help.

2013-05-09 Thread John Colvin
On Thursday, 9 May 2013 at 19:32:44 UTC, Zz wrote: Hi, I decided to try out kxml and I have the following error. test.d(10): Error: found '.' when expecting ',' test.d(11): Error: found '.' when expecting ',' when the following is compiled. module test; import kxml.xml; private import

Re: Tricky code with exceptions

2013-05-09 Thread bearophile
Brad Anderson: a 64-bit Windows dmd build did not crash and here is the output. Thank you for the data point. So maybe the problem is only on 32 bit Windows. Bye, bearophile

Re: kxml help.

2013-05-09 Thread Zz
Thanks On Thursday, 9 May 2013 at 20:26:28 UTC, John Colvin wrote: On Thursday, 9 May 2013 at 19:32:44 UTC, Zz wrote: Hi, I decided to try out kxml and I have the following error. test.d(10): Error: found '.' when expecting ',' test.d(11): Error: found '.' when expecting ',' when the

Re: Tricky code with exceptions

2013-05-09 Thread evilrat
On Thursday, 9 May 2013 at 20:33:17 UTC, bearophile wrote: Brad Anderson: a 64-bit Windows dmd build did not crash and here is the output. Thank you for the data point. So maybe the problem is only on 32 bit Windows. Bye, bearophile win8 dmd 2.062 32-bit also crashes

Re: Deallocate array?

2013-05-09 Thread Matic Kukovec
Hi again Steve, or anyone else whose reading this. I was playing around with D and C# and need help getting this array stuff to work. My D program: import std.stdio, std.cstream, std.array; void main() { string[] temp_array = new string[1]; for(int i=0;i1;i++)

Re: Tricky code with exceptions

2013-05-09 Thread Juan Manuel Cabo
Tested on Linux - Kubuntu 12.04 64bits dmd 2.058 -m32 dmd 2.058 64 bits dmd 2.062 -m32 dmd 2.062 and the output is this for all of the above: Loop: 0 Loop: 1 Caught Loop: 2 Loop: 3 Caught Loop: 4 Loop: 5 Caught Then, tested on Windows

Re: Tricky code with exceptions

2013-05-09 Thread Juan Manuel Cabo
On Friday, 10 May 2013 at 01:05:39 UTC, Juan Manuel Cabo wrote: Then, tested on Windows XP SP3 32 bits, dmd 2.062, and it DIDN'T CRASH. The output is: Mm, sorry!!, it did crash but I had dr watson disabled in that VM. Confirmed adding a writeln(finished) after the foreach, which isn't

Re: Deallocate array?

2013-05-09 Thread Ali Çehreli
On 05/09/2013 05:58 PM, Matic Kukovec wrote: Hi again Steve, or anyone else whose reading this. I was playing around with D and C# and need help getting this array stuff to work. [...] My question is what is how do i get the same C# functionality in D without running out of memory and

Re: Deallocate array?

2013-05-09 Thread Steven Schveighoffer
On Thu, 09 May 2013 22:14:41 -0400, Ali Çehreli acehr...@yahoo.com wrote: On a 32-bit system string is 8 bytes (e.g. by pragma(msg, string.sizeof)). So you have a single array of 800 million bytes. Then, each of those strings point at 22 bytes of individully allocated memory areas. No,

Re: Deallocate array?

2013-05-09 Thread Ali Çehreli
On 05/09/2013 07:43 PM, Steven Schveighoffer wrote: On Thu, 09 May 2013 22:14:41 -0400, Ali Çehreli acehr...@yahoo.com wrote: Then, each of those strings point at 22 bytes of individully allocated memory areas. No, each array points at static data. Strings are immutables stored in the

Re: Tricky code with exceptions

2013-05-09 Thread Dan Olson
evilrat evilrat...@gmail.com writes: On Thursday, 9 May 2013 at 20:33:17 UTC, bearophile wrote: Brad Anderson: a 64-bit Windows dmd build did not crash and here is the output. Thank you for the data point. So maybe the problem is only on 32 bit Windows. Bye, bearophile win8 dmd 2.062

Re: Scoped import bug?

2013-05-09 Thread Kenji Hara
On Thursday, 9 May 2013 at 18:25:39 UTC, Mike Linford wrote: On Thursday, 9 May 2013 at 09:52:12 UTC, Kenji Hara wrote: On Thursday, 9 May 2013 at 05:01:15 UTC, Mike Linford wrote: I'm not sure whether or not I've encountered a bug or whether my understanding of scoped imports is just faulty.