suggested change to foreach index

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Jun 10 14:33:10 PDT 2006


"Deewiant" <deewiant.doesnotlike.spam at gmail.com> wrote in message 
news:e6ev28$o1k$1 at digitaldaemon.com...

> I guess I'm the only one that doesn't like this idea, then. I think "auto" 
> is
> overloaded enough as it is; I'm still waiting for "var" or some such for 
> type
> inference.

I'd really like something else for type inference too, but until that 
happens, "auto" would make the most sense.  I think 'var' or something along 
those lines would be better; and it would be best if it functioned _as a 
type_ which would just stand for a "placeholder" type until the type could 
be determined in the semantic pass.

> And I always thought it was obvious that foreach() uses its own index, but 
> that
> might be since I've only recently (say, a few days back) begun to use type
> inference with it. When you write "size_t i, type x; something" it's 
> obvious
> enough, and when I write "i, type x" I think of the longer form, realising 
> it's
> short for just that.

Well, keep in mind that many of my proposals are based on my virulent hatred 
of most uses of type inference ;)  It's bad enough when people start 
overusing auto; it's worse when it's not even obvious that a new variable is 
being declared as well!

> Personally, I'd prefer "out" instead of "inout" or "alias", but that's 
> just me. <g>

That's good too, but the best would be if/when we get a true type-inference 
keyword for use with index inference, and then nothing when you want to use 
the outer scope's variable (to be consistent with the behavior of for 
loops). 





More information about the Digitalmars-d mailing list