Re: Signed word lengths and indexes

2010-06-14 Thread Andrei Alexandrescu
Kagamin wrote: bearophile Wrote: and using signed words (I think C# uses ints for that purpose) CLS bans unsigneds. Signed ints FTW!!! CLS = ? Andrei

Re: Signed word lengths and indexes

2010-06-14 Thread Kagamin
bearophile Wrote: > and using signed words (I think C# uses ints for that purpose) > CLS bans unsigneds. Signed ints FTW!!!

Re: TDPL shipping off Amazon

2010-06-14 Thread Olli Aalto
On 14.6.2010 13:18, Andrei Alexandrescu wrote: Olli Aalto wrote: On 11.6.2010 18:34, Andrei Alexandrescu wrote: Looks like Amazon has finally stocked up on TDPL and is delivering it as of today. Just received my "Collector's Edition". :) O. I'm starting to sweat over here. Andrei Don't

Re: D const enables multi-reader synchronization

2010-06-14 Thread Sean Kelly
Tomek Sowiñski Wrote: > > 3. If answer to 2. is yes, how do we tackle write-starvation? In a > read-mostly scenario the mutating thread may be held up forever. The implementation in core.sync.rwmutex can be set to favor readers or writers. So you can choose the method most appropriate to your

Re: D const enables multi-reader synchronization

2010-06-14 Thread Sean Kelly
Tomek Sowiñski Wrote: > This is a continuation of a recent thread "Synchronized const methods" on > D.learn. > > Currently only one thread at a time can execute a synchronized method. But > think about D's const -- it's deep, so if a method is const, it can't > possibly mutate its object. S

Re: D const enables multi-reader synchronization

2010-06-14 Thread Robert Jacques
On Mon, 14 Jun 2010 15:17:57 -0400, Tomek Sowiński wrote: This is a continuation of a recent thread "Synchronized const methods" on D.learn. Currently only one thread at a time can execute a synchronized method. But think about D's const -- it's deep, so if a method is const, it can't pos

Re: Constraints error messages [Was: Re: Constrained Templates]

2010-06-14 Thread BCS
Hello bearophile, A syntax like the following allows to add the user-defined error messages too, but it's bad looking, so probably something quite better can be invented: template Foo(T) if (condition1) else pragma(msg, "error message1") if (condition2) else pragma(msg, "error message2") { }

Re: Signed word lengths and indexes

2010-06-14 Thread bearophile
Walter Bright: > Like I said, this didn't appear in Python until quite recently (3.0), so that > cannot be the primary productivity advantage of Python. You are wrong, see my other answer. Bye, bearophile

Re: Signed word lengths and indexes

2010-06-14 Thread BCS
Hello Steven, div0 writes: for(uint i = end - 1; i < length; --i) ... What does "length" represent here? It's not clear to me how "i" descending toward zero is going to break the guard condition. My thought exactly. If ithe assumption is wrong, don't ask me to do a code review because I

Re: Signed word lengths and indexes

2010-06-14 Thread Walter Bright
bearophile wrote: Walter Bright: As for "unsafe", I think you need to clarify this, as D is not memory unsafe despite the existence of integer over/under flows.< Modern languages must understand that there are other forms of safety beside memory safety. Integer overflows and signed-unsigned co

Re: Signed word lengths and indexes

2010-06-14 Thread Walter Bright
Ellery Newcomer wrote: On 06/14/2010 05:48 PM, Walter Bright wrote: D provides powerful abstractions for iteration; it is becoming less and less desirable to hand-build loops with for-statements. Ooo ooo, can we remove it? No :-) I have a hard time believing that Python and Ruby are more

Re: Signed word lengths and indexes

2010-06-14 Thread bearophile
bearophile: > 2) I don't like D to silently gulp down expressions that mix signed and > unsigned integers and spit out wrong results when the integers were negative. Walter, answering something similar: >Andrei and I went down that alley for a while. It's not practical. OK. Then just removing as

Re: Signed word lengths and indexes

2010-06-14 Thread bearophile
div0: >Well for a start, you lose half your addressable memory.< This matters mostly with char/ubyte/byte arrays on 32 bit systems. If you have arrays of shorts, ints or pointers/references or you are on 64 bit systems this is not so important. And the extra safety it gives me is a price I can

Re: Signed word lengths and indexes

