Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread ReneSac
On Sunday, 15 April 2012 at 02:56:21 UTC, Joseph Rushton Wakeling wrote: On Saturday, 14 April 2012 at 19:51:21 UTC, Joseph Rushton Wakeling wrote: GDC has all the regular gcc optimization flags available IIRC. The ones on the GDC man page are just the ones specific to GDC. I'm not talking

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Joseph Rushton Wakeling
On 15/04/12 09:23, ReneSac wrote: What really amazes me is the difference between g++, DMD and GDC in size of the executable binary. 100 orders of magnitude! I have remarked it in another topic before, with a simple hello world. I need to update there, now that I got DMD working. BTW, it is 2

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Joseph Rushton Wakeling
On 15/04/12 10:29, Joseph Rushton Wakeling wrote: ... the compiler accepts it. Whether that's because it's acceptably pure, or because the compiler just doesn't detect this case of impurity, is another matter. The int k is certainly mutable from outside the scope of the function, so AFAICS it

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Dmitry Olshansky
On 15.04.2012 12:29, Joseph Rushton Wakeling wrote: On 15/04/12 09:23, ReneSac wrote: What really amazes me is the difference between g++, DMD and GDC in size of the executable binary. 100 orders of magnitude! I have remarked it in another topic before, with a simple hello world. I need to

Spawn threads and receive/send

