Re: [go-nuts] How to constrain an integral type's values

2023-09-08 Thread 'Thomas Bushnell BSG' via golang-nuts
I recommend using strings as the base type for things like this, rather than ints. There is no need to use ints, just because that's what C uses. Thomas On Fri, Sep 8, 2023 at 3:24 AM 'Mark' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I often create small multi-value flag types,

Re: [go-nuts] Re: From which programming language did the idea for Golang's interface mechanism design originate?

2023-09-01 Thread 'Thomas Bushnell BSG' via golang-nuts
Another precedent for the idea was the use of a "behavior" to specify the methods which a Smalltalk object can receive. Basically, it was realized that the question of the class hierarchy for an object was an implementation concern which the users of an object should not care about. So early

Re: [go-nuts] Please consider voting to reopen Golang subreddit

2023-06-26 Thread 'Thomas Bushnell BSG' via golang-nuts
I mean, this is mostly true, except that the protesters do have the right to administer the subreddit in the way they choose, as long as they are the admins. As you said, if you don't like that, you are of course free to use a different site. But it seems a bit off-kilter to say "if you don't

Re: [go-nuts] Re: Why not tuples?

2022-12-07 Thread 'Thomas Bushnell BSG' via golang-nuts
Use the json package to parse the incoming data. Transform it as you please. Use the json package to format the output. I'm not sure I see the problem. On Sat, Dec 3, 2022, 10:47 PM Diogo Baeder wrote: > Hi there, sorry for weighting in so late in the game, but I just started > again to learn

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread 'Thomas Bushnell BSG' via golang-nuts
a behavior, and then using classes as names for behaviors. On Tue, Nov 22, 2022 at 11:46 AM Robert Engels wrote: > What would be the purpose of writing B calling a method on A that doesn’t > exist? > > On Nov 22, 2022, at 10:36 AM, 'Thomas Bushnell BSG' via golang-nuts < >

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread 'Thomas Bushnell BSG' via golang-nuts
Both Java and Go require that a method be instantiated in the declared interface of the type at compile time. This is contrary to the point of late binding. In the case of Go, this cannot be detected, because everything is built together. But with Java, you cannot call a method on an object

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread 'Thomas Bushnell BSG' via golang-nuts
Asking "the definition of object oriented programming" seems a bad idea to me. Alan Kay invented the term, and he was pretty clear that C++ was not anything like what he had in mind, and yet, a lot of people think C++ is an object oriented language. I don't, as it happens. Inheritance used to be

Re: [go-nuts] Race detector question

2022-09-15 Thread 'Thomas Bushnell BSG' via golang-nuts
arify, if the atomic read of Y sees the updated Y then a subsequent >> non-atomic read of X must see the updated X. This is a happens before >> relationship. >> >> The question was if the race detector understands this - I know - why not >> try it out… >> &g

Re: [go-nuts] Race detector question

2022-09-15 Thread 'Thomas Bushnell BSG' via golang-nuts
at 9:41 AM, Robert Engels wrote: >> >> To clarify, if the atomic read of Y sees the updated Y then a subsequent >> non-atomic read of X must see the updated X. This is a happens before >> relationship. >> >> The question was if the race detector understands this -

Re: [go-nuts] Race detector question

2022-09-15 Thread 'Thomas Bushnell BSG' via golang-nuts
appens before > relationship. > > The question was if the race detector understands this - I know - why not > try it out… > > On Sep 15, 2022, at 9:39 AM, Robert Engels wrote: > >  > I think it needs to see the updated X - which agrees with burak. > > Reading Z is

Re: [go-nuts] Race detector question

2022-09-15 Thread 'Thomas Bushnell BSG' via golang-nuts
You cannot make that assumption. It's not about what the race detector can detect. Goroutine one: Writes non-synchronized X Writes atomic Y Writes non-synchronized Z with the value of X+Y Goroutine two Reads atomic Y and sees the new value Can goroutine two now read non-synchronized X

Re: [go-nuts] Is Go a security malware risk?

2022-08-22 Thread 'Thomas Bushnell BSG' via golang-nuts
This is not a problem that arises from *you *using Go; it's a problem arising from the fact that *other *people are using Go to write malware, and bad security techniques are unable to deal with it. You could stop using Go entirely and it wouldn't change the dynamic. The better course is not to

