@@ -7,23 +7,15 @@ import (
77
88type Function struct {
99 Name string
10- Id int
1110 Func func (args ... interface {}) (interface {}, error )
1211 Types []reflect.Type
1312 Validate func (args []reflect.Type ) (reflect.Type , error )
1413}
1514
16- const (
17- Len = iota + 1
18- Abs
19- Int
20- Float
21- )
22-
23- var Builtins = map [int ]* Function {
24- Len : {
15+ var Builtins = []* Function {
16+ {
2517 Name : "len" ,
26- Id : Len ,
18+ Func : Len ,
2719 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
2820 if len (args ) != 1 {
2921 return anyType , fmt .Errorf ("invalid number of arguments for len (expected 1, got %d)" , len (args ))
@@ -35,9 +27,9 @@ var Builtins = map[int]*Function{
3527 return anyType , fmt .Errorf ("invalid argument for len (type %s)" , args [0 ])
3628 },
3729 },
38- Abs : {
30+ {
3931 Name : "abs" ,
40- Id : Abs ,
32+ Func : Abs ,
4133 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
4234 if len (args ) != 1 {
4335 return anyType , fmt .Errorf ("invalid number of arguments for abs (expected 1, got %d)" , len (args ))
@@ -49,9 +41,9 @@ var Builtins = map[int]*Function{
4941 return anyType , fmt .Errorf ("invalid argument for abs (type %s)" , args [0 ])
5042 },
5143 },
52- Int : {
44+ {
5345 Name : "int" ,
54- Id : Int ,
46+ Func : Int ,
5547 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
5648 if len (args ) != 1 {
5749 return anyType , fmt .Errorf ("invalid number of arguments for int (expected 1, got %d)" , len (args ))
@@ -67,9 +59,9 @@ var Builtins = map[int]*Function{
6759 return anyType , fmt .Errorf ("invalid argument for int (type %s)" , args [0 ])
6860 },
6961 },
70- Float : {
62+ {
7163 Name : "float" ,
72- Id : Float ,
64+ Func : Float ,
7365 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
7466 if len (args ) != 1 {
7567 return anyType , fmt .Errorf ("invalid number of arguments for float (expected 1, got %d)" , len (args ))
0 commit comments