FAQ
I don't see how viewing Bool as an unsigned one bit integer yiels True +
True = 2. Actually, an overflow occurs so it's rather
True + True = False. Please tell me what you mean with »retrofitting«. I
did always see booleans as members of the field Z/2.

Am Freitag, 1. März 2013 22:12:56 UTC+1 schrieb John Nagle:
On 3/1/2013 12:07 PM, Robert Clausecker wrote:
For quite a lot applications it would be nice to be able to treat bool as a
one bit (unsigned) integer
Bad idea.

The languages that work that way, like C and Python, do that
because they originally lacked a Boolean type. Retrofitting
a Boolean type results in weird semantics, like "True + True"
being equal to 2, as it is in Python. It's a classic mistake
in language design.

Go had a Boolean type from the beginning, and got this one right.

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

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 14 of 21 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 1, '13 at 7:02p
activeMar 3, '13 at 2:38a
posts21
users9
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase