You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the primary way to access simple Go functions from WDTE is by providing a GoFunc to call. While this is nice as a low-level system, it would be quite useful to be able to just wrap existing Go functions without having to worry about perfectly matching the Func.Call() API. As such, a set of functions for automatically creating Funcs from existing Go structures would be quite useful.
As these are not technically required for the core functionality of WDTE, they should probably be in a separate package, such as wrap, fun, or simple. Maybe auto. Hmmm...
func Func(name string, f interface{}) wdte.Func. Takes a name so that the frame can be subbed properly and a function. It uses reflection to create a wrapper around f that properly converts arguments passed from WDTE to requested types, automatically handling built-in types separately, and then converts the return value back as well. Might also support multiple return values.
A variant of Func that lets the user specify how the arguments are handled, allowing for more complicated WDTE function signatures.
The opposite of Func. A function that converts a wdte.Func to a Go function. Probably should work similarly to reflect.MakeFunc.
The text was updated successfully, but these errors were encountered:
DeedleFake
changed the title
Add Convience Functions for Wrapping Go Functionality
auto: new package for automatically wrapping Go functionality
Nov 28, 2018
Currently, the primary way to access simple Go functions from WDTE is by providing a
GoFunc
to call. While this is nice as a low-level system, it would be quite useful to be able to just wrap existing Go functions without having to worry about perfectly matching theFunc.Call()
API. As such, a set of functions for automatically creatingFunc
s from existing Go structures would be quite useful.As these are not technically required for the core functionality of WDTE, they should probably be in a separate package, such as
wrap
,fun
, orsimple
. Maybeauto
. Hmmm...func Func(name string, f interface{}) wdte.Func
. Takes a name so that the frame can be subbed properly and a function. It uses reflection to create a wrapper aroundf
that properly converts arguments passed from WDTE to requested types, automatically handling built-in types separately, and then converts the return value back as well. Might also support multiple return values.Func
that lets the user specify how the arguments are handled, allowing for more complicated WDTE function signatures.Func
. A function that converts awdte.Func
to a Go function. Probably should work similarly toreflect.MakeFunc
.The text was updated successfully, but these errors were encountered: