Re: foreach ... else statement

2009-01-08 Thread Nick Sabalausky
"Walter Bright" wrote in message news:gk6150$n6...@digitalmars.com... > Nick Sabalausky wrote: >> "Rioshin an'Harthen" wrote in message >> news:gk4kfh$ri...@digitalmars.com... >>> "Walter Bright" kirjoitti viestissä >>> news:gk1dag$pt...@digitalmars.com... I keep thinking I should put on

Re: foreach ... else statement

2009-01-08 Thread Walter Bright
Nick Sabalausky wrote: "Rioshin an'Harthen" wrote in message news:gk4kfh$ri...@digitalmars.com... "Walter Bright" kirjoitti viestissä news:gk1dag$pt...@digitalmars.com... I keep thinking I should put on a "Compiler Construction" seminar! A net-seminar, please, so that those of us who want to

Re: foreach ... else statement

2009-01-08 Thread Walter Bright
BCS wrote: Reply to Walter, Robert Fraser wrote: Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! *cough* NWCPP *cough* I'd like to do a paid one . BTW, Bartosz has graciously offered the Jan NWCPP speaking engagement to me. I'll be talking about

Re: foreach ... else statement

2009-01-08 Thread BCS
Reply to Walter, Robert Fraser wrote: Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! *cough* NWCPP *cough* I'd like to do a paid one . BTW, Bartosz has graciously offered the Jan NWCPP speaking engagement to me. I'll be talking about mixins and t

Re: foreach ... else statement

2009-01-08 Thread Nick Sabalausky
"Rioshin an'Harthen" wrote in message news:gk4kfh$ri...@digitalmars.com... > "Walter Bright" kirjoitti viestissä > news:gk1dag$pt...@digitalmars.com... >> I keep thinking I should put on a "Compiler Construction" seminar! > > A net-seminar, please, so that those of us who want to attend actuall

Re: foreach ... else statement

2009-01-08 Thread Rioshin an'Harthen
"Walter Bright" kirjoitti viestissä news:gk1dag$pt...@digitalmars.com... I keep thinking I should put on a "Compiler Construction" seminar! A net-seminar, please, so that those of us who want to attend actually can.

Re: foreach ... else statement

2009-01-07 Thread Walter Bright
Robert Fraser wrote: Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! *cough* NWCPP *cough* I'd like to do a paid one . BTW, Bartosz has graciously offered the Jan NWCPP speaking engagement to me. I'll be talking about mixins and templates. All are we

Re: foreach ... else statement

2009-01-07 Thread Robert Fraser
Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! *cough* NWCPP *cough*

Re: foreach ... else statement

2009-01-07 Thread Andrei Alexandrescu
Walter Bright wrote: Andrei Alexandrescu wrote: Walter Bright wrote: Academic papers on compiler optimizations always start out with "assume there are no pointers, no references, no arrays, no exceptions, no threads, no aliasing, no overflows, no signed/unsigned, there are infinite registers

Re: foreach ... else statement

2009-01-07 Thread Walter Bright
Andrei Alexandrescu wrote: Walter Bright wrote: Academic papers on compiler optimizations always start out with "assume there are no pointers, no references, no arrays, no exceptions, no threads, no aliasing, no overflows, no signed/unsigned, there are infinite registers available, registers a

Re: foreach ... else statement

2009-01-07 Thread Bill Baxter
On Thu, Jan 8, 2009 at 10:28 AM, Andrei Alexandrescu wrote: > Walter Bright wrote: >> >> Bill Baxter wrote: >>> >>> On Thu, Jan 8, 2009 at 6:46 AM, Andrei Alexandrescu >>> wrote: Bill Baxter wrote: > > On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright > wrote: >> >> Sea

Re: foreach ... else statement

2009-01-07 Thread Andrei Alexandrescu
Walter Bright wrote: Bill Baxter wrote: On Thu, Jan 8, 2009 at 6:46 AM, Andrei Alexandrescu wrote: Bill Baxter wrote: On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright wrote: Sean Kelly wrote: I keep thinking I should put on a "Compiler Construction" seminar! You should. The academic courses

Re: foreach ... else statement

2009-01-07 Thread BCS
Reply to Walter, Bill Baxter wrote: On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright It's like in physics class you're always dealing with frictionless brakes and pointless masses. You mean massless points? Or was that deliberate? I wondered if anyone would notice that (!). Yes, it's delib

Re: foreach ... else statement

2009-01-07 Thread Walter Bright
Bill Baxter wrote: On Thu, Jan 8, 2009 at 6:46 AM, Andrei Alexandrescu wrote: Bill Baxter wrote: On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright wrote: Sean Kelly wrote: I keep thinking I should put on a "Compiler Construction" seminar! You should. The academic courses do a good job with th

Re: foreach ... else statement

