Why not use something like if token.in(EOL,EOF) …
with varadic args this is trivial. And with generics you probably only need to write a single ‘in’ function (haven’t tested). > On Mar 18, 2025, at 6:50 PM, Mike Schinkel <m...@newclarity.net> wrote: > > Hi all, > > While working on a parser, I've repeatedly encountered patterns like: > > if c == ' ' || c == '\t' { /* handle whitespace */ } > if token == EOL || token == EOF { /* handle end markers */ } > if lexer.Type == TextLine || lexer.Type == WhitespaceLine { /* handle lines > */ } > > Go already allows multiple values in case statements: > > switch c { > case ' ', '\t': > /* handle whitespace */ > } > > I'm wondering if there could be a more elegant way to express this pattern in > Go, perhaps something conceptually similar to: > > if c [some_syntax] ' ', '\t' { /* handle whitespace */ } > > Do you think that the Go team would be likely to consider such a proposal, or > would taking the time to prepare and submit a proposal likely just be for > naught? > > If this seems worthy of a proposal, what syntax do you think might be the > best fit for the Go language? > > Thanks, > > -Mike > > -- > 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. > To view this discussion visit > https://groups.google.com/d/msgid/golang-nuts/F06145BC-B54C-4C3C-A04A-E9E6839E8169%40newclarity.net. -- 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. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/54769CBC-A9EF-4C6C-9C9B-111A62078489%40ix.netcom.com.