What do BLOCK!s in PATH!s do?


#1

What GROUP! should do in a PATH! seems fairly clear. It should evaluate, and then whatever it evaluates to becomes as if you’d written it literally there. So you’d expect foo/(1 + 1) and foo/2 to do the same thing, (modulo any strange overrides of + that keep it from returning 2)

But BLOCK! is now a first class citizen in PATH!s. Which raises the question of if it has a uniform handling that applies to anything, or if it’s something each path dispatcher handles on a case-by-case basis?

In NewPath, I want BLOCK! basically to do an UNSPACED operation. Hand-waving a moment, let’s call the operator that does this “newpath-to-local”.

>> projects: [#ren-c ./make/ ...] 
>> name: "rebmake"
>> newpath-to-local /home/(p)/(p: 'ren-c select projects p)/[name .r]
== %/home/hostilefork/ren-c/make/rebmake.r

This is a hand-wavy vision toward what I think the world might look like with inert tuples (where .r is the tuple form of [_ r]) and continuing the trend started by refinement of things starting with slash being evaluator inert.

But the key is that while GROUP! churned along and threw out the intermediates, the BLOCK! reduced and put the pieces together. I think this is an interesting direction for NewPath, but I don’t know if it makes much sense as a generalized behavior.

Would people use it?

>> data: [<foo> <bar> 10 <baz> <mumble> 20]
>> x: <foo>

>> data/[x <bar>]    
== 10

There might be other uses. Like zero-based indexing.

>> data: [a b c d]
>> index: 1
>> data/(index) 
== a
>> data/[index]
== b

It could force SELECT semantics instead of PICK semantics:

>> data: [2 a 1 b]
>> data/(1)
== 2
>> data/[1]
== b

The argument we could make for reducing it could be that you could always do the non-reduced form as:

path/([some stuff])

But now you can also do the reduced form as:

path/(:[some stuff])

So making path/[some stuff] a synonym for that in all path dispatch cases across the board seems like it might be a little weak.

But maybe it’s not? I really don’t know. I’m more interested in dialect uses because at least then you know what you’re writing and why. So I guess the thing to do is keep an eye out and see what the pattern is.