Re: TDPL available for preorder on amazon.com

2009-06-11 Thread Jarrett Billingsley
On Thu, Jun 11, 2009 at 1:05 AM, Saaaem...@needmail.com wrote: Hope you like the cover - my sister's art. http://tinyurl.com/lyrsyk Andrei The first programming book I'll buy :) 500 pages.. is that normal for programming books? What he's not telling you is that the pages are only 10cm

Re: TDPL available for preorder on amazon.com

2009-06-11 Thread Andrei Alexandrescu
Saaa wrote: Hope you like the cover - my sister's art. http://tinyurl.com/lyrsyk Andrei The first programming book I'll buy :) 500 pages.. is that normal for programming books? That's just an estimate. Any relation to a stable D2? Well, one begets the other. Andrei

Serialization for D. Comments, please!

2009-06-11 Thread BCS
the latest and greatest: http://arrayboundserror.blogspot.com/2009/06/serialization-for-d-part-6-of-n.html This time I'm hoping for some feedback on how people want to interface with 3rd party types.

Re: TDPL available for preorder on amazon.com

2009-06-11 Thread Nick Sabalausky
Saaa em...@needmail.com wrote in message news:h0q2tb$1nq...@digitalmars.com... 500 pages.. is that normal for programming books? Roughly, yea. Most of the ones on my bookshelf range from 300 to 1000 pages.

Re: Serialization for D. Comments, please!

2009-06-11 Thread grauzone
BCS wrote: the latest and greatest: http://arrayboundserror.blogspot.com/2009/06/serialization-for-d-part-6-of-n.html This time I'm hoping for some feedback on how people want to interface with 3rd party types. Is there any real reason for all those mixins?

Re: Serialization for D. Comments, please!

2009-06-11 Thread grauzone
Is there any real reason for all those mixins? which ones? All used by the user. That would be Serializable and SerializableRecuring.

Re: Serialization for D. Comments, please!

2009-06-11 Thread grauzone
BCS wrote: Reply to grauzone, Is there any real reason for all those mixins? which ones? All used by the user. That would be Serializable and SerializableRecuring. What else would you use? I guess if I really wanted to I could use the same device as for 3rd party types, but that just

Re: Serialization for D. Comments, please!

2009-06-11 Thread BCS
Reply to grauzone, BCS wrote: Reply to grauzone, Is there any real reason for all those mixins? which ones? All used by the user. That would be Serializable and SerializableRecuring. What else would you use? I guess if I really wanted to I could use the same device as for 3rd party

Re: cv2pdb 0.3 released

2009-06-11 Thread torhu
On 09.06.2009 20:44, Rainer Schuetze wrote: The visualizer macros in autoexp.dat are quite complex and can be slow, especially if you have associative arrays with a lot of entries. Please try it without the autoexp.dat entries. Didn't seem to matter much, but then there were no assoc arrays

Re: cv2pdb 0.3 released

2009-06-11 Thread torhu
On 09.06.2009 21:25, Bill Baxter wrote: On Mon, Jun 8, 2009 at 3:43 PM, torhun...@spam.invalid wrote: As someone mostly used to msvc 6, I have to say that debugging in msvc 9 is incredibly sluggish in comparison. Most actions in the debugger takes several seconds to complete, while in msvc

Re: Serialization for D. Comments, please!

2009-06-11 Thread Christopher Wright
grauzone wrote: Is there any real reason for all those mixins? which ones? All used by the user. That would be Serializable and SerializableRecuring. Also, what is curing in this context, and why would you need to do it multiple times?

Re: Serialization for D. Comments, please!

2009-06-11 Thread BCS
Hello Christopher, SerializableRecuring. Also, what is curing in this context, and why would you need to do it multiple times? My spelling sucks: s/Recuring/Recurring/

Re: Arrays vs slices

2009-06-11 Thread bearophile
Steve Schveighoffer: No, please no! Do I really need to carry around an integer that is going to be unused 99.9% of the time (In my case, probably 100%)? I'd rather have a special type that has a stride. Strides aren't essential, but once in a while they are useful, I use them now and

Re: Count your blessings!

2009-06-11 Thread bearophile
Robert Fraser: As well as the incompatibility with intuition. If anything, I'd think the Elvis operator is more of an or since x ?: y means x !is null ? x : y. Doesn't evaluate both arguments unless the first is false (or in this case, null)? Yes, it's a relative of or. In Python the

Re: Count your blessings!

