Re: [go-nuts] Are float64 and float32 exact in Golang (like strictfp in Java)

2020-09-25 Thread Rob Pike
There is more than one Go compiler and the use of fused-multiply-add is not guaranteed. The Go spec permits FMA but does not require it. I suggest reading the "Floating-point operators" section of the specification for clarity here. -rob On Sat, Sep 26, 2020 at 9:23 AM Ian Lance Taylor

Re: [go-nuts] Find n-th root of a big number

2020-09-22 Thread Rob Pike
I'm not going to debug you program for you - you'll learn more doing it yourself, but I glanced at it and saw immediately that you're missing an easy optimization. Raising a number to an integer power can be done much faster by repeated squaring according to the bit pattern of the exponent. I'll

Re: [go-nuts] Re: Efficient bitmask twiddling

2020-09-01 Thread Rob Pike
It's not a bit array, it's a bool array. Can you make it a bit array and use bit != 0 for the boolean elsewhere? -rob On Wed, Sep 2, 2020 at 5:55 AM Oliver Smith < oliver.sm...@superevilmegacorp.com> wrote: > Do godbolt links get eaten? https://godbolt.org/z/vbeobs > > On Tuesday, September 1,

Re: [go-nuts] Re: Speed up png.Decode

2020-06-26 Thread Rob Pike
Without information about the particular images - the data set you're working with - it's hard to provide any accurate advice. If the images are small, maybe it's all overhead. If the images are of a particular form of PNG, maybe a fast path is missing. And so on. To get meaningful help for

Re: [go-nuts] Why isn't there "number plus" postfix syntax for more than or equal?

2020-04-23 Thread Rob Pike
if r == 13 despiteallobjections { ... } -rob On Fri, Apr 24, 2020 at 8:04 AM 'Dan Kortschak' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I look forward to the addition of the definition of "in a handwavy > sense" to the spec. > > On Thu, 2020-04-23 at 11:41 -0700, Michael Jones

Re: [go-nuts] testing code that uses ioutil.ReadDir?

2020-04-12 Thread Rob Pike
I am the author of the test coverage tool, and I do not believe that 100% code coverage is the right goal. Coverage is a proxy for testing quality, but not a guarantee of it. Getting to 100% coverage is a better indicator of chasing metrics than of actually writing good tests. I'm happy if my

Re: [go-nuts] correction in make documentation

2020-04-11 Thread Rob Pike
It's not just the size, though, it's also what kind of thing gets made. I think it's better as is. -rob On Sun, Apr 12, 2020 at 6:02 AM Feroz Jilla wrote: > Hello community :) > > I was going through the golang documentation on the `make` function here - >

Re: [go-nuts] Is this code in package unix assuming machine endianess?

2020-03-11 Thread Rob Pike
More context, in the form of self-promotion: https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html -rob On Wed, Mar 11, 2020 at 9:42 PM Tom Parkin wrote: > On Tue, 10 Mar 2020 at 23:14, Ian Lance Taylor wrote: > >> On Tue, Mar 10, 2020 at 4:03 PM Tom Parkin wrote: >> > >> > I'm

Re: [go-nuts] Re: Why isn't there strings.reverse("str") function?

2020-02-27 Thread Rob Pike
Once bytten, twice shy. -rob On Fri, Feb 28, 2020 at 10:17 AM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > The key observation is that you only look at a byte once. > > On Thu, Feb 27, 2020, 22:49 Amnon Baron Cohen wrote: > >> You are right. >> I had wrongly assumed that

Re: [go-nuts] why golang unicode katakana table don't include 0x30fc ..

2019-12-10 Thread Rob Pike
That's a good question and I haven't figured it out, but I bet it has to do with U+30fb not being in L class: % unicode -d -U 30fa 30fb 30fc U+30FA 'ヺ' KATAKANA LETTER VO category: Lo canonical combining classes: 0 bidirectional category: L character decomposition mapping: 30F2 3099

Re: [go-nuts] using or extending or forking+renaming github.com/google/licensecheck to provide similar functionality

2019-11-14 Thread Rob Pike
ingLicenseReferences.c > > Command listlicenses iterates over all files in the subtree, gathering > all full or partial (broken) license references. Command listlicenses > uses the functionality similar to github.com/google/licensecheck to > check the files in the file system. > > >

Re: [go-nuts] using or extending or forking+renaming github.com/google/licensecheck to provide similar functionality

