You are right. But this felt clean and obvious syntax. Back to NewGate! On Sunday, October 2, 2016 at 1:47:27 PM UTC+3:30, Axel Wagner wrote: > > Because that wouldn't be "the zero value" anymore. > It would require that, when you do e.g. > x := make([]gate, 4096) > that the compiler emits the code to initialize everything. The same > recursively for each type that contains a gate and for each function which > uses a local gate variable. > So this would imply a significant hidden runtime overhead when using that > type. > > The advantage of the zero type is, that it always is just zero-initialized > memory. > > On Sun, Oct 2, 2016 at 11:33 AM, dc0d <kaveh.sh...@gmail.com <javascript:> > > wrote: > >> Why there is no field initializer in Go? Like: >> >> type gate struct { >> outgoing = make(chan *sendRequest) >> incoming = make(chan update, 10) >> } >> >> Doesn't that make zero value more useful? The syntax already exists for >> global variables so IMHO not much new would get introduced to the language >> syntax - I can not tell of it's pros & cons for semantic or overall, >> deeply, but seems a practical thing for making the zero value even more >> interesting. >> >> -- >> 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...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > >
-- 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.