Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread James Miller
On 7 March 2012 19:30, H. S. Teoh hst...@quickfur.ath.cx wrote: On 03/06/2012 10:05 PM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Timon Gehr
On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive. The problem is not that length is

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Timon Gehr
On 03/07/2012 11:01 AM, Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive.

Re: Raw socket TCP/IP

2012-03-07 Thread maarten van damme
this might be a little late but could it be that the ethernet header was also needed?

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Andrej Mitrovic
On 3/7/12, Timon Gehr timon.g...@gmx.ch wrote: The problem is not that length is unsigned. The issue is the implicit conversion from signed to unsigned. You bet. I've once had this hard to spot bug where I've used a call that was something like max(0, min(10, expression)), and this ended up

Re: Why is std.algorithm.reduce impure?

2012-03-07 Thread Simen Kjærås
On Wed, 07 Mar 2012 01:41:22 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: It really takes very little for something to be impure, and optimizations often do it, because they end up using low-level constructs which aren't pure - some of which could be but aren't and others which

Re: Why is std.algorithm.reduce impure?

2012-03-07 Thread Timon Gehr
On 03/07/2012 05:29 PM, Simen Kjærås wrote: On Wed, 07 Mar 2012 01:41:22 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: It really takes very little for something to be impure, and optimizations often do it, because they end up using low-level constructs which aren't pure - some of which

Re: duplicate symbol linker errors, my fault or D's?

2012-03-07 Thread Zach the Mystic
On Tuesday, 6 March 2012 at 07:29:54 UTC, Jacob Carlborg wrote: Actually the -lib switch might be the answer to one of the incremental compilation problems DMD suffers from. That DMD usually does not output all symbols to all object files which can result in missing symbols when doing

SocketStream exceptions and disconnect handling

2012-03-07 Thread Pedro Lacerda
Hi all, I'm trying to handle disconnections transparently on SocketStream. I thought something like this: void send(ubyte[] buffer) in { assert(buffer.length 0); } body { if (!stream.isAlive) connect(); auto sent = stream.write(buffer); if (sent == 0) throw new

Re: SocketStream exceptions and disconnect handling

2012-03-07 Thread Pedro Lacerda
My english is bugged, I mean handle reconnections transparently. Sorry. Pedro Lacerda 2012/3/7 Pedro Lacerda pslace...@gmail.com Hi all, I'm trying to handle disconnections transparently on SocketStream. I thought something like this: void send(ubyte[] buffer) in { assert(buffer.length

Re: SocketStream exceptions and disconnect handling

2012-03-07 Thread Regan Heath
On Wed, 07 Mar 2012 17:29:25 -, Pedro Lacerda pslace...@gmail.com wrote: 2012/3/7 Pedro Lacerda pslace...@gmail.com Hi all, I'm trying to handle disconnections transparently on SocketStream. I thought something like this: void send(ubyte[] buffer) in { assert(buffer.length 0); } body {

Re: Why is std.algorithm.reduce impure?

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 17:58:43 Timon Gehr wrote: On 03/07/2012 05:29 PM, Simen Kjærås wrote: On Wed, 07 Mar 2012 01:41:22 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: It really takes very little for something to be impure, and optimizations often do it, because they end up

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 11:01:05 Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better

Re: Why is std.algorithm.reduce impure?

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 17:29:24 Simen Kjærås wrote: On Wed, 07 Mar 2012 01:41:22 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: It really takes very little for something to be impure, and optimizations often do it, because they end up using low-level constructs which aren't

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Sean Cavanaugh
On 3/7/2012 12:57 PM, Jonathan M Davis wrote: On Wednesday, March 07, 2012 11:01:05 Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the I suspect that the reality of the matter is that if we disallowed implicit

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 13:20:41 Sean Cavanaugh wrote: On 3/7/2012 12:57 PM, Jonathan M Davis wrote: On Wednesday, March 07, 2012 11:01:05 Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the I suspect that

Re: D RTTI?