2019-11-13 Thread Rob Pike
Can you please explain in more detail what you're asking for? I don't understand the problem you have or why the current package cannot handle it. -rob On Wed, Nov 13, 2019 at 7:05 PM wrote: > Hi, > > "licensecheck classifies license files and heuristically determines > how well they

Re: [go-nuts] Channels may not be the best solution in Go

2019-10-05 Thread Rob Pike
> > > Not all programs benefit from concurrency. Writing concurrent code for > essentially sequential programs will not benefit from multiple cores, > like generating prime numbers. Do not forget that concurrency includes > overhead for context switch and memory barriers. Using channels in a >

[go-nuts] Go Time #100 with Robert Griesemer and myself

2019-09-25 Thread Rob Pike
It's now live: https://changelog.com/gotime/100 -rob -- 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

Re: [go-nuts] select on slice of channels

2019-09-13 Thread Rob Pike
The feature was in Newsqueak but we deliberately omitted it from Go because the cost of the operation can be very high and we weren't comfortable provided such concise notation for such an expensive operation. -rob On Fri, Sep 13, 2019 at 4:02 PM Ian Lance Taylor wrote: > On Thu, Sep 12, 2019

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Rob Pike
Printf can print hexadecimal just fine. Never understood the point of encoding/hex. Meanwhile, for questions about strings, see blog.golang.org/strings. -rob On Tue, Aug 20, 2019 at 9:00 PM Sam Whited wrote: > I personally wouldn't do this. If you're going to incur the overhead of a > heap

Re: [go-nuts] Gob encoding not working to NFS

2019-06-14 Thread Rob Pike
The problem is that os.NewFile makes a new File struct; it doesn't create a file. Also, the first argument should be an open file descriptor, not a flag. I think you want to use os.Create. You certainly don't want NewFile. -rob On Sat, Jun 15, 2019 at 12:21 AM wrote: > I have been writing

Re: [go-nuts] Re: A good indicator of code quality

2019-06-10 Thread Rob Pike
"[T]he Heisenberg Uncertainty Principle says that you cannot measure something without changing it". Actually no, that is the Observer Paradox. The Heisenberg Uncertainty Principle states that the product of the uncertainty of complementary variables, such as momentum and position, can never be

Re: [go-nuts] Creating a request language from scratch

2019-06-07 Thread Rob Pike
Some minor advice: https://commandcenter.blogspot.com/2011/08/regular-expressions-in-lexing-and.html -- 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

Re: [go-nuts] Re: Interesting public commentary on Go...

2019-05-24 Thread Rob Pike
If that's true - and it might well not be - it's a surprise to me. When launching the language we explicitly made sure NOT to trademark it. -rob On Fri, May 24, 2019 at 10:50 AM Gerald Henriksen wrote: > On Fri, 24 May 2019 07:40:52 +1000, you wrote: > > >The last sentence of the article is

Re: [go-nuts] Re: Interesting public commentary on Go...

2019-05-23 Thread Rob Pike
The last sentence of the article is not correct. The name Go is not trademarked by Google, at least as a programming language trademark. There are other things Google makes called Go (an interesting signal on its own) and they might be trademarked, but Go the language is not a trademark. -rob --

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-17 Thread Rob Pike
wrote: > On Sat, 2019-05-18 at 09:43 +1000, Rob Pike wrote: > > Australia is closer to Britain but sticks with jail > > and tire. > > I don't think this is true Australia wide - in Melbourne and Adelaide > (my home cities), I have always seen gaol and tyre. > > >

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-17 Thread Rob Pike
It is of course more complicated than most people believe. The right is often wrong; the wrong often has long precedence. The British -ise ending is an early 20th century misguided respelling based on invalid theories of etymology. Programme is just something that came out of the blue, from

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

2019-04-25 Thread Rob Pike
I am pretty sure that the decision not to have ?: in Go was a unanimous decision by Robert, Ken and myself after almost no discussion. It is too easy to abuse, as the FAQ states. -rob -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] how to get file's current offset

2019-04-19 Thread Rob Pike
I just use 1 so I don't have to look up what it's called these days, but I'm seriously old school. -rob On Sat, Apr 20, 2019 at 3:19 AM Michael Jones wrote: > I’ve been doing that since 6th Edition, 1976/77 > > On Thu, Apr 18, 2019 at 8:00 AM andrey mirtchovski > wrote: > >> > offset, err :=

Re: [go-nuts] Re: Learning Data Structures and algorithms with Golang