2010-06-14 Thread bearophile
Walter Bright: >D provides powerful abstractions for iteration; it is becoming less and less >desirable to hand-build loops with for-statements.< I agree. >As for "unsafe", I think you need to clarify this, as D is not memory unsafe >despite the existence of integer over/under flows.< Modern

Re: Signed word lengths and indexes

2010-06-14 Thread Ellery Newcomer
On 06/14/2010 05:48 PM, Walter Bright wrote: bearophile wrote: I have found a Reddit discussion few days old: http://www.reddit.com/r/programming/comments/cdwz5/the_perils_of_unsigned_iteration_in_cc/ It contains this, that I quote (I have no idea if it's true), plus follow-ups: At Google u

Re: Signed word lengths and indexes

2010-06-14 Thread Steven E. Harris
div0 writes: > for(uint i = end - 1; i < length; --i) > ... What does "length" represent here? It's not clear to me how "i" descending toward zero is going to break the guard condition. -- Steven E. Harris

Re: Signed word lengths and indexes

2010-06-14 Thread Walter Bright
div0 wrote: I do think that allowing un-casted assignments between signed/unsigned is a problem though; that's where most of the bugs creep up I've come across crop up. I think D should simply disallow implicit mixing of signd-ness. Andrei and I went down that alley for a while. It's not prac

Re: Signed word lengths and indexes

2010-06-14 Thread Walter Bright
bearophile wrote: I have found a Reddit discussion few days old: http://www.reddit.com/r/programming/comments/cdwz5/the_perils_of_unsigned_iteration_in_cc/ It contains this, that I quote (I have no idea if it's true), plus follow-ups: At Google using uints of all kinds for anything other tha

Re: Signed word lengths and indexes

2010-06-14 Thread div0
On 14/06/2010 21:52, bearophile wrote: I have found a Reddit discussion few days old: http://www.reddit.com/r/programming/comments/cdwz5/the_perils_of_unsigned_iteration_in_cc/ It contains this, that I quote (I have no idea if it's true), plus follow-ups: At Google using uints of all kinds fo

Re: D const enables multi-reader synchronization

2010-06-14 Thread Brad Roberts
On Mon, 14 Jun 2010, Tomek Sowi?ski wrote: > Dnia 14-06-2010 o 21:27:24 Brad Roberts > napisa?(a): > > > Const methods only prevent mutating 'this'. You can still call functions > > that mutate other state (via globals or passed in arguments). > > But synchronized on a method also protects only

Re: Signed word lengths and indexes

2010-06-14 Thread bearophile
Byron Heads: > Isn't this why D has foreach and foreach_reverse? If you mean the exact problem the original article was talking about, then you are right. But foreach and foreach_reverse are not enough to solve the general safety problem caused by the widespread usage of unsigned words in a lang

Re: Signed word lengths and indexes

2010-06-14 Thread Byron Heads
On Mon, 14 Jun 2010 16:52:04 -0400, bearophile wrote: > If D wants to be "a systems programming language. Its focus is on > combining the power and high performance of C and C++ with the > programmer productivity of modern languages like Ruby and Python." it > must understand that numerical safety

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Matthias Pleh
Am 14.06.2010 22:53, schrieb "Jérôme M. Berger": Steven Schveighoffer wrote: On Mon, 14 Jun 2010 13:42:20 -0400, Walter Bright wrote: I see Amazon has two "used" copies at $77.14. Why would anyone try to sell a copy at double the price of new, when the new is in stock and shipping? Probab

Re: D const enables multi-reader synchronization

2010-06-14 Thread Jérôme M. Berger
Tomek Sowiński wrote: > 3. If answer to 2. is yes, how do we tackle write-starvation? In a > read-mostly scenario the mutating thread may be held up forever. > I'd say that as soon as someone requests the write lock, nobody can get the read lock anymore. Then when the current readers relea

Signed word lengths and indexes

2010-06-14 Thread bearophile
I have found a Reddit discussion few days old: http://www.reddit.com/r/programming/comments/cdwz5/the_perils_of_unsigned_iteration_in_cc/ It contains this, that I quote (I have no idea if it's true), plus follow-ups: >At Google using uints of all kinds for anything other than bitmasks or other >

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Jérôme M. Berger
Steven Schveighoffer wrote: > On Mon, 14 Jun 2010 13:42:20 -0400, Walter Bright > wrote: > >> I see Amazon has two "used" copies at $77.14. >> >> Why would anyone try to sell a copy at double the price of new, when >> the new is in stock and shipping? > > Probably the same reason the ask prices

