Added TryCallFunction methods to Caller. This allows functions to be called without allocating a Function object. An alternative solution would be to convert Function into a struct, but this is a much larger change!
The main shortcoming with this is that ValueBox cannot be stack allocated. So this API is really just passing the buck on allocating anything - the caller can avoid allocations (rent an array) but it's not very ergonomic. See the unit tests for example.
Another implementation could have generic arguments for all possible call/return combinations (and then use ValueBox.Converter<T>().Box(value)). This would be a fairly nice API to use, but would require generating yet more huge blobs of code.
I'm open to other suggestions on a better way to pass arguments and results.
Added
TryCallFunction
methods toCaller
. This allows functions to be called without allocating aFunction
object. An alternative solution would be to convertFunction
into a struct, but this is a much larger change!The main shortcoming with this is that
ValueBox
cannot be stack allocated. So this API is really just passing the buck on allocating anything - the caller can avoid allocations (rent an array) but it's not very ergonomic. See the unit tests for example.Another implementation could have generic arguments for all possible call/return combinations (and then use
ValueBox.Converter<T>().Box(value)
). This would be a fairly nice API to use, but would require generating yet more huge blobs of code.I'm open to other suggestions on a better way to pass arguments and results.