Re: template specialization

2010-06-08 Thread Don
Larry Luther wrote: Thanks guys. Simen asked: "Is there a problem?". Well, I kind of expected a "ubyte" buffer to be matched with a "get(T:ubyte)". I thought methods were searched for the "best" match. No, C++ does it that way, and it gets horrendously complicated. In D, it has to ma

Re: template specialization

2010-06-08 Thread Larry Luther
Thanks guys. Simen asked: "Is there a problem?". Well, I kind of expected a "ubyte" buffer to be matched with a "get(T:ubyte)". I thought methods were searched for the "best" match. Larry

Re: template specialization

2010-06-08 Thread Ellery Newcomer
On 06/08/2010 05:01 PM, Robert Clipsham wrote: On 08/06/10 22:25, Larry Luther wrote: Q: Is this the way it's supposed to be? Yes, byte implicitly casts to ubyte so it's accepted. Try switching the templates round, they will both be byte. The way around this is to add template constraints to t

Re: template specialization

2010-06-08 Thread Robert Clipsham
On 08/06/10 22:25, Larry Luther wrote: Q: Is this the way it's supposed to be? Yes, byte implicitly casts to ubyte so it's accepted. Try switching the templates round, they will both be byte. The way around this is to add template constraints to the templates: void get(T:ubyte)(T[] buffer)

Re: template specialization

2010-06-08 Thread Simen kjaeraas
Larry Luther wrote: get (T:ubyte)(T[] buffer) get (T:ubyte)(T[] buffer) get (T)(T[] buffer) Q: Is this the way it's supposed to be? Looks very much correct, yes. Is there a problem? -- Simen

template specialization

2010-06-08 Thread Larry Luther
This code: import std.stdio; class A { void get (T:ubyte)(T[] buffer) { writefln( "get (T:ubyte)(T[] buffer)\n"); } void get (T:byte)(T[] buffer) { writefln( "get (T:byte)(T[] buffer)\n"); } void get (T)(T[] buffer) { writefln( "get (T)(T[] buffer)\n"); } } void main

Re: std.array.Appender with fixed size arrays

2010-06-08 Thread Ali Çehreli
Richard Webb wrote: Hi, While trying to get some things to build in D2, i noticed that the code: import std.array; void main (string[] args) { string s; auto app = appender(&s); app.put(['a', 'b']); } / works, but if it's changed to; char[

Re: std.array.Appender with fixed size arrays

2010-06-08 Thread bearophile
Richard Webb: > char[2] tmp = ['a', 'b']; > app.put(tmp); > > then it fails. Seems to be because char[2] isn't a forward range, so it > doesn't match the version of put that takes a range. > > Is this a bug? Maybe it's not a bug, but it's a limitation. With some more work on the Appender then t

std.array.Appender with fixed size arrays

2010-06-08 Thread Richard Webb
Hi, While trying to get some things to build in D2, i noticed that the code: import std.array; void main (string[] args) { string s; auto app = appender(&s); app.put(['a', 'b']); } / works, but if it's changed to; char[2] tmp = ['a', 'b']; a

Re: why is this cast necessary?

2010-06-08 Thread Graham Fawcett
Hi Steve, On Mon, 07 Jun 2010 23:46:40 -0400, Steven Schveighoffer wrote: > On Mon, 07 Jun 2010 23:02:48 -0400, Graham Fawcett > wrote: > >> Hi folks, >> >> This program works as expected in D2: >> >> import std.stdio; >> import std.algorithm; >> >> T largestSubelement(T)(T[][] lol)

Re: "D Programming Language"

2010-06-08 Thread Robert Clipsham
On 08/06/10 13:12, Lars T. Kyllingstad wrote: I don't know when you ordered it, but that has changed now, at least. At amazon.co.uk it costs £18.50, while at amazon.com it sells for $42.70 -- roughly £29. Also, for Europeans, the delivery cost is lower if you order from UK. -Lars I ordered i

Re: Tuple to tuple conversion

2010-06-08 Thread Lars T. Kyllingstad
On Tue, 08 Jun 2010 21:10:54 +0900, Masahiro Nakagawa wrote: > On Tue, 08 Jun 2010 19:39:43 +0900, Simen kjaeraas > wrote: > >> Simen kjaeraas wrote: >> >>> Lars T. Kyllingstad wrote: >>> FWIW, I've run across the same error, while writing code that had nothing to do with tuples

Re: Tuple to tuple conversion

2010-06-08 Thread Masahiro Nakagawa
On Tue, 08 Jun 2010 19:39:43 +0900, Simen kjaeraas wrote: Simen kjaeraas wrote: Lars T. Kyllingstad wrote: FWIW, I've run across the same error, while writing code that had nothing to do with tuples. And I've seen others complaining about it too. It seems to be a rather elusive bug

Re: "D Programming Language"

2010-06-08 Thread Lars T. Kyllingstad
On Tue, 08 Jun 2010 13:00:51 +0100, Robert Clipsham wrote: > On 08/06/10 11:23, Patrick Byrne wrote: >> Amazon (UK) tells me that publication of this book is delayed. Is it >> still coming soon, please? >> >> -- >> Patrick Byrne > > I ordered it from amazon.com, it was half the priceof the UK ver

Re: "D Programming Language"

2010-06-08 Thread Robert Clipsham
On 08/06/10 11:23, Patrick Byrne wrote: Amazon (UK) tells me that publication of this book is delayed. Is it still coming soon, please? -- Patrick Byrne I ordered it from amazon.com, it was half the priceof the UK version ;) I've had no delay message about it for a while now, the last one I g

Re: Tuple to tuple conversion

2010-06-08 Thread Lars T. Kyllingstad
On Tue, 08 Jun 2010 12:56:04 +0200, Simen kjaeraas wrote: > Lars T. Kyllingstad wrote: >> That's consistent with my experiences too. It seems to be triggered by >> a Phobos unittest. >> >> Still, I can't reproduce it with your test case. Which DMD version are >> you using? > > 2.045. Actually,

Re: Tuple to tuple conversion

2010-06-08 Thread Simen kjaeraas
Lars T. Kyllingstad wrote: That's consistent with my experiences too. It seems to be triggered by a Phobos unittest. Still, I can't reproduce it with your test case. Which DMD version are you using? 2.045. Actually, I can't reproduce it now either. Ah, found the problem. "dmd a b -unittest"

Re: Tuple to tuple conversion

2010-06-08 Thread Simen kjaeraas
Lars T. Kyllingstad wrote: I'm not sure I understand this. Do you then import a and b into another module to reproduce the error? This doesn't do it for me... As the bug report says: "dmd -unittest a b" -- Simen

Re: Tuple to tuple conversion

2010-06-08 Thread Lars T. Kyllingstad
On Tue, 08 Jun 2010 12:39:43 +0200, Simen kjaeraas wrote: > Simen kjaeraas wrote: > >> Lars T. Kyllingstad wrote: >> >>> FWIW, I've run across the same error, while writing code that had >>> nothing >>> to do with tuples. And I've seen others complaining about it too. It >>> seems to be a rat

Re: Tuple to tuple conversion

2010-06-08 Thread Lars T. Kyllingstad
On Tue, 08 Jun 2010 12:31:50 +0200, Simen kjaeraas wrote: > Lars T. Kyllingstad wrote: > >> FWIW, I've run across the same error, while writing code that had >> nothing to do with tuples. And I've seen others complaining about it >> too. It seems to be a rather elusive bug in Phobos. > > This

Re: Tuple to tuple conversion

2010-06-08 Thread Simen kjaeraas
Simen kjaeraas wrote: Lars T. Kyllingstad wrote: FWIW, I've run across the same error, while writing code that had nothing to do with tuples. And I've seen others complaining about it too. It seems to be a rather elusive bug in Phobos. This has now been tracked down to the importing of

Re: "D Programming Language"

2010-06-08 Thread Lars T. Kyllingstad
On Tue, 08 Jun 2010 11:23:23 +0100, Patrick Byrne wrote: > Amazon (UK) tells me that publication of this book is delayed. Is it > still coming soon, please? I also ordered it from Amazon UK, and got the same message. But the book is, as far as I know, finished and printed. So I suppose it's mo

Re: Tuple to tuple conversion

2010-06-08 Thread Simen kjaeraas
Lars T. Kyllingstad wrote: FWIW, I've run across the same error, while writing code that had nothing to do with tuples. And I've seen others complaining about it too. It seems to be a rather elusive bug in Phobos. This has now been tracked down to the importing of std.typecons in two includ

"D Programming Language"

2010-06-08 Thread Patrick Byrne
Amazon (UK) tells me that publication of this book is delayed. Is it still coming soon, please? -- Patrick Byrne