func (packages CombinedPackage) LookupFunc(f LookupFunc) error {
	var err error
	names := map[string]struct{}{}
	w := func(name string, decl Declaration) error {
		if _, ok := names[name]; !ok {
			err = f(name, decl)
			names[name] = struct{}{}
		}
		return err
	}
	for _, pkg := range packages {
		_ = pkg.LookupFunc(w)
		if err != nil {
			break
		}
	}
	if err == StopLookup {
		err = nil
	}
	return err
}
LookupFunc calls the LookupFunc method of each package in order. As soon as
f returns StopLookup, LookupFunc returns. If the same declaration name is
in multiple packages, f is only called with its first occurrence.
package native
import "errors"
var StopLookup = errors.New("stop lookup")
type LookupFunc func(name string, decl Declaration) error
type ImportablePackage interface {
	PackageName() string
	Lookup(name string) Declaration
	LookupFunc(f LookupFunc) error
}
type Importer interface {
	Import(path string) (ImportablePackage, error)
}
type CombinedImporter []Importer
func (importers CombinedImporter) Import(path string) (ImportablePackage, error) {
	for _, importer := range importers {
		p, err := importer.Import(path)
		if p != nil || err != nil {
			return p, err
		}
	}
	return nil, nil
}
type Packages map[string]ImportablePackage
func (pp Packages) Import(path string) (ImportablePackage, error) {
	if p, ok := pp[path]; ok {
		return p, nil
	}
	return nil, nil
}
type Package struct {
	Name string
	Declarations Declarations
}
func (p Package) PackageName() string {
	return p.Name
}
func (p Package) Lookup(name string) Declaration {
	return p.Declarations[name]
}
func (p Package) LookupFunc(f LookupFunc) error {
	var err error
	for n, d := range p.Declarations {
		if err := f(n, d); err != nil {
			break
		}
	}
	if err == StopLookup {
		err = nil
	}
	return err
}
type CombinedPackage []ImportablePackage
func (packages CombinedPackage) PackageName() string {
	if len(packages) == 0 {
		return ""
	}
	return packages[0].PackageName()
}
func (packages CombinedPackage) Lookup(name string) Declaration {
	for _, pkg := range packages {
		if decl := pkg.Lookup(name); decl != nil {
			return decl
		}
	}
	return nil
}