Re: [go-nuts] global goroutine data / thread local storage?

2020-09-26 Thread Ian Lance Taylor
On Fri, Sep 25, 2020 at 6:36 PM Alex Besogonov wrote: > > On Friday, September 25, 2020 at 4:43:45 PM UTC-7 Ian Lance Taylor wrote: >> >> On Fri, Sep 25, 2020 at 10:35 AM Alex Besogonov >> wrote: >> > >> > Inheritable goroutine-locals would actuall

Re: [go-nuts] global goroutine data / thread local storage?

2020-09-26 Thread Ian Lance Taylor
or _, p := range s { p := p go func() { atomic.Add(, p.SlowMethod()) }() } } but the two functions would work very differently. Ian > On Friday, September 25, 2020 at 4:43:45 PM UTC-7 Ian Lance Taylor wrote: >> >> On Fri, Sep 25, 2020 at

Re: [go-nuts] global goroutine data / thread local storage?

2020-09-25 Thread Ian Lance Taylor
On Wednesday, September 23, 2020 at 5:55:50 PM UTC-7 Ian Lance Taylor wrote: >> >> On Wed, Sep 23, 2020 at 5:46 PM Alex Mills wrote: >> > >> > There appears to be a way to get a reference on the goroutine id: >> > >> > http://blog.sgmansfield.com/2015/12/

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

2020-09-25 Thread Ian Lance Taylor
On Fri, Sep 25, 2020 at 4:03 PM Ryan Keppel wrote: > > Does golang generate the SSE2 over the x87 floating point instructions on > x64? In Java terms, it's always using strictfp? You could check the assembly > I suppose. On amd64 the Go compiler uses SSE2. It does not use x87. However, the

Re: [go-nuts] global goroutine data / thread local storage?

2020-09-24 Thread Ian Lance Taylor
oroutine IDs are not reused. (Well, a goroutine ID is just a 64-bit integer so it could technically wrap around and be reused in that way, but it seems unlikely.) Ian > On Wed, Sep 23, 2020 at 5:54 PM Ian Lance Taylor wrote: >> >> On Wed, Sep 23, 2020 at 5:46 PM Alex Mills wro

Re: [go-nuts] global goroutine data / thread local storage?

2020-09-23 Thread Ian Lance Taylor
On Wed, Sep 23, 2020 at 5:46 PM Alex Mills wrote: > > There appears to be a way to get a reference on the goroutine id: > > http://blog.sgmansfield.com/2015/12/goroutine-ids/ But as you can see by reading that blog article, that is almost a joke. Go considers these things to be better handled

Re: [go-nuts] Evaluation order of return

2020-09-23 Thread Ian Lance Taylor
On Wed, Sep 23, 2020 at 1:10 AM cs.ali...@gmail.com wrote: > > I am not actually questioning the current design, as you both said it is not > a good practice to call a return statement as I wrote above, I am trying to > understand the relation between memory, interface and order of evaluation.

Re: [go-nuts] Windows Write Call Error when Writing to Network mapped Folder.

2020-09-23 Thread Ian Lance Taylor
all rc.Write with a function literal that calls unix.WriteFile with the handle. Ian > On Tue, Sep 22, 2020 at 9:04 PM Ian Lance Taylor wrote: >> >> On Tue, Sep 22, 2020 at 11:14 AM helhadad wrote: >> > >> > Hi Folks, >> > I am trying to create file and w

Re: [go-nuts] Windows Write Call Error when Writing to Network mapped Folder.

2020-09-22 Thread Ian Lance Taylor
On Tue, Sep 22, 2020 at 11:14 AM helhadad wrote: > > Hi Folks, > I am trying to create file and write to it on a network mapped drive, which I > can access, create, delete and edit files using windows explorer or CMD > (Windows 10/Server 2016). > > You can find all details of the issue and

Re: [go-nuts] [generics] Typo for type with type argument

2020-09-21 Thread Ian Lance Taylor
On Mon, Sep 21, 2020 at 9:08 AM Christian Persson wrote: > > I have found a small typo in the current draft for generics. In the section > "Function argument type inference" >

Re: [go-nuts] Evaluation order of return

2020-09-21 Thread Ian Lance Taylor
On Mon, Sep 21, 2020 at 9:34 AM 'Axel Wagner' via golang-nuts wrote: > > The evaluation order is defined here: > https://golang.org/ref/spec#Order_of_evaluation > The important part is that the order of evaluation in a return statement is > only defined for function calls, method calls and

Re: [go-nuts] flag: bug with shared values?

2020-09-18 Thread Ian Lance Taylor
On Fri, Sep 18, 2020 at 12:50 AM Manfred Touron wrote: > > 1. if I need to open an issue or not on the go repo, if the fix is not about > code, it can be about doc maybe? Documentation fixes are always welcome. You can open an issue or just send a change. > 2. if other gophers has ideas of

Re: [go-nuts] Why does interface type carries pointer to basic types but not values itself?

