Fear uncertainty and doubt

309 views
Skip to first unread message

Sonia Keys

unread,
Jun 21, 2012, 10:00:48 AM6/21/12
to golan...@googlegroups.com
Some recent comments on Stack Overflow are bugging me.  I'm asking for help here because the comments have the effect of spreading FUD about Go.  The posted question asks how to create a case insensitive map.  The troublesome comments make false statements about Go's handling of Unicode (when the OP wasn't even concerned with Unicode.)  Correcting this person would seem to be accepting their challenge to an off-topic flame war.  Instead, I would encourage anyone with a SO account to flag these comments for moderation.  Note that on the flag dialog, while the "off-topic or unconstructive" radio button is appropriate, the "other" button allows you to send a message to moderators explaining what you feel is wrong with the comments.

Matt Kane's Brain

unread,
Jun 21, 2012, 10:07:57 AM6/21/12
to Sonia Keys, golan...@googlegroups.com
I don't see any anti-Go FUD. Did something get deleted?
--
matt kane's brain
http://hydrogenproject.com

Aram Hăvărneanu

unread,
Jun 21, 2012, 10:15:19 AM6/21/12
to Matt Kane's Brain, Sonia Keys, golan...@googlegroups.com
FUD on the Internet? Preposterous!

--
Aram Hăvărneanu

roger peppe

unread,
Jun 21, 2012, 10:25:04 AM6/21/12
to Sonia Keys, golan...@googlegroups.com
On 21 June 2012 15:00, Sonia Keys <soni...@gmail.com> wrote:
> Some recent comments on Stack Overflow are bugging me.  I'm asking for help
> here because the comments have the effect of spreading FUD about Go.  The
> posted question asks how to create a case insensitive map.  The troublesome
> comments make false statements about Go's handling of Unicode (when the OP
> wasn't even concerned with Unicode.)

The comments seem reasonable to me. It's correct that you can't
do a case insensitive map that works correctly with unicode characters
by using strings.ToLower. That's the reason that strings.EqualFold
exists.

I wonder if using strings.Map(unicode.SimpleFold, s) would be wrong
too. Unicode is too subtle for me...

Matt Kane's Brain

unread,
Jun 21, 2012, 10:37:54 AM6/21/12
to roger peppe, Sonia Keys, golan...@googlegroups.com
On Thu, Jun 21, 2012 at 10:25 AM, roger peppe <rogp...@gmail.com> wrote:
> I wonder if using strings.Map(unicode.SimpleFold, s) would be wrong
> too. Unicode is too subtle for me...

It doesn't look like that's quite right. unicode.SimpleFold is
intended to iterate through all cases. I think you need a wrapper
function around SimpleFold like this:

func Fold(r rune) (s rune) {
for {
s = unicode.SimpleFold(r)
if s <= r {
return
} else {
r = s
}
}
panic("unreachable")

Sonia Keys

unread,
Jun 21, 2012, 10:45:59 AM6/21/12
to golan...@googlegroups.com, roger peppe, Sonia Keys
So Unicode case folding might be an interesting question.  The OP there wasn't asking that question.  strings.  The comments assert that strings.ToLower only works for ASCII, which at a casual glance at source is not true.  I see return Map(unicode.ToLower, s), which seems to be doing at least something Unicode aware.

On Thursday, June 21, 2012 10:37:54 AM UTC-4, mkb wrote:

peterGo

unread,
Jun 21, 2012, 10:51:59 AM6/21/12
to golang-nuts
Sonia,

Read The Unicode Standard and other Unicode documentation.
http://unicode.org/

Peter

On Jun 21, 10:00 am, Sonia Keys <soniak...@gmail.com> wrote:
> Some recent comments on Stack Overflow are bugging me.  I'm asking for help
> here because the comments have the effect of spreading FUD about Go.  The
> posted question<http://stackoverflow.com/questions/11124705/how-to-create-a-case-inse...>asks how to create a case insensitive map.  The troublesome comments make

Patrick Mylund Nielsen

unread,
Jun 21, 2012, 10:55:35 AM6/21/12
to peterGo, golang-nuts
ToLower works just fine for Unicode strings, there will just be "collisions" because it's not as simple as "upper" or "lower", which is what I assume tchrist was referring to when he said it "didn't work for Unicode strings" (in hash tables)

Paul Borman

unread,
Jun 21, 2012, 11:04:54 AM6/21/12
to Patrick Mylund Nielsen, peterGo, golang-nuts
Unicode doesn't even always have a single encoding for the same string.  There is an entire section of unicode dedicated to producing canonical strings.  This would be important when using as a key to a map.  I think this is way beyond what most people think of when they say "case insensitive".

    -Paul

unread,
Jun 21, 2012, 11:14:40 AM6/21/12
to golan...@googlegroups.com
On Thursday, June 21, 2012 4:00:48 PM UTC+2, Sonia Keys wrote:
Some recent comments on Stack Overflow are bugging me.  I'm asking for help here because the comments have the effect of spreading FUD about Go.  The posted question asks how to create a case insensitive map.  The troublesome comments make false statements about Go's handling of Unicode (when the OP wasn't even concerned with Unicode.)  Correcting this person would seem to be accepting their challenge to an off-topic flame war.  Instead, I would encourage anyone with a SO account to flag these comments for moderation.  Note that on the flag dialog, while the "off-topic or unconstructive" radio button is appropriate, the "other" button allows you to send a message to moderators explaining what you feel is wrong with the comments.

The author of the questionable comments on Stack Overflow (tchrist) is right, but he overreacted. It was incorrect to start his reply with "This is completely wrong", the correct form is "You are right, but [mention some improvements here]".

Aside from this, "godoc unicode" says that:

    There is no mechanism for full case folding, that is, for characters
    that involve multiple runes in the input or output.

Patrick Mylund Nielsen

unread,
Jun 21, 2012, 11:13:58 AM6/21/12
to Paul Borman, peterGo, golang-nuts
Then the question becomes if it's relevant for most maps, but given that it's a "case-insensitive map", it's probably likely to use user-supplied keys, in which case it really is, and restricting to ASCII might be the easiest solution.

Andy Balholm

unread,
Jun 21, 2012, 11:18:23 AM6/21/12
to golan...@googlegroups.com, Sonia Keys
Before you call this comment FUD about Go, you should see what tchrist has to say about unicode support in Perl, his favorite language:


P.S. I recommend installing the Symbola font and viewing his post in Firefox. His post itself requires better Unicode support than some browsers have.

Patrick Mylund Nielsen

unread,
Jun 21, 2012, 11:28:15 AM6/21/12
to Andy Balholm, golan...@googlegroups.com, Sonia Keys
That's actually really good.

PS: I'm not Sonia, but I think the "FUD" was that he claimed that ToLower "doesn't work" for Unicode strings/characters, which clearly isn't correct in Go. It just doesn't work how you might expect--rather, in a way that is undesirable for the hash table key use case. This post was a better (and less condescending) explanation why.

Sonia Keys

unread,
Jun 21, 2012, 1:16:32 PM6/21/12
to golan...@googlegroups.com, Andy Balholm, Sonia Keys
Thanks to all for interesting comments and education.  It looks like someday the good answer will be something like Collate.Key, currently in exp/locale/collate.  Is this right?

Andy Balholm

unread,
Jun 21, 2012, 1:21:45 PM6/21/12
to golan...@googlegroups.com, Andy Balholm, Sonia Keys
That would actually go beyond case-insensitivity, but it might be what most of the people who ask for case-insensitivity actually need.

Rob 'Commander' Pike

unread,
Jun 21, 2012, 6:53:14 PM6/21/12
to tch...@perl.com, golan...@googlegroups.com, peterGo
On Thu, Jun 21, 2012 at 3:43 PM, <tch...@perl.com> wrote:
> The world is not ASCII any longer.

It never was.

-rob
Reply all
Reply to author
Forward
0 new messages