FAQ
Hi all,

I'm just curious why functions such as len() and cap() return an 'int'
instead of a 'uint'. I see several downsides of using signed types in these
situations:

     (1) it's confusing since it's implied that negative values might be
returned (and perhaps should be checked for?), and
     (2) it throws away half of the usable values for the type
(2147483648 values thrown out on 32-bit machines)

It's of course a pedantic observation, but for a language with a focus on
correctness such as Go, why are signed types used in such situations?

Thanks!

David

--
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

  • Andrey mirtchovski at May 22, 2013 at 6:10 am
    here's a previous thread on the subject:

    https://groups.google.com/d/msg/golang-nuts/jJWAAMdquwQ/jhWhxJJbzVYJ

    --
    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.
  • Davekeck at May 22, 2013 at 6:16 am
    Thanks Andrey, I searched but didn't see that topic.

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 22, '13 at 6:05a
activeMay 22, '13 at 6:16a
posts3
users2
websitegolang.org

2 users in discussion

Davekeck: 2 posts Andrey mirtchovski: 1 post

People

Translate

site design / logo © 2022 Grokbase