Re: Errors in TDPL

2010-06-24 Thread Alix Pexton
Does anyone else feel that the following is a fair clarification? Page 396 ... This means that communicating processors "forget" the exact order in which data was written: one tread writes x and then y and for a while another thread sees the new y but only the old x. vvv This means that co

Re: Errors in TDPL

2010-06-24 Thread Lars T. Kyllingstad
On Wed, 23 Jun 2010 11:51:40 -0500, Andrei Alexandrescu wrote: > On 06/23/2010 11:40 AM, Walter Bright wrote: >> Jonathan M Davis wrote: >>> Well, while I, personally, would put a semicolon there (it feels naked >>> to me without one), dmd doesn't actually seem to require it. But TDPL >>> says tha

Re: Errors in TDPL

2010-06-24 Thread Simen kjaeraas
Andrei Alexandrescu wrote: I mistakingly assumed D followed C in that regard. Given the argument stated in this thread (that absent semicolons require more context to be absorbed while reading), do you agree that D should make the semicolon required? Yes -- Simen

Re: Errors in TDPL

2010-06-24 Thread Jonathan M Davis
Alix Pexton wrote: > On 24/06/2010 09:09, Jonathan M Davis wrote: >> Alix Pexton wrote: >> >>> Can someone sanity check me on the code on pages 334-5? >>> >>> Does the method push really need !empty in its in contract? >>> >>> I might not be fully awake yet>< >>> >>> A... >> >> It has to be an err

Re: Errors in TDPL

2010-06-24 Thread Alix Pexton
On 24/06/2010 09:09, Jonathan M Davis wrote: Alix Pexton wrote: Can someone sanity check me on the code on pages 334-5? Does the method push really need !empty in its in contract? I might not be fully awake yet>< A... It has to be an error. If you couldn't push onto an empty stack, then yo

Re: Errors in TDPL

2010-06-24 Thread Jonathan M Davis
Alix Pexton wrote: > Can someone sanity check me on the code on pages 334-5? > > Does the method push really need !empty in its in contract? > > I might not be fully awake yet >< > > A... It has to be an error. If you couldn't push onto an empty stack, then you'd never be able to put anything

Re: Errors in TDPL

2010-06-24 Thread Alix Pexton
Can someone sanity check me on the code on pages 334-5? Does the method push really need !empty in its in contract? I might not be fully awake yet >< A...

Re: Errors in TDPL

2010-06-24 Thread eles
I did not try to start a polemic, but to give something to think about. There are more opinions on the matter and, as you may see, mine differs of yours. Is not a tragedy. However, I think one should be more aware when supporting habit per se. Maybe adding "until" as an aliasing for "while not

Re: Errors in TDPL

2010-06-23 Thread Jonathan M Davis
eles wrote: > It is a shame that compatibility issues prevail over quality and > improvement. Ditching the do...while loop could be unacceptable now, > but why do not propose a better alternative mechanism? That way, we > would have both compatibility and quality. > > eles Quality prevails over

Re: Errors in TDPL

2010-06-23 Thread bearophile
Andrei Alexandrescu: > Walter agreed to fix do-while to require a semicolon. Good. This was the relative bug: http://d.puremagic.com/issues/show_bug.cgi?id=4374 Bye, bearophile

Re: Errors in TDPL

2010-06-23 Thread eles
== Quote from bearophile (bearophileh...@lycos.com)'s article > Alix Pexton: > > In some ways I think it was a mistake in to reuse while in the first > > place, but that was a decision that was made a loong time before D... > Pascal-like languages use repeat-until, but I prefer the C do-while becau

Re: Errors in TDPL

2010-06-23 Thread Andrei Alexandrescu
On 06/23/2010 05:44 PM, Alix Pexton wrote: On 23/06/2010 16:24, Andrei Alexandrescu wrote: On 06/23/2010 02:11 AM, Rick Trelles wrote: Saving a keystroke, if it is in sound and clear way, is a plus. At least the option to save the keystroke should be maintained. I don't see now any advantages

