FunctionDecls provides one or more fully formed function declarations to be added to the environment.
(funcs ...*decls.FunctionDecl)
| 219 | |
| 220 | // FunctionDecls provides one or more fully formed function declarations to be added to the environment. |
| 221 | func FunctionDecls(funcs ...*decls.FunctionDecl) EnvOption { |
| 222 | return func(e *Env) (*Env, error) { |
| 223 | var err error |
| 224 | for _, fn := range funcs { |
| 225 | if existing, found := e.functions[fn.Name()]; found { |
| 226 | fn, err = existing.Merge(fn) |
| 227 | if err != nil { |
| 228 | return nil, err |
| 229 | } |
| 230 | } |
| 231 | e.functions[fn.Name()] = fn |
| 232 | } |
| 233 | return e, nil |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | // FunctionOpt defines a functional option for configuring a function declaration. |
| 238 | type FunctionOpt = decls.FunctionOpt |