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

2020-08-24 Thread adonovan via golang-nuts
On Thursday, 20 August 2020 20:28:23 UTC-4, Ian Lance Taylor wrote: > We’re going to settle on square brackets for the generics syntax. FWIW, the same square-bracket syntax was used by Barbara Liskov's CLU in the mid-1970s, and was, as far as I can tell, the first syntax used for parametric

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

2019-05-29 Thread adonovan via golang-nuts
On Tuesday, 21 May 2019 01:18:34 UTC-4, Ben Hoyt wrote: > > I'm looking at adding a timeout option to my GoAWK script interpreter... > Are there better / more performant ways to handle this? > Hi Ben, imposing resource bounds is a tricky problem. It's possible to do it in an interpreter

[go-nuts] Re: Announcing: Skylark in Go

2018-11-03 Thread adonovan via golang-nuts
Starlark is the new name for the Skylark configuration language. (The old name was the code name for a subproject of Bazel and was not suitable for a project in its own right.) The Starlark in Go implementation has moved. The code is now hosted at https://github.com/google/starlark-go but

[go-nuts] Re: Announcing: Skylark in Go

2017-11-07 Thread adonovan via golang-nuts
On Saturday, 4 November 2017 11:52:05 UTC-4, Keith Brown wrote: > > Are there any native golang tools simar to this which work on > Windows/Linux/OSX? > The Skylark interpreter doesn't make any particular assumptions about the CPU or OS, so it should be highly portable. Please file an issue

Re: [go-nuts] go/types#Check is not resolving external package source positions.

2017-10-31 Thread adonovan via golang-nuts
Glad you got things working. A few quick remarks: 1) You don't need to call ParseDir or CreateFromFiles. The loader will figure out what files you need to load for each package; just call config.Import(packagename). 2) The go/types tutorial says that export data doesn't contain position

[go-nuts] Re: Constructor return advice

2017-04-21 Thread adonovan via golang-nuts
On Friday, 21 April 2017 12:28:25 UTC-4, st ov wrote: > > In general, is it advisable to return pointers to newly constructed > instances when using constructors? > > Would it matter more for types that don't have members of composite types > slice and maps? > So in the following example,

[go-nuts] Re: Go Compiler Intermediate Representation

2017-02-22 Thread adonovan via golang-nuts
On Tuesday, 21 February 2017 12:23:44 UTC-5, Arpit Aggarwal wrote: > > I am doing a project in which I need Go compiler's intermediate > representation(IR) (which is semantics preserving and I can get all all > info like line number and data type and other features) (human readable) to >

[go-nuts] Re: howto programatically resolve an import path ?

2016-12-25 Thread adonovan via golang-nuts
On Friday, 23 December 2016 14:01:15 UTC-5, mhh...@gmail.com wrote: > > Hi, > > i m looking for the right way to load and parse an ast.ImportSpec > referenced into an ast.File object. > > Its mostly about the path resolution, I can t find a method like > > parse(baseDir string, pkgPath string)...

Re: [go-nuts] Modern Garbage Collection Article

2016-12-20 Thread adonovan via golang-nuts
On Tuesday, 20 December 2016 00:31:52 UTC-5, Ian Lance Taylor wrote: > > [Go] is designed to let you control when and > how memory is allocated, giving you control over when memory is > allocated. The effect is that in Go you can adjust your program to > reduce GC overhead, rather than tuning

[go-nuts] Re: are functions garbage collected?

2016-12-19 Thread adonovan via golang-nuts
On Monday, 19 December 2016 06:52:40 UTC-5, Jason E. Aten wrote: > > In the context of having a REPL for Go (and the new plugin support!) where > we would generate functions at runtime, I'm curious if the garbage > collector could be made to scan (perhaps on cue) some designated sub-space > for

Re: [go-nuts] [ANN] browse