2020-09-18 Thread Ian Lance Taylor
On Fri, Sep 18, 2020 at 10:31 AM Никифор Серяков wrote: > > Lets imagine this code. > > ```go > var i int > > func main() { > i = 3 > > F(i) > } > > var q interface{} > > //go:noinline > func F(a interface{}) { > q = a > } > ``` > > then run `go tool compile -S ~/a.go` > > Skipping

Re: [go-nuts] Cloud the current generic draft constraint a type parameter must be exactly some types

2020-09-18 Thread Ian Lance Taylor
On Fri, Sep 18, 2020 at 10:07 AM tapi...@gmail.com wrote: > > instead of sharing the same underlying types with some types? In the current design draft, the answer is yes, but only for non-predeclared defined types.

Re: [go-nuts] flag: bug with shared values?

2020-09-17 Thread Ian Lance Taylor
On Thu, Sep 17, 2020 at 5:04 PM Manfred Touron wrote: > > I think that I discovered a bug in the stdlib flag package: > > sharedFlag := "init-value" > fooFs := flag.NewFlagSet("foo", flag.ContinueOnError) > barFs := flag.NewFlagSet("bar", flag.ContinueOnError) > fooFs.StringVar(,

Re: [go-nuts] Catch/handle cgo SIGSEGV

2020-09-17 Thread Ian Lance Taylor
t could be safe. But it would not be safe for a C signal handler to call a Go function that calls panic. That would leave the program with most signals blocked. Ian > Ian Lance Taylor a következőt írta (2020. szeptember 17., csütörtök, 21:00:52 > UTC+2): >> >> On Thu, Sep 17, 202

Re: [go-nuts] Catch/handle cgo SIGSEGV

2020-09-17 Thread Ian Lance Taylor
On Thu, Sep 17, 2020 at 8:52 AM Tamás Gulácsi wrote: > > I'm searching for help in https://github.com/godror/godror/issues/100 - I've > added a recover, called debug.SetPanicOnFault, without success: the extra > free still panics with SIGSEGV, and the recover does not catch it (or I coded > it

Re: [go-nuts] RISCV & Golang custom-compilations ahead?

2020-09-13 Thread Ian Lance Taylor
On Sun, Sep 13, 2020 at 1:50 AM josvazg wrote: > > This is not a proposal, just a curiosity question to check if anyone in the > Go ecosystem has already thought on this issue and have some solutions in > mind. > > I might be late to this realization, but nowadays is pretty clear Intel >

Re: [go-nuts] alloc vs totalalloc in memory

2020-09-11 Thread Ian Lance Taylor
ocated for heap objects. If that is not clear, what is not clear about it? Ian > On Thursday, September 10, 2020 at 6:40:34 PM UTC-7 Ian Lance Taylor wrote: >> >> On Thu, Sep 10, 2020 at 4:39 PM Alexander Mills >> wrote: >> > >> > I have this helper fun

Re: [go-nuts] Proposal: auto return String instead of []byte if requested

2020-09-11 Thread Ian Lance Taylor
On Fri, Sep 11, 2020 at 9:45 AM Kevin Chadwick wrote: > > I apologise if this has already been discussed. Google didn't turn up anything > directly related. > > If you read a file using the following that returns a byte slice. > > tlsCertb, err := ioutil.ReadFile("/etc/ssl/mycert") > if err !=

Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Ian Lance Taylor
xited leaving detached thread which waiting in >> futex_wait_queue_me is still present. >> >> The main issue is I am not able to reproduce this, since this go process is >> very big. >> >> Any way to verify this OR take it further. >> >> Thanks &

Re: [go-nuts] alloc vs totalalloc in memory

2020-09-10 Thread Ian Lance Taylor
On Thu, Sep 10, 2020 at 4:39 PM Alexander Mills wrote: > > I have this helper func to print memory usage (detect a memory leak?) > > > func PrintMemUsage() { > var m runtime.MemStats > runtime.ReadMemStats() > // For info on each, see: https://golang.org/pkg/runtime/#MemStats > fmt.Printf("Alloc

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-10 Thread Ian Lance Taylor
e quotes because otherwise gdb will think it is a structure field reference). At least, gdb works that way on GNU/Linux, not sure about your operating system. Ian > On Thursday, September 10, 2020 at 12:15:04 PM UTC+9 Ian Lance Taylor wrote: >> >> On Wed, Sep 9, 2020 at

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-10 Thread Ian Lance Taylor
If I recall correctly, __tls_get_addr (which is of course a general utility that has nothing particularly to do with Go) will return the address of runtime.g for the thread that calls it. Ian > On Thursday, September 10, 2020 at 12:15:04 PM UTC+9 Ian Lance Taylor wrote: >> >> On

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-09 Thread Ian Lance Taylor
On Wed, Sep 9, 2020 at 7:39 PM Yonatan Gizachew wrote: > > This might be trivial, but could you explain me the relationship between the > following? > 1. value returned by __tls_get_addr This is the address of the TLS control block. The exact definition depends on the architecture. All TLS

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-09 Thread Ian Lance Taylor
On Wed, Sep 9, 2020 at 7:26 PM Yonatan Gizachew wrote: > > Is there any known problems that could appear when we run golang C-shared > libraries in an OS that uses a non-preemptive scheduling mechanism. I am > experiencing some problems related to TLS (more specifically runtime.m0 and >

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Ian Lance Taylor
On Wed, Sep 9, 2020 at 4:59 AM Jan Mercl <0xj...@gmail.com> wrote: > > If the intent is to have Go alignments/offsets of types compatible > with the C ABI then I think it's safe to say this is a bug. > > And the existence of the syscall package, in some cases passing > Go-defined structs to the

Re: [go-nuts] Re: why the binary generated by go test has no symbol table

2020-09-08 Thread Ian Lance Taylor
On Tue, Sep 8, 2020 at 7:04 PM buaa...@gmail.com wrote: > > I wrote a tool to get binary file's symbol table during initialization, and > do some special tests, but it fails on Linux, so I get the log like: > > $ go test > 2020/09/09 10:02:44 reading /tmp/go-build334351549/b001/xxx.test: no

Re: [go-nuts] [ generics ] Added constraint type inference to the design draft

2020-09-08 Thread Ian Lance Taylor
On Tue, Sep 8, 2020 at 5:47 PM Steven Blenkinsop wrote: > > Reading over the pointer method example, I noticed that a derived type cannot > be inferred in a nested call while leaving method constraints intact: > > type DerivedTypeConstraint[T any] interface { > type *T > Method() > } > > func

Re: [go-nuts] Re: why the binary generated by go test has no symbol table

2020-09-08 Thread Ian Lance Taylor
On Mon, Sep 7, 2020 at 7:07 PM buaa...@gmail.com wrote: > > There is no ldflags provided, so why the symbol table is stripped Because if you run "go test" without the -c option, the executable is built, run, and then thrown away. There no reason to spend time generating debugging information

Re: [go-nuts] Syntactic analysis with Gocc

2020-09-08 Thread Ian Lance Taylor
On Tue, Sep 8, 2020 at 11:56 AM Abraham wrote: > > Hi, I am trying to implement a parser with Gocc. This is the file with the > definition of the grammar. ... > However the parse input, I am not able to correctly read the latest > production of Opc (MLinea) and a syntax error. I think the

Re: [go-nuts] cgo cross compilation to arm failed

2020-09-07 Thread Ian Lance Taylor
On Sun, Sep 6, 2020 at 1:53 PM 'Hubert Hirtz' via golang-nuts wrote: > > I am trying to cross-compile a project that depends on sqlite3 on a > amd64 machine (host) for an armhf machine (target), using clang with the > appropriate "--target" flag. > > The build fails on runtime/cgo with the

Re: [go-nuts] zombie parent scenario with golang

2020-09-07 Thread Ian Lance Taylor
Go runtime ? If the process is defunct, then none of the thread stacks matter. They are just where the thread happened to be when the process exited. What is the real problem you are seeing? Ian > On Thursday, August 27, 2020 at 1:43:39 PM UTC-7 Ian Lance Taylor wrote: >>

Re: [go-nuts] Asynchronous preemption

2020-09-04 Thread Ian Lance Taylor
stuck in a system call for a while, and detach them from their P, and start running a new thread associated with that P. This is scheduler activity, and it permits additional parallelism in the program, but it's not preemption. Ian > On Thursday, September 3, 2020 at 12:35:26 PM UTC+9 Ian Lance Tay

Re: [go-nuts] Deep printing in the reflect package

2020-09-04 Thread Ian Lance Taylor
eems popular, and then consider whether to bring it into the standard library. You suggest that traversing nested data structure is reflect's domain, but I'm not sure I agree. The only current case is reflect.DeepEqual. Ian > On Friday, September 4, 2020 at 4:24:23 PM UTC-4 Ian Lance Taylor wrote: >> &

Re: [go-nuts] What is The compiler's -json optimization logging

2020-09-04 Thread Ian Lance Taylor
[ + drchase ] On Fri, Sep 4, 2020 at 1:16 PM Falco Wockenfuß wrote: > > sorry if this is a dumb question, but the Release Notes for go 1.15 have the > Note: > The compiler's -json optimization logging now reports large (>= 128 byte) > copies and includes explanations of escape analysis

Re: [go-nuts] Deep printing in the reflect package

2020-09-04 Thread Ian Lance Taylor
On Fri, Sep 4, 2020 at 1:11 PM aind...@gmail.com wrote: > > Often on my team, Go programmers (particularly new ones) simply want full > visibility into a data structure when debugging. For those who aren't > familiar with pointers, seeing a hexadecimal number show up in a log can be > really

Re: [go-nuts] Asynchronous preemption

2020-09-02 Thread Ian Lance Taylor
On Wed, Sep 2, 2020 at 7:14 PM Yonatan Gizachew wrote: > > Is it possible to stop the asynchronous preemption like: > GODEBUG=asyncpreemptoff=1 go build -o libgotest.so -buildmode=c-shared > -compiler=gccgo test.go > > I am using gccgo compiler. Note that executables built by the gccgo compiler

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2020-09-02 Thread Ian Lance Taylor
On Wed, Sep 2, 2020 at 3:45 AM targe...@gmail.com wrote: > > > Other people have said this too, but I want to emphasize that there > are not 4 potential states of an interface value. There are 2 > potential states: 1) interface does not hold any value, and is == nil; > 2) interface holds a value,

Re: [go-nuts] cgo godefs questions

2020-09-01 Thread Ian Lance Taylor
On Tue, Sep 1, 2020 at 12:10 AM 'Dan Kortschak' via golang-nuts wrote: > > I am working on some C/Go interop code that includes this horror on the > C side (TYPE_BITS is 5 and NAMED_BITS is 16): > > ``` > struct sxpinfo_struct { > SEXPTYPE type : TYPE_BITS; >

Re: [go-nuts] [generics] Bugs + something else

2020-08-31 Thread Ian Lance Taylor
On Mon, Aug 31, 2020 at 5:49 PM p...@pjebs.com.au wrote: > > 1. > For this Go 2 snippet: https://go2goplay.golang.org/p/vbfBBmjxaMi > > Why can't I use square brackets when calling the constructor? Sorry, the Go 2 playground isn't fully up to date. > 2. Variadic `any` types + allowing a called

Re: [go-nuts] Re: [ generics] Moving forward with the generics design draft

2020-08-31 Thread Ian Lance Taylor
On Mon, Aug 31, 2020 at 10:25 AM samir.el...@gmail.com wrote: > > Great improvements. Well done. > > Any intentions to make methods accept additional type arguments ? See https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#No-parameterized-methods . Ian

Re: [go-nuts] rin: return if nil syntactic sugar

2020-08-30 Thread Ian Lance Taylor
On Sun, Aug 30, 2020 at 7:16 PM Zakaria bin Haris wrote: > > Idk if this has been proposed or discussed before. > > Given the last error handling abbreviation proposal is rejected. How about > some simple syntactic sugar like this: > > rin Something() > > Which is just a sugar for: > > if

Re: [go-nuts] Memory Leak in bytes.Buffer String() method

2020-08-30 Thread Ian Lance Taylor
On Sun, Aug 30, 2020 at 8:25 AM Sarath Prabath Redlapalli Jaya wrote: > > Hi, we've been observing high memory usage in the following code > https://github.com/Masterminds/squirrel/blob/master/placeholder.go#L113 > > We measured from pprof of heap > > (pprof) top20 > > Showing nodes accounting

Re: [go-nuts] Re: Memory Leak in bytes.Buffer String() method

2020-08-30 Thread Ian Lance Taylor
On Sun, Aug 30, 2020 at 8:28 AM Sarath Prabath Redlapalli Jaya wrote: > > The memory usage of containers are ever increasing and has grown from 100 MB > to ~ 1 GB in couple of hours. Not able to understand where the gap is, even > though the the builder is being reset. Would keeping a sync.Pool

Re: [go-nuts] about go tool link, where link get code(text segment) from *.o files and write it to executable files?

2020-08-30 Thread Ian Lance Taylor
On Sun, Aug 30, 2020 at 7:32 AM xie cui wrote: > > i am trying to understand code of cmd/link, i need to know where linker get > instructions(text segment in executable file) from *o file, and where linker > write the binary data (.text segment) to excutable file(in linux it 's a elf > file).

Re: [go-nuts] How to correctly run test in Golang source code directory runtime?

2020-08-28 Thread Ian Lance Taylor
On Fri, Aug 28, 2020 at 9:35 AM Chai Baoyang <88304...@qq.com> wrote: > > Hi All, > I tried to run "go test -timeout 30s -run ^TestMemStats$" in the source > directory runtime. But failed with error infomation below: > "error.go:7:8: use of internal package internal/bytealg not allowed >

Re: [go-nuts] zombie parent scenario with golang

2020-08-27 Thread Ian Lance Taylor
On Thu, Aug 27, 2020 at 10:01 AM Uday Kiran Jonnala wrote: > > I have a situation on zombie parent scenario with golang > > A process (in the case replicator) has many goroutines internally > > We hit into panic() and I see the replicator process is in Zombie state > > <<>>>:~$ ps -ef | grep

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2020-08-27 Thread Ian Lance Taylor
On Thu, Aug 27, 2020 at 3:53 AM targe...@gmail.com wrote: > > Please don't forget that interface pointer isn't simple. It's a so-called > "fat pointer" which consists of pointer to data and pointer to methods table. > Thus, we have 4 potential states - (nil, nil), (nil, pointer), (pointer, nil)

Re: [go-nuts] Naming environment variables

2020-08-26 Thread Ian Lance Taylor
On Wed, Aug 26, 2020 at 8:03 AM Siddhesh Divekar wrote: > > What is the convention to name an environment variable if the program is > going to set it and use it. > I have seen both ABC_DEF & AbcDef forms of it. Do you mean the name used for the environment variable, or the name used in the Go

Re: [go-nuts] Re: Generics and parentheses

2020-08-25 Thread Ian Lance Taylor
Thanks for the note. Please see the discussion at https://groups.google.com/d/msg/golang-nuts/iAD0NBz3DYw/VcXSK55XAwAJ . Ian On Tue, Aug 25, 2020 at 1:21 PM Kaveh Shahbazian wrote: > > After playing in generics playground with a dozen of cases that came to my > mind, IMHO brackets seem to be

Re: [go-nuts] Possible reasons for a segmentation fault inside mallocgc during package importing

2020-08-24 Thread Ian Lance Taylor
On Mon, Aug 24, 2020 at 7:05 PM Yonatan Gizachew wrote: > > We were trying to run a go c-shared library on a emulator (Written in C/C++). > We use gccgo compiler to create .so file from test.go file, so that the > runtime could be liked dynamically. Currently we are facing a problem while >

Re: [go-nuts] Generics - type inference - which type parameters?

2020-08-24 Thread Ian Lance Taylor
On Mon, Aug 24, 2020 at 4:34 PM Patrick Smith wrote: > > I may be missing something, but it seems to me that one point in the draft's > discussion of type inference could usefully be clarified >

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-24 Thread Ian Lance Taylor
On Thu, Aug 20, 2020 at 9:54 PM Ian Lance Taylor wrote: > > Our intent here is that "any" will be available for all code. Yes, we > wouldn't do it if it weren't for its use as a type constraint. But if > we are going to do it for type constraints, there seems

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2020-08-23 Thread Ian Lance Taylor
On Sun, Aug 23, 2020 at 1:16 PM Denis Cheremisov wrote: > > You may use something like this > > value2 := *(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer()) + > 8)) > if value2 == 0 { > return true > } > > on AMD64, should work also for any 64 bit

Re: [go-nuts] Re: [ generics] Moving forward with the generics design draft

2020-08-23 Thread Ian Lance Taylor
On Sun, Aug 23, 2020 at 3:00 PM Juliusz Chroboczek wrote: > > > We’re going to permit type switches on type parameters that have type > > lists, without the “.(type)” syntax. The “(.type)” syntax exists to > > clarify code like “switch v := x.(type)”. > > Could you please give an example of the

Re: [go-nuts] how golang choose instructions?

2020-08-23 Thread Ian Lance Taylor
On Sat, Aug 22, 2020 at 10:31 PM xie cui wrote: > > we can find same dynamic programming algorithm(like BURS bottom rewriting > system), to choose instructions in book about compiler technique. but as far > as i know, it seems that golang just transform ast to ssa IR, then lower to > machine

Re: [go-nuts] Go routines stuck in runtime_pollwait

2020-08-22 Thread Ian Lance Taylor
On Sat, Aug 22, 2020 at 12:06 PM Siddhesh Divekar wrote: > > We saw an issue with our process running in k8s on ubuntu 18.04. > Most of the go routines are stuck for several minutes in http/http2 net code. > > Have you seen similar issues ? > > goroutine 2800143 [select, 324 minutes]: >

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread Ian Lance Taylor
On Fri, Aug 21, 2020, 9:16 PM 'Dan Kortschak' via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Sat, 2020-08-15 at 21:44 -0700, Ian Lance Taylor wrote: > > On Sat, Aug 15, 2020 at 3:45 PM 'Dan Kortschak' via golang-nuts > > wrote: > > > > >

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-21 Thread Ian Lance Taylor
On Fri, Aug 21, 2020 at 3:03 PM Axel Wagner wrote: > > On Fri, Aug 21, 2020 at 11:46 PM Ian Lance Taylor wrote: >> >> Yes, there are various such possibilities. >> >> What jimmy frasche said above is correct: nothing changes in the case >> of a type switc

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-21 Thread Ian Lance Taylor
the type or pass it >> to a function taking an interface compatible with the constraint. >> Also, I shudder to even imagine how this could be put into a spec. >> >>> >>> >>> >>>> On Fri, Aug 21, 2020 at 2:07 PM roger peppe wrote: >>>> > >&

Re: [go-nuts] Unique GO language features

2020-08-21 Thread Ian Lance Taylor
On Fri, Aug 21, 2020 at 10:16 AM joseph.p...@gmail.com wrote: > > I really like the 'defer' statement and think it would be a useful addition > to other programming languages. I believe that Swift has also added a defer statement, which I assume was based on the idea in Go. > The feature where

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-21 Thread Ian Lance Taylor
On Thu, Aug 20, 2020, 11:22 PM Bakul Shah wrote: > On Aug 20, 2020, at 5:27 PM, Ian Lance Taylor wrote: > > > 3. > > > > We’re going to clarify that when considering the operations permitted > > for a value whose type is a type parameter, we will ignore the method

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-21 Thread Ian Lance Taylor
On Fri, Aug 21, 2020, 12:37 AM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Just to clarify, the intent is to make the declaration in the spec `type > any = interface{}`, not `type any interface{}`, correct? The latter would > be more analogous to `error`. Either has

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-20 Thread Ian Lance Taylor
On Thu, Aug 20, 2020 at 8:28 PM jimmy frasche wrote: > > To clarify on the type switches, would it have to be used like this: > > type C interface { > type X, Y > } > > func f(x X) X { > return x > } > > func g[T C](v T) T { > switch v { > case X: > // to use v as an X > // we

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-20 Thread Ian Lance Taylor
On Thu, Aug 20, 2020 at 8:52 PM burak serdar wrote: > > On Thu, Aug 20, 2020 at 8:22 PM Jan Mercl <0xj...@gmail.com> wrote: > > > > On Fri, Aug 21, 2020 at 2:28 AM Ian Lance Taylor wrote: > > > > > To simplify the common case of a type parameter that has

[go-nuts] [ generics] Moving forward with the generics design draft

2020-08-20 Thread Ian Lance Taylor
After many discussions and reading many comments, we plan to move forward with some changes and clarifications to the generics design draft. 1. We’re going to settle on square brackets for the generics syntax. We’re going to drop the “type” keyword before type parameters, as using square

Re: [go-nuts] Why was islibrary not set correctly when using -buildmode=c-shared with gccgo compiler

2020-08-18 Thread Ian Lance Taylor
19, 2020 at 8:52:48 AM UTC+9 Ian Lance Taylor wrote: >> >> On Mon, Aug 17, 2020 at 10:42 PM Yonatan Gizachew wrote: >> > >> > Sorry I couldn't provide code to reproduce the case, but I just wanted to >> > know if there are known cases for my issue. >>

Re: [go-nuts] Why was islibrary not set correctly when using -buildmode=c-shared with gccgo compiler

2020-08-18 Thread Ian Lance Taylor
On Mon, Aug 17, 2020 at 10:42 PM Yonatan Gizachew wrote: > > Sorry I couldn't provide code to reproduce the case, but I just wanted to > know if there are known cases for my issue. > From the golang source code, in the runtime library proc.go file there is > this code snippet >

Re: [go-nuts] [generics] Type list syntax

2020-08-18 Thread Ian Lance Taylor
On Tue, Aug 18, 2020 at 1:48 PM Frederik Zipp wrote: > > Ian Lance Taylor schrieb am Dienstag, 18. August 2020 um 21:26:23 UTC+2: >> >> What would it mean to permit any type as a constraint? > > > Each type would match exactly the same types it would match in a plai

Re: [go-nuts] New linker

2020-08-18 Thread Ian Lance Taylor
On Sat, Aug 15, 2020 at 11:49 PM Amnon wrote: > > Austin's doc refers to your idea of a new object format for the 21st century. > Has anyone developed that? No, that is still just a thought. > As someone who has been writing linkers since 1988, (most famously the Gold > linker), and who has a

Re: [go-nuts] [generics] Type list syntax

2020-08-18 Thread Ian Lance Taylor
On Tue, Aug 18, 2020 at 11:29 AM Frederik Zipp wrote: > > The more I think about it the less I understand why type list should reside > inside interfaces. I can only think of two reasons: > > 1) Avoid a new keyword for type lists. > 2) The idea that only interfaces should be able to act as

Re: [go-nuts] [generics] Type list syntax

2020-08-18 Thread Ian Lance Taylor
On Tue, Aug 18, 2020 at 7:38 AM Frederik Zipp wrote: > > The draft syntax for type lists is a comma separated list: > > type SignedInteger interface { > type int, int8, int16, int32, int64 > } > > Wouldn't it be more consistent with existing Go syntax regarding types if it > was a

Re: [go-nuts] [generics] Constraint type inference not working

2020-08-17 Thread Ian Lance Taylor
On Sun, Aug 16, 2020 at 7:42 AM jake...@gmail.com wrote: > > When I try the example from the "Constraint type inference" section of the > Draft Design: > https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#constraint-type-inference > it does not seem to

Re: [go-nuts] How to build an object file for a specific GOOS and GOARCH with external linker?

2020-08-17 Thread Ian Lance Taylor
On Sun, Aug 16, 2020 at 12:53 AM rotusm...@gmail.com wrote: > > i took your suggestions, tried the '-work' option it showed me the temporary > directory where the build files are stored, but they didn't contain the > object file. After exploring that a little, i found out out that the 'go >

Re: [go-nuts] Re: What does "ex-wait-release" mean?

2020-08-17 Thread Ian Lance Taylor
On Mon, Aug 17, 2020 at 8:56 AM jake...@gmail.com wrote: > > See https://groups.google.com/g/golang-dev/c/qtxOW0x4Rrw/m/WqepX5V6AQAJ on > the golang-dev forum. It mean that it was wait-release but the tree is now > open for development. And the new tag helps us find CLs that were postponed

Re: [go-nuts] Generics and parentheses

2020-08-17 Thread Ian Lance Taylor
On Mon, Aug 17, 2020 at 10:13 AM Jonathan Gerber wrote: > > 1) Of the enumerated omissions, the ones that I think are really unfortunate > are, in order of importance, from my perspective: > > No operator methods & no adapters - Doesn't this make generic types sort of > second class?. I think

Re: [go-nuts] Memory synchronization by channel operations and mutexes

2020-08-17 Thread Ian Lance Taylor
On Mon, Aug 17, 2020 at 9:06 AM jake...@gmail.com wrote: > > My understanding is that atomic does not 'synchronize memory' in general. If > you use a Mutex, then everything that happened before is 'synchronized'. If > you use atomic then only the atomic variable is 'synchronized'. That is kind

Re: [go-nuts] [generics]: Pointer methods in interfaces used as constraints?

2020-08-15 Thread Ian Lance Taylor
On Fri, Aug 14, 2020 at 9:31 PM Patrick Smith wrote: > > https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#pointer-method-example > has this example: > > // Setter2 is a type constraint that requires that the type > // implement a Set method that sets

Re: [go-nuts] New linker

2020-08-15 Thread Ian Lance Taylor
On Sat, Aug 15, 2020 at 11:49 AM Amnon wrote: > > What is the best place to read about the ongoing work on the new linker? > With the Go 1.15 release, how far along are we with the plans? > What has been achieved? > And what is still to come? The work on the new linker is close to complete and

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-15 Thread Ian Lance Taylor
On Sat, Aug 15, 2020 at 3:45 PM 'Dan Kortschak' via golang-nuts wrote: > > I would like to be able to obtain the original type for an alias given > a source input. I can see in "go/types" that it's possible to know > whether a named type is an alias by `typ.Obj().IsAlias()`, but I cannot > see

Re: [go-nuts] [ generics ] Concrete example of comparables and generic function types

2020-08-14 Thread Ian Lance Taylor
On Thu, Aug 13, 2020 at 8:37 PM Beka Westberg wrote: > > Hello! I just ran into a problem that is solved really nicely with the new > generics proposal and I thought someone might find it interesting :D > > I was trying to implement a library for doing ascii art programmatically. The > main

Re: [go-nuts] How to build an object file for a specific GOOS and GOARCH with external linker?

2020-08-14 Thread Ian Lance Taylor
On Fri, Aug 14, 2020 at 8:29 AM wrote: > > i'm trying to create an object file by using "go build" for GOOS=linux > GOARCH=386. > My current go environment has GOOS=linux GOARCH=amd64. > > i know that go build directly builds and links the files, but i want to link > files using an external

Re: [go-nuts] [ generics ] Added constraint type inference to the design draft

2020-08-13 Thread Ian Lance Taylor
On Thu, Aug 13, 2020 at 3:09 PM roger peppe wrote: > > I do feel that the "all or nothing" nature of type parameter lists (if you > specify one type parameter, you must explicitly specify all of the others > too, even if they could otherwise be inferred) is likely to get in the way > here. I'd

Re: [go-nuts] [generics] Was "no type contracts" considered?

2020-08-13 Thread Ian Lance Taylor
On Wed, Aug 12, 2020 at 9:58 AM Markus Heukelom wrote: > > > > On Mon, Aug 10, 2020 at 8:30 PM Ian Lance Taylor wrote: >> >> Go is a strictly typed languages, and constraints are the meta-types >> of type parameters. > > > I just realised there might

Re: [go-nuts] Go1.15 + SQLite Driver + Windows + Ld.exe results in ld error "unrecognized option --high-entropy-va"

2020-08-13 Thread Ian Lance Taylor
On Thu, Aug 13, 2020 at 12:01 PM Corey Gilmore wrote: > > Setup: > - Go 1.15 > - https://github.com/mattn/go-sqlite3 SQL driver > - Windows 10 (2004) > - Ld.exe (via MingW via TDM-GCC), version 2.25 > > Prior to go1.15, running "go run main.go" or "go build" would work without > issue. With

Re: [go-nuts] [ generics ] Added constraint type inference to the design draft

2020-08-13 Thread Ian Lance Taylor
On Thu, Aug 13, 2020 at 9:22 AM jimmy frasche wrote: > > Would the constraints package have Pointer[E], Slice[E], and so on? Good question. I don't know. We can certainly add them if we see people using them. > What happens if you have > type SC(type E I) interface { > type []E > } >

Re: [go-nuts] Is there any plan for go plugin .so can be used by different version of go from compiled?

2020-08-13 Thread Ian Lance Taylor
On Thu, Aug 13, 2020 at 9:21 AM zhizhao wang wrote: > > If go plugin .so used by different version of go from compiled, the different > package error will occur. > So is there any plan to fix this problem? I am not aware of anybody working on this. It's a very hard problem. Ian -- You

[go-nuts] [ generics ] Added constraint type inference to the design draft

2020-08-12 Thread Ian Lance Taylor
I just added a new section to the generics design draft describing constraint type inference. This is a generalization and simplification of the earlier pointer method approach, which has now been removed. I would be happy to hear any comments. Thanks.

Re: [go-nuts] Seperate debuginfo?

2020-08-12 Thread Ian Lance Taylor
On Wed, Aug 12, 2020 at 8:43 AM ethan.pailes via golang-nuts wrote: > > The C ecosystem allows one to generate a separate file containing debug info > so that you can initially install a stripped library or binary and then only > pull in the debug info as needed. I'm interested in doing the

Re: [go-nuts] Generics: after type lists

2020-08-11 Thread Ian Lance Taylor
t doesn't mean we shouldn't consider it. But it does mean that we should also consider how likely it is to arise. Ian > > On Aug 11, 2020, at 10:31 PM, Ian Lance Taylor wrote: > > > > On Tue, Aug 11, 2020 at 4:19 PM Patrick Smith wrote: > >> > >> On Sun,

Re: [go-nuts] Generics: after type lists

2020-08-11 Thread Ian Lance Taylor
On Tue, Aug 11, 2020 at 4:19 PM Patrick Smith wrote: > > On Sun, Aug 9, 2020 at 6:29 PM Ian Lance Taylor wrote: > > If we accept this argument, then in Go it wouldn't be appropriate to > > write a single function that works on both builtin and user-defined > > ty

Re: [go-nuts] How do disable vDSO for i386 and use linker script?

2020-08-11 Thread Ian Lance Taylor
On Tue, Aug 11, 2020 at 12:26 PM wrote: > > I also have a quick follow up question based on #1 here: > > >> 1. Is it possible to completely disable use of the vDSO for i386/Linux > >> programs? If so, is this done at build time, or automatically by the go > >> runtime? > > >There is no way to

Re: [go-nuts] How do disable vDSO for i386 and use linker script?

2020-08-11 Thread Ian Lance Taylor
On Tue, Aug 11, 2020 at 8:12 AM wrote: > > I am attempting to build a simple hello-world go program for a custom > operating system that provides compatibility with a subset of Linux syscalls > through the INT 0x80 syscall inferface. > > My understanding is that go uses the Linux vDSO for time

Re: [go-nuts] [proposal] Make go compiler work with different syntax versions in same project to support adaptivity

2020-08-10 Thread Ian Lance Taylor
res for Go programmers. We don't want to roll out a version of generics that we then have to change in some incompatible way. That would force people to rewrite programs over time, which is painful, and will decrease people's perception of Go as a stable and reliable language. Ian > On Mon,

Re: [go-nuts] [generics] Was "no type contracts" considered?

2020-08-10 Thread Ian Lance Taylor
On Mon, Aug 10, 2020 at 6:07 AM Markus Heukelom wrote: > > For what it is worth: for non-exported functions/types all operations could > be allowed, possibly leading to infamous C++-level error messages but as you > are the author of the package, those error messages would make sense to you >

Re: [go-nuts] Re: [generics] How to use maps in generic structs?

2020-08-10 Thread Ian Lance Taylor
On Mon, Aug 10, 2020 at 7:08 AM Markus Heukelom wrote: > > Just a quick thought, instead of "comparable" (and type lists) maybe we could > use a single operator to specify the required "operators" interface: > > type BiMap[type V, K ==] struct { > forward map[K]V > reverse map[V]K > } > > func

Re: [go-nuts] Re: [generics] How to use maps in generic structs?

2020-08-10 Thread Ian Lance Taylor
On Mon, Aug 10, 2020 at 7:08 AM Alvadron wrote: > > The type of map keys in Go should be comparable. As you haven't specified any > restriction to the type parameters, it doesn't compile because Go doesn't > know whether K and V are comparable. > > If you add the restriction "comparable", then

Re: [go-nuts] Generics: after type lists

2020-08-09 Thread Ian Lance Taylor
On Fri, Aug 7, 2020 at 4:33 PM Patrick Smith wrote: > > I like the second draft for generics. It seems to me a large > simplification and improvement over the first draft. Considering just > the state of Go today, I would be quite happy with this, even if it's > not perfect. Thanks to Ian,

Re: [go-nuts] [proposal] Make go compiler work with different syntax versions in same project to support adaptivity

2020-08-09 Thread Ian Lance Taylor
On Sat, Aug 8, 2020 at 7:51 PM wrote: > > Add support of optional syntax_version to file beginning, allow compiler to > tokenize/compile file by the compiler of syntax_version, using any number of > syntax_version-s in same project > > Why? Because go takes ridiculously long to implement

  1   2   3   4   5   6   7   8   9   10   >