Re: Errors in TDPL

2010-06-23 Thread bearophile
Alix Pexton: > In some ways I think it was a mistake in to reuse while in the first > place, but that was a decision that was made a loong time before D... Pascal-like languages use repeat-until, but I prefer the C do-while because the condition in repeat-until is the opposite of the one you use

Re: Errors in TDPL

2010-06-23 Thread Alix Pexton
On 23/06/2010 17:51, Andrei Alexandrescu wrote: On 06/23/2010 11:40 AM, Walter Bright wrote: Jonathan M Davis wrote: Well, while I, personally, would put a semicolon there (it feels naked to me without one), dmd doesn't actually seem to require it. But TDPL says that the semicolon is required.

Re: Errors in TDPL

2010-06-23 Thread Alix Pexton
On 23/06/2010 16:24, Andrei Alexandrescu wrote: On 06/23/2010 02:11 AM, Rick Trelles wrote: Saving a keystroke, if it is in sound and clear way, is a plus. At least the option to save the keystroke should be maintained. I don't see now any advantages in using a pair of braces over a single semi

Re: Errors in TDPL

2010-06-23 Thread Andrei Alexandrescu
On 06/23/2010 11:40 AM, Walter Bright wrote: Jonathan M Davis wrote: Well, while I, personally, would put a semicolon there (it feels naked to me without one), dmd doesn't actually seem to require it. But TDPL says that the semicolon is required. So, it does appear to be an error in the text. Of

Re: Errors in TDPL

2010-06-23 Thread Walter Bright
Jonathan M Davis wrote: Well, while I, personally, would put a semicolon there (it feels naked to me without one), dmd doesn't actually seem to require it. But TDPL says that the semicolon is required. So, it does appear to be an error in the text. Of course, there's no helping his pet peeve re

Re: Errors in TDPL

2010-06-23 Thread Jonathan M Davis
Rory McGuire wrote: > On Tue, 22 Jun 2010 23:37:59 +0200, Andrei Alexandrescu > wrote: > >> Walter, can we require a semicolon please? > +1 > > With the semi colon missing its as bad as: > for (;i<100;i++); >writeln(i); > > esp. with large amount of code > >> Andrei > > Rory It's not th

Re: Errors in TDPL

2010-06-23 Thread Andrei Alexandrescu
On 06/23/2010 02:11 AM, Rick Trelles wrote: Saving a keystroke, if it is in sound and clear way, is a plus. At least the option to save the keystroke should be maintained. I don't see now any advantages in using a pair of braces over a single semicolon for a null statement, but why not keep it b

Re: Errors in TDPL

2010-06-23 Thread Andrei Alexandrescu
On 06/23/2010 04:56 AM, Don wrote: bearophile wrote: Andrei: void main() { goto FOO; FOO:; } Yes. It shouldn't compile. Walter and I agreed that solitary semicolons are useless (you can always use {} as an empty statement and that actually makes things clearer to everyone), I have had to use

Re: Errors in TDPL

2010-06-23 Thread Lars T. Kyllingstad
On Wed, 23 Jun 2010 11:56:12 +0200, Don wrote: > bearophile wrote: >> Andrei: void main() { goto FOO; FOO:; } >>> Yes. It shouldn't compile. Walter and I agreed that solitary >>> semicolons are useless (you can always use {} as an empty statement >>> and that actually

Re: Errors in TDPL

2010-06-23 Thread Don
bearophile wrote: Andrei: void main() { goto FOO; FOO:; } Yes. It shouldn't compile. Walter and I agreed that solitary semicolons are useless (you can always use {} as an empty statement and that actually makes things clearer to everyone), I have had to use a LABEL:; in D code, to

Re: Errors in TDPL

2010-06-23 Thread Rory McGuire
On Tue, 22 Jun 2010 23:37:59 +0200, Andrei Alexandrescu wrote: Walter, can we require a semicolon please? +1 With the semi colon missing its as bad as: for (;i<100;i++); writeln(i); esp. with large amount of code Andrei Rory

