About allowing conversion from bool to int

308 views
Skip to first unread message

Victor Giordano

unread,
Oct 20, 2023, 1:12:06 PM10/20/23
to golang-nuts
Hello fellow gopherships... ¿How you doing? 

Hope just fine!

A week ago I proposed to allow conversion from bool to int, assuming false to 0 and true to be 1. This was the proposal and I do appreciate a lot the polite responses from Ian.

I pick my pike and dig into... the discussion... trying to understand what was the force or the motivation that refuses the proposal. 

I Found two interesting comments:
And what i perceive is that the cons is: It may harm readability.

Well... If that is the case... (because, that is what I understood, and forget me if I'm wrong!) I have some points to put into the table if you allow... please, do not take it hard... I'm trying to make an statement

1) One line Swapping

a, b := 1, 2 // I never use this.. I always forget if the 1 go to the a and the 2 go to b or vice-versa.. (Like now!) 

I do like to write three lines instead of one...


Well...  actual web apps require to write in JavaScript, JavaScript uses  block scopes..  so I appreciate a LOT this feature of the language, but as long this language has to live with other languages (like JavaScript) I don't feel that this will release me from the burden of knowing how to deal with block scopes variables used in a closure. JavaScript is not an example of well designed language but is the language widely used in web apps.

3) Generics... 

Well... With interfaces I already got the genericity I need to model abstractions.. But I do appreciate generics, because they do allow us to write less code at the cost complicating the language grammar. I start to use them... but before that I have no problem on converting an slice of interfaces using a for loop.

4) I "grow" writing these lines on any C program  I'm not too old (to reason), but also not too young  (to dream). I have 40

#define TRUE 1
#define FALSE 0

That definitively has shaped my mind.

So the statement is:

The points 1,2 and 3 I show... are examples of questionable (at least, for me) things that you directly inject into the language. The point 4 I show how I feel that a bool is, in turn, an int.

The proposal of making bool to int, could co exists. And people can choose to use it or not. You may give it a try... for me (and other folks) well come in handy in situations like this (context: count the number of Spanish's cards that belongs to the GOLD suit).

If you say me: "Ey victor, we just won't put it because we don't like it" <- I will buy it. 

Or

You may convince me... I leave that to you. I will try to stay open (I do recognize myself as person that can be a little stubborn.)

Final words

Is not my language and you have done a wonderful job... I mean.. from the old days in C, passing thought the cosmos of C++, then OOP disembark with Java and C#... and then Golang mixing a lot of learned lessons into a single language!

Actual final words:

Informal Greetings!  🤠🧉



Volker Dobler

unread,
Oct 20, 2023, 3:19:38 PM10/20/23
to golang-nuts
I use 1 a lot and 4 (or the suggested bool<-->int conv) never.
I have no idea what you want to express with 2
and 4 addresses a kind of problem that has no
simple solution like a one-line function.

V.

Victor Giordano

unread,
Oct 20, 2023, 5:49:29 PM10/20/23
to Volker Dobler, golang-nuts
Volker. I don't know how to reply to what you state. I'm open to listen or read any thoughts you have about not using bool to int.


--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/dSvR3uskT6M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/61e90e0d-30a1-4c75-b6d3-9933dcaad632n%40googlegroups.com.


--
V

Victor Giordano

unread,
Oct 20, 2023, 9:15:07 PM10/20/23
to Volker Dobler, golang-nuts

My intention is to actually know any reason about not pushing forward that proposal... because I need to understand why... Is there any reason out there? I don't know where to ask.... 
I tried to put on the table pros and cons.. but no further feedback was received. 

Request
image.png

Response
image.png

If nobody plays along with me and shows a cost.. I will answer myself by timeout this and say that there is no reason besides any personal preference. Volker, ¿do you understand my intention? ¿it is too much to ask? 

--
V

Volker Dobler

unread,
Oct 20, 2023, 9:47:07 PM10/20/23
to golang-nuts
I have to admit I do not understand your intention.
You made a proposal to change the language.
A lot of people (me included) do not see this change
as good (not needed, other solutions are available,
lots of drawbacks, bad experience with such stuff
in general, edge case, can be done in trivial code,
etc. pp.) You seem to not like these arguments and 
think your pro arguments are better?

I'm sorry but I cannot contribute anything with
more "substance" here.

V. 

Victor Giordano

unread,
Oct 20, 2023, 10:15:45 PM10/20/23
to golang-nuts


---------- Forwarded message ---------
De: Victor Giordano <vituc...@gmail.com>
Date: vie, 20 oct 2023 a las 19:09
Subject: Re: [go-nuts] Re: About allowing conversion from bool to int
To: Volker Dobler <dr.volke...@gmail.com>


Volker I'm very grateful for your answer! Thanks!!!

> A lot of people (me included) do not see this change
as good (not needed, other solutions are available,
lots of drawbacks, bad experience with such stuff
in general, edge case, can be done in trivial code,
etc. pp.) 
All these reasons are valid but I'm a little afraid of arguing right now. You don't seem to be open to critics or other visions. Also I know and I understand that you don't have to. In any case, thanks for the insight.

> You seem to not like these arguments 
That totally right

> and  think your pro arguments are better?
I do not say that (you may point me where I do say that...) neither was my intention. 

My intention is to discover any reason that can convince me. Also I'm in the mood for discussing, this is a group for discussion, right?

Thanks again.


Ian Lance Taylor

unread,
Oct 21, 2023, 12:32:12 AM10/21/23
to Victor Giordano, Volker Dobler, golang-nuts
On Fri, Oct 20, 2023 at 2:14 PM Victor Giordano <vituc...@gmail.com> wrote:

My intention is to actually know any reason about not pushing forward that proposal... because I need to understand why... Is there any reason out there? I don't know where to ask.... 

The first step is to read https://go.dev/issue/9367 and https://go.dev/issue/45320.  There are various reasons in those issues.

It's may be useful to distinguish _any reason_ from _a reason you agree with_.  Even if you don't agree with the reasons in those issues, they are still reasons, and other people find them convincing.

Ian

Victor Giordano

unread,
Oct 21, 2023, 3:14:48 AM10/21/23
to Ian Lance Taylor, Volker Dobler, golang-nuts
Ian thanks!

Yes.. I admit  that I haven't read those issues entirely.... Now I have finished reading and also reach this very interesting issue

At first glance I noticed these comments
Then (On the second read...)

Ok...that's enough... don't convince me completely but it may be the right thing 🤔... yes... you all have fair points....
And allow me to say that when discussing with a buddy at work he states "ey, a reason could be to keep minimalism... so you get less ways to do the same, it is more straightforward.. less choices, less doubts" that statement shakes me.. almost convinced me.  But again... I see we don't think quite the same.... nevertheless my thirst for understanding more was fulfilled..

According to the reactions on this issue's initial comment... it seems that there are more people in favor than against..  Perhaps there will be any slight change to consider or cast a votation sometime in the future..?

Thanks for your patience!..
Greetings
--
V

Victor Giordano

unread,
Oct 21, 2023, 12:58:26 PM10/21/23
to Ian Lance Taylor, Volker Dobler, golang-nuts
Errata: Added missing link (and enhanced with an snapshot)

According to the reactions on this issue's initial comment... it seems that there are more people in favor (20) than against (3)..  Perhaps there will be any slight change to consider or cast a votation sometime in the future..?
image.png
--
V
Reply all
Reply to author
Forward
0 new messages