Skip to content

WISH: apply design to cover function extension cases #171

@hiiamboris

Description

@hiiamboris

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions