It was originally one of the use cases: here and here and here
Currently still, general extension of other functions with apply is quite convoluted. Example - extend any function with a single print statement:
traced: function [f [word! path!]] [
args: parse spec: spec-of get f [collect any [
/local to end
| set w [word! | lit-word! | refinement!] keep (to get-word! w)
| set w get-word! keep (to paren! w)
| skip
]]
func spec compose/deep/only [
print (rejoin ["in " f])
apply/all quote (f) compose/only (args)
]
]
In the above I have to parse and arrange an argument list, fill it with get-words to avoid double evaluation, then on every invocation compose it to prepare values for possible get-args.
Test:
>> probe': traced 'probe
>> probe' "abc"
in probe
"abc"
== "abc"
>> quote': traced 'quote
>> quote' probe
in quote
== probe
This wish is to have an easy extension without the need for composition on each call.
It was originally one of the use cases: here and here and here
Currently still, general extension of other functions with
applyis quite convoluted. Example - extend any function with a single print statement:In the above I have to parse and arrange an argument list, fill it with get-words to avoid double evaluation, then on every invocation
composeit to prepare values for possible get-args.Test:
This wish is to have an easy extension without the need for composition on each call.