On 8 August 2017 at 08:15, <martin.r...@programmfabrik.de> wrote: > >> The Go philosophy is explicitly *not* to give you everything you want. >> It *is* to give you everything you need to build everything you want, >> like Lego. >> > > Yeah right, when men still where real men and programmed their own device > drivers... > > Or take a car, give me parts & tools and I am ready to give you a ride in > say a year? > > >> Every language is different. Any developer worth their salt won't dismiss >> a tool out-of-hand for such a trivial reason. >> > > No nobody would. But trivial things add up and then people run away or > never sign up. > > I have learnt to never not listen to your (potential) users. > > If a new project comes on board of the Go train, people already have to > wrap their heads around new (admittedly interesting) concepts, they have to > accept "err != nil" spaghetti, distinction between Array and Slices, make > and new, and so on. > > Personally I got really interested when I died around your standard > library which I really like and it seems to give us exactly what we need, > not too much, not too little. > >> >> Also, consider the fact that in Python, the same loop is happening. Go >> just doesn't hide that from the developer, making it easier for us to >> reason about things like performance. You can write your own "find" >> function in seconds if you want one. >> > > It just looks awkward: > > contains := false > for _, n := range excluded_numbers { > if byte(m) == n { > contains = true > } > } > if !contains { > ... > > Seriously? 2017? >
I'd usually write that as as separate function: func isExcluded(ns []byte, m byte) bool { for _, n := range ns { if n == m { return true } } return false } For that *particular* case, you could always use bytes.Index(excluded_numbers, byte(m)) >= 0 though. Yes, it feels a little tedious sometimes, but if you add up the number of times you actually have to do this, it's generally not too much. There's a trade-off going on here. cheers, rog. > Martin > > >> -- >> ☕😎 >> > -- > 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. > -- 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.