2009-06-11 Thread Andrei Alexandrescu
bearophile wrote: In my dlibs there's a lazyOr() that takes any number of arguments and returns the first one that's true (where true is defined by a standard function boolean() that returns false for 0, null, objects/structs that have a length and where such length is zero). A reduced (and

Re: Count your blessings!

2009-06-11 Thread bearophile
Andrei Alexandrescu: I guess this would work better: CommonType!(Tx, Ty) lazyOr(Tx, Ty)(Tx x, lazy Ty y) { ... } What's the improvement? (And I think that code of mine gives a better error message.) Bye, bearophile

Re: Count your blessings!

2009-06-11 Thread BCS
Reply to bearophile, Andrei Alexandrescu: I guess this would work better: CommonType!(Tx, Ty) lazyOr(Tx, Ty)(Tx x, lazy Ty y) { ... } What's the improvement? class C {} class D1 : C {} class D2 : C {} D1 d1; D2 d2; auto r = lazyOr(d1, d2); (And I think that code of mine gives a better

Re: Arrays vs slices

2009-06-11 Thread Steven Schveighoffer
bearophile Wrote: Steve Schveighoffer: No, please no! Do I really need to carry around an integer that is going to be unused 99.9% of the time (In my case, probably 100%)? I'd rather have a special type that has a stride. Strides aren't essential, but once in a while they are

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Walter Bright
davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider: byte b; if (b == 1) here you're comparing two different sizes, a byte and an int. Disallowing such (in its various incarnations)

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Jarrett Billingsley
2009/6/11 Walter Bright newshou...@digitalmars.com: davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider:   byte b;   if (b == 1) here you're comparing two different sizes, a byte and

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Walter Bright
Jarrett Billingsley wrote: Weren't polysemous types supposed to avoid all that? It kept getting too complicated.

Re: Inlining asm functions

2009-06-11 Thread Brad Roberts
On Thu, 11 Jun 2009, Frits van Bommel wrote: bearophile wrote: creal expi(real y) { version (LDC) pragma(allow_inline); asm { fld y; fsincos; fxch ST(1), ST(0); } // add code here if asm isn't allowed } Note

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Lionello Lunesu
Walter Bright wrote: davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider: byte b; if (b == 1) here you're comparing two different sizes, a byte and an int. Disallowing such (in its

Re: Inlining asm functions

2009-06-11 Thread Frits van Bommel
Brad Roberts wrote: On Thu, 11 Jun 2009, Frits van Bommel wrote: Note that for LDC, an even more optimal arrangement is something like[1]: - version(LDC) import ldc.llvmasm; creal expi(real y) { return __asm!(creal)(fsincos, ={st(0)},={st(1)},0, y); } - My appologies if I cut

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Don
Walter Bright wrote: davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider: byte b; if (b == 1) here you're comparing two different sizes, a byte and an int. Disallowing such (in its

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Frits van Bommel
Don wrote: For bonus points: [end of message] I guess nobody'll be getting those bonus points then... :P

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Andrei Alexandrescu
Don wrote: Walter Bright wrote: davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider: byte b; if (b == 1) here you're comparing two different sizes, a byte and an int. Disallowing

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread bearophile
Andrei Alexandrescu: Hey, please bugzillize everything. Walter is almost done with revamping integers support into a framework that is superior to both Java/C# and C/C++. I just found three bugs in phobos by using his alpha compiler. Walter is kind of magic, I see :-)) He brings toys. Once

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Derek Parnell
On Fri, 12 Jun 2009 02:08:14 +0200, Don wrote: Walter Bright wrote: davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider: byte b; if (b == 1) here you're comparing two

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Don
Derek Parnell wrote: On Fri, 12 Jun 2009 02:08:14 +0200, Don wrote: Walter Bright wrote: davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider: byte b; if (b == 1) here you're

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Don
Frits van Bommel wrote: Don wrote: For bonus points: [end of message] I guess nobody'll be getting those bonus points then... :P g For bonus points: Code like the following is also almost certainly a bug: byte b = -1; if (b == 255) ... // FALSE! When variable of byte or short type is

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Rainer Deyke
Don wrote: But then you still have the problem that the high half of the short was extended from the low half in two different ways, once by sign-extend, once by zero-extend. Mixing sign-extend and zero-extend in the same expression is asking for trouble. I disagree. In fact, I don't sign

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Sean Kelly
Walter Bright wrote: davidl wrote: It seems that comparing two different operands with different size makes no sense. The compiler should issue an error against that. Consider: byte b; if (b == 1) here you're comparing two different sizes, a byte and an int. Disallowing such (in its

Re: why implicitly allowing compare ubyte and byte sucks

2009-06-11 Thread Don
Rainer Deyke wrote: Don wrote: But then you still have the problem that the high half of the short was extended from the low half in two different ways, once by sign-extend, once by zero-extend. Mixing sign-extend and zero-extend in the same expression is asking for trouble. I disagree. In

Re: D_Version2 problem

2009-06-11 Thread Robert Fraser
David Ferenczi wrote: == Quote from Sergey Gromov (snake.sc...@gmail.com)'s article Sun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote: The D_Version2 version identifier doesn't work properly for me. Tried compiling with dmd 1.039. D_Version2 is set even if I pass -v1 to it. Is this a bug or am I

Re: Inside the switch statement

2009-06-11 Thread Kagamin
template duffs_device(alias id1, alias id2, alias s) { void duff_loop() { if (id1 id2) { typeof(id1) n = (id2 - id1 + 7) / 8; switch ((id2 - id1) % 8) { case 0:do { s(); case 7: s();

Re: Inside the switch statement

2009-06-11 Thread bearophile
Kagamin: The Duff's device is said to be an optimization, but I get blunt device only 0.7% slower. Compilers already know about the Duff's device, and sometimes they use it automatically. Bye, bearophile

array depth template

2009-06-11 Thread Saaa
Is this a good way to get the depth of an array? int getArrayDepth(T)(ref T array) { static if( is(T A:A[]) ) { A arr; return 1 + getArrayDepth(arr); } else { return 0; } return -1; }

Re: array depth template

2009-06-11 Thread BCS
Hello Saaa, Is this a good way to get the depth of an array? int getArrayDepth(T)(ref T array) { static if( is(T A:A[]) ) { A arr; return 1 + getArrayDepth(arr); } else { return 0; } return -1; } I just posted this today http://www.dsource.org/projects/scrapple/browser/trunk/Serial/utill.d

Re: D compiler for .NET

2009-06-11 Thread Tim Matthews
Jason House wrote: Earlier today, I tried to use the D compiler for .NET from http://dnet.codeplex.com/ Beyond compilation of the compiler, I found zero instructions on what to do next. How do I integrate the compiler into the .NET framework/visual studio? I'd like to be able to add D

Re: Simple trampoline code

2009-06-11 Thread Ellery Newcomer
bearophile wrote: I'm trying to convert to D2 the following (quite simplified up) Python code, that implements a trampoline to run tail-call functions with no stack overflow: # Python code # *args means almost all the arguments def trampoline(fun, *args): thunk = lambda : fun(*args)

Re: array depth template

2009-06-11 Thread Jarrett Billingsley
On Thu, Jun 11, 2009 at 9:15 PM, Saaaem...@needmail.com wrote: Is this a good way to get the depth of an array? int getArrayDepth(T)(ref T array) { static if( is(T A:A[]) ) { A arr; return 1 + getArrayDepth(arr); } else { return 0; } return -1; } It's kind of the right idea, but..

Re: Simple trampoline code

2009-06-11 Thread BCS
Hello Ellery, bearophile wrote: I'm trying to convert to D2 the following (quite simplified up) Python code, that implements a trampoline to run tail-call functions with no stack overflow: [...] How DO you define the signature of a function that returns itself? Last I checked, you

Re: array depth template

2009-06-11 Thread Jarrett Billingsley
On Thu, Jun 11, 2009 at 11:02 PM, Saaaem...@needmail.com wrote: Any advantage to using two? I just tend to prefer template specialization when doing type pattern matching. It works out better than is() in some cases. He also does : is( T B ==B[]) iso is( T B:B[] ) Any significant

Re: Simple trampoline code

2009-06-11 Thread Ellery Newcomer
BCS wrote: Hello Ellery, bearophile wrote: I'm trying to convert to D2 the following (quite simplified up) Python code, that implements a trampoline to run tail-call functions with no stack overflow: [...] How DO you define the signature of a function that returns itself? Last I

Re: array depth template

2009-06-11 Thread Saaa
Any advantage to using two? I just tend to prefer template specialization when doing type pattern matching. It works out better than is() in some cases. Looks very Haskell like :) He also does : is( T B ==B[]) iso is( T B:B[] ) Any significant difference there? I'm.. not sure, in this

Re: Simple trampoline code

2009-06-11 Thread BCS
Hello Ellery, BCS wrote: Hello Ellery, bearophile wrote: I'm trying to convert to D2 the following (quite simplified up) Python code, that implements a trampoline to run tail-call functions with no stack overflow: [...] How DO you define the signature of a function that returns

Re: array depth template

2009-06-11 Thread Saaa
It's kind of the right idea, but.. it's also kind of weird. template ArrayDepth(T: T[]) { const ArrayDepth = 1 + ArrayDepth!(T); } template ArrayDepth(T) { const ArrayDepth = 0; } This lets you get the depth of any array _type_, like ArrayDepth!(int[][]) gives 2. Although I don't

Re: array depth template

2009-06-11 Thread Saaa
template BaseType(T: T[]) { const BaseType = BaseType!(T); } template BaseType(T) {const BaseType = T; } .. else static if( std2.traits.isNumeric!( BaseType!(T) ) ) { .. ddata\ddata.d(192): template instance isNumeric!(int) does not match any template declaration ddata\ddata.d(192): Error:

Re: array depth template

2009-06-11 Thread Jarrett Billingsley
On Fri, Jun 12, 2009 at 12:04 AM, Saaaem...@needmail.com wrote: template BaseType(T: T[]) { const BaseType = BaseType!(T); } template BaseType(T) {const BaseType = T; } .. else static if( std2.traits.isNumeric!( BaseType!(T) ) ) { .. ddata\ddata.d(192): template instance isNumeric!(int)

Re: array depth template

2009-06-11 Thread Jarrett Billingsley
On Thu, Jun 11, 2009 at 11:45 PM, Saaaem...@needmail.com wrote: I'm.. not sure, in this case anyway.  Normally == does strict type comparison while : does implicit type conversion, but in this case, is() is being (ab)used to pick apart a type rather than test one.  I think it'll always return

tuples

2009-06-11 Thread Ellery Newcomer
what is up with this code? auto t = tuple(1,'a',3.333,false); pragma(msg,typeof(t.tupleof[2 .. $]).stringof); spits out (double, bool, int, char, double, bool)

Re: array depth template

2009-06-11 Thread Saaa
Your template. Types are not values, you cannot declare a constant that is a type. You have to use alias instead: template BaseType(T: T[]) { alias BaseType!(T) BaseType; } template BaseType(T) { alias T BaseType; } Erm, why did this print corretly? writefln(`BaseType = `,

Re: tuples

2009-06-11 Thread Saaa
what is up with this code? auto t = tuple(1,'a',3.333,false); pragma(msg,typeof(t.tupleof[2 .. $]).stringof); spits out (double, bool, int, char, double, bool) template Tuple(E...) { alias E Tuple; } alias Tuple!(1,'a',3.333,false) t; pragma(msg,typeof(t.tupleof[2 .. $]).stringof);

[Issue 3057] Add pure annotations to core.stdc.*

2009-06-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #9 from Sobirari Muhomori ma...@pochta.ru 2009-06-11 04:19:22 PDT --- assert(str1!=str2,pwnd); *fixed -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because:

[Issue 3057] Add pure annotations to core.stdc.*

2009-06-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #8 from Sobirari Muhomori ma...@pochta.ru 2009-06-11 04:17:10 PDT --- char* str1=obj.str1; const char* str2=obj.str2; auto len1=strlen(str2); str1[0]=0; auto len2=strlen(str2); assert(str1==str2,pwnd); GCC has stricter

[Issue 3062] New: -run compiler switch ignores -I option

2009-06-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3062 Summary: -run compiler switch ignores -I option Product: D Version: 2.030 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal

[Issue 3062] -run compiler switch ignores -I option

2009-06-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3062 Frits van Bommel fvbom...@wxs.nl changed: What|Removed |Added Status|NEW |RESOLVED

[Issue 3064] New: Invalid array operation accepted, generates bad code

2009-06-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3064 Summary: Invalid array operation accepted, generates bad code Product: D Version: 1.045 Platform: x86_64 URL: http://www.digitalmars.com/d/1.0/arrays.html OS/Version: Linux

Re: [Issue 3001] Templated types within a mixin not reinstantiated properly for new instantiation

2009-06-11 Thread Christopher Wright
--- Comment #1 from Matti Niemenmaa matti.niemenmaa+dbugzi...@iki.fi 2009-06-11 09:32:40 PDT --- I'm bumping this to 'blocker' because it's preventing me from using DMD for my project. I think we need clarification on the definition and usage of blocker. I typically would use it to mean

Blockers (was Re: [Issue 3001])

2009-06-11 Thread Matti Niemenmaa
Christopher Wright wrote: --- Comment #1 from Matti Niemenmaa matti.niemenmaa+dbugzi...@iki.fi 2009-06-11 09:32:40 PDT --- I'm bumping this to 'blocker' because it's preventing me from using DMD for my project. I think we need clarification on the definition and usage of blocker. I

Re: [Issue 3054] New: multithreading GC problem. And Stdio not multithreading safe

2009-06-11 Thread Sean Kelly
What is the expected behavior?