On Wed, Oct 19, 2016 at 11:38 AM, Michael Jones <michael.jo...@gmail.com> wrote:
> As in a number of previous questions, this one was asked poorly and the 
> answers dance all around the intention. I had decided never to enter the fray 
> of these oddly-put assertion/half questions, but since this is lingering, may 
> I suggest that this is his real question:
>
> “can we have var-style declarations in the places where the shorthand syntax 
> is allowed?”
>
> elaborating…
>
> for i := 0; i < 10; i++ {…}
>
> might also allow
>
> for var i int; i < 10; i++ {…}
>
> and likewise in other short-variable-permitting contexts.
>
> Personally, it seems that the simplest argument in favor would be 
> orthogonality and the best argument in favor would be the natural creation of 
> multiple scope local variables. This “best” is not very strong, though, since 
> it is unclear to me how you could introduce variables of multiple types.
>
> Not taking sides here…just feeling that the core issue was not addressed. Nor 
> was the much better question that was not asked, “why was the decision made 
> in Go not to allow non-short variable declarations in these contexts?”

Thanks for trying to clarify.

I'm not sure I buy the orthogonality argument here.  I mean, why not
permit any statement in the first clause of a for statement?  Why
restrict it to just variable declarations?  But if we accept that it
is restricted, I think it seems reasonable to restrict only to short
variable declarations, since `for var i int` seems to me to be ugly.

You can create multiple local variables in the for scope by writing, for example
    for a, b := 0, 10; a < b; a++ {
(That would work with var, too).

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to