Meaning of META-BLOCK! ^[...]

Found one glitch... there was an idiom of using the inertness in some places with blocks.

>> spaced ["Reduced" 1 + 2 "Content"]
== "Reduced 3 Content"

>> spaced @["Unreduced" 1 + 2 "Content"]
== "Unreduced 1 + 2 Content"

>> meta pack [1 + 2 10 + 20]
== ~['3 '30]~

>> meta pack @[1 + 2 10 + 20]
== ~['1 '+ '2 '10 '+ '20]~

This won't work anymore, as the evaluator isn't inert here.

HOWEVER... there is a construct that can pick up the slack. The META-BLOCK!

>> ^[1 + 2 10 + 20]
== '[1 + 2 10 + 20]

It produces a block which is quoted, and which captured a binding. So it is suitable for this purpose. It does raise questions like "what to do if the block is double or triple quoted" etc, but I think raising an error is fine for the moment.


Coincidentally, I was thinking about my desire to have a proper FOR dialect.

 >> for x [1 to 3] [print x]
 1
 2
 3

And then, the concept of "going meta" struck me as interesting:

 >> for x meta [1 to 3] [print x]
 1
 to
 3

Which would mean that FOR when given a quoted block would enumerate its contents vs. run the dialect. Then you could also write that as:

 >> for x ^[1 to 3] [print x]
 1
 to
 3

If you didn't want a binding you need a quoted block and a generator applied to the resulting unbound block:

 >> for x each '[1 to 3] [print x]
 1
 to
 3

It's interesting to see the parts coming together with some things not being as useless as first thought.

So thinking about it more, I don't know if this is what META-BLOCK! should do.

META-GROUP! takes the evaluative behavior of GROUP! and metas the product:

>> ^(1 + 2)
== '3

>> ^(null)
== ~null~

That makes sense. So what if ^[...] would reduce the block and meta each item?

 >> ^[1 + 2 null]
 == ['3 ~null~]

That's half the behavior of what we call PACK today. If you make it an antiform, you can use it with multi return:

 [a b]: anti ^[1 + 2 null]

What good is half the behavior? Well, it's more about the idea of having a REDUCE parallel that can actually reduce anything and put it in "suspended animation". Packs are one place this has become useful, but other places could use it too.

It came up when I was thinking about what a META-FENCE! might do:

>> ^{a: 3 b: null}

I was wondering if quoted-bound-fence made sense, and wondered if making all the assignments meta would make more sense.

Anyway, behavior of ^[...] is something I'm rethinking.

1 Like