Notes IV
Bill Baxter
dnewsgroup at billbaxter.com
Sat Jan 26 09:53:30 PST 2008
Jarrod wrote:
> On Fri, 25 Jan 2008 18:08:46 +0900, Bill Baxter wrote:
>
>> It's funny you should say that, because just today I was staring at a
>> couple of foreaches that were giving me compiler errors and scratching
>> my head. Turns out I had written this:
>>
>> foreach(i,ang, angles) {
>> ...
>> }
>>
>> Now maybe you can see right away what's wrong, but in my somewhat sleepy
>> state and with my preferred ProggyTT programming font, I just didn't
>> notice the missing pixel there. It's much harder to mistake a comma
>> for an 'in'.
>
> But there will still be a comma or a semicolon there for cases where you
> want the index.
> Wouldn't just allowing commas and semicolons work better?
Was that part of the proposal? I was just wanting the semicolon to be
replaced by 'in' in all cases so you'd never see a semicolon in a
foreach. Ever. Anyway this has been asked for before. Walter said "no"
because the grammar would have to be special cased to treat 'in'
differently inside the foreach. It's a reasonable decree. I still pine
for it, though, every time I accidentally put a comma in there instead
of a semicolon. :-)
>
>> Hmm, that doesn't sound like a scientific study. Python has many more
>> users than D despite the fact that apparently most people don't like it.
>
> Perhaps I should say 'many' instead of 'most' don't like it. I frequent
> and moderate a few programming forums, and trust me, there are a *lot* of
> groans and moans about it. *Especially* from the lisp/scheme fans. They
> seem to hate it with a passion. Some have even written some 'interesting'
> poems about it. True story.
Ok, that is certainly true. I myself thought it was ridiculous till I
tried it. Now I merely think of it as an acceptable alternative. I
think it's mostly a wash. Slightly cleaner-looking code at the cost of
some slight annoyances. The biggest of those to me is that you have to
be a little more careful when you copy-paste a block of code in the
middle of some function. In many cases an editor cannot tell what
nesting level you intend for it to be at. But it's not a big problem by
any means.
--bb
More information about the Digitalmars-d
mailing list