Re: [go-nuts] ast.NewPackage errors for built in types

2021-10-16 Thread 'Richard Oudkerk' via golang-nuts
imports[path] = pkg > } > return pkg, nil > } > > This now works for all cases which don't import external packages. So now > I just need to do the on demand load of packages, which I suspect will lead > me right back to packages.Load. > > On Sat

Re: [go-nuts] ast.NewPackage errors for built in types

2021-10-16 Thread 'Richard Oudkerk' via golang-nuts
You could try building the universe scope for ast.NewPackage from types.Universe. For example https://play.golang.org/p/1E5Iu4vW3g9 func NewPackage(fset *token.FileSet, files map[string]*ast.File) (*ast.Package, error) { univ, err := universe() if err != nil { return nil, err } return ast.NewP

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

2020-08-24 Thread 'Richard Oudkerk' via golang-nuts
The current proposal says *The rule is that if a type contraint has a single type parameter, and it is used in a function's type parameter list witho

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

2020-08-10 Thread 'Richard Oudkerk' via golang-nuts
Another way to bridge the gap between builtin and custom types could be to have a package op that has functions that delegate to either an operator or a method. Then you could write generic functions like func Min[type T op.Lessable](a, b T) T { if op.Less(a, b) { return b } return a