Exemplo n.º 1
0
func (d *LocalDispatcher) Dispatch(context *Context, funcApply *lang.FuncApply) interface{} {
	ref := funcApply.Ref()
	// args := funcApply.Args()
	funcExists := context.Exists(ref.String())
	if funcExists {
		fmt.Printf("Found function [%s]\n", ref)
	} else {
		fmt.Printf("No such function [%s]\n", ref)
	}
	return nil
}
Exemplo n.º 2
0
func doFuncApply(rift *lang.Rift, env collections.PersistentMap, funcApply *lang.FuncApply) interface{} {
	f := dereference(rift, env, funcApply.Ref()).(func([]interface{}) interface{})
	args := funcApply.Args().Values()
	var argValues []interface{}
	for _, arg := range args {
		argValue := evaluate(rift, env, arg.(*lang.Node))
		argValues = append(argValues, argValue)
	}
	returnValue := make(chan interface{}, 1)
	go func() {
		returnValue <- f(argValues)
	}()
	return <-returnValue
}