2019-04-14 Thread Rob Pike
Bhagvan: Please note that the language is called Go, not Golang. -rob On Mon, Apr 15, 2019 at 1:49 AM Robert Solomon wrote: > I actually find it useful to have these posted here. I'm a notice Go > programmer, and these references help me. > I also saw a reference to "Hands On GUI

Re: [go-nuts] Pointer declaration syntax

2019-03-10 Thread Rob Pike
& turns a value into a pointer. * turns a pointer into a value. Whether a pointer should be declared with & or * or "ptr" or anything else is an arbitrary decision made the way it was by the Go designers because, as Ian says, C did it with *. -rob On Mon, Mar 11, 2019 at 10:22 AM Michael Jones

Re: [go-nuts] go vet tool

2019-03-04 Thread Rob Pike
Ah, yes it does work, if not documented in 'go help vet'. Thanks. -rob On Tue, Mar 5, 2019 at 10:20 AM Ian Lance Taylor wrote: > On Mon, Mar 4, 2019 at 2:00 PM Rob Pike wrote: > > > > The help for go vet does not mention that one can pass individual files, > only packag

Re: [go-nuts] go vet tool

2019-03-04 Thread Rob Pike
The help for go vet does not mention that one can pass individual files, only packages. -rob On Tue, Mar 5, 2019 at 6:20 AM Ian Lance Taylor wrote: > On Sun, Mar 3, 2019 at 11:02 PM wrote: > > > > Is it possible to use go vet as go tool vet . With go > vet it is giving no go source files,

Re: [go-nuts] go vet tool

2019-03-04 Thread Rob Pike
I do wish it were still possible to do "go vet file.go" or "go vet directory" although I do understand why it is not (type checking). Over time, everything gets better but also worse and always bigger and more complex. -rob On Mon, Mar 4, 2019 at 6:02 PM wrote: > Is it possible to use go vet

Re: [go-nuts] Is Go a single pass compiler?

2019-02-27 Thread Rob Pike
The Go compiler was single pass until we allowed use before declaration. -rob On Thu, Feb 28, 2019 at 10:46 AM wrote: > Thanks, Ian. > > I remember reading in some compiler book that languages should be designed > for a single pass to reduce compilation speed. > > Go proves that wrong :) It's

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread Rob Pike
If you don't need precision, just generate ints and scale them. -rob On Tue, Feb 26, 2019 at 9:39 AM DrGo wrote: > Thanks Ian, > The std lib float32 is slow for my purpose. In my benchmarking it is > actually slower than the float64. But I don’t even need float16 precision. > I am working on

Re: [go-nuts] Mismatched types work sometimes?

2019-02-11 Thread Rob Pike
You might find blog.golang.org/constants helpful. -rob On Tue, Feb 12, 2019 at 5:04 AM Jamie Caldwell wrote: > Thanks for the help and quick response Tyler. > > On Mon, 11 Feb 2019 at 17:56, Tyler Compton wrote: > >> Constant expressions like 'A' or 3 or named constants like "const x = 7" >>

Re: [go-nuts] Modules. A "new" system.

2019-02-05 Thread Rob Pike
% ivy */iota 1000

Re: [go-nuts] Modules. A "new" system.

2019-02-05 Thread Rob Pike
Oberon inspired a number of languages. For instance, Limbo's GC also collects files, and modules are just objects you assign to when importing them, and are collected when no longer referenced. -rob On Wed, Feb 6, 2019 at 10:06 AM Michael Jones wrote: > ha ha! yes indeed. i was counting

Re: [go-nuts] Using "er" and "able" for interfaces

2019-01-17 Thread Rob Pike
It depends on the nature of the verb (method) and whether it's being used to refer to the subject or the object, whether it is transitive or intransitive, and all the rest of that messy human grammar nonsense. Which is why trying to align the with justifications to English grammar is a fool's

Re: [go-nuts] Re: What are the reasonable reasons to use pointers?

2019-01-07 Thread Rob Pike
e, and after > that, all the "2" arguments in my program were invisibly changed. > > I was 16 or 17, was an explorer scout at BTL, and was quick to embrace 6th > edition UNIX and ed over TOPS-10 and TECO (ignoring the brilliantly named > SOS, "son of stopgap") > &g

Re: [go-nuts] Re: What are the reasonable reasons to use pointers?

2019-01-06 Thread Rob Pike
Fortran depends heavily on pointers for its semantics: It is a call by reference language. You just don't see them explicit in the language and you have no control over whether an argument will be modified by a procedure. -rob On Mon, Jan 7, 2019 at 5:13 AM Victor Giordano wrote: > i guess

