Re: [go-nuts] Adding &&= and ||= operators for working with bools
sorry...i'm not skilled at linking to old groups discussions. https://groups.google.com/d/topic/golang-nuts/xwkDwB9Q0Rs/discussion not agitating. ;-) just recalling. On Sat, Jan 5, 2019 at 9:16 PM Rob Pike wrote: > edit: seems NOT worth it. > > -rob > > > On Sun, Jan 6, 2019 at 4:16 PM Rob Pike wrote: > >> That link doesn't work - it's into your mailbox. >> >> However, I do remember talking about this option some time ago, including >> when the language was first being designed. It didn't seem common enough to >> warrant adding, and C got along fine without it. Your regularity argument >> carries some weight but it still seems worth it. >> >> If you disagree, file a proposal explaining the argument. >> >> -rob >> >> >> On Sun, Jan 6, 2019 at 3:28 PM Michael Jones >> wrote: >> >>> not Rob but rather Ian... >>> (6/22/2012) >>> >>> >>> https://mail.google.com/mail/u/0/#label/go%2Fgolang-nuts/FMfcgxwBTsjnkHgqhvQfLqrXsJdHZRxC >>> >>> On Sat, Jan 5, 2019 at 7:52 PM Michael Jones >>> wrote: >>> I brought it up early on, wanting AND (&) and OR (|) as well as AND-ASSIGN (&=) and OR-ASSIGN (|=). Not enthusiastic about shortcut operators on assignment form. Rob posted here that he was ok/open to the idea. On Sat, Jan 5, 2019 at 5:55 PM Caleb Spare wrote: > Sometimes when working with bools I wish I could write > > myBool &&= x > > rather than > > myBool = myBool && x > > I believe that && and || are the only binary operators in the language > for which the assignment form makes sense but doesn't exist (i.e., we > have +=, &^=, >>=, and so on). So in some sense adding these last two > operators would be symmetric and would make working with bools just as > convenient as working with integers, floats, bit fields, etc. > > Has this been discussed before? It's hard to search for this. > > Caleb > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- *Michael T. jonesmichael.jo...@gmail.com * >>> >>> >>> -- >>> >>> *Michael T. jonesmichael.jo...@gmail.com * >>> >>> -- >>> 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. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- *Michael T. jonesmichael.jo...@gmail.com * -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Adding &&= and ||= operators for working with bools
edit: seems NOT worth it. -rob On Sun, Jan 6, 2019 at 4:16 PM Rob Pike wrote: > That link doesn't work - it's into your mailbox. > > However, I do remember talking about this option some time ago, including > when the language was first being designed. It didn't seem common enough to > warrant adding, and C got along fine without it. Your regularity argument > carries some weight but it still seems worth it. > > If you disagree, file a proposal explaining the argument. > > -rob > > > On Sun, Jan 6, 2019 at 3:28 PM Michael Jones > wrote: > >> not Rob but rather Ian... >> (6/22/2012) >> >> >> https://mail.google.com/mail/u/0/#label/go%2Fgolang-nuts/FMfcgxwBTsjnkHgqhvQfLqrXsJdHZRxC >> >> On Sat, Jan 5, 2019 at 7:52 PM Michael Jones >> wrote: >> >>> I brought it up early on, wanting AND (&) and OR (|) as well as >>> AND-ASSIGN (&=) and OR-ASSIGN (|=). >>> >>> Not enthusiastic about shortcut operators on assignment form. >>> >>> Rob posted here that he was ok/open to the idea. >>> >>> On Sat, Jan 5, 2019 at 5:55 PM Caleb Spare wrote: >>> Sometimes when working with bools I wish I could write myBool &&= x rather than myBool = myBool && x I believe that && and || are the only binary operators in the language for which the assignment form makes sense but doesn't exist (i.e., we have +=, &^=, >>=, and so on). So in some sense adding these last two operators would be symmetric and would make working with bools just as convenient as working with integers, floats, bit fields, etc. Has this been discussed before? It's hard to search for this. Caleb -- 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. For more options, visit https://groups.google.com/d/optout. >>> >>> >>> -- >>> >>> *Michael T. jonesmichael.jo...@gmail.com * >>> >> >> >> -- >> >> *Michael T. jonesmichael.jo...@gmail.com * >> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Adding &&= and ||= operators for working with bools
That link doesn't work - it's into your mailbox. However, I do remember talking about this option some time ago, including when the language was first being designed. It didn't seem common enough to warrant adding, and C got along fine without it. Your regularity argument carries some weight but it still seems worth it. If you disagree, file a proposal explaining the argument. -rob On Sun, Jan 6, 2019 at 3:28 PM Michael Jones wrote: > not Rob but rather Ian... > (6/22/2012) > > > https://mail.google.com/mail/u/0/#label/go%2Fgolang-nuts/FMfcgxwBTsjnkHgqhvQfLqrXsJdHZRxC > > On Sat, Jan 5, 2019 at 7:52 PM Michael Jones > wrote: > >> I brought it up early on, wanting AND (&) and OR (|) as well as >> AND-ASSIGN (&=) and OR-ASSIGN (|=). >> >> Not enthusiastic about shortcut operators on assignment form. >> >> Rob posted here that he was ok/open to the idea. >> >> On Sat, Jan 5, 2019 at 5:55 PM Caleb Spare wrote: >> >>> Sometimes when working with bools I wish I could write >>> >>> myBool &&= x >>> >>> rather than >>> >>> myBool = myBool && x >>> >>> I believe that && and || are the only binary operators in the language >>> for which the assignment form makes sense but doesn't exist (i.e., we >>> have +=, &^=, >>=, and so on). So in some sense adding these last two >>> operators would be symmetric and would make working with bools just as >>> convenient as working with integers, floats, bit fields, etc. >>> >>> Has this been discussed before? It's hard to search for this. >>> >>> Caleb >>> >>> -- >>> 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. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> >> *Michael T. jonesmichael.jo...@gmail.com * >> > > > -- > > *Michael T. jonesmichael.jo...@gmail.com * > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Adding &&= and ||= operators for working with bools
not Rob but rather Ian... (6/22/2012) https://mail.google.com/mail/u/0/#label/go%2Fgolang-nuts/FMfcgxwBTsjnkHgqhvQfLqrXsJdHZRxC On Sat, Jan 5, 2019 at 7:52 PM Michael Jones wrote: > I brought it up early on, wanting AND (&) and OR (|) as well as AND-ASSIGN > (&=) and OR-ASSIGN (|=). > > Not enthusiastic about shortcut operators on assignment form. > > Rob posted here that he was ok/open to the idea. > > On Sat, Jan 5, 2019 at 5:55 PM Caleb Spare wrote: > >> Sometimes when working with bools I wish I could write >> >> myBool &&= x >> >> rather than >> >> myBool = myBool && x >> >> I believe that && and || are the only binary operators in the language >> for which the assignment form makes sense but doesn't exist (i.e., we >> have +=, &^=, >>=, and so on). So in some sense adding these last two >> operators would be symmetric and would make working with bools just as >> convenient as working with integers, floats, bit fields, etc. >> >> Has this been discussed before? It's hard to search for this. >> >> Caleb >> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > > *Michael T. jonesmichael.jo...@gmail.com * > -- *Michael T. jonesmichael.jo...@gmail.com * -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Adding &&= and ||= operators for working with bools
I brought it up early on, wanting AND (&) and OR (|) as well as AND-ASSIGN (&=) and OR-ASSIGN (|=). Not enthusiastic about shortcut operators on assignment form. Rob posted here that he was ok/open to the idea. On Sat, Jan 5, 2019 at 5:55 PM Caleb Spare wrote: > Sometimes when working with bools I wish I could write > > myBool &&= x > > rather than > > myBool = myBool && x > > I believe that && and || are the only binary operators in the language for > which the assignment form makes sense but doesn't exist (i.e., we have +=, > &^=, >>=, and so on). So in some sense adding these last two operators > would be symmetric and would make working with bools just as convenient as > working with integers, floats, bit fields, etc. > > Has this been discussed before? It's hard to search for this. > > Caleb > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- *Michael T. jonesmichael.jo...@gmail.com * -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Adding &&= and ||= operators for working with bools
Sometimes when working with bools I wish I could write myBool &&= x rather than myBool = myBool && x I believe that && and || are the only binary operators in the language for which the assignment form makes sense but doesn't exist (i.e., we have +=, &^=, >>=, and so on). So in some sense adding these last two operators would be symmetric and would make working with bools just as convenient as working with integers, floats, bit fields, etc. Has this been discussed before? It's hard to search for this. Caleb -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: C++ 11 to Golang convertor
Mr. Tiwari: Major ports are rather like major rewrites, in that if you think of the program as a tree, the parts that stay the same are the trunk and branches, and the parts that change are the leaves. If you draw a picture of the old program on a whiteboard, you have an (initial) design for the new program. If the calls and parameters look like a reasonably good API, you can start by writing *mock leaves*, which will help you understand both the program and the new language. it should pass your integration tests, albeit with fake data. Then start filling in the low-level details, starting with the *last* step and working backwards. Each time you break something, your tests will tell you, and you can fix it quickly. In a previous life, this and some elegant tooling allowed my employer to make a profit off doing fixed-price ports. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: C++ 11 to Golang convertor
I am reminded of someone once asked how to go from Burlington MA to Waltham, when what he really wanted to do was go from Burlington to Logan Airport. (For the uninformed, via Waltham is not generally how most would do it.) This conversation is thoughtfully covering all angles of the C++ to Go problem, but I may suggest one steps back and defines the ORIGINAL problem being solved and the requirements of the solution. (Not the approach, and certainly not the design, but the basic requirements.) What is the C++ doing which is required, and why does it have to re-implemented in Go? -ahd- -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: C++ 11 to Golang convertor
A rewrite will be better. Really. On Sat, Jan 5, 2019 at 10:11 AM Abhishek Tiwari wrote: > Hi Jake & Friends, > > Thank you so much for awesome response and great help. I am going through > all replies in detail one by one. > Actually, I am working on solving a job assignment : 8-10 C++ files need > to be converted to Go. > As far as the technical details of the code is concerned, seems its a > little complex C++ 11 code. > I feel rewriting from scratch is good way to go about it but I am very > new to Go Syntax , so that is the difficult part. > Hence I can not myself describe what that code is actually doing, at the > moment :-) > Will come back soon! > > Best Regards > Abhishek > > > On Thu, Jan 3, 2019 at 10:41 PM wrote: > >> There are so, so many ways to go about porting functionality from one >> language to another. I hope you have seriously considered why you want to >> make such a port. The answer to that will likely, in part, drive your >> strategy. In addition the nature and size of the code base, and your >> timeline, will effect the strategy used. >> >> I would note that any tool that ports from C++, or even C, to Go is going >> to produce ugly, unmaintainable, and non-idiomatic code, at best. Turning >> that into real Go code would still be a major project. There is a great >> video about the process that the go team used to convert the compiler from >> C to Go, but I can not find it now. >> >> Have you considered rewriting from scratch? That can often be less >> painful that one might think, if you already have a really good suite of >> "functional level" tests that you can use to ensure functional continuity. >> >> Another strategy that comes to mind is to use cgo to do the rewrite one >> component of library at a time. This could be done one of two ways. Either >> keep the program (or library, or whatever it is,) as a C++ app, and call >> into your converted go code. Or, conversely, write a go program that calls >> into C++ for unconverted functionally. >> >> Of course, with no real information about what you have, or what you are >> trying to achieve, you can only get general advice. >> >> Good Luck. >> >> >> On Wednesday, January 2, 2019 at 10:37:17 PM UTC-5, aureal...@gmail.com >> wrote: >>> >>> Hello All >>> >>> I have C++ 11 source files which I need to convert to Go language code >>> Is there any converter tool for this. >>> I google quite a few tools, none seems powerful and complete enough to >>> do the job.for me. >>> Please help >>> >>> Thanks >>> Abhishek >>> >> -- >> 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/aPHLrfwQh3A/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> golang-nuts+unsubscr...@googlegroups.com. > > >> For more options, visit https://groups.google.com/d/optout. >> > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- *Michael T. jonesmichael.jo...@gmail.com * -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Json decode : Monitoring errors properly
I got it. In fact, if the buffer is bad, it is not erased, and Buffered() returns it (and not the following). That was my misunderstanding. Thank you all ! On Thursday, 27 December 2018 00:31:12 UTC+1, Kevin Conway wrote: > > > I believe https://golang.org/pkg/encoding/json/#Decoder.Buffered was > added for this purpose. > > I just caught on that this method is exactly what you showed in the > original message. I guess my input can be reduced to "I think that's your > only option when using the decoder". > > I do think you've correctly identified they the buffer isn't guaranteed to > contain the whole object since the decoder has early exit error conditions. > I'm not sure how you'd change that without rewriting the decoder. > >> -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: C++ 11 to Golang convertor
Hi Jake & Friends, Thank you so much for awesome response and great help. I am going through all replies in detail one by one. Actually, I am working on solving a job assignment : 8-10 C++ files need to be converted to Go. As far as the technical details of the code is concerned, seems its a little complex C++ 11 code. I feel rewriting from scratch is good way to go about it but I am very new to Go Syntax , so that is the difficult part. Hence I can not myself describe what that code is actually doing, at the moment :-) Will come back soon! Best Regards Abhishek On Thu, Jan 3, 2019 at 10:41 PM wrote: > There are so, so many ways to go about porting functionality from one > language to another. I hope you have seriously considered why you want to > make such a port. The answer to that will likely, in part, drive your > strategy. In addition the nature and size of the code base, and your > timeline, will effect the strategy used. > > I would note that any tool that ports from C++, or even C, to Go is going > to produce ugly, unmaintainable, and non-idiomatic code, at best. Turning > that into real Go code would still be a major project. There is a great > video about the process that the go team used to convert the compiler from > C to Go, but I can not find it now. > > Have you considered rewriting from scratch? That can often be less painful > that one might think, if you already have a really good suite of > "functional level" tests that you can use to ensure functional continuity. > > Another strategy that comes to mind is to use cgo to do the rewrite one > component of library at a time. This could be done one of two ways. Either > keep the program (or library, or whatever it is,) as a C++ app, and call > into your converted go code. Or, conversely, write a go program that calls > into C++ for unconverted functionally. > > Of course, with no real information about what you have, or what you are > trying to achieve, you can only get general advice. > > Good Luck. > > > On Wednesday, January 2, 2019 at 10:37:17 PM UTC-5, aureal...@gmail.com > wrote: >> >> Hello All >> >> I have C++ 11 source files which I need to convert to Go language code >> Is there any converter tool for this. >> I google quite a few tools, none seems powerful and complete enough to do >> the job.for me. >> Please help >> >> Thanks >> Abhishek >> > -- > 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/aPHLrfwQh3A/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] C++ 11 to Golang convertor
Yes, the preprocessor… The preprocessor is one of the biggest obstacles to readable C-to-Go translation. rsc/c2go largely ignores preprocessor directives other than #include—and it doesn’t include a translation of the headers at the top of every output file. But most C programs are a lot more dependent on the preprocessor than gc was. So every other C-to-Go tool I’ve seen works from preprocessed source. So they tend to dump a translation of most of /usr/include at the top of the file. (Leaven doesn’t, though, because clang optimizes most of that stuff back out.) And some functions are halfway to machine code by the time all the macros are expanded. A good translation from C to Go needs to look as much like the original, un-preprocessed C source as possible. But a powerful translation tool will probably need to preprocess, parse, and typecheck the code, while keeping track of the source location that everything corresponds to—and then use that information to guide the translation. Andy -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: C++ 11 to Golang convertor
On Friday, January 4, 2019 at 2:41:19 PM UTC-5, robert engels wrote: > > I still think it would be a nearly impossible task given the C code in the > wild - outside of threading, the common usage of ‘unions’ - there is no > way I know of to map these to a simple Go struct, or even several - you > need something like protobufs. So even if you could convert, you’d end up > with code that is probably harder to maintain/verify than the original C > code. > I've worked on a lot of this old infrastructure code myself, which is how I know that use of unions and threading simply isn't that common in it. You have to bear in mind that a lot of it was originally written in the last century, before the standards people won their war. So for practical purpose ANSI pthreads didn't yet exist, though in the NTP case (the one I've been elbow-deep in recently) some threading stuff was bolted on later to avoid stalling on DNS lookups. As for security checking each line..yes, in an ideal world, but not necessary for the translation to be a worthy improvement, Sure, we know the C code is leaky, but given the verification properties of both languages, a line-by-line translation can't make you worse off unless there's some huge undetected hole in the Go libraries. That's a bet I'm willing to make. You haven't noticed what I think is a larger problem - preprocessor conditionals. That's a headache. Still puzzling on that one. -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] new year greetings
To everyone!! Let's say in golang fashion way... func year_2018 () { defer greetingsOf("2019") // code that happened across 2018... } func greetingsOf(year string) { fmt.Println("happy new fresh " + year ) } That is!! Greetings and nice start to all! -- 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. For more options, visit https://groups.google.com/d/optout.