2012-03-07 Thread Artur Skawina
On 03/07/12 00:19, H. S. Teoh wrote: On Tue, Mar 06, 2012 at 11:40:19PM +0100, Artur Skawina wrote: On 03/06/12 20:37, H. S. Teoh wrote: On Tue, Mar 06, 2012 at 01:51:51AM +0100, Artur Skawina wrote: [...] class A { string prop1; int prop2; void serialize(this THIS)() {

Method invocation -- why it's not working?

2012-03-07 Thread Comrad
1 struct A 2 { 3 double[2] _x; 4 } 5 6 @property ref double y(ref A a) {return a._x[1];} 7 8 void main() 9 { 10 A a1; 11 a1.y=2.; 12 } dmd test.d gives me: Error: no property 'y' for type 'A'

Ddoc: no docs generated for nested structs?

2012-03-07 Thread H. S. Teoh
I wrote a whole bunch of documentation for a struct that I later decided to transplant inside another struct (because the two are closely linked), and now the former struct's docs have vanished. Is this expected behaviour? T -- I am a consultant. My job is to make your job redundant. -- Mr Tom

Re: Method invocation -- why it's not working?

2012-03-07 Thread Simen Kjærås
On Thu, 08 Mar 2012 00:21:36 +0100, Comrad comrad.karlov...@googlemail.com wrote: 1 struct A 2 { 3 double[2] _x; 4 } 5 6 @property ref double y(ref A a) {return a._x[1];} 7 8 void main() 9 { 10 A a1; 11 a1.y=2.; 12 } dmd test.d gives me: Error: no

Re: Method invocation -- why it's not working?

2012-03-07 Thread Ali Çehreli
On 03/07/2012 03:21 PM, Comrad wrote: 1 struct A 2 { 3 double[2] _x; 4 } 5 6 @property ref double y(ref A a) {return a._x[1];} 7 8 void main() 9 { 10 A a1; 11 a1.y=2.; 12 } dmd test.d gives me: Error: no property 'y' for type 'A' You are testing out the new UFCS, right? Well, I

Re: Method invocation -- why it's not working?

2012-03-07 Thread Ali Çehreli
On 03/07/2012 03:54 PM, Ali Çehreli wrote: On 03/07/2012 03:21 PM, Comrad wrote: 1 struct A 2 { 3 double[2] _x; 4 } 5 6 @property ref double y(ref A a) {return a._x[1];} 7 8 void main() 9 { 10 A a1; 11 a1.y=2.; 12 } dmd test.d gives me: Error: no property 'y' for

Re: Method invocation -- why it's not working?

2012-03-07 Thread Andrej Mitrovic
Don't worry Ali I thought the same thing. :p

Re: Ddoc: no docs generated for nested structs?

2012-03-07 Thread H. S. Teoh
On Wed, Mar 07, 2012 at 03:49:26PM -0800, H. S. Teoh wrote: I wrote a whole bunch of documentation for a struct that I later decided to transplant inside another struct (because the two are closely linked), and now the former struct's docs have vanished. Is this expected behaviour? [...]

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Ary Manzana
On 3/7/12 2:28 AM, Ali Çehreli wrote: On 03/06/2012 09:11 PM, ixid wrote: I'm writing my first basic algorithms, this one is merge sort. This version throws an exception when array.length - setSize is negative (which should be fine, the rest of my function would deal with it): template

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread James Miller
On 8 March 2012 15:39, Ary Manzana a...@esperanto.org.ar wrote: On 3/7/12 2:28 AM, Ali Çehreli wrote: On 03/06/2012 09:11 PM, ixid wrote:   I'm writing my first basic algorithms, this one is merge sort. This   version throws an exception when array.length - setSize is negative   (which

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Jonathan M Davis
On Thursday, March 08, 2012 16:15:08 James Miller wrote: Its the semantics in C/C++ and D explicitly tries to have the same semantics as them. From what I remember its to aid people moving from those language to D. More like it's to avoid code silently breaking when it's ported. In general,

Re: Ddoc: no docs generated for nested structs?

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 16:37:44 H. S. Teoh wrote: On Wed, Mar 07, 2012 at 03:49:26PM -0800, H. S. Teoh wrote: I wrote a whole bunch of documentation for a struct that I later decided to transplant inside another struct (because the two are closely linked), and now the former struct's

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Ellery Newcomer
On 03/07/2012 12:23 AM, Ali Çehreli wrote: There are probably hundreds of discussions about that over the years on many different language newsgroups and forums. :) There is no clear winner: Both sides of the arguments seem to have good points. Ali know any good ones off the top of your

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Ali Çehreli
On 03/07/2012 07:51 PM, Ellery Newcomer wrote: On 03/07/2012 12:23 AM, Ali Çehreli wrote: There are probably hundreds of discussions about that over the years on many different language newsgroups and forums. :) There is no clear winner: Both sides of the arguments seem to have good points.

Can I do an or in a version block?

