On Wednesday, November 9, 2016 at 6:29:13 PM UTC+8, Dave Cheney wrote:
>
> There are already too many ways to declare and or assign a variable in Go.
> Adding more is not a solution.
how about to prefix a ~ before identifiers to avoid shadowing:
func f() {
a, err := 1, error.New("an
On Thursday, November 10, 2016 at 1:23:33 AM UTC+8, Marvin Renich wrote:
>
> * T L [161109 11:57]:
> > yes, := can be avoided totally.
> > but := really has some benefits.
> >
> > The contradiction is the short form is 80% good with 20% bad side
> effects.
>
> I
* T L [161109 11:57]:
> yes, := can be avoided totally.
> but := really has some benefits.
>
> The contradiction is the short form is 80% good with 20% bad side effects.
I disagree. I saves three characters and in doing so adds much more
cognitive load to distinguish
* T L [161109 05:18]:
> On Friday, October 21, 2016 at 11:26:46 PM UTC+8, T L wrote:
> > Thanks, gri, this is almost the answer I want.
> >
> > I still have two small questions about the short form.
> > 1. would it be good to allow all identifiers in a short form are old ones
On Wednesday, November 9, 2016 at 8:13:36 PM UTC+8, Jan Mercl wrote:
>
> On Wed, Nov 9, 2016 at 1:00 PM T L
> wrote:
>
> > many? I see only two ones.
>
> v := expr
> var v = expr
> var v T
> var v T = expr
>
the last 3 and function/method parameters, and named return
On Wed, Nov 9, 2016 at 1:00 PM T L wrote:
> many? I see only two ones.
v := expr
var v = expr
var v T
var v T = expr
--
-j
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop
and function/method parameters, and named return arguments.
On Wednesday, 9 November 2016 23:13:36 UTC+11, Jan Mercl wrote:
>
> On Wed, Nov 9, 2016 at 1:00 PM T L
> wrote:
>
> > many? I see only two ones.
>
> v := expr
> var v = expr
> var v T
> var v T = expr
>
> --
>
> -j
On Wednesday, November 9, 2016 at 6:29:13 PM UTC+8, Dave Cheney wrote:
>
> There are already too many ways to declare and or assign a variable in Go.
> Adding more is not a solution.
many? I see only two ones.
--
You received this message because you are subscribed to the Google Groups
There are already too many ways to declare and or assign a variable in Go.
Adding more is not a solution.
--
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
On Friday, October 21, 2016 at 11:26:46 PM UTC+8, T L wrote:
>
>
>
> On Friday, October 21, 2016 at 4:31:51 AM UTC+8, gri wrote:
>>
>> To answer the subject line question: No, short variable declarations are
>> not technically necessary. We could have chosen not to have them. But there
>> are
On Friday, October 21, 2016 at 4:31:51 AM UTC+8, gri wrote:
>
> To answer the subject line question: No, short variable declarations are
> not technically necessary. We could have chosen not to have them. But there
> are good reasons for them. It was a deliberate design decision.
>
> Let me
To answer the subject line question: No, short variable declarations are
not technically necessary. We could have chosen not to have them. But there
are good reasons for them. It was a deliberate design decision.
Let me throw in a bit of historical perspective:
Rob's invention of ":=" in one of
On Thursday, October 20, 2016 at 3:25:18 AM UTC+8, Ian Lance Taylor wrote:
>
> On Wed, Oct 19, 2016 at 11:38 AM, Michael Jones > wrote:
> > As in a number of previous questions, this one was asked poorly and the
> answers dance all around the intention. I had decided
rg>, T L <tapir@gmail.com>, golang-nuts
<golang-nuts@googlegroups.com>
Subject: Re: [go-nuts] Are short variable declarations necessary?
var could do that too:
https://play.golang.org/p/v9pQSZPTh_
(not that I'm advocating in favor of var in more places)
On Wed, Oct 19, 2
s@googlegroups.com> on behalf of Ian Lance Taylor <
> i...@golang.org>
> Date: Wednesday, October 19, 2016 at 12:25 PM
> To: Michael Jones <michael.jo...@gmail.com>
> Cc: T L <tapir@gmail.com>, golang-nuts <golang-nuts@googlegroups.com>
> Subject: Re:
ups.com>
Subject: Re: [go-nuts] Are short variable declarations necessary?
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).
--
You received this message because you are subscribe
On Wed, Oct 19, 2016 at 11:38 AM, Michael Jones 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
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
On Wed, Oct 19, 2016 at 3:24 AM, T L wrote:
>
> On Wednesday, October 19, 2016 at 5:43:48 AM UTC+8, Ian Lance Taylor wrote:
>>
>> On Tue, Oct 18, 2016 at 7:50 AM, T L wrote:
>> >
>> > On Tuesday, October 18, 2016 at 10:40:02 PM UTC+8, Ian Lance Taylor
>> >
On Wed, Oct 19, 2016 at 12:51 PM T L wrote:
> but I don't want to leak i in outer block, and adding a {} pair is
overkill.
That's an example answering the question in the title of this thread.
--
-j
--
You received this message because you are subscribed to the Google
On Wednesday, October 19, 2016 at 6:28:21 PM UTC+8, Nyah Check wrote:
>
> This can still work
>
> *var int i = 0*
> *for i < MAX {*
> * //statements here*
> * i++*
> *}*
>
> Cheers!
>
but I don't want to leak i in outer block, and adding a {} pair is overkill.
>
> On Wed, Oct 19, 2016 at
>
>
> *var int i = 0*
>
var i int = 0
--
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
This can still work
*var int i = 0*
*for i < MAX {*
* //statements here*
* i++*
*}*
Cheers!
On Wed, Oct 19, 2016 at 11:24 AM, T L wrote:
>
>
> On Wednesday, October 19, 2016 at 5:43:48 AM UTC+8, Ian Lance Taylor wrote:
>
>> On Tue, Oct 18, 2016 at 7:50 AM, T L
>
> sorry, from my experience, short form doesn't reduces the number of lines
> immensely comparing to var form.
> And sometimes, more code lines are needed by using short form.
>
> Yeah, sometimes. But we are not forced to use it though; Anyone can use
any feature as they see fit.
Cheers!
--
On Wednesday, October 19, 2016 at 5:43:48 AM UTC+8, Ian Lance Taylor wrote:
>
> On Tue, Oct 18, 2016 at 7:50 AM, T L
> wrote:
> >
> > On Tuesday, October 18, 2016 at 10:40:02 PM UTC+8, Ian Lance Taylor
> wrote:
> >>
> >> On Tue, Oct 18, 2016 at 7:21 AM, T L
On Wednesday, October 19, 2016 at 6:06:22 AM UTC+8, Nyah Check wrote:
>
> Hi TL,
>
> I can't talk on behalf of the creators of the language; but from my
> personal experience; it makes code more succinct and easier to write;
> something more or less like "doing more with less" if you know what
Hi TL,
I can't talk on behalf of the creators of the language; but from my
personal experience; it makes code more succinct and easier to write;
something more or less like "doing more with less" if you know what I mean.
It's one the the features I love the most in Go. It just makes programming
On Tue, Oct 18, 2016 at 7:50 AM, T L wrote:
>
> On Tuesday, October 18, 2016 at 10:40:02 PM UTC+8, Ian Lance Taylor wrote:
>>
>> On Tue, Oct 18, 2016 at 7:21 AM, T L wrote:
>> >
>> > alternative question, why followings are not accepted in syntax:
>> >
>>
The reason for short variable declarations is, that it makes reuse easier
in cases of multiple return values. e.g.
var a, err = Foo()
if err != nil {
return err
}
var b, err = a.Bar()
if err != nil {
return err
}
doesn't work. That being said, the duplication between ways of declaring
On Tuesday, October 18, 2016 at 11:01:18 PM UTC+8, Pietro Gagliardi
(andlabs) wrote:
>
> No, the reason for short variable declarations is to avoid having to
> stutter the type of variables everywhere.
>
You can also avoid having to stutter the type of variables by using var
declaration.
No, the reason for short variable declarations is to avoid having to stutter
the type of variables everywhere. It's part of the reason why Go is strongly
typed yet doesn't fully feel that way, and was one of the main design goals at
first.
Why the control statements require one, however, is
On Tue, Oct 18, 2016 at 7:21 AM, T L wrote:
>
> alternative question, why followings are not accepted in syntax:
>
> if var x = 5; x > 3 {
> _ = x
> }
>
> for var x = range []int{0,1,2} {
> _ = x
>
> }
>
> switch var x = "abc"; x {
>
alternative question, why followings are not accepted in syntax:
if var x = 5; x > 3 {
_ = x
}
for var x = range []int{0,1,2} {
_ = x
}
switch var x = "abc"; x {
default:
_ = x
}
switch var x = (interface{}(true)).(type) {
33 matches
Mail list logo