Re: [go-nuts] Go Mod SSH doesn't work

2022-08-05 Thread 'Thomas Bushnell BSG' via golang-nuts
I'm confused; while I haven't used that sort of setup, the documentation does seem to address the case. https://go.dev/ref/mod#module-proxy https://go.dev/ref/mod#vcs https://go.dev/ref/mod#private-modules I can't tell from what you're saying whether you're using those facilities or not, but

Re: [go-nuts] Pointer to a pointer

2022-03-15 Thread 'Thomas Bushnell BSG' via golang-nuts
Yes indeed! These constructions all give us *expressions *with many consecutive stars. But they don't give us *types *with that. (and you can't assign a *Number to a **Number, for example) On Tue, Mar 15, 2022 at 11:50 AM Jan Mercl <0xj...@gmail.com> wrote: > On Tue, Mar 15, 2022 at 4:41 PM

Re: [go-nuts] Pointer to a pointer

2022-03-15 Thread 'Thomas Bushnell BSG' via golang-nuts
On Thu, Mar 10, 2022 at 4:31 AM Rob Pike wrote: > On Thu, Mar 10, 2022 at 5:08 PM shan...@gmail.com > wrote: > > > > Is this really how you want to be known? > > Sure, why not? It's a more interesting program than one might think. > > For a richer example of the foundational idea here, see the

Re: [go-nuts] Pointer to a pointer

2022-03-15 Thread 'Thomas Bushnell BSG' via golang-nuts
On Wed, Mar 9, 2022 at 11:38 PM Jan Mercl <0xj...@gmail.com> wrote: > A linked list, for example, consists of pointers to pointers to pointers... > Not in the normal implementation it doesn't. Typically it might be: type element struct { value int next *element } next is a pointer to an

Re: [go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-31 Thread 'Thomas Bushnell BSG' via golang-nuts
On Fri, Jan 28, 2022 at 1:12 PM Rudolf Martincsek wrote: > > 2) Long variable names. > > Where I work (not in Go), writing comments is frowned upon. That includes > "docblock" style comments. If a function needs to be documented, it means > the implementation is too complex and must be broken

Re: [go-nuts] go text://protocol client?

2021-04-14 Thread 'Thomas Bushnell BSG' via golang-nuts
In *Ash Wednesday, *T. S. Eliot wrote the line "Lady, three white leopards sat under a juniper tree in the cool of the day" When he was asked what it meant, he aisd "It means, 'Lady, three white leopards sat under a juniper tree in the cool of the day'" I suspect if there were a better

Re: [go-nuts] text/template: Can't call method/function with 0 results.

2021-04-09 Thread 'Thomas Bushnell BSG' via golang-nuts
I find the current behavior clearer. What would you like a no-valued function to insert in the template? Even if it was the zero value, that could be the string-typed zero value, or the int-typed zero value, and so forth. It could be defined, but why not make it explicit if you want it to insert

Re: [go-nuts] Re: Update to generics proposal

2021-04-06 Thread 'Thomas Bushnell BSG' via golang-nuts
On Mon, Apr 5, 2021 at 9:04 PM yiyus wrote: > > then I guess you mean that interface { MyInt } will accept any type > > argument whose underlying type is the same as the underlying type of > > MyInt. But that seems strange. There is no connection between MyInt > > and MyInt2, except that they

Re: [go-nuts] Re: A message from the CoC committee

2021-03-24 Thread 'Thomas Bushnell BSG' via golang-nuts
On Wed, Mar 24, 2021 at 3:18 PM ben...@gmail.com wrote: > I'm comparing to various legal systems, in which there is almost always > the possibility of appeal, even for heinous crimes. > Not forever; and especially not in cases of abuse of process. For example, the United States Supreme Court

Re: [go-nuts] now that the election is over can we please remove the political ad for golang.org

2021-03-18 Thread 'Thomas Bushnell BSG' via golang-nuts
On Wed, Mar 17, 2021 at 8:33 AM mortdeus wrote: > Are you absolutely SURE you want to keep up the "your not welcome here" > sign to people who literally find the message to be dangerous to the very > people they claim to want to protect. Do we really want to encourage an > opensource culture,