2012-03-07 Thread Tyler Jameson Little
I would like to do something like this: version (linux || BSD) { // do something... } else { version (Windows) { // do something else } else { // do something else assert(false, Unsupported operating system); } } The only way I've been able to do this, is

Re: Can I do an or in a version block?

2012-03-07 Thread James Miller
On 8 March 2012 18:38, Tyler Jameson Little beatgam...@gmail.com wrote: I would like to do something like this: version (linux || BSD) {    // do something... } else {    version (Windows) {        // do something else    } else {        // do something else        assert(false,

Re: Can I do an or in a version block?

2012-03-07 Thread Ali Çehreli
On 03/07/2012 10:07 PM, James Miller wrote: On 8 March 2012 18:38, Tyler Jameson Littlebeatgam...@gmail.com wrote: I would like to do something like this: version (linux || BSD) { // do something... } else { version (Windows) { // do something else } else { // do

Re: Can I do an or in a version block?

2012-03-07 Thread Jonathan M Davis
On Thursday, March 08, 2012 06:38:48 Tyler Jameson Little wrote: I would like to do something like this: version (linux || BSD) { // do something... } else { version (Windows) { // do something else } else { // do something else assert(false,

Re: Method invocation -- why it's not working?

2012-03-07 Thread Comrad
On Thursday, 8 March 2012 at 00:04:55 UTC, Ali Çehreli wrote: On 03/07/2012 03:54 PM, Ali Çehreli wrote: On 03/07/2012 03:21 PM, Comrad wrote: 1 struct A 2 { 3 double[2] _x; 4 } 5 6 @property ref double y(ref A a) {return a._x[1];} 7 8 void main() 9 { 10 A a1; 11 a1.y=2.; 12 } dmd

Re: Method invocation -- why it's not working?

2012-03-07 Thread H. S. Teoh
On Thu, Mar 08, 2012 at 07:32:18AM +0100, Comrad wrote: [...] Basically, I was following Andrei's book, where this feature is described. It's a pity, that it's not working (except arrays somehow) :( - I need it! Yeah there are some features in the book that aren't completely implemented yet.

Re: Method invocation -- why it's not working?

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 22:40:02 H. S. Teoh wrote: On Thu, Mar 08, 2012 at 07:32:18AM +0100, Comrad wrote: [...] Basically, I was following Andrei's book, where this feature is described. It's a pity, that it's not working (except arrays somehow) :( - I need it! Yeah there are

Re: Can I do an or in a version block?

2012-03-07 Thread Tyler Jameson Little
Now, you could do version(x) version = xOrY else version(y) version = xOrY version(xOrY) {} Huh, clever! I like it!! I hope I don't have to do that very often, though... Of course, if the issue is linux || FreeBSD, you might want to just consider using Posix. Unless you're doing

Re: Can I do an or in a version block?

2012-03-07 Thread Tyler Jameson Little
Now, you could do version(x) version = xOrY else version(y) version = xOrY version(xOrY) {} Huh, clever! I like it!! I hope I don't have to do that very often, though... Of course, if the issue is linux || FreeBSD, you might want to just consider using Posix. Unless you're doing

Re: Raw socket TCP/IP

2012-03-07 Thread Tyler Jameson Little
Just curious, but what exactly do you need a raw IP socket for?

Re: Raw socket TCP/IP

2012-03-07 Thread dennis luehring
Am 08.02.2012 19:35, schrieb Eyyub: BUMP, I really need help please ! Eyyub. what are you trying to archive? did you got an Ethernet-Frame+IP-Frame+(your replacement for tcp or udp) - or are your trying to change the tcp frame before sending? and if your using Windows:

Re: Method invocation -- why it's not working?

2012-03-07 Thread Comrad
On Thursday, 8 March 2012 at 06:43:45 UTC, Jonathan M Davis wrote: On Wednesday, March 07, 2012 22:40:02 H. S. Teoh wrote: On Thu, Mar 08, 2012 at 07:32:18AM +0100, Comrad wrote: [...] Basically, I was following Andrei's book, where this feature is described. It's a pity, that it's not

Re: Method invocation -- why it's not working?

2012-03-07 Thread Jonathan M Davis
On Thursday, March 08, 2012 08:37:38 Comrad wrote: On Thursday, 8 March 2012 at 06:43:45 UTC, Jonathan M Davis wrote: On Wednesday, March 07, 2012 22:40:02 H. S. Teoh wrote: On Thu, Mar 08, 2012 at 07:32:18AM +0100, Comrad wrote: [...] Basically, I was following Andrei's book, where