Idea for Naming Function Arguments Out of the Way

As part of Rebol's contention-for-short-names problem, there are many instances where refinements have names like /ALL where they conflict with common natives or lib functions.

When this happens, I tend to do something to name them out of the way and put the lib function back:

foo: function [
    bar [block!]
    /all "foo all the bars"
][
    all_FOO: all
    all: :lib.all
    ...
]

Clearly we need a better pattern.

Maybe there could be two features that work together on this. One would be the ability to ask that the function's frame be passed in as a variable, and another would be to suppress binding of an argument in the body.

foo: function [
    bar [block!]
    /.all "foo all the bars"
    <frame> f
][
    all [...]  ; would be the ALL from LIB
    if f.all [print "Fooing all the bars"]
]

It's already kind of necessary to be able to get the FRAME! of a function into a variable (asking for binding of 'return is clunky, and you have no way of doing it with a lambda that has no parameters or locals). Then the dot could mark arguments as being "member-access-only" via the dot.

I think this is better than trying to name things out of the way. It could work for normal arguments too:

foo: function [
    .bar [block!]
    /.all "foo all the bars"
    <frame> f
][
    ; use f.bar and f.all, with BAR and ALL left as-is
]

It might not be the most beautiful thing in the world, but this is a real problem that is very frustrating when it comes up. And when you encourage people to play with words, they shouldn't be afraid to reuse them in refinements if they make sense.

The only qualm I might have would be conflict with other meanings of BLANK!-headed TUPLE!s, but so far it seems like inertness is what we've got.

Objections? Better ideas? :cricket: :cricket:

1 Like

While reading this, I had the thought, that tuples might be useful here, so I think this is in support of your idea.
I'm a bit surprised at how integral tuples seem to become to the features of whatever ren-c morphs into :wink: as tuples have been one of the lesser useful datatypes of Rebol (at least to me).

2 Likes