Documentation ¶
Overview ¶
The methodpool is an awful hack for creating Go types with methods.
A type with a method is pulled out of the pool and embedded in a struct created with reflect.StructOf.
These method structs appear first in the struct definition and have no size, so a pointer to them is a pointer to the real value. Each of these method structs from the pool is only used for one new type, so a global map lets us work out the real type of the value.
This imposes two limits on a methodik that should not exist:
- methods can only be defined on struct types
- only a limited number of method signatures are possible
All of this can be replaced by either reflect.NamedOf (which is https://golang.org/issue/16522), or by generating then compiling Go to a plugin and loading that. Hopefully darwin plugin support will be ready for 1.9, and this can be retired.
Index ¶
- func EvalFile(path string) error
- type MethodPoolRead1
- type MethodPoolRead2
- type MethodPoolRead3
- type MethodPoolWrite1
- type MethodPoolWrite2
- type MethodPoolWrite3
- type Panic
- type Program
- type Scope
- type UntypedBool
- type UntypedComplex
- type UntypedFloat
- type UntypedInt
- type UntypedRune
- type UntypedString
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MethodPoolRead1 ¶
type MethodPoolRead1 struct{}
type MethodPoolRead2 ¶
type MethodPoolRead2 struct{}
type MethodPoolRead3 ¶
type MethodPoolRead3 struct{}
type MethodPoolWrite1 ¶
type MethodPoolWrite1 struct{}
type MethodPoolWrite2 ¶
type MethodPoolWrite2 struct{}
type MethodPoolWrite3 ¶
type MethodPoolWrite3 struct{}
type Program ¶
type Program struct { Universe *Scope Cur *Scope Types *typecheck.Checker Pkgs map[string]*gowrap.Pkg Path string // contains filtered or unexported fields }
type Scope ¶
type UntypedBool ¶
type UntypedBool struct{ Bool bool }
type UntypedComplex ¶
func (UntypedComplex) String ¶
func (uc UntypedComplex) String() string
type UntypedFloat ¶
type UntypedInt ¶
type UntypedRune ¶
type UntypedRune struct{ Rune rune }
type UntypedString ¶
type UntypedString struct{ String string }