2016-12-16 Thread adonovan via golang-nuts
On Friday, 16 December 2016 06:22:47 UTC-5, Jan Mercl wrote: > > > but I am curious: why the need for internal/gc, "a Go compiler front > end. Work in progess" ? > > it seems to be very much alike to go/types (or, rather, a mix of > go/types and go/ast). > > For example (not completely fair

[go-nuts] Re: Code-base Refactoring Tool for Go , Move files from packages to sub packages

2016-12-14 Thread adonovan via golang-nuts
On Tuesday, 13 December 2016 20:06:49 UTC-5, Dave Cheney wrote: > > I advice caution, Go is not Java and does not permit circular > dependencies. The more packages you have, the greater the chance you have > of creating a circular dependency. > That's a rather dark viewpoint. Absent further

Re: [go-nuts] import a "main" package

2016-12-13 Thread adonovan via golang-nuts
On Tuesday, 13 December 2016 11:34:24 UTC-5, Jan Mercl wrote: > > On Tue, Dec 13, 2016 at 5:19 PM Manlio Perillo > wrote: > > > However I think that there is no reason why a "main" package should not > be importable, to the point that > > I think that the fact that a

[go-nuts] Re: Code-base Refactoring Tool for Go , Move files from packages to sub packages

2016-12-13 Thread adonovan via golang-nuts
On Tuesday, 13 December 2016 08:58:00 UTC-5, jis...@hifx.co.in wrote: > > > > http://stackoverflow.com/questions/41121448/code-base-refactoring-tool-for-go-move-files-from-packages-to-sub-packages > > Currently my code-base have just 1 level of packages , due to the increase > in number of

Re: [go-nuts] Is there a tool or a library that lets me typecheck Go programs?

2016-12-13 Thread adonovan via golang-nuts
On Monday, 12 December 2016 12:22:51 UTC-5, Jan Mercl wrote: > > On Mon, Dec 12, 2016 at 6:20 PM wrote: > > > I realize that obviously the Go compiler does it, I was wondering if > there is a good API for that I can use, like the ast package? > > See

Re: [go-nuts] Are Go locks/mutex not the same as ordinary locks/mutexes?

2016-11-30 Thread adonovan via golang-nuts
On Tuesday, 29 November 2016 13:10:49 UTC-5, Ian Lance Taylor wrote: > > On Tue, Nov 29, 2016 at 9:51 AM, Roger Alsing > wrote: > > Coming from C++/C# background where locks/mutexes are considered evil > due to > > blocking threads. > > Due to how the Go goroutine

[go-nuts] Re: Large 2D slice performance question

2016-11-30 Thread adonovan via golang-nuts
> > On Wednesday, 30 November 2016 03:37:55 UTC+2, Mandolyte wrote: >> >> I have a fairly large 2D slice of strings, about 115M rows. These are >> (parent, child) pairs that, processed recursively, form a tree. I am >> "materializing" all possible trees as well as determining for each root >>

Re: [go-nuts] CFG for a Go program

2016-11-30 Thread adonovan via golang-nuts
On Wednesday, 30 November 2016 05:13:15 UTC-5, akshans...@gmail.com wrote: > > Thanks a lot for your valuable suggestions. I think the one using SSA form > will be helpful for my project. > Lest there be any confusion: there are two unrelated SSA forms for Go code, the one used internally by

Re: [go-nuts] CFG for a Go program

2016-11-28 Thread adonovan via golang-nuts
On Monday, 28 November 2016 09:04:55 UTC-5, atd...@gmail.com wrote: > > > I concur. > > On Monday, November 28, 2016 at 4:35:13 AM UTC+1, Michael Jones wrote: >> >> Details of this would make a great Go Blog post… >> > There is certainly a dearth of documentation on how to make the key design

Re: [go-nuts] CFG for a Go program

2016-11-27 Thread adonovan via golang-nuts
If you're building tools for source code analysis, you may find the golang.org/x/go/ssa representation easier to work with than the internals of the compiler. Build and run this command to see an example: $ go get golang.org/x/tools/cmd/ssadump $ ssadump -build=F fmt Alternatively, the

Re: [go-nuts] Short Variable Declaration Question

2016-11-23 Thread adonovan via golang-nuts
On Friday, 18 November 2016 10:30:45 UTC-5, Ian Lance Taylor wrote: > > I think the book is trying to stress that it declares out but does not > declare err. I agree that the sentence seems to imply that it does > not assign a value to out, but in fact it does both declare out and > assign a

[go-nuts] Re: Concurrent map error in net/http/trasport

2016-11-10 Thread adonovan via golang-nuts
On Thursday, 10 November 2016 04:09:29 UTC-5, James Pettyjohn wrote: > > I ran into this on go 1.6.2 amd64, seems unlikely this is a core issue and > I need to look else where in the project but has anyone seen this before? > > fatal error: concurrent map read and map write > > goroutine 21619

[go-nuts] Re: Concurrent SQL queries with PG

2016-11-08 Thread adonovan via golang-nuts
On Monday, 7 November 2016 19:54:35 UTC-5, Mandolyte wrote: > > Thanks for the quick response. and for your book - one of the best I've > ever purchased! > Thanks! Glad it was helpful. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Noob question: Pointers to interfaces

2016-11-07 Thread adonovan via golang-nuts
On Monday, 7 November 2016 17:55:57 UTC-5, Kaylen Wheeler wrote: > > I'm trying to find a typesafe way to access a type-indexed map of > components. This map can contain objects of any type, and the keys are > reflect.Type. > > One strategy I thought may work would be to pass a pointer to a

[go-nuts] Re: Concurrent SQL queries with PG

2016-11-07 Thread adonovan via golang-nuts
On Monday, 7 November 2016 16:57:29 UTC-5, Mandolyte wrote: > > I have what amounts to a recursion problem and I wrote a minimal test > using go routines. I am able to vary the max number of go routines as a > parameter on the command line (*). But the times don't vary much whether a > single

[go-nuts] Re: stop go run from printing "exit status 1"?

2016-11-05 Thread adonovan via golang-nuts
On Friday, 4 November 2016 22:49:17 UTC-4, Nate Finch wrote: > > If the script you run with go run returns a non-zero exit status, go run > prints "exit status N" and itself then returns with exit code 1. > > Now, this seems like a double mistake - first off, the only time go run > should print

Re: [go-nuts] Multiple-reader single-writer map access - is this lockless workaround safe?

2016-11-04 Thread adonovan via golang-nuts
On Thursday, 3 November 2016 23:54:46 UTC-4, 刘桂祥 wrote: > > sorry could you provide a complete example ? > > I try this but not find question > package main > > > import "time" > > > type T struct{ x int } > > > var global *T > > > func f() { > p := new(T) > p.x = 1 > global = p // "publish"

Re: [go-nuts] golang closure variable

2016-11-03 Thread adonovan via golang-nuts
On Thursday, 3 November 2016 03:05:47 UTC-4, 刘桂祥 wrote: > > > package main > > import "time" > > func main() { > s := []int{100, 200} > println() > go func() { > s[0] = 300 > s = []int{300, 400} > }() > time.Sleep(1 * time.Second) > } > > just curious about this ,can you help explain the

Re: [go-nuts] Oxymoron: language spec: ``untyped boolean value''

2016-11-03 Thread adonovan via golang-nuts
On Wednesday, 2 November 2016 11:24:38 UTC-4, Martin Steffen wrote: > > I meant more: the _terminology_ of being untyped may reflect an internal > treatment of how the go compiler treats > those things: inside the go-compiler, the ``static phase''/type > checker/type inferencer may treat > for

Re: [go-nuts] Re: There has no Mutex.Trylock() implemention or similar method ?

2016-10-24 Thread adonovan via golang-nuts
On Sunday, 23 October 2016 16:17:29 UTC-4, John Souvestre wrote: > > Take a look at https://github.com/LK4D4/trylock/blob/master/trylock.go . > > > > I believe that it is easier and performs better. > Yes, this looks like a sound solution if you don't need the re-entrant behavior. -- You

[go-nuts] Re: There has no Mutex.Trylock() implemention or similar method ?

2016-10-23 Thread adonovan via golang-nuts
On Friday, 21 October 2016 09:05:10 UTC-4, Michael Liu wrote: > > I've a race scenario used with Mutex.Lock with Lock() and Unlock(). now > multi-routines try to lock the resource and start a few logical code if the > Lock.Lock() succesfully. other routines don't need to block util >

Re: [go-nuts] the defer list

2016-10-19 Thread adonovan via golang-nuts
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 memory management is a part of life in the C world. defer is the >> solution that Go comes up with to situations where

Re: [go-nuts] What is called reference values in Golang?

2016-10-19 Thread adonovan via golang-nuts
On Wednesday, 19 October 2016 06:33:09 UTC-4, Jan Mercl wrote: > > On Wed, Oct 19, 2016 at 12:27 PM T L > wrote: > > Nothing. The language specification does not mention it. > > People use that term based on definitions specified for other programming > languages, but those

[go-nuts] Re: Is it safe to modify any part of a pointer?

2016-10-18 Thread adonovan via golang-nuts
On Tuesday, 18 October 2016 15:30:36 UTC-4, Joshua Liebow-Feeser wrote: > > are there any bits in a pointer which, when modified, won't mess with the > GC? > Even if there are, using them would constrain the future choices of the GC team, for which they will not thank you. This seems like a

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread adonovan via golang-nuts
On Monday, 17 October 2016 10:10:47 UTC-4, Sokolov Yura wrote: > > Mutex needs not to be type-safe. > And Mutex is not part of concept of "language tailored towards > concurrency". > Go does not take a strong Erlang-like stance against concurrency with shared variables, so mutexes really are

[go-nuts] Re: Using atomics for close checks

2016-10-04 Thread adonovan via golang-nuts
On Tuesday, 4 October 2016 13:32:03 UTC-4, Ahmed (OneOfOne) W. wrote: > > Some of our code uses something like: > > type Dummy struct { > closed int64 > } > > func(d *Dummy) IsClosed() bool { > return atomic.LoadInt64() == 1 > } > > func(d *Dummy) Close() error { > if !atomic.CompareAndSwapInt64(,

[go-nuts] Re: Parsing ambiguity?

2016-09-16 Thread adonovan via golang-nuts
On Friday, 16 September 2016 06:43:38 UTC-4, Jan Mercl wrote: > > Which rule selects the first parse? Can anybody please enlighten me? > Thanks in advance. > The grammar is indeed ambiguous, but the ambiguity is (implicitly) resolved by favoring the leftmost derivation, which is what you get

Re: [go-nuts] Multiple-reader single-writer map access - is this lockless workaround safe?

2016-09-12 Thread adonovan via golang-nuts
On Monday, 12 September 2016 12:04:30 UTC-4, sqweek E. wrote: > > Yes, through plain assignment. What problems arise from that? > Here's the general form of the problem. In the code below, one goroutine (f) creates a variable, initializes it (x=1), then shares its address with another

[go-nuts] Re: Type And Interface Equivalence

2016-09-02 Thread adonovan via golang-nuts
On Friday, 2 September 2016 09:51:52 UTC-4, Kevin Conway wrote: > > Given a type T that implements interfaces A1 and A2, T is an acceptable > input for any function that requires an A1 or A2 as input. Given A1 and A2 > are identical in definition, the return value of a function that returns an

[go-nuts] Re: Close a reader to quit a loop without closing its source

2016-08-31 Thread adonovan via golang-nuts
On Wednesday, 31 August 2016 07:48:12 UTC-4, Dave Cheney wrote: > > Unfortunately POSIX does not guarantee that close from one thread will > unblock another. To read from a file without waiting longer than a specified time, you need to use the POSIX 'select' system call, which you can find at

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-29 Thread adonovan via golang-nuts
On Monday, 29 August 2016 13:36:00 UTC-4, Conrad Irwin wrote: > > because of the automatic escape detection, I no longer think of a pointer > as being the intrinsic address of a value; rather in my mind the & operator > creates a new pointer value that when dereferenced returns the value. > >

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-29 Thread adonovan via golang-nuts
On Friday, 26 August 2016 23:58:53 UTC-4, T L wrote: > > And there is also an exception for the counter rule: map elements are not > addressable. > Just because you can use the assignment syntax m[k]=v to update a map element does not mean a map element is a variable ("addressable"). This is

[go-nuts] Re: SSA back-translation / destruction

2016-08-19 Thread adonovan via golang-nuts
On Wednesday, 17 August 2016 12:00:46 UTC-4, HWJ wrote: > > TL;DR: what's the best way to do SSA back-translation when using > x/tools/go/ssa? > > I'm thinking about a Go compiler which accepts a subset of Go and emits > assembly for a microcontroller. Instead of going all the way from >

[go-nuts] Re: const values of any types can't be compared to interface{} values?

2016-08-15 Thread adonovan via golang-nuts
On Monday, 1 August 2016 17:53:59 UTC+1, T L wrote: > > > ex: > > package main >> >> func main() { >> // error: illegal constant expression: *int == interface {} >> _ = (*int)(nil) == interface{}(nil) >> } > > This is a compiler bug (https://github.com/golang/go/issues/16702). Thanks

[go-nuts] Re: golang.org/x/tools/go/loader: file names of parsed *ast.File

2016-08-15 Thread adonovan via golang-nuts
On Saturday, 13 August 2016 22:27:42 UTC+1, Paul Jolly wrote: > > On Saturday, 13 August 2016 21:58:37 UTC+1, Paul Jolly wrote: >> >> Am I missing something obvious here? >> > > Please excuse the reply to self, but I have discovered what I was missing. > > For the sake of completeness, here is how

Re: [go-nuts] russian language books about Go

2016-06-26 Thread adonovan via golang-nuts
On Friday, 24 June 2016 03:10:56 UTC-4, Oleg Puchinin wrote: > > Hello ! > Where I can find subject ? > Hi Oleg, our book The Go Programming Language (gopl.io) is now available in Russian, thanks to Williams Press: http://www.williamspublishing.com/Books/978-5-8459-2051-5.html The ozon.ru site

[go-nuts] Re: importer.Default not able to find packages in $GOPATH

2016-06-17 Thread adonovan via golang-nuts
On Friday, 17 June 2016 15:21:55 UTC-4, Joshua Liebow-Feeser wrote: > > Hi All, > > I'm trying to use the go/* packages to parse and type check Go source > code. I've downloaded github.com/coreos/etcd to test this on, and I'm > currently trying it out in the etcdserver subdirectory. When I run