Re: Errors in TDPL

2010-06-23 Thread Norbert Nemec
On 22/06/10 00:35, Leandro Lucarella wrote: Andrei Alexandrescu, el 21 de junio a las 17:43 me escribiste: If efficiency is still sub-par, retro could detect that it's working with iota and generate specialized code. That's not too difficult; for integers, retro(iota(a, b)) could actually be a r

Re: Errors in TDPL

2010-06-22 Thread Rick Trelles
Saving a keystroke, if it is in sound and clear way, is a plus. At least the option to save the keystroke should be maintained. I don't see now any advantages in using a pair of braces over a single semicolon for a null statement, but why not keep it both ways? I never liked the semicolon afte

Re: Errors in TDPL

2010-06-22 Thread bearophile
Andrei: > > void main() { > > goto FOO; > > FOO:; > > } > > Yes. It shouldn't compile. Walter and I agreed that solitary semicolons > are useless (you can always use {} as an empty statement and that > actually makes things clearer to everyone), I have had to use a LABEL:; in D code,

Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu
On 06/22/2010 04:53 PM, bearophile wrote: Andrei Alexandrescu: you agreed there is no solitary semicolon statement in D,< This compiles, is this a solitary semicolon statement? void main() { goto FOO; FOO:; } Yes. It shouldn't compile. Walter and I agreed that solitary semicolons

Re: Errors in TDPL

2010-06-22 Thread Jonathan M Davis
Andrei Alexandrescu wrote: > > Walter, was that intentional? The grammar has no semicolon but the > example does. That makes the example wrong because you agreed there is > no solitary semicolon statement in D, and TDPL does mention that. > > IMHO the semicolon makes for more robust code. Consid

Re: Errors in TDPL

2010-06-22 Thread bearophile
Andrei Alexandrescu: >you agreed there is no solitary semicolon statement in D,< This compiles, is this a solitary semicolon statement? void main() { goto FOO; FOO:; } > Walter, can we require a semicolon please? +1 Bye, bearophile

Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu
On 06/22/2010 04:14 PM, Jonathan M Davis wrote: Andrei Alexandrescu wrote: On 06/21/2010 03:32 PM, Ellery Newcomer wrote: I was biting my tongue on the subject, but on page 73 the grammar for the do while loop has a semicolon at the end. AAH THERE IS NOOO SEMICOLON AT T

Re: Errors in TDPL

2010-06-22 Thread Jonathan M Davis
Andrei Alexandrescu wrote: > On 06/21/2010 03:32 PM, Ellery Newcomer wrote: >> I was biting my tongue on the subject, but on page 73 the grammar for >> the do while loop has a semicolon at the end. AAH >> THERE IS NOOO SEMICOLON AT THE END. >> >> Wow. Sorry. This is a pet p

Re: Errors in TDPL

2010-06-22 Thread Bill Baxter
On Tue, Jun 22, 2010 at 11:52 AM, Andrei Alexandrescu wrote: > On 06/22/2010 01:45 PM, Bill Baxter wrote: >> >> On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu >>  wrote: >>> >>> On 06/21/2010 02:09 PM, Jonathan M Davis wrote: Okay. I am in no way trying to say anything negative ab

Re: Errors in TDPL

2010-06-22 Thread Jonathan M Davis
Bill Baxter wrote: > On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu > wrote: >> On 06/21/2010 02:09 PM, Jonathan M Davis wrote: >>> >>> Okay. I am in no way trying to say anything negative about TDPL. >> >> [snip] >> >> You are being too kind about this :o). Of course we need an errata list

Re: Errors in TDPL