Re: [go-nuts] Adding &&= and ||= operators for working with bools

2019-01-05 Thread Rob Pike
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 c

Re: [go-nuts] Adding &&= and ||= operators for working with bools

2019-01-05 Thread Rob Pike
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

Re: [go-nuts] if/switch statements as expressions

2018-12-19 Thread Rob Pike
BCPL had a construct like this, and we did consider doing something analogous, but in the end Go is not an expression language. C and BCPL are, and that property does lead to problems, although they are probably avoidable with careful language design. But Go is not an expression language, so

Re: [go-nuts] Re: Plan9 reborn as a guest OS atop of Golang runtime

2018-12-11 Thread Rob Pike
man achievement in OS design: > Inferno. > > https://en.wikipedia.org/wiki/Inferno_(operating_system) > http://www.vitanuova.com/inferno/ > https://bitbucket.org/inferno-os/inferno-os > > Inferno was written in the early 90's by Ken Thompson, Rob Pike, Roger > Peppé, Dennis Ritchie,

Re: [go-nuts] Strange behaviour of left shift

2018-12-05 Thread Rob Pike
Most of this is explained in blog.golang.org/constants. -rob On Thu, Dec 6, 2018 at 4:04 AM Andy Balholm wrote: > When an untyped integer constant is converted to a typed value, it always > becomes int. I suppose the rules could be made more complicated to handle > values that won’t fit in an

Re: [go-nuts] Rethink possibility to make circular imports

2018-11-29 Thread Rob Pike
And to reduce build time, especially for incremental builds. -rob On Fri, Nov 30, 2018 at 8:17 AM Ian Lance Taylor wrote: > On Thu, Nov 29, 2018 at 5:22 AM Michel Levieux > wrote: > > > > The last few days I've been thinking a lot about the fact that Go does > not allow circular imports. > >

Re: [go-nuts] Re: go language sensitive editor?

2018-11-22 Thread Rob Pike
2018 at 6:04 PM Rob Pike wrote: > > > > Ed is the standard text editor. > > > > -rob > > > > > > On Wed, Nov 21, 2018 at 8:15 AM wrote: > >> > >> > >> Another vote for VS Code. I'm a hobbyist and have tried lots of editors.

Re: [go-nuts] Re: go language sensitive editor?

2018-11-22 Thread Rob Pike
http://man.cat-v.org/unix-6th/1/ed On Fri, Nov 23, 2018 at 12:48 AM Anirudh Vyas wrote: > Could never get this one - Ed is the standard editor, is there a > historical context of this? Did people say this a lot back when there were > vim emacs and Ed only as choices of editors? > On Nov 22,

Re: [go-nuts] Re: go language sensitive editor?

2018-11-20 Thread Rob Pike
Ed is the standard text editor. -rob On Wed, Nov 21, 2018 at 8:15 AM wrote: > > Another vote for VS Code. I'm a hobbyist and have tried lots of editors. > > On Tuesday, November 20, 2018 at 1:52:11 PM UTC-7, Pat Farrell wrote: >> >> I know, this is both a FAQ and an unanswerable question. I'm

Re: [go-nuts] Example of setting a struct field value via reflection requested

2018-11-06 Thread Rob Pike
https://blog.golang.org/laws-of-reflection shows how to do this, with explanation. -rob On Tue, Nov 6, 2018 at 11:26 AM Eric Raymond wrote: > > > On Monday, November 5, 2018 at 6:18:27 PM UTC-5, kortschak wrote: >> >> https://play.golang.org/p/EtXlOCR1fDY >> > > Thanks, I was able to adapt

Re: [go-nuts] Traverse directory without infinite loops while following symlinks

2018-10-08 Thread Rob Pike
No, I was thinking of Occam but being wrong. -rob On Mon, Oct 8, 2018 at 9:52 PM roger peppe wrote: > On 8 October 2018 at 08:53, Rob Pike wrote: > > Actually the original is a paper: > > https://www.cs.cmu.edu/~crary/819-f09/Hoare78.pdf > > The book came later and is su

Re: [go-nuts] Traverse directory without infinite loops while following symlinks

2018-10-08 Thread Rob Pike
:41 PM wrote: > I haven't seen a mention of the original book neither here nor on > golang-dev for quite some time, maybe this helps: usingcsp.com > It has been freely available for a few years now. > > > On 10/8/18, Rob Pike wrote: > > Not Per Brinch Hansen. He did

