Re: Return const object through mutable Object

2012-04-15 Thread Jacob Carlborg
On 2012-04-16 02:33, Jonathan M Davis wrote: It definitely looks like a bug. Whether it returns Foo or Object should have no effect on constness, and since f is a member variable of Foo, and the this pointer/reference is const, bar is going to have to return a const reference to it, which the se

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 anyon

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 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 ma

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
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. Winni

Re: floats default to NaN... why?

2012-04-15 Thread F i L
Jerome BENOIT wrote: Just because mathematical equations behave differently with zero doesn't change the fact that zero _conceptually_ represents "nothing" You are totally wrong: here we are dealing with key concept of the group theory. Zero is the starting place for any (daily used) scale.

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.

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: 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 const

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 >

Re: Templates in classes => what is wrong?

2012-04-15 Thread Ali Çehreli
On 04/15/2012 01:27 PM, jerro wrote: - 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? That's much better. :) D takes care of doing the right thing in that case. Ali

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" 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 impurity, is another mat

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 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 Somedude
Le 15/04/2012 23:33, Ashish Myles a écrit : > On Sun, Apr 15, 2012 at 5:16 PM, Somedude 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 > wrot

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 work

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 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 optimization

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 arra

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]; ram

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 : 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 std.stdio; struct foo

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 Trass3r
Am 15.04.2012, 21:20 Uhr, schrieb 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. Yep.

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.

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: 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. ===

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 = (i

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(): thread

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 error

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 )

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++ ) { > t

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 jo

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 ) ; } ; >} >retu

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 de

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 Artur Skawina
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: 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 t

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)

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: 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

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: 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 up

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 _sh

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 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 abou