2010-06-22 Thread Graham Fawcett
On Tue, 22 Jun 2010 11:45:39 -0700, Bill Baxter wrote: > On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu > wrote: >> On 06/21/2010 02:09 PM, Jonathan M Davis wrote: >>> >>> Okay. I am in no way trying to say anything negative about TDPL. >> >> [snip] >> >> You are being too kind about this :

Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu
On 06/22/2010 01:45 PM, Bill Baxter wrote: On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu wrote: On 06/21/2010 02:09 PM, Jonathan M Davis wrote: Okay. I am in no way trying to say anything negative about TDPL. [snip] You are being too kind about this :o). Of course we need an errata

Re: Errors in TDPL

2010-06-22 Thread Bill Baxter
On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu wrote: > On 06/21/2010 02:09 PM, Jonathan M Davis wrote: >> >> Okay. I am in no way trying to say anything negative about TDPL. > > [snip] > > You are being too kind about this :o). Of course we need an errata list. I > was hoping I'd need to se

Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu
On 06/22/2010 11:16 AM, Byron Heads wrote: On pg. 12 you define a recursive binary search, you forgot to pass value on the recursive call. -B Saw the erratum you posted - thanks! Andrei

Re: Errors in TDPL

2010-06-22 Thread Byron Heads
On pg. 12 you define a recursive binary search, you forgot to pass value on the recursive call. -B

Re: Errors in TDPL

2010-06-22 Thread biozic
ment not be a single ;. In the grammar, this is a ScopeStatement, which is a NonEmptyStatement or a BlockStatement. http://www.digitalmars.com/d/2.0/statement.html#ScopeStatement Not always: http://d.puremagic.com/issues/show_bug.cgi?id=4024 Bugs in the compiler aren't errors in TDPL! I t

Re: Errors in TDPL

2010-06-22 Thread Walter Bright
is a ScopeStatement, which is a NonEmptyStatement or a BlockStatement. http://www.digitalmars.com/d/2.0/statement.html#ScopeStatement Not always: http://d.puremagic.com/issues/show_bug.cgi?id=4024 Bugs in the compiler aren't errors in TDPL!

Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu
On 06/22/2010 07:18 AM, bearophile wrote: So I suggest to replace that line in the iota() costructor with: enforce(step != 0); And then create an empty generator if pastLast<= current (and the step is 1). Absolutely. I wrote that test to simplify my life, but in the final version iota should

Re: Errors in TDPL

2010-06-22 Thread bearophile
Andrei: >I optimized things such that the commonly used path (many calls to empty, >front, and popFront) is as fast as possible. The initial work will be >amortized for most loops.< New timings: Running time, best of 3, seconds: test1: 0.31 test1 opt: 0.07 test2: 0.31 test2 opt

Re: Errors in TDPL

2010-06-22 Thread biozic
Le 22/06/10 10:54, Walter Bright a écrit : Andrei Alexandrescu wrote: On 06/21/2010 08:47 PM, Jonathan M Davis wrote: On page 82 of TDPL, it's talking about try/catch/finally statements, and it says that "all controlled statement must be block statements; that is they must be enclosed with brac

Re: Errors in TDPL

2010-06-22 Thread Walter Bright
Andrei Alexandrescu wrote: On 06/21/2010 08:47 PM, Jonathan M Davis wrote: On page 82 of TDPL, it's talking about try/catch/finally statements, and it says that "all controlled statement must be block statements; that is they must be enclosed with braces." However, dmd does not seem to require

Re: Errors in TDPL

2010-06-22 Thread Alix Pexton
On 21/06/2010 21:51, Tomek Sowiński wrote: Dnia 21-06-2010 o 21:57:49 Alix Pexton napisał(a): There is only one mention of lazy evaluation in the index and it doesn't mention the lazy k/w at all. I seem to remember Andrei dislikes it, but also that there is another way to get function params t

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 10:01 PM, BCS wrote: On page 6 it say: "the code sample above also introduced the if statement" but none of them do. Could you please add that to the errata? http://erdani.com/tdpl/errata Andrei

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 08:47 PM, Jonathan M Davis wrote: On page 82 of TDPL, it's talking about try/catch/finally statements, and it says that "all controlled statement must be block statements; that is they must be enclosed with braces." However, dmd does not seem to require that try/catch/finally blocks