Re: [go-nuts] Traverse directory without infinite loops while following symlinks

2018-10-07 Thread Rob Pike
Not Per Brinch Hansen. He did monitors, which are just serialization. Tony Hoare did CSP. -rob On Mon, Oct 8, 2018 at 12:46 PM Michael Jones wrote: > The greatness of go parallelism is that it is almost invisible. This is > the legacy of CSP, Per Brinch Hansen’s Communicating Sequential

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

2018-09-20 Thread Rob Pike
PL/I is unmatched. -rob On Fri, Sep 21, 2018 at 10:13 AM Drew Derbyshire wrote: > On Wednesday, September 19, 2018 at 10:30:11 PM UTC-7, Sathish VJ wrote: >> >> I've been asked this question a few times and I haven't been able to find >> an answer. Why does go reverse the order of variable

Re: [go-nuts] Re: Generics as builtin typeclasses

2018-09-08 Thread Rob Pike
"A contract is a compile-time description of which types are permitted for a polymorphic function or type." No, it's not. It's a collection of statement-like operations that must be legally compilable, under restricted circumstances, by the type at the point of instantiation, plus some special

Re: [go-nuts] Re: Generics as builtin typeclasses

2018-09-07 Thread Rob Pike
Would this work? contract unsigned(u T) { 1 << u } It's another infelicitous horror, but I believe it exploits the only place in the language where an unsigned integer is required. -rob -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Re: Generics as builtin typeclasses