Re: D const enables multi-reader synchronization

2010-06-14 Thread Tomek Sowiński
Dnia 14-06-2010 o 21:27:24 Brad Roberts napisał(a): On Mon, 14 Jun 2010, Tomek Sowi?ski wrote: This is a continuation of a recent thread "Synchronized const methods" on D.learn. Currently only one thread at a time can execute a synchronized method. But think about D's const -- it's dee

Constraints error messages [Was: Re: Constrained Templates]

2010-06-14 Thread bearophile
Yao G.: > Something I would like to see with template constraints, is the ability to > show text messages, like when static if is used. This is a problem I too have. In D1 I used to write code like: template Foo(T) { static assert(condition1, "error message1"); static assert(condition2, "e

Re: D const enables multi-reader synchronization

2010-06-14 Thread Brad Roberts
On Mon, 14 Jun 2010, Tomek Sowi?ski wrote: > This is a continuation of a recent thread "Synchronized const methods" on > D.learn. > > Currently only one thread at a time can execute a synchronized method. But > think about D's const -- it's deep, so if a method is const, it can't possibly > mutat

D const enables multi-reader synchronization

2010-06-14 Thread Tomek Sowiński
This is a continuation of a recent thread "Synchronized const methods" on D.learn. Currently only one thread at a time can execute a synchronized method. But think about D's const -- it's deep, so if a method is const, it can't possibly mutate its object. So many synchronized const method c

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Steven Schveighoffer
On Mon, 14 Jun 2010 13:42:20 -0400, Walter Bright wrote: I see Amazon has two "used" copies at $77.14. Why would anyone try to sell a copy at double the price of new, when the new is in stock and shipping? Probably the same reason the ask prices for stock go up to 100 times their value

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Walter Bright
I see Amazon has two "used" copies at $77.14. Why would anyone try to sell a copy at double the price of new, when the new is in stock and shipping?

Re: TDPL shipping off Amazon

2010-06-14 Thread Brad Roberts
On 6/14/2010 3:18 AM, Andrei Alexandrescu wrote: > Olli Aalto wrote: >> On 11.6.2010 18:34, Andrei Alexandrescu wrote: >>> Looks like Amazon has finally stocked up on TDPL and is delivering it as >>> of today. >>> >> >> Just received my "Collector's Edition". :) >> >> O. > > I'm starting to sweat

Re: Constrained Templates

2010-06-14 Thread Simen kjaeraas
Don wrote: This can be trivially shown to be NP-complete. void bar(T)() { static if ( big_function!T) { T t; t.flabbergast( ); } } Compiler cannot determine if T needs flabbergast(), unless it evaluates big_function. Which can be arbitrarily complicated. But how does t

Re: Constrained Templates

2010-06-14 Thread Simen kjaeraas
Jason House wrote: Simen kjaeraas Wrote: Leandro Lucarella wrote: > it would be nice > to have some sort of way to tell the compiler to write the template > constraints for us (the obvious ones at least, there might be other > template constraints desired besides the ones the ones the compil

Re: Constrained Templates

2010-06-14 Thread Don
Simen kjaeraas wrote: Leandro Lucarella wrote: it would be nice to have some sort of way to tell the compiler to write the template constraints for us (the obvious ones at least, there might be other template constraints desired besides the ones the ones the compiler can figure out). This way,

Re: Constrained Templates

2010-06-14 Thread Yao G.
:D That's weird. I just filled some typical form controls and clicked submit. No "autoban" button was clicked. Yao G. On Sun, 13 Jun 2010 20:05:04 -0500, Walter Bright wrote: Yao G. wrote: It is now displayed in the front page. http://www.reddit.com/r/programming/ On Sun, 13 Jun 2010

Re: Constrained Templates

2010-06-14 Thread Jason House
Simen kjaeraas Wrote: > Leandro Lucarella wrote: > > it would be nice > > to have some sort of way to tell the compiler to write the template > > constraints for us (the obvious ones at least, there might be other > > template constraints desired besides the ones the ones the compiler can > > fig

Re: Constrained Templates

2010-06-14 Thread Simen kjaeraas
Leandro Lucarella wrote: it would be nice to have some sort of way to tell the compiler to write the template constraints for us (the obvious ones at least, there might be other template constraints desired besides the ones the ones the compiler can figure out). This way, the errors can be impro

Re: Is there a way to get the names of a function's parameters?

2010-06-14 Thread Simen kjaeraas
Simen kjaeraas wrote: One needs to match parentheses from the last parentheses in the typeof.stringof. string parameterNamesOf( alias fn )( ) { string fullName = typeof(&fn).stringof; int pos = fullName.lastIndexOf( ')' ); int end = pos; int count = 0; do {

Re: Is there a way to get the names of a function's parameters?

2010-06-14 Thread Simen kjaeraas
Jacob Carlborg wrote: Here you go: http://tango.pastebin.com/M38jdhGd including calling using named arguments. Does not handle function/delegate return types. struct S {} void function(int delegate(float)) F(string delegate(), string function(string, string), float, double, S); writeln(

Re: TDPL shipping off Amazon

2010-06-14 Thread Andrei Alexandrescu
Olli Aalto wrote: On 11.6.2010 18:34, Andrei Alexandrescu wrote: Looks like Amazon has finally stocked up on TDPL and is delivering it as of today. Just received my "Collector's Edition". :) O. I'm starting to sweat over here. Andrei

Re: Is there a way to get the names of a function's parameters?

2010-06-14 Thread Jacob Carlborg
On 2010-06-14 00:56, Adam Ruppe wrote: Given: void foo(int a, string b); You can use std.traits.ParameterTypeTuple to get (int, string). Is there any method, at all, to get ("a", "b") out of it? I can't find one, and am considering import("mysrc.d"); and finding it that way, but figured I'd as

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Rory McGuire
On Mon, 14 Jun 2010 11:59:41 +0200, Rory McGuire wrote: I cancelled with amazon last week and ordered with informit. Got it this morning. On Mon, 14 Jun 2010 11:21:40 +0200, filgood wrote: Although the price is very good on Amazon, one needs to wait till August to get a copy of the book.

Re: TDPL shipping off Amazon

2010-06-14 Thread Olli Aalto
On 11.6.2010 18:34, Andrei Alexandrescu wrote: Looks like Amazon has finally stocked up on TDPL and is delivering it as of today. Just received my "Collector's Edition". :) O.

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Rory McGuire
I cancelled with amazon last week and ordered with informit. Got it this morning. On Mon, 14 Jun 2010 11:21:40 +0200, filgood wrote: Although the price is very good on Amazon, one needs to wait till August to get a copy of the book. I've followed the advice from some other people on the NG, c

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Richard Webb
I pre-ordered it from http://www.bookdepository.co.uk/book/9780321635365/The-D-Programming-Language, who now have it listed as "dispatched within 48 hours", so hopefully won't have to wait too long :-)

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread filgood
Although the price is very good on Amazon, one needs to wait till August to get a copy of the book. I've followed the advice from some other people on the NG, cancelled my amazon order and went to Informit ($49.99 + $9 to ship to the UK). Ordered it last week Thursday and it's already shipped by

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Andrei Alexandrescu
Lars T. Kyllingstad wrote: On amazon.co.uk it costs £18.50, which is roughly $26. http://www.amazon.co.uk/D-Programming-Language-Andrei-Alexandrescu/ dp/0321635361/ref=sr_1_1?ie=UTF8&s=books&qid=1276503587&sr=1-1 -Lars Wow, 50% - that's pretty awesome. Amazon seems to be carrying an aggressi

Re: Price drop for TDPL on Amazon to $41.10

2010-06-14 Thread Lars T. Kyllingstad
On amazon.co.uk it costs £18.50, which is roughly $26. http://www.amazon.co.uk/D-Programming-Language-Andrei-Alexandrescu/ dp/0321635361/ref=sr_1_1?ie=UTF8&s=books&qid=1276503587&sr=1-1 -Lars

Re: Is the declaration grammar definition of 'Parameter' correct?

2010-06-14 Thread Don
BCS wrote: That would be a start as well as a necessary step in getting a extractor working (to test the tools output against), but if the docs and the parser are maintained separately, the docs will be wrong sooner rather than later. I think that's very unlikely to be true. The existing erro

Re: [ot] D users at Google

2010-06-14 Thread Michael Farnsworth
On 06/07/2010 10:09 PM, BCS wrote: IIRC there are a few D users who work for Google (I know there is now at least one :D ) but I don't remember who. For that matter, are there other D users in the Mountain View/San Jose area? Man, I'm late to the game responding. I'm in the east bay, working