Re: [go-nuts] now that the election is over can we please remove the political ad for golang.org

2021-03-18 Thread 'Thomas Bushnell BSG' via golang-nuts
On Wed, Mar 17, 2021 at 8:22 AM mortdeus wrote: > Why do black lives matter more than Syrian lives? Nobody said they do. The banner does not make any comparisons. Thomas -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] now that the election is over can we please remove the political ad for golang.org

2021-03-18 Thread 'Thomas Bushnell BSG' via golang-nuts
On Wed, Mar 17, 2021 at 8:22 AM mortdeus wrote: > The problem is that this inspires a political discussion that obviously > should happen with your city council or your therapist. Not with gophers. > If you don't believe the political discussion should happen, then I would recommend you resist

Re: [go-nuts] Code coverage in error cases when compared to other languages

2021-02-05 Thread 'Thomas Bushnell BSG' via golang-nuts
On Thu, Feb 4, 2021 at 4:35 PM Charles Hathaway wrote: > Hey all, > > Thomas, I agree that the code you provide would benefit from unit tests, > but I would like to focus my question on the very common case which simply > throws the error without additional edge cases, such as the example given

Re: [go-nuts] Code coverage in error cases when compared to other languages

2021-01-28 Thread 'Thomas Bushnell BSG' via golang-nuts
IMO: To give these things names, you have: func Foo(...) ..., error { do things here... err := makeASubroutineCall(...) if err != nil { return ..., err } do more things } And we suppose that makeASubroutineCall is already will tested and you know it returns errors correctly. What

Re: [go-nuts] chan chan question

