FunctionBinding provides the implementation of a variadic overload. The provided function is protected by a runtime type-guard which ensures runtime type agreement between the overload signature and runtime argument types.
(binding functions.FunctionOp)
| 885 | // FunctionBinding provides the implementation of a variadic overload. The provided function is protected by a runtime |
| 886 | // type-guard which ensures runtime type agreement between the overload signature and runtime argument types. |
| 887 | func FunctionBinding(binding functions.FunctionOp) OverloadOpt { |
| 888 | return func(o *OverloadDecl) (*OverloadDecl, error) { |
| 889 | if o.HasBinding() { |
| 890 | return nil, fmt.Errorf("overload already has a binding: %s", o.ID()) |
| 891 | } |
| 892 | if o.hasLateBinding { |
| 893 | return nil, fmt.Errorf("overload already has a late binding: %s", o.ID()) |
| 894 | } |
| 895 | o.functionOp = binding |
| 896 | return o, nil |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | // LateFunctionBinding indicates that the function has a binding which is not known at compile time. |
| 901 | // This is useful for functions which have side-effects or are not deterministically computable. |