If you have parts of your function that are made on every call, you can improve performance by binding the body to statics.
e.g. instead of:
foo: func [
some-arg
] [
bar: func [...] [...]
...
bar ...
]
You would move the definition of BAR out, so it only has to create the function once.
foo: func [
some-arg
] bind {
bar: func [...] [...]
} [
...
bar ...
]
But it's often the case that these helpers want to see the locals of the function, on a per-instantiation basis. Something like this:
foo: func [
some-arg
] bind {
bar: func [y] [return some-arg + y]
} [
...
bar ...
]
You can see @hiiamboris doing that by binding the object, to a function:
So basically he names the object, creates the function bound to the object, and then turns around and binds the object back to the function:
obj: {
bar: func [y] [return some-arg + y]
}
foo: func [
some-arg
] bind obj [
...
bar ...
]
bind foo/ obj
Ren-C binding doesn't do this. And there are good reasons why.
But there might be something that can be done, with the leading dot variables. e.g. the functions could be methods?
foo: func [
some-arg
] bind {
[.]: ~ ; initialize to meaningless value
bar: func [y] [return .some-arg + y]
} [
[.]: binding of $return ; or however you get the frame
...
bar ...
]
Not that pretty, but at least it's possible. Problem is--though--that there's still only one static object bound to the function, so if the function recurses this breaks.
I think this is a scenario deserving of a solution. So worth thinking about.