2012-04-15 Thread Luis Panadero Guardeño
I'm trying to implement a clock thread that sends messages and get blocked when the message queue it's full. So I try this: void func() { int n; while (1) { receive( (int i) { writeln(n, : Received the number , i); n++;} ); } } void clock() { receive((Tid tid) { while (1) {

Re: Spawn threads and receive/send

2012-04-15 Thread Luis Panadero Guardeño
Auto response : the main thread ends, and It signal func to end, so It never receive any message from clock. I fix it, doing that main sleep 1000 seconds after sending func Tid to clock Luis Panadero Guardeño wrote: I'm trying to implement a clock thread that sends messages and get blocked

Templates in classes = what is wrong?

2012-04-15 Thread Xan
hi, I have this code: import std.conv, std.stdio, std.stream, std.string; import std.socket, std.socketstream; import std.datetime; class Algorisme(U,V) { string nom; uint versio; V delegate (U) funcio; } int main(string [] args) { auto alg = Algorisme!(int,int); alg.nom

Re: Templates in classes = what is wrong?

2012-04-15 Thread John Chapman
On Sunday, 15 April 2012 at 11:16:43 UTC, Xan wrote: int main(string [] args) { auto alg = Algorisme!(int,int); Should be: auto alg = new Algorisme!(int, int); alg.nom = Doblar; alg.versio = 1; alg.funcio = (int a) {return 2*a}; Should be: alg.funcio = (int a)

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Kevin Cox
On Apr 15, 2012 4:30 AM, Joseph Rushton Wakeling joseph.wakel...@webdrake.net wrote: ... the compiler accepts it. Whether that's because it's acceptably pure, or because the compiler just doesn't detect this case of impurity, is another matter. The int k is certainly mutable from outside the

Re: Calling delegate properties without parens

2012-04-15 Thread Piotr Szturmaj
Artur Skawina wrote: On 04/15/12 03:01, Piotr Szturmaj wrote: Artur Skawina wrote: @property is for functions masquerading as data, i'm not sure extending it to pointers and delegates would be a good idea. What you are asking for is basically syntax sugar for: struct CommonInputRange(E)

Re: Calling delegate properties without parens

2012-04-15 Thread Piotr Szturmaj
Jonathan M Davis wrote: On Saturday, April 14, 2012 20:47:20 Piotr Szturmaj wrote: struct CommonInputRange(E) { @property bool delegate() empty; @property E delegate() front; void delegate() popFront; } front returns an element in the range. In your case, it's returning a

Re: Thread join behaviour

2012-04-15 Thread Russel Winder
On Sat, 2012-04-14 at 23:25 +0200, Artur Skawina wrote: [...] 'threads' is a (lazy) range; auto threads = array(map ! ( ( int a ) { void delegate ( ) f ( ) { return delegate ( ) { writeln ( a ) ; } ; } return new

Re: Thread join behaviour

2012-04-15 Thread Russel Winder
On Sat, 2012-04-14 at 17:10 -0400, Matt Soucy wrote: [...] If you merge the two foreach loops into one, doing t.start();t.join(); it doesn't have this issue. Also, when I run your code repeatedly the number of successful numbers printed changes a lot. I'm assuming that you're trying to join

Re: Thread join behaviour

2012-04-15 Thread Russel Winder
On Sat, 2012-04-14 at 23:27 +0200, Somedude wrote: [...] This works: int main ( immutable string[] args ) { auto threadgroup = new ThreadGroup(); void delegate ( ) f (int a ) { return delegate ( ) { writeln ( a ) ; } ; } for ( int n = 0; n 10; n++ ) {

Re: Thread join behaviour

2012-04-15 Thread Artur Skawina
On 04/15/12 15:55, Russel Winder wrote: On Sat, 2012-04-14 at 23:25 +0200, Artur Skawina wrote: [...] 'threads' is a (lazy) range; auto threads = array(map ! ( ( int a ) { void delegate ( ) f ( ) { return delegate ( ) { writeln ( a ) ; } ;

Return const object through mutable Object

2012-04-15 Thread Jacob Carlborg
class Foo { Foo f; Foo bar () const { return f; } } The above code results in the compile error: Error: cannot implicitly convert expression (this.f) of type const(Foo) to test.Foo But if I change bar to: Object bar () const { return f; } I don't get any

Re: Spawn threads and receive/send

2012-04-15 Thread Ali Çehreli
On 04/15/2012 03:03 AM, Luis Panadero Guardeño wrote: Auto response : the main thread ends, and It signal func to end, so It never receive any message from clock. I fix it, doing that main sleep 1000 seconds after sending func Tid to clock This too should work at the end of main():

Re: Templates in classes = what is wrong?

2012-04-15 Thread Xan
On Sunday, 15 April 2012 at 11:23:37 UTC, John Chapman wrote: On Sunday, 15 April 2012 at 11:16:43 UTC, Xan wrote: int main(string [] args) { auto alg = Algorisme!(int,int); Should be: auto alg = new Algorisme!(int, int); alg.nom = Doblar; alg.versio = 1; alg.funcio =

Re: Thread join behaviour

2012-04-15 Thread Russel Winder
On Sun, 2012-04-15 at 16:04 +0200, Artur Skawina wrote: [...] (my old GDC needs the explicit function, no idea if newer frontends still require that) OK, works for me with GDC as well, DMD is broken! I'll file a bug report. -- Russel.

this() const

2012-04-15 Thread sclytrack
this( const size_t step) const { this.step = step; } Error: cannot modify const/immutable/inout expression this.step Is this the expected behavior? Thanks.

Re: Templates in classes = what is wrong?

2012-04-15 Thread Ali Çehreli
On 04/15/2012 11:39 AM, Xan wrote: On Sunday, 15 April 2012 at 11:23:37 UTC, John Chapman wrote: On Sunday, 15 April 2012 at 11:16:43 UTC, Xan wrote: int main(string [] args) { auto alg = Algorisme!(int,int); Should be: auto alg = new Algorisme!(int, int); alg.nom = Doblar; alg.versio

Re: this() const

2012-04-15 Thread Trass3r
Am 15.04.2012, 21:20 Uhr, schrieb sclytrack sclytr...@hotmail.com: this( const size_t step) const { this.step = step; } Error: cannot modify const/immutable/inout expression this.step Is this the expected behavior? Thanks. Yep.

Re: Templates in classes = what is wrong?

2012-04-15 Thread jerro
- Return 0 from main() for successful exit, anything else by convention means some sort of error. Why not just declare main return type to be void?

Re: this() const

2012-04-15 Thread Simon
On 15/04/2012 21:07, Trass3r wrote: Am 15.04.2012, 21:20 Uhr, schrieb sclytrack sclytr...@hotmail.com: this( const size_t step) const { this.step = step; } Error: cannot modify const/immutable/inout expression this.step Is this the expected behavior? Thanks. Yep. No it's not: import

Re: shared status

2012-04-15 Thread Kapps
On Saturday, 14 April 2012 at 10:48:16 UTC, Luis Panadero Guardeño wrote: What is the status of shared types ? I try it with gdmd v4.6.3 And I not get any warring/error when I do anything over a shared variable without using atomicOp. It's normal ? shared ushort ram[ram_size];

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Somedude
Le 15/04/2012 09:23, ReneSac a écrit : On Sunday, 15 April 2012 at 02:56:21 UTC, Joseph Rushton Wakeling wrote: On Saturday, 14 April 2012 at 19:51:21 UTC, Joseph Rushton Wakeling wrote: GDC has all the regular gcc optimization flags available IIRC. The I notice the 2D array is declared

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Ashish Myles
On Sun, Apr 15, 2012 at 5:16 PM, Somedude lovelyd...@mailmetrash.com wrote: Le 15/04/2012 09:23, ReneSac a écrit : On Sunday, 15 April 2012 at 02:56:21 UTC, Joseph Rushton Wakeling wrote: On Saturday, 14 April 2012 at 19:51:21 UTC, Joseph Rushton Wakeling wrote: GDC has all the regular gcc

Re: Thread join behaviour

2012-04-15 Thread Somedude
Le 15/04/2012 20:40, Russel Winder a écrit : On Sun, 2012-04-15 at 16:04 +0200, Artur Skawina wrote: [...] (my old GDC needs the explicit function, no idea if newer frontends still require that) OK, works for me with GDC as well, DMD is broken! I'll file a bug report. It works here (DMD

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Somedude
Le 15/04/2012 23:33, Ashish Myles a écrit : On Sun, Apr 15, 2012 at 5:16 PM, Somedude lovelyd...@mailmetrash.com wrote: Le 15/04/2012 09:23, ReneSac a écrit : On Sunday, 15 April 2012 at 02:56:21 UTC, Joseph Rushton Wakeling wrote: On Saturday, 14 April 2012 at 19:51:21 UTC, Joseph Rushton

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Somedude
Le 15/04/2012 23:41, Somedude a écrit : Le 15/04/2012 23:33, Ashish Myles a écrit : On Sun, Apr 15, 2012 at 5:16 PM, Somedude lovelyd...@mailmetrash.com wrote: Oh right, sorry for this. It's a bit confusing. Now apart from comparing the generated asm, I don't see.

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-15 Thread Timon Gehr
On 04/15/2012 02:23 PM, Kevin Cox wrote: On Apr 15, 2012 4:30 AM, Joseph Rushton Wakeling joseph.wakel...@webdrake.net mailto:joseph.wakel...@webdrake.net wrote: ... the compiler accepts it. Whether that's because it's acceptably pure, or because the compiler just doesn't detect this case of

Re: Return const object through mutable Object

2012-04-15 Thread Jonathan M Davis
On Sunday, April 15, 2012 17:57:27 Jacob Carlborg wrote: class Foo { Foo f; Foo bar () const { return f; } } The above code results in the compile error: Error: cannot implicitly convert expression (this.f) of type const(Foo) to test.Foo But if I

Re: this() const

2012-04-15 Thread Jonathan M Davis
On Sunday, April 15, 2012 21:20:23 sclytrack wrote: this( const size_t step) const { this.step = step; } Error: cannot modify const/immutable/inout expression this.step Is this the expected behavior? Thanks. const and immutable postblit constructors

making ntfs do faster deletes

2012-04-15 Thread Jay Norwood
I'm trying to figure out how to achieve folder deletion times close to the times achieved with the parallel rmd after myDefrag sortByName on a folder. It takes less than 3.5 secs for a 2G layout that has been sorted, and with the rmd configured so that it also works on a sorted list. This is a

Re: floats default to NaN... why?

2012-04-15 Thread F i L
Forums are messing up, so I'll try and respond in sections. /test

Re: floats default to NaN... why?

2012-04-15 Thread F i L
Actually, all of this discussion has made me think that having a compiler flag to change FP values to zero as default would be a good idea. Basically my opinion is largely influenced by a couple things. That is: - I believe a lot of good programmers are used to using zero for default.

Re: floats default to NaN... why?

2012-04-15 Thread bearophile
F i L: I should be able to tackle something like adding a compiler flag to default FP variables to zero. If I write the code, would anyone object to having a flag for this? I strongly doubt Walter Andrei will accept this in the main DMD trunk. Bye, bearophile

Re: floats default to NaN... why?

2012-04-15 Thread F i L
On Monday, 16 April 2012 at 03:25:15 UTC, bearophile wrote: F i L: I should be able to tackle something like adding a compiler flag to default FP variables to zero. If I write the code, would anyone object to having a flag for this? I strongly doubt Walter Andrei will accept this in the

Re: floats default to NaN... why?

2012-04-15 Thread Ary Manzana
On 4/16/12 12:00 PM, F i L wrote: On Monday, 16 April 2012 at 03:25:15 UTC, bearophile wrote: F i L: I should be able to tackle something like adding a compiler flag to default FP variables to zero. If I write the code, would anyone object to having a flag for this? I strongly doubt Walter

Re: floats default to NaN... why?

2012-04-15 Thread F i L
On Monday, 16 April 2012 at 04:05:35 UTC, Ary Manzana wrote: On 4/16/12 12:00 PM, F i L wrote: On Monday, 16 April 2012 at 03:25:15 UTC, bearophile wrote: F i L: I should be able to tackle something like adding a compiler flag to default FP variables to zero. If I write the code, would