I am trying to wrap up functions with refinements in a generic way so they can be called without the refinement. For instance, ARRAY-INITIAL size value
instead of ARRAY/INITIAL size value
wrap: function [refined [path!] args [block!]] [
function args compose [
(refined) (args)
]
]
array-initial wrap 'array/initial [size value]
Not too fancy. Seems to work in general, but this has something weird if you call it using a function:
>> n: 0 array/initial 4 does [++ n]
== [10 11 12 13]
>> n: 10 array-initial 4 does [++ n]
== [10 10 10 10]
When I source
it I get this:
>> source array-initial
array-initial: make function! [[size value][array/initial size value]]
Okay, so what's happening is that the function is being called in the wrapper and the result of the call passed...not the function. One workaround would be to use a get-word to avoid the evaluation:
>> array-initial-2: function [size value] [array/initial size :value]
>> array-initial-2: 10 array-initial-2 4 does [++ n]
[10 11 12 13]
But I was looking for a general approach. What's the best way to proxy the parameters without having this happen?