2018-09-07 Thread Rob Pike
contract unsigned(v T) { // Require T to be an integer type. v % 1 // This is satisfied by any unsigned integer type, but not by a signed integer type. v = 1<<(unsafe.Sizeof(v) * 8 - 1) } That requires an import, not to mention unsafe, which raises the issue of whether a contract

Re: [go-nuts] GO lang implementation for one deck card shuffle

2018-08-15 Thread Rob Pike
The math/rand package has 38848 bits of state. The seed value is only 64 bits, yes, but that's a separate question. Is seeding what you are concerned with? -rob On Thu, Aug 16, 2018 at 1:19 PM, Pat Farrell wrote: > I want to build a poker simulator. For this, I need a nice method to > shuffle

Re: [go-nuts] Why does Go not include a stack trace by default in the errors package?

2018-08-06 Thread Rob Pike
My thinking is part of the discussion in https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html -rob On Tue, Aug 7, 2018 at 7:43 AM, 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > The message from an `error` is not for consumption by a developer,

Re: [go-nuts] Godoc index generator fails in gob encoder due to size

2018-05-16 Thread Rob Pike
The encoder has a 1GB upper limit on message size. You're right that it might not be documented. Or adjustable, which perhaps it should be, but then you need to make sure both ends have the same setting. It's all rather clumsy, writing big blobs on a network. See

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Rob Pike
There is a widespread dislike of do-while in C. Pretty much every time I've wanted it, my code reviewer made me take it out. I agree it has its place but it's one of those style things that social pressures seem to force. I would not be the one to try to argue for its return; I couldn't handle the

Re: [go-nuts] globals defined by stringer utility

2018-05-08 Thread Rob Pike
I don't see that it matters much either way. It's clean enough as it is. It's generated code, after all, and therefore is allowed to be ugly. Its merit is not in the prettiness of the code it generates but in other aspects, such as efficiency of both machine and programmer. There may be one small

Re: [go-nuts] Re: Go could really use a while statement

2018-05-08 Thread Rob Pike
The original suggestion (using while instead of for) may be the first time someone has complained that Go is not verbose enough. -rob -- 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

Re: [go-nuts] Re: Fancy Comments & Documentation

2018-04-19 Thread Rob Pike
If you want gofmt to preserve ASCII art, just indent it. https://play.golang.org/p/2ulwl8orRlG On Fri, Apr 20, 2018 at 3:47 PM, Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > If your variable and function names don't explain what is going on, you > will encounter a big maintenance

Re: [go-nuts] Undocumented behaviour - panic exiting with exit code 2?

2018-03-06 Thread Rob Pike
Largely in agreement. Moved the conversation to the bug. On Wed, Mar 7, 2018 at 11:08 AM, Ian Lance Taylor <i...@golang.org> wrote: > On Tue, Mar 6, 2018 at 3:55 PM, Rob Pike <r...@golang.org> wrote: > > That's poor. Exit code 2 is supposed to mean 'incorrect argum

Re: [go-nuts] Undocumented behaviour - panic exiting with exit code 2?

2018-03-06 Thread Rob Pike
https://github.com/golang/go/issues/24284 On Wed, Mar 7, 2018 at 10:55 AM, Rob Pike <r...@golang.org> wrote: > That's poor. Exit code 2 is supposed to mean 'incorrect arguments' in the > Unix tradition. > > Something like 127 or 255 would be better. > > -rob > > O

Re: [go-nuts] Undocumented behaviour - panic exiting with exit code 2?

2018-03-06 Thread Rob Pike
That's poor. Exit code 2 is supposed to mean 'incorrect arguments' in the Unix tradition. Something like 127 or 255 would be better. -rob On Wed, Mar 7, 2018 at 10:39 AM, cachvico wrote: > Curious why panic appears to exit with code 2 ( >

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-25 Thread Rob Pike
No. As I said, there are no guarantees. As it says in https://golang.org/doc/go1compat: - Use of package unsafe. Packages that import unsafe may depend on internal properties of the Go implementation. We reserve the right to make changes to the

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-25 Thread Rob Pike
The main rule about unsafe is that your program might work or might not. There are no guarantees either way. That's why it's called 'unsafe' and why you shouldn't use it. Your program that 'works' today could break tomorrow. -rob On Mon, Feb 26, 2018 at 4:43 AM, Marvin Renich

Re: [go-nuts] Re: Go 1.10 is released

2018-02-19 Thread Rob Pike
You could say export GOCACHE=off in your bashrc to disable the cache permanently. -rob On Tue, Feb 20, 2018 at 8:00 AM, Henrik Johansson wrote: > Ok, good to know. Thanks! > > > On Mon, Feb 19, 2018, 21:49 Ian Lance Taylor wrote: > >> On Mon, Feb 19,

Re: [go-nuts] Re: All Forms of Wishful Generics

2018-02-19 Thread Rob Pike
Jesper, I find myself in rare but mild disagreement about your claims for stack-based virtual machines. Please have a look at this short paper about the Dis VM from Inferno: http://flint.cs.yale.edu/jvmsem/doc/inferno.ps We found a JIT for Dis could be tiny, especially compared to Java JITs, and

Re: [go-nuts] “Design Patterns: Elements of Reusable Object-Oriented Software” in Go

2018-02-07 Thread Rob Pike
Isn't the visitor pattern just a way to implement type switch in languages that don't implement type switch? That's certainly how I saw it when using C++. Go has a type switch, and so has no need for the visitor pattern, a perfect example of the principle that a design pattern is just a way to

Re: [go-nuts] get_tls macro and friends

2018-01-24 Thread Rob Pike
If you run go build with the -work flag, you can see the directory in which the build happens, and go_asm is written there. -rob On Thu, Jan 25, 2018 at 2:25 PM, Caleb Spare wrote: > Quick question about the Go assembler. > > I'm trying to use the get_tls and related macros

Re: [go-nuts] Re: select multiple expressions per case

2017-12-20 Thread Rob Pike
There is no particular reason, it was just to keep things simple, if it was even talked about. I don't think it was. If you want to propose a change, now is a good time to do that. Not sure the idea is above the bar, though. -rob On Thu, Dec 21, 2017 at 9:39 AM,

Re: [go-nuts] Re: Elphaba Chess

2017-12-01 Thread Rob Pike
Go is an open-source language. It's not "tied" to anything. Yes, Google invests in its development but so do other companies and many, many open source developers. It has a strong place in modern data centers but it is being used in just about every place imaginable now; some have even done kernel

Re: [go-nuts] newbie trying unusual sort

2017-11-07 Thread Rob Pike
Look at the "Example (SortKeys)" part of https://golang.org/pkg/sort/ -rob On Wed, Nov 8, 2017 at 12:38 PM, rob wrote: > Hi. I am trying to sort a slice of a struct using one of two different > fields. > > type directory struct { > name string > subtotal int64

Re: [go-nuts] Re: time.Parse with millisecond separated by colon

2017-10-30 Thread Rob Pike
Or you could change the : to a . and use time.Parse. -rob On Tue, Oct 31, 2017 at 4:47 AM, Jim Cote wrote: > See https://golang.org/src/time/format.go?s=23626:23672#L249. The > standard library is explicitly looking for the period. Your easiest > solution would be to

Re: [go-nuts] Re: log. Sprintf

2017-10-18 Thread Rob Pike
fmt.Fprintf is fine for concurrent use if you use it properly. It does a single write system call to the output once the result is created. C does not guarantee that, if that's how you came to think it unsafe. The same applies to log.Printf. -rob On Thu, Oct 19, 2017 at 6:48 AM, Alex Buchanan

Re: [go-nuts] nil maps

2017-10-17 Thread Rob Pike
A nil map is like a regular map but it has nothing in it, cannot grow, and takes zero space. -rob On Tue, Oct 17, 2017 at 5:31 PM, Christian Himpel wrote: > The spec defines: "A nil map is equivalent to an empty map except that no > elements may be added."

Re: [go-nuts] Re: param represents a bit in struct?

2017-10-15 Thread Rob Pike
C shouldn't support bitfields either, but that's off-topic. -rob On Mon, Oct 16, 2017 at 3:14 PM, Dave Cheney wrote: > Sorry, Go does not support C's bitfields > > > On Monday, 16 October 2017 14:50:48 UTC+11, sheepbao wrote: >> >> is golang has any like this represents a bit

Re: [go-nuts] Re: big.Int.SetString fails with string created with bytes.Buffer

2017-10-10 Thread Rob Pike
That's not necessary. As it says in the last part of the quoted documentation, In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer. Using NewBuffer to create an empty buffer is a mistake. -rob On Wed, Oct 11, 2017 at 2:47 AM, Marvin

Re: [go-nuts] big.Int.SetString fails with string created with bytes.Buffer

2017-10-10 Thread Rob Pike
You almost never want bytes.NewBuffer. Its only purpose is to load a buffer with existing data to be read using Buffer.Read. -rob On Tue, Oct 10, 2017 at 8:14 PM, wrote: > Oh yes, thank you. I totally missed that, thinking the bytes.Buffer was > preallocated with 4

Re: [go-nuts] Re: Copying slice over itself

2017-09-07 Thread Rob Pike
That test is only sufficient if the zeroth elements in the two slices are at the same address, which is often not true: https://play.golang.org/p/TH53Pxt5Do Two slices sharing an array will, however, share their last element. Here is a better test, but this is pretty magical stuff:

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-05 Thread Rob Pike
If you find that lines like if err != nil are a significant fraction of non-test code, your code probably needs a better error handling strategy, not a language change. I have done measurements in the past and although people complain a lot about the presence of that statement, it shows up much

Re: [go-nuts] Re: Reading bytes into uint32

2017-08-23 Thread Rob Pike
Apologies, typo. This is it: https://play.golang.org/p/9XWoCiUH2D On Thu, Aug 24, 2017 at 8:39 AM, Rob Pike <r...@golang.org> wrote: > I believe there is no safe (that is, unsafe-free) way to discover the > native byte order. In a sense, this is because depending on the native

Re: [go-nuts] Re: Reading bytes into uint32

2017-08-23 Thread Rob Pike
I believe there is no safe (that is, unsafe-free) way to discover the native byte order. In a sense, this is because depending on the native byte order is intrinsically unsafe. It is by definition not portable. It is a terrible design decision. By the way, that program may work but it's not

Re: [go-nuts] Reading bytes into uint32

2017-08-23 Thread Rob Pike
I know the use of native byte order didn't come from you, but that's lazy and wrong. https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html -rob On Thu, Aug 24, 2017 at 12:12 AM, Wojciech S. Czarnecki wrote: > On Wed, 23 Aug 2017 10:51:25 +0200 > Christian von

Re: [go-nuts] [ANN] Edit - Acme command language

2017-08-08 Thread Rob Pike
Grep for conquest. -rob On Wed, Aug 9, 2017 at 6:58 AM, roger peppe wrote: > On 8 August 2017 at 21:34, Michael Jones wrote: >> The Four Horsemen of the Apocalypse, surely! It would be tempting fate to >> shade them or step on their brand. > > Ah,

Re: [go-nuts] [ANN] Edit - Acme command language

2017-08-08 Thread Rob Pike
When I wrote that (1985?), I was misinformed about the Four Horsemen. Also now "u-" is redo. -rob On Tue, Aug 8, 2017 at 8:59 PM, roger peppe wrote: > It's nice to see this, but it would be nicer still if it > was amenable to representations that weren't > just a slice of

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

2017-07-27 Thread Rob Pike
Very few, though. Very few. As the proverb says: Gofmt's style is no one's favorite, yet gofmt is everyone's favorite. -rob On Thu, Jul 27, 2017 at 6:49 PM, Ecstatic Coder wrote: > Btw please don't take it

Re: [go-nuts] Why does this program carry test flags once compiled?

2017-07-24 Thread Rob Pike
I haven't got the context but I agree that importing the testing package outside of a test is a very bad idea. If I could, I would disallow it altogether. -rob -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Offline Go Documentation Tools

2017-07-24 Thread Rob Pike
The "go doc" (distinct from "godoc") command works fine offline. It fact it never goes on line. -rob On Tue, Jul 25, 2017 at 2:45 AM, Tyler Compton wrote: > For cursor-sensitive help dialogs, you may find Language Server > Protocol[1] interesting. It provides what you're

Re: [go-nuts] Re: default --help flag behavior

2017-07-19 Thread Rob Pike
The Unix tradition, fading away like all the other Unix traditions, is that exit code 0 is for success, 1 is for failed execution, and 2 is for reporting that the usage was incorrect, preventing it from running. Although one could make the case that "-help" did what it was supposed to do,

Re: [go-nuts] Programming paradigm.

2017-07-16 Thread Rob Pike
This might help. https://talks.golang.org/2012/splash.article -rob On Mon, Jul 17, 2017 at 3:13 AM, Mayank Acharya wrote: > Dear all, > I am new to Go language. > > I searched a lot to understand it's paradigm structure but still not > getting clear idea about that.

Re: [go-nuts] The log library

2017-07-11 Thread Rob Pike
The key word is simple. We wanted a minimum possible logging library that is easy to use and efficient, with the expectation that those wanting fancier, richer libraries could build their own and debate the right interface. That is exactly what has happened. See https://github.com/golang/glog for

Re: [go-nuts] Error in golang's playground example.

2017-07-11 Thread Rob Pike
It runs fine for me. I believe you might have typed something in that window. It is an editable box, and if you type something there unintentionally it may surprise you with an error. -rob On Wed, Jul 12, 2017 at 12:43 AM, wrote: > PFA > > -- > You received this

Re: [go-nuts] Re: API patterns for a function with a single argument that is rarely needed

2017-07-08 Thread Rob Pike
>From https://talks.golang.org/2012/splash.article: *One feature missing from Go is that it does not support default function arguments. This was a deliberate simplification. Experience tells us that defaulted arguments make it too easy to patch over API design flaws by adding more arguments,

Re: [go-nuts] Why the default format for nil slice and map is not nil?

2017-07-05 Thread Rob Pike
It's probably just me not thinking things through in the early days of building the Go libraries. There's a lot of that. Hindsight is easy; foresight not so much. -rob On Wed, Jul 5, 2017 at 11:46 PM, Yann Salaün wrote: > Hello, > > I was surprised to realize today that

Re: [go-nuts] Re: How to manage multiple versions of Go?

2017-06-25 Thread Rob Pike
I just use the shell for this: % cat bin/go1.4 #!/bin/sh export GOARCH=amd64 export GOOS=darwin export GOROOT=/home/r/go1.4 # Note! export GOBIN=$GOROOT/bin exec $GOBIN/go "$@" % Then when I want to run Go 1.4 tests, I just say "go1.4 build" instead of "go build". -rob On Mon, Jun 26, 2017

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

2017-06-15 Thread Rob Pike
Code comments can be helpful with unusual situations like this. -rob On Fri, Jun 16, 2017 at 4:25 AM, Goodwin Lawlor wrote: > Thanks for the explanation. > > My random guess was that it's the compiler version of deleting your > browser cache... If exit fails, blank

Re: [go-nuts] Re: remove last index of character from string and also want use strings.LastIndex(s, sep string)

2017-05-27 Thread Rob Pike
blog.golang.org/slices and blog.golang.org/strings -rob On Sat, May 27, 2017 at 11:14 AM, wrote: > I find the method like: > > package main > > > import ( > "fmt" > "strings" > "unicode/utf8" > ) > > > func main() { > var str = "a/b/汉字/d/汉字" > var _, size =

Re: [go-nuts] Problem with HINDI NAMES

2017-05-25 Thread Rob Pike
This is https://github.com/golang/go/issues/5167. See also https://github.com/golang/go/issues/16033. -rob On Fri, May 26, 2017 at 1:15 AM, Bakul Shah wrote: > In other words, you should file a bug report (but technically it is a > language change). > > For Go purposes

  1   2   >