2009-01-07 Thread Walter Bright
Bill Baxter wrote: On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright It's like in physics class you're always dealing with frictionless brakes and pointless masses. You mean massless points? Or was that deliberate? I wondered if anyone would notice that (!). Yes, it's deliberate.

Re: foreach ... else statement

2009-01-07 Thread Bill Baxter
On Thu, Jan 8, 2009 at 6:46 AM, Andrei Alexandrescu wrote: > Bill Baxter wrote: >> >> On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright >> wrote: >>> >>> Sean Kelly wrote: > > I keep thinking I should put on a "Compiler Construction" seminar! You should. The academic courses do a g

Re: foreach ... else statement

2009-01-07 Thread Andrei Alexandrescu
Bill Baxter wrote: On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright wrote: Sean Kelly wrote: I keep thinking I should put on a "Compiler Construction" seminar! You should. The academic courses do a good job with theory and general application, but that isn't quite the same as one based on pract

Re: foreach ... else statement

2009-01-07 Thread Bill Baxter
On Thu, Jan 8, 2009 at 5:54 AM, Walter Bright wrote: > Sean Kelly wrote: >>> >>> I keep thinking I should put on a "Compiler Construction" seminar! >> >> You should. The academic courses do a good job with theory and >> general application, but that isn't quite the same as one based on >> practic

Re: foreach ... else statement

2009-01-07 Thread Walter Bright
Tomas Lindquist Olsen wrote: On Wed, Jan 7, 2009 at 6:07 AM, Walter Bright The last time I even heard of a compiler that fell over and gave up optimizing if it saw a goto was in the early 80's. I have a hard time believing LDC has problems with it, but if it does, the authors sho

Re: foreach ... else statement

2009-01-07 Thread Walter Bright
Sean Kelly wrote: I keep thinking I should put on a "Compiler Construction" seminar! You should. The academic courses do a good job with theory and general application, but that isn't quite the same as one based on practical experience. That's true. I learned the theory taking a compiler con

Re: foreach ... else statement

2009-01-07 Thread Tomas Lindquist Olsen
On Wed, Jan 7, 2009 at 6:07 AM, Walter Bright wrote: > Don wrote: > >> I still avoid goto because I was told to. But eventually I realised that >> it's 100% propaganda. I actually think my code would be cleaner if I used >> it; it would allow lots of local flag variables to be eliminated. >> But I

Re: foreach ... else statement

2009-01-07 Thread Sean Kelly
== Quote from Walter Bright (newshou...@digitalmars.com)'s article > Don wrote: > > I still avoid goto because I was told to. But eventually I realised that > > it's 100% propaganda. I actually think my code would be cleaner if I > > used it; it would allow lots of local flag variables to be elimin

Re: foreach ... else statement

2009-01-07 Thread Daniel Keep
Robert Fraser wrote: Daniel Keep Wrote: It's rather ironic, but one thing that struck me going from Visual Basic to Python was that VB had much nicer error handling; instead of having error handling all over the place, it was all localised to the end of the function. This is why I absolutel

Re: foreach ... else statement

2009-01-06 Thread BCS
Reply to Walter, I keep thinking I should put on a "Compiler Construction" seminar! That would be fun. If I could, I'd show up.

Re: foreach ... else statement

2009-01-06 Thread Benji Smith
Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! Sign me up!

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
Andrei Alexandrescu wrote: The challenge the paper addresses is constructing the SSA form in one shot. There are indeed algorithms that build the SSA in several passes. My vague recollection from a compiler construction class is that there are a number of static analyses that need to do a fixe

Re: foreach ... else statement

2009-01-06 Thread Andrei Alexandrescu
Walter Bright wrote: grauzone wrote: bearophile wrote: Don: Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. That construct can avoid gotos in some common situations. And regarding the compiler back-end, I

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
Don wrote: I still avoid goto because I was told to. But eventually I realised that it's 100% propaganda. I actually think my code would be cleaner if I used it; it would allow lots of local flag variables to be eliminated. But I still have this residual prejudice against 'goto' which is really

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
Don wrote: It's possible to create grotesque configurations of 'goto' which are extremely difficult to analyze. For a human, yes. For well-known optimization algorithms, no.

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
grauzone wrote: bearophile wrote: Don: Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. That construct can avoid gotos in some common situations. And regarding the compiler back-end, I think it's also bette

Re: foreach ... else statement

2009-01-06 Thread Robert Fraser
Daniel Keep Wrote: > It's rather ironic, but one thing that struck me going from Visual Basic > to Python was that VB had much nicer error handling; instead of having > error handling all over the place, it was all localised to the end of > the function. This is why I absolutely adore scope sta

Re: foreach ... else statement