Re: Errors in TDPL

2010-06-21 Thread Brad Roberts
On 6/21/2010 8:12 PM, Andrei Alexandrescu wrote: > > I optimized things such that the commonly used path (many calls to > empty, front, and popFront) is as fast as possible. The initial work > will be amortized for most loops. > > On my machine, test4 is still 2x slower than foreach_reverse in an

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 08:28 PM, bearophile wrote: Andrei Alexandrescu: That's not too difficult; for integers, retro(iota(a, b)) could actually be a rewrite to iota(b - 1, a, -1).< This is good. In my dlibs the xchain converts xchain(xchain(x, y), z) and similar into xchain(x, y, z). Figuring ou

Re: Errors in TDPL

2010-06-21 Thread BCS
On page 6 it say: "the code sample above also introduced the if statement" but none of them do. -- ... <

Re: Errors in TDPL

2010-06-21 Thread BCS
Hello Tomek, I think the delegate ought to be pure to make the magic happen. That would be a god idea if the feature were strictly for lazy (no cost unless you need it) evaluation but there are other use that need to be able to cause side effects. -- ... <

Re: Errors in TDPL

2010-06-21 Thread Jonathan M Davis
On page 82 of TDPL, it's talking about try/catch/finally statements, and it says that "all controlled statement must be block statements; that is they must be enclosed with braces." However, dmd does not seem to require that try/catch/finally blocks have braces, which is what I would expect that

Re: Errors in TDPL

2010-06-21 Thread bearophile
Andrei Alexandrescu: >That's not too difficult; for integers, retro(iota(a, b)) could actually be a >rewrite to iota(b - 1, a, -1).< This is good. In my dlibs the xchain converts xchain(xchain(x, y), z) and similar into xchain(x, y, z). >Figuring out all corner cases, steps greater than 1, an

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 06:35 PM, Leandro Lucarella wrote: Andrei Alexandrescu, el 21 de junio a las 17:43 me escribiste: If efficiency is still sub-par, retro could detect that it's working with iota and generate specialized code. That's not too difficult; for integers, retro(iota(a, b)) could actually b

Re: Errors in TDPL

2010-06-21 Thread Leandro Lucarella
Andrei Alexandrescu, el 21 de junio a las 17:43 me escribiste: > If efficiency is still sub-par, retro could detect that it's working > with iota and generate specialized code. That's not too difficult; > for integers, retro(iota(a, b)) could actually be a rewrite to > iota(b - 1, a, -1). Figuring

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 06:30 PM, torhu wrote: On 22.06.2010 00:39, Andrei Alexandrescu wrote: I started an errata list in form of a community wiki at http://www.erdani.com/tdpl/errata For those of us who have still only got the pdf version, is that the same text as the printed one? Should we report er

Re: Errors in TDPL

2010-06-21 Thread torhu
On 22.06.2010 00:39, Andrei Alexandrescu wrote: I started an errata list in form of a community wiki at http://www.erdani.com/tdpl/errata For those of us who have still only got the pdf version, is that the same text as the printed one? Should we report errors in the pdf version, or wait un

Re: Errors in TDPL

2010-06-21 Thread Jonathan M Davis
Andrei Alexandrescu wrote: > On 06/21/2010 02:09 PM, Jonathan M Davis wrote: >> Okay. I am in no way trying to say anything negative about TDPL. > [snip] > > You are being too kind about this :o). Well, I didn't want to post on the main D list and come across as saying that the new book is full

Re: Errors in TDPL

