I know I am making a late entry to this discussion, but I dont see the
problem with creating generic functions for the bitwise operations if you
think they decrease readability.

An example: http://play.golang.org/p/pbZybh920X

It works perfectly, is readable, and has good performance and memory
footprint. The con is that it's not extendable to more than 64 flags per
field, but it covers the most common use cases.

Den lördagen den 21:e april 2012 kl. 23:17:38 UTC+2 skrev Archos:
I've a struct with 15 boolean fields besides of another kind of
fields. Would be better if those boolean fields were managed like

type check uint16

const (
isFoo check = 1 << iota

although it it's most verbose during checking:

if check&isFoo != 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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
postedJun 26, '13 at 12:27p
activeJun 26, '13 at 12:27p

1 user in discussion

Robinwassen: 1 post



site design / logo © 2021 Grokbase