2009-01-06 Thread Daniel Keep
Brian wrote: [snip] neither of those seem necessary in that example, whats wrong with this: void somefunction() { do_stuff(); if (error) handle_error(); else do_more_stuff(); } A few things I can think of: 1. You're mixing error handli

Re: foreach ... else statement

2009-01-06 Thread Brian
On Mon, 05 Jan 2009 11:13:49 +0100, grauzone wrote: > void somefunction() { > do_stuff(); > if (error) > goto error_exit: > do_more_stuff(); > > return; > > error_exit: > handle_error(); > } > > This could be replaced by something like this: > > void

Re: foreach ... else statement

2009-01-05 Thread Christopher Wright
Nick Sabalausky wrote: bool isFound=false; foreach(char[] key, Foo f; fooAA) { if(f.someFlag && key in barAA && f.someVal > barAA[key].someVal) { isFound = true; break; } } if(!isFound) Stdout.formatln("Missing!"); foreach (a, b; aa) if (weLike(a, b)) goto fou

Re: foreach ... else statement

2009-01-05 Thread Danny Wilson
foreach(languageStatement; AllProgrammingLanguages) Stdout.format( "It's possible to create grotesque configurations of '{}' which are "~ "extremely difficult to analyze. But most uses of {} are simple.", languageStatement ).newline;

Re: foreach ... else statement

2009-01-05 Thread Don
grauzone wrote: bearophile wrote: Don: Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. That construct can avoid gotos in some common situations. And regarding the compiler back-end, I think it's also bette

Re: foreach ... else statement

2009-01-05 Thread Don
bearophile wrote: Don: Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. Structured programming does not mean no gotos. You should really read the original paper "Goto considered harmful", you'll find it's

Re: foreach ... else statement

2009-01-05 Thread grauzone
bearophile wrote: Don: Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. That construct can avoid gotos in some common situations. And regarding the compiler back-end, I think it's also better to start thinki

Re: foreach ... else statement

2009-01-05 Thread bearophile
Don: > Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. That construct can avoid gotos in some common situations. And regarding the compiler back-end, I think it's also better to start thinking what's good for

Re: foreach ... else statement

2009-01-05 Thread bearophile
BCS: > I think your expectation would be a good feature but I can't really see else > being the right keyword to use. How about "finally"? Or another option with > scope(*) like "fallthrough"? The good thing of "else" is that you don't need a new keyword. But it's not intuitive. A better keywor

Re: foreach ... else statement

2009-01-05 Thread Don
bearophile wrote: Brian: any chance we could see something like pythons else statement on iterative loops in D (Might be useful on regular for loops too but not as much)? http://docs.python.org/tutorial/controlflow.html#break-and-continue- statements-and-else-clauses-on-loops It seems everyo

Re: foreach ... else statement

2009-01-04 Thread Denis Koroskin
On Mon, 05 Jan 2009 01:11:34 +0300, BCS wrote: Reply to Nick, I had never heard of that before, but it certainly seems like something I'd find useful. Any time I'm using for or foreach to find something, I end up having to use some sort of "isFound" flag and check that after the loop. A for..

Re: foreach ... else statement

2009-01-04 Thread bearophile
Daniel de Kok: >Wouldn't it be more adequate to rewrite this as a function/method that takes a >predicate?< In my dlibs there are things that allow to do that, but the code is slower. --- BCS: >Wait, that's not the way I would expect else to work.< See the answer by Guido V. R. hi

Re: foreach ... else statement

2009-01-04 Thread BCS
Reply to Nick, I had never heard of that before, but it certainly seems like something I'd find useful. Any time I'm using for or foreach to find something, I end up having to use some sort of "isFound" flag and check that after the loop. A for...else would be much nicer, for example: [...]

Re: foreach ... else statement

2009-01-04 Thread Daniel de Kok
On Sun, 04 Jan 2009 14:01:41 -0500, Nick Sabalausky wrote: > bool isFound=false; > foreach(char[] key, Foo f; fooAA) > { > if(f.someFlag && key in barAA && f.someVal > barAA[key].someVal) > { > isFound = true; > break; > } > } > if(!isFound) > Stdout.formatln("Missin

Re: foreach ... else statement

2009-01-04 Thread Nick Sabalausky
"bearophile" wrote in message news:gjqpt0$1lr...@digitalmars.com... > Brian: >> any chance we could see something like pythons else statement on >> iterative loops in D (Might be useful on regular for loops too but not as >> much)? >> http://docs.python.org/tutorial/controlflow.html#break-and-con

Re: foreach ... else statement

2009-01-04 Thread bearophile
Brian: > any chance we could see something like pythons else statement on > iterative loops in D (Might be useful on regular for loops too but not as > much)? > http://docs.python.org/tutorial/controlflow.html#break-and-continue- > statements-and-else-clauses-on-loops It seems everyone has ignor