2010-06-21 Thread Spacen Jasset
Andrei Alexandrescu wrote: On 06/21/2010 05:35 PM, Spacen Jasset wrote: I am only on page ten, I believe I saw a minor typo somewhere in the preface, that's all so far. I look forward to pondering the rest in the coming days. oh yes. Preface "D is a language that attempts to consistently do th

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 05:35 PM, Spacen Jasset wrote: I am only on page ten, I believe I saw a minor typo somewhere in the preface, that's all so far. I look forward to pondering the rest in the coming days. oh yes. Preface "D is a language that attempts to consistently do the right thing within the con

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 04:06 PM, bearophile wrote: Adam Ruppe: foreach(i; retro(iota(0, 10))) { } Oh, right! Or even just: foreach (i; retro(iota(10))) {} But abstraction has a cost, see below. I have written three test programs. Nice work. iota() currently uses the formula initial + i * step to c

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 03:32 PM, Ellery Newcomer wrote: I was biting my tongue on the subject, but on page 73 the grammar for the do while loop has a semicolon at the end. AAH THERE IS NOOO SEMICOLON AT THE END. Wow. Sorry. This is a pet peeve of mine. Can't help that, sorry...

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 02:57 PM, Alix Pexton wrote: There is only one mention of lazy evaluation in the index and it doesn't mention the lazy k/w at all. I seem to remember Andrei dislikes it, but also that there is another way to get function params to be evaluated lazily without using it. lazy is quit

Re: Errors in TDPL

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 02:09 PM, Jonathan M Davis wrote: Okay. I am in no way trying to say anything negative about TDPL. [snip] You are being too kind about this :o). Of course we need an errata list. I was hoping I'd need to set it up later, but hey, that's a sign people actually are reading the boo

Re: Errors in TDPL

2010-06-21 Thread Spacen Jasset
I am only on page ten, I believe I saw a minor typo somewhere in the preface, that's all so far. I look forward to pondering the rest in the coming days. oh yes. Preface "D is a language that attempts to consistently do the right thing within the constraints it choose: sys" etc missing

Re: Errors in TDPL

2010-06-21 Thread bearophile
Adam Ruppe: > foreach(i; retro(iota(0, 10))) { } Oh, right! Or even just: foreach (i; retro(iota(10))) {} But abstraction has a cost, see below. I have written three test programs. // test1 import std.c.stdio: printf; void main() { enum int N = 100_000_000; int count;

Re: Errors in TDPL

2010-06-21 Thread Tomek Sowiński
Dnia 21-06-2010 o 21:57:49 Alix Pexton napisał(a): There is only one mention of lazy evaluation in the index and it doesn't mention the lazy k/w at all. I seem to remember Andrei dislikes it, but also that there is another way to get function params to be evaluated lazily without using i

Re: Errors in TDPL

2010-06-21 Thread Ellery Newcomer
I was biting my tongue on the subject, but on page 73 the grammar for the do while loop has a semicolon at the end. AAH THERE IS NOOO SEMICOLON AT THE END. Wow. Sorry. This is a pet peeve of mine.

Re: Errors in TDPL

2010-06-21 Thread Adam Ruppe
On 6/21/10, bearophile wrote: > How do you write this? > foreach_reverse (i; 0 .. 10) foreach(i; retro(iota(0, 10))) { } ?

Re: Errors in TDPL

2010-06-21 Thread Alix Pexton
foreach_reverse has been deprecated in favor of using the combination of foreach and retro. So, TDPL is missing at least some keywords in its list, and the online docs have too many. In any case, I figured that it would be helpful if any errors in TDPL could be pointed out, since it could be helpf

Re: Errors in TDPL

2010-06-21 Thread bearophile
Jonathan M Davis: An online Errata Corrige will be very useful. > and I believe that foreach_reverse has been deprecated in favor of > using the combination of foreach and retro. How do you write this? foreach_reverse (i; 0 .. 10) Bye, bearophile

Errors in TDPL

2010-06-21 Thread Jonathan M Davis
ted in favor of using the combination of foreach and retro. So, TDPL is missing at least some keywords in its list, and the online docs have too many. In any case, I figured that it would be helpful if any errors in TDPL could be pointed out, since it could be helpful to Andrei and could be