2020-06-22 Thread 'Thomas Bushnell, BSG' via golang-nuts
You can send any object you like across a channel of the appropriate type. It sends the actual object (in this case, the channel) just as for an integer, it sends the value, or for a map, the whole map. errChan in the snippet you quote is an ordinary variable, and this is its declaration (like

Re: [go-nuts] [generics] replace ()/(type ) with :[]

2020-06-18 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Thu, Jun 18, 2020 at 9:46 AM Kiswono Prayogo wrote: > Personally () parentheses seems like to be harder to read, too similar > with function calls. > This is exactly why I like it. These are parameters, and should be thought of just like other parameters in a function call. -- You received

Re: [go-nuts] Re: political fundraising on golang.org!

2020-06-16 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Tue, Jun 16, 2020 at 11:51 AM 'K Richard Pixley' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I do not agree with the Rust team. I would prefer to make my technology > decisions based on technological criterion. But if you force me to make > that decision based on your religion,

Re: [go-nuts] Re: political fundraising on golang.org!

2020-06-16 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Tue, Jun 16, 2020 at 10:41 AM Space A. wrote: > > Are you saying you don't care about the rest of the World? This > "situation" does not affect in any way many many gophers which have to deal > with much more serious problems than you could imagine, on a daily basis. > There are a lot of

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Mon, Jun 15, 2020 at 9:27 AM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Mon, Jun 15, 2020 at 1:04 PM Jon Reiter wrote: > >> Ok. I live in Singapore. Here is a statement from the Singapore Police >> Force directly telling foreigners not to advocate for

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Mon, Jun 15, 2020 at 12:30 PM Jon Reiter wrote: > It's not difficult to imagine banners like "free (some geographic place)" > or "remember (someone or some date)" causing severe problems. This banner > differs only in degree of risk. It increases the risk of a problem by some > non-0

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread 'Thomas Bushnell, BSG' via golang-nuts
020, at 10:00 AM, 'Thomas Bushnell, BSG' via golang-nuts < > golang-nuts@googlegroups.com> wrote: > >  > I'm saddened by all the snowflakes who can't handle a message they > disagree with for a second, which is literally costing them exactly nothing. > > I'm als

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread 'Thomas Bushnell, BSG' via golang-nuts
It might be helpful to know that the Equal Justice Initiative is strongly supported by the Google.org foundation ( https://www.google.org/our-work/inclusion/equal-justice-initiative/) and Google itself ( https://about.google/main/google-supports-equal-justice-initiative/), and has been for years.

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread 'Thomas Bushnell, BSG' via golang-nuts
Eric: It's not your list. You don't get to decide the policies of the list. On Sun, Jun 14, 2020 at 4:44 PM Eric S. Raymond wrote: > Sam Whited : > > This is not a simple political issue, it is a personal human issue. It > > is a social issue. It is a justice issue. > > It is the injection of

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread 'Thomas Bushnell, BSG' via golang-nuts
I'm saddened by all the snowflakes who can't handle a message they disagree with for a second, which is literally costing them exactly nothing. I'm also saddened by anyone who thinks the message itself is somehow objectionable. But I won't stop being an anti-racist just because some people are

Re: [go-nuts] Re: what is the complexity of regexp.MustCompile()?

2020-06-09 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Tue, Jun 9, 2020 at 11:23 AM Axel Wagner wrote: > If you actually read OPs second E-Mail, they did and they didn't find it > very clear. With that in mind, your message isn't very nice. > (Also, not to be repetitive or anything: ~80% of the messages in this > thread aren't actually concerned

Re: [go-nuts] Re: what is the complexity of regexp.MustCompile()?

2020-06-09 Thread 'Thomas Bushnell, BSG' via golang-nuts
I'm surprised none of you have taken all this time to just go read the code, where it is clearly linear. On Mon, Jun 8, 2020 at 9:12 PM Robert Engels wrote: > The OP specifically asked about compilation - in fact it’s in the title. > You stated the compilation complexity is a DoS attack vector.

Re: [go-nuts] Re: what is the complexity of regexp.MustCompile()?

2020-06-08 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Mon, Jun 8, 2020 at 12:02 PM Axel Wagner wrote: > On Mon, Jun 8, 2020 at 5:41 PM Thomas Bushnell, BSG > wrote: > >> The OP was about MustCompile, so I think it's clear they are not using >> patterns passed in by external requests. >> > > I don't think that's clear at all. How do you assume

Re: [go-nuts] Re: what is the complexity of regexp.MustCompile()?

2020-06-08 Thread 'Thomas Bushnell, BSG' via golang-nuts
The OP was about MustCompile, so I think it's clear they are not using patterns passed in by external requests. On Mon, Jun 8, 2020 at 9:39 AM Robert Engels wrote: > I will claim it also doesn’t matter because you need external bounding > anyway. Take a simple recursive directory listing. It is

Re: [go-nuts] Is this a safe way to block main thread but not main goroutine?

2020-04-29 Thread 'Thomas Bushnell, BSG' via golang-nuts
That seems needlessly complex. Why not just skip the weird init, and just have main do a go to the thing you want to be not on the main thread, and let the main thread do its thing? On Wed, Apr 29, 2020 at 4:19 PM Akhil Indurti wrote: > I want to run the main goroutine on another thread besides

Re: [go-nuts] An important proposal will fail without your support

2020-03-10 Thread 'Thomas Bushnell, BSG' via golang-nuts
In C it's called _. While it's not normally considered good Go style, you could use a "." import of the package, and call the function G. Then: "fmt.Println(G("message text at %t with %n bytes"), time, number) Notice that (following C) the gettext lookup function is called with the string, and

Re: [go-nuts] Difference with function returning struct and function returning pointer to struct

2019-11-20 Thread 'Thomas Bushnell, BSG' via golang-nuts
You can only assign to something which is addressable in the sense of https://golang.org/ref/spec#Address_operators. That is: "either a variable, pointer indirection, or slice indexing operation; or a field selector of an addressable struct operand; or an array indexing operation of an

Re: [go-nuts] Existing production-ready libraries for parallelizing HTTP requests?

2019-08-20 Thread 'Thomas Bushnell, BSG' via golang-nuts
I am of the opinion that a case like this is best handled by simply writing the thing you want. Concurrency limits are easily managed by using tokens to gate fetches. One simple technique is to make a channel of struct{} with capacity equal to the maximum number of concurrent connections you are

Re: [go-nuts] Re: Adding a timeout to a script interpreter (without leaking a goroutine)

2019-05-30 Thread 'Thomas Bushnell, BSG' via golang-nuts
plus you'd lose the ability to compute ackerman's function, which i'm doing all the time On Wed, May 29, 2019 at 7:35 AM adonovan via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Tuesday, 21 May 2019 01:18:34 UTC-4, Ben Hoyt wrote: >> >> I'm looking at adding a timeout option to my

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
I'm a big fan of the ternary operator in general. Maybe this is because I'm an old timey Lisper. A lot of the things people see as "abuse" or "too complex" are equally problems with || and &&. This is also true for Jan's point: that ?: affects control flow by omitting execution sometimes. It

Re: [go-nuts] What does "identifier...type" mean in a function definition?

2019-04-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
"..." is called an ellipsis (plural ellipses). The presence or absence of the space is unimportant; you're seeing the way gofmt formats it, but the parser doesn't care. Since period is not a legitimate constituent of an identifier name, they scan in separate tokens either way. On Thu, Apr 25,

Re: [go-nuts] Question regarding gob

2019-03-26 Thread 'Thomas Bushnell, BSG' via golang-nuts
I mean, everything except the things that are not pointers. On Tue, Mar 26, 2019 at 2:45 PM Robert Engels wrote: > This is not really true. In Java everything is a pointer (reference) and > has no problem with the semantics of passing a reference, it is built into > the serialization. They may

Re: [go-nuts] bytes.Buffer.ReadAt?

2019-03-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
Notice the logic in (*bytes.Buffer).grow which will throw away already read data, specifically in the case n <= c/2--m. On Mon, Mar 25, 2019 at 9:57 AM fREW Schmidt wrote: > Oh thanks, I'll switch my code to reader, though as far as I can tell, > bytes.Buffer doesn't discard already read data,

Re: [go-nuts] Re: Wuffs: a new, memory-safe programming language

2019-01-11 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Fri, Jan 11, 2019 at 9:33 AM Eric S. Raymond wrote: > Thomas Bushnell, BSG : > > Suppose it has a way, however. Now you have Go code which will have a > > bounds fault instead of a data leak. That's better, I suppose - the > > resulting bug is now "the server crashes" instead of "the server

Re: [go-nuts] Re: Wuffs: a new, memory-safe programming language

2019-01-10 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Thu, Jan 10, 2019 at 10:49 AM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > On Thu, Jan 10, 2019 at 7:39 PM Thomas Bushnell, BSG > wrote: > >> >>> The server crashes - that's how we handle "any other exception", as a >> rule. >> >> > I write Erlang for a living. We don't

Re: [go-nuts] Re: Wuffs: a new, memory-safe programming language

2019-01-10 Thread 'Thomas Bushnell, BSG' via golang-nuts
> > > * Even if we did this, the bug only turns into a packet of death. A packet >> of death on this scale is of almost the same level of annoyance and chaos. >> (Witness this week's firestorm about an email packet of death on some Cisco >> something or other.) >> >> > I did address this. If each

Re: [go-nuts] Re: Wuffs: a new, memory-safe programming language

2019-01-10 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Thu, Jan 10, 2019 at 8:50 AM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > On Wed, Jan 9, 2019 at 7:55 PM 'Thomas Bushnell, BSG' via golang-nuts < > golang-nuts@googlegroups.com> wrote: > >> >> I'm curious about why transpilation w

Re: [go-nuts] Re: Wuffs: a new, memory-safe programming language

2019-01-09 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Jan 9, 2019 at 10:07 AM Eric S. Raymond wrote: > > Reasonable people can disagree, but I favor rewriting over > > transpilation, for draining that swamp. > > The problem is that in general nobody *does* rewrite old > infrastructure code. It tends to work just well enough to fester in >

Re: [go-nuts] Re: why does go reverse the order of name and type? "i int" vs "int i"

2018-09-21 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Fri, Sep 21, 2018 at 11:07 AM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > in programming languages putting the type first basically only appears in > C and its (ill-born) children. > Like that's literally wrong. I prefer Go's order, which borrows from Pascal. But C's order is

Re: [go-nuts] Re: I am not in favor of generics.

2018-09-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Sep 19, 2018 at 4:04 PM robert engels wrote: > > The opinion that well, since there is no implements I can define my own > interface, and pass some stdlib struct that I can’t control as an > “implementor” is hogwash. Because you also don’t control this code, the API > is free to change -

Re: [go-nuts] Re: I am not in favor of generics.

2018-09-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
That's a different case than one which "implements" addresses. You don't need "implements" to address that problem, if you think it's a problem. Adding "implements" doesn't help. I understand there are people who think adding generics might help, but that's a different thing. On Wed, Sep 19,

Re: [go-nuts] Re: I am not in favor of generics.

2018-09-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
Huh? Type safety is still checked by the compiler. Implements does nothing except put a road-block in the way and prohibit you from making an interface that some other package happens to implement. On Wed, Sep 19, 2018 at 1:40 PM Robert Engels wrote: > Go not having implements is a big problem

Re: [go-nuts] Re: I am not in favor of generics.

2018-09-18 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Tue, Sep 18, 2018 at 1:04 PM wrote: > It would be nice, for example, to have a full range of collection types in > the standard library without the need to use interface{}, type assertions > and the performance overhead of 'boxing'. > >From the earliest days of Object Oriented Programming,

Re: [go-nuts] Reference to type satisfying a specified interface

2018-08-30 Thread 'Thomas Bushnell, BSG' via golang-nuts
Basically you almost never want pointer-to-interface in practice. The temptation is to have a struct which satisfies your interface, and then you end up with thinking you want pointer-to-interface. Instead, make pointer-to-struct satisfy the interface, and then you don't need

Re: [go-nuts] Global variable initialized in init() not working in main()

2018-02-05 Thread 'Thomas Bushnell, BSG' via golang-nuts
Your init is closing the file before returning, so at that point all the writes are failing. If you check the error you receive from logger.Print you should see something to that effect. Thomas On Mon, Feb 5, 2018 at 1:39 PM wrote: > I'm initializing a Logger variable in an

Re: [go-nuts] Why doesn't sync.Cond embed sync.Locker?

2017-11-13 Thread 'Thomas Bushnell, BSG' via golang-nuts
Sometimes you want multiple Conds which share the same Locker. When you want it, it's frequently essential and very annoying if you can't have it. On Sun, Nov 12, 2017 at 7:02 PM T L wrote: > . > > -- > You received this message because you are subscribed to the Google

Re: [go-nuts] nil maps

2017-10-17 Thread 'Thomas Bushnell, BSG' via golang-nuts
Here's a case that comes up for me: type table map[string]map[string]string func (t table) add(x, y, z string) { if t[x] == nil { t[x] = make(map[string]string) } t[x][y] = z } func (t table) get(x, y string) string { return t[x][y] } The fact that t[x] can be indexed even if it

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-31 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Sat, Jul 29, 2017 at 10:36 AM wrote: > > But as Gofmt can ALREADY enforces this common coding style, and can be run > at any time, including before committing code on the depots, why should it > be enforced by the COMPILER too ? > The compiler does not enforce the

Re: [go-nuts] Re: pet peeve: it's Go not golang

2017-07-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
Google Search is weird. I searched for "game of life in go" and all ten links were great hits for just that. When I search for "go game life", the implementation of Conway's game is the fifth link; still not so bad. Thomas On Tue, Jul 25, 2017 at 2:47 PM wrote: > Yes, the

Re: [go-nuts] pet peeve: it's Go not golang

2017-07-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
And when there is confusion, "Go language" is much nicer to read than "golang". On Tue, Jul 25, 2017 at 11:16 AM Skip Tavakkolian < skip.tavakkol...@gmail.com> wrote: > Although "go" is a verb, an adjective and a noun (including the game), > there shouldn't be any confusion in what Go is, when

Re: [go-nuts] Uncontrolled map access can crash the program --- how?

2017-07-05 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Jul 5, 2017 at 12:29 PM Peter Kleiweg wrote: > From the faq: https://golang.org/doc/faq#atomic_maps > > ... uncontrolled map access can crash the program. > > In what situations does this apply? > > Can I have two goroutines reading a single map at the same time?

Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
Something similar at https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/abort.c;h=19882f3e3dc1ab830431506329c94dcf1d7cc252;hb=HEAD#l138 in the GNU C library. Sometimes you just need to be absolutely certain that a function doesn't return. On Thu, Jun 15, 2017 at 2:16 PM Rob Pike

Re: [go-nuts] Is it safe to invoke len(channel) on multi-gorountine

2017-06-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
As you discovered, it is perfectly *safe *to call len on a channel in use by multiple goroutines: you'll get a correct answer and you won't provoke a crash or anything. But you can't use it as a signal that a following receive will work if another goroutine might have received in the interim. On

Re: [go-nuts] Fast string sorting

2017-06-13 Thread 'Thomas Bushnell, BSG' via golang-nuts
That's really nice! Consider a case where I am sorting a slice of structs, but the underlying sort is based on a string within the structs. Or, with some other radixable datatype besides strings. Can we figure out an interface (similar to sort.Interface) which would permit a solution for either

Re: [go-nuts] Expected declaration, found 'package'

2017-04-26 Thread 'Thomas Bushnell, BSG' via golang-nuts
A single Go source file is not allowed to be in more than one package. On Wed, Apr 26, 2017 at 8:52 AM Tong Sun wrote: > Hi, > > I'm trying to put different code collection into the same Go source file, > (from here >

Re: [go-nuts] Change imaginary part of a complex

2017-04-20 Thread 'Thomas Bushnell, BSG' via golang-nuts
The other way is to add the c to its conjugate and then add the imaginary part, using cmplx.Conj. But that really amounts to what you're doing already. On Thu, Apr 20, 2017 at 3:20 AM Val wrote: > Hello folks > To keep real part of a complex, and set its imag part, I'm

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread 'Thomas Bushnell, BSG' via golang-nuts
There is no such distinction in json as a float vs. an int; they are just numbers. This is essentially a consequence of the javascript underpinnings of json. Thomas On Thu, Mar 2, 2017 at 2:29 AM Basile Starynkevitch < bas...@starynkevitch.net> wrote: > Hello All, > > This could be related to

Re: [go-nuts] Re: Trying to understand := and named return values

2017-02-22 Thread 'Thomas Bushnell, BSG' via golang-nuts
Function parameters are not a good place (in general - there are exceptions) to document arguments. // Frob the outer otter. FrobOuterOtter(otter Otter) is not better than // Frob the outer otter FrobOuterOtter(Otter) from the standpoint of external documentation. But if you want the function

Re: [go-nuts] How do you implement and use Context.Done?

2017-02-21 Thread 'Thomas Bushnell, BSG' via golang-nuts
Oops! ::blush:: On Tue, Feb 21, 2017 at 11:39 AM Axel Wagner <axel.wagner...@googlemail.com> wrote: > Wrong list :) You meant to link here: > https://godoc.org/context#Context.Err > > On Tue, Feb 21, 2017 at 8:15 PM, 'Thomas Bushnell, BSG' via golang-nuts < > golang-nuts

Re: [go-nuts] How do you implement and use Context.Done?

2017-02-21 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Mon, Feb 20, 2017 at 11:42 AM Ian Lance Taylor wrote: > On Sun, Feb 19, 2017 at 2:57 PM, wrote: > > Thanks, I see you build it up with decorators on a standard prototype. > > For example: https://play.golang.org/p/PJy5lE9QqF > > > > So context.Done is a

Re: [go-nuts] about sorting array

2017-02-01 Thread 'Thomas Bushnell, BSG' via golang-nuts
Not quite. The slice shares storage with the array, so changing an element of the slice is the same as changing an element of the array. Slicing in Go (unlike some other languages) does not copy the elements. Thomas On Wed, Feb 1, 2017 at 4:56 PM Néstor Flórez wrote: > OK,

Re: [go-nuts] Re: Best practice when creating temporary files

2016-11-21 Thread 'Thomas Bushnell, BSG' via golang-nuts
It's fine to try, but you should design your entire system with the assumption that your program may crash at any moment and leave something around. This is why the OS cleans up /tmp. Thomas On Mon, Nov 21, 2016 at 9:01 AM Steven Hartland wrote: > That's a bad

Re: [go-nuts] Re: Stalking people online for thought crimes! This is what the Go project has succumbed to!

2016-11-04 Thread 'Thomas Bushnell, BSG' via golang-nuts
If you believe there is an issue which is not being addressed properly, please use the procedure at https://golang.org/conduct#reporting. Thomas On Fri, Nov 4, 2016 at 12:22 PM wrote: > All I see here is nothing is done to moderate /r/golang despite threads > being

Re: [go-nuts] Working with characters in strings

2016-10-31 Thread 'Thomas Bushnell, BSG' via golang-nuts
ail.com> wrote: > On Mon, Oct 31, 2016 at 06:06:23PM +, 'Thomas Bushnell, BSG' via > golang-nuts wrote: > > Strings are specified to be UTF8, so if you cast a string to []byte you > > will see its UTF8 representation. > > They are not. A Go string may contain arbitra

Re: [go-nuts] Working with characters in strings

2016-10-31 Thread 'Thomas Bushnell, BSG' via golang-nuts
I don't know what you mean by "characters", since you're distinguishing them from runes. Do you mean bytes? Strings are specified to be UTF8, so if you cast a string to []byte you will see its UTF8 representation. Thomas On Sat, Oct 29, 2016 at 4:42 AM wrote: > > I

Re: [go-nuts] the defer list

2016-10-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
Ah, yes, that's true indeed. On Wed, Oct 19, 2016 at 2:33 PM adonovan via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Wednesday, 19 October 2016 16:50:55 UTC-4, Thomas Bushnell, BSG wrote: > > On Wed, Oct 19, 2016 at 1:47 PM Pietro Gagliardi > wrote: > > Manual

Re: [go-nuts] the defer list

2016-10-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Oct 19, 2016 at 1:47 PM Pietro Gagliardi wrote: > Manual memory management is a part of life in the C world. defer is the > solution that Go comes up with to situations where explicit cleanup is > necessary, and it's a powerful tool that I'm pretty sure *is* an

Re: [go-nuts] Re: Why + and += operators for string but not slices?

2016-09-16 Thread 'Thomas Bushnell, BSG' via golang-nuts
The thread already shows several alternative interpretations which are different from that. Go tries to avoid constructions that require careful specification of that sort. Append already causes enough confusion, but that's important enough that dropping it would be a loss. + for slices is only

Re: [go-nuts] Re: Why + and += operators for string but not slices?

2016-09-16 Thread 'Thomas Bushnell, BSG' via golang-nuts
The values of the summation are indeed unambiguous, but the data aliasing properties are not. On Fri, Sep 16, 2016, 12:58 PM wrote: > Thank you both. > > To Ian: but a slice is not a matrix or a list. > > To Axel: append() and copy() compliment indexing and slicing well

Re: [go-nuts] Unary +

2016-08-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
50 years later. > > > > P.S. If you visited Thomas Payne’s bookshop in London (in the 1750s) you > could have bought your own copy of Francis Maseres’ *“A dissertation on > the use of the negative sign in algebra: containing a demonstration of the > rules usually given concer

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Aug 3, 2016 at 7:36 AM T L wrote: > Often, I need converting a []T to []interface{} to use the []interface as > a variable length parameter. > But converting a []T for []interface{} in a for loop is neither clean nor > efficient. > If there was a builtin that did

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread 'Thomas Bushnell, BSG' via golang-nuts
Don't confuse variadic arguments with slice arguments, by the way. On Wed, Aug 3, 2016 at 8:20 AM T L wrote: > > > On Wednesday, August 3, 2016 at 10:53:34 PM UTC+8, Jessta wrote: > >> On 4 Aug 2016 12:36 a.m., "T L" wrote: >> > >> > Often, I need

Re: [go-nuts] Plurality of package naming

2016-07-12 Thread 'Thomas Bushnell, BSG' via golang-nuts
That's advice for a very different style of language than Go. Go does not have "objects" in the sense of that post. A Go interface, for example, does not "have lots of instance variables, lots of arguments, and pass lots of data around probably." A class is not a struct is not a Go interface.

Re: [go-nuts] Interface{} constrains on specific types

2016-06-24 Thread 'Thomas Bushnell, BSG' via golang-nuts
The trick is to do this: Decl special_interface and then special_interface requires an unexported interface which you implement in the specific (new) types that you can store in the thing. On Fri, Jun 24, 2016 at 3:10 PM 'Mihai B' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I'm

Re: [go-nuts] Re: A proposal for generic in go

2016-06-22 Thread 'Thomas Bushnell, BSG' via golang-nuts
Really? How would you implement math.Max with generics? Thomas On Wed, Jun 22, 2016, 5:45 AM Viktor Kojouharov wrote: > https://golang.org/pkg/math/ and https://golang.org/pkg/container/ are > just two stdlib packages that would greatly benefit from some kind of >