1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // This file implements objsets.
7 // An objset is similar to a Scope but objset elements
8 // are identified by their unique id, instead of their
13 // An objset is a set of objects identified by their unique id.
14 // The zero value for objset is a ready-to-use empty objset.
15 type objset
map[string]Object
// initialized lazily
17 // insert attempts to insert an object obj into objset s.
18 // If s already contains an alternative object alt with
19 // the same name, insert leaves s unchanged and returns alt.
20 // Otherwise it inserts obj and returns nil.
21 func (s
*objset
) insert(obj Object
) Object
{
23 if alt
:= (*s
)[id
]; alt
!= nil {
27 *s
= make(map[string]Object
)