>> In my opinion, having a supplementary keyword is costly, it makes the
>> language more complex and adds to what you must know. And it might mask to
>> newcomers what's behind instantiating a struct. It also makes one more
>> reserved word.
[citation needed] Go has fewer keywords than any other curly brace
language, http://golang.org/ref/spec#Keywords.
You cannot do this without new
>> So what's the reasoning behind new ? Is it something useful ? Should we
>> use it ?
http://play.golang.org/p/-VfcIz8N2o
So basically, Dave's point doesn't really stand?
This kind of question is interesting, because Go wants to remain as minimal as possible from what I understand, yet there is this built-in function clobbering up the namespace.
Wasn't this discussed because it was just obvious that Go should have it because almost every language has it?
This might be a dumb question, but since we have the & operator to take the address of composite literals, why was that not extended to other types?
On Tuesday, 5 November 2013 12:29:38 UTC+1, Dave Cheney wrote:
You cannot do this without new
http://play.golang.org/p/-VfcIz8N2o
--
On Nov 5, 2013 1:58 PM, "Florian Margaine" <flo...@margaine.com> wrote:
>
> So basically, Dave's point doesn't really stand?
>
> This kind of question is interesting, because Go wants to remain as minimal as possible from what I understand, yet there is this built-in function clobbering up the namespace.
i wouldn't say it clobbers namespace because it's not a keyword. you can still use new as an identifier.
> Wasn't this discussed because it was just obvious that Go should have it because almost every language has it? Any decision around this kind of built-in stuff is quite important. And adding something for the sake of it is usually not a great idea since it's very hard to remove something.
you need to consider the history of the project. i think new is introduced first before there is make.
> Is Dave's (rare) case the only reason why `new` was added?
i don't think it is a rare case.
Or much more gotchaery ones like typed nils.
So, leave new alone, it's not hurting anyone and you really can live most of your life as a Go programmer with only a passing relationship to it.
And it was in fact just curiosity. I wouldn't ask if I didn't care :-)
This kind of reaction is awesome; thanks for being you.
Feelings set apart, I got my answer on this thread: `new` is originally there because it was the first, and and it's still the one to go for in some situations.
Thanks everyone for your input!