How to avoid getting a METH habit

The "function spec dialect" has been moving along. In R3-Alpha, to get a locals-gathering function which imports a binding for an "external" variable, and has some static state...you would have had to write:

import-me: 10
function/extern/with [
    {Your function title here}
    some-arg
    /local some-local
][
    import-me: some-arg + state
    state: state + 20
][
    import-me
][
    state: 30
]

The same thing is expressed in Ren-C more elegantly without refinements, expanding the spec dialect so that things can be put up front. The terminology is improved, also:

import-me: 10
function [
    {Your function title here}
    some-arg
    <local> some-local
    <static> state: (30) ;-- makes more sense than /WITH
    <with> import-me ;-- nicer than extern, "with" makes sense for binding
][
    import-me: some-arg + state
    state: state + 20
]

Another expansion just folded the behavior of PROC and PROCEDURE into FUNC and FUNCTION, with the return: <void> notation.

But that still leaves one great divide: the FUNC and FUNCTION question. And humorously, the non-locals gathering form of METHOD is METH.

Which raises the question...

Can we indicate locals gathering in FUNCTION's spec and drop FUNC?

I'm not necessarily saying that FUNC couldn't stick around as a shorthand. Maybe PROC and PROCEDURE will stick around too. Perhaps even METH. But it would be nice if they weren't actually necessary.

One way of looking at the problem would be that FUNC-like behavior comes from keeping locals-gathering by default, then somehow saying you want to "wildcard" the WITH-ness:

foo: function [x y z <with> <*>] [
   ...
]

That's sort of like saying "import the world". The opposite end of the spectrum would be to say that FUNC's non-locals gathering is the default, and you have to wildcard the locals:

foo: function [x y z <local> <*>] [
    ...
]

Of course, either way there's the problem of what to do when someone mixes and matches, or says <local> <*> <with> <*>.

Since I don't have a good answer at the moment, I brought in some METH, and have been using it. :zombie:
But I'm wondering if there's a way to get by without it, and get life back on track.

1 Like