In trying to get COMPOSE to lose /ONLY, there was a time when it looked for doubled groups.
>> block: [a b c]
>> compose [(block) ((block))]
== [a b c [a b c]]
I liked it, and I said:
But I found concerns:
To be fair: it's hardly the only case where if you jump to conclusions on reading a few characters that you'll have problems because the code keeps going and may invalidate the assumptions you made by looking at those few characters. But it still wasn't perfect.
...and as it turned out, it was another one of those "close but no cigar" cases of wanting to mark the intent of splice specially, but using a mechanism that's not as good as splice isotopes!.
I think that doubled-up-groups are a neat example of a dialecting concept, where you might want to give that significance. It would certainly belong in the dialecting handbook (if we had one).
But in the COMPOSE case, we have a better option... compose [... (spread block) ...] (or another operator of your choice that produces block isotopes). And it's more fitting for the core, because it doesn't have the weakness mentioned above.
Not that it would be hard to write again, but here's the C code for detecting doubled groups!
INLINE bool Is_Any_Doubled_Group(const Element* group) {
assert(Any_Group_Heart(Cell_Heart(group)));
const Cell* tail;
const Cell* inner = Cell_Array_At(&tail, group);
if (inner + 1 != tail) // should be exactly one item
return false;
return Is_Group(inner); // if true, it's a ((...)) GROUP!
}
I realized that this speaks to a whole category of possibilites we have in dialecting, which is to "make up" asymmetric delimiter pairs by coupling things with List delimiters:
(* You've got starred GROUP!s *)
(| Banana clips are famousish |)
(> Perhaps some pointy groups <)
(< Then reverse pointy groups >)
[: Colon shall be a WORD! now :]
[/ Slash blocks...very slashy /]
You'll have to throw in the space between the delimiting unless you're specifically doubling up a List delimiter, e.g. a {{Double-fence}}.
But there's some pretty interesting potential here. I feel like having a tool in the box for it would be neat:
>> [start /end]: find-synthdelimit [*] second [a [* b c *] d e]
== [b c *]
>> end
== [*]
>> [start /end]: find-synthdelimit '(> <) second [a (> b c <) d e]
== (b c <)
>> end
== (<)
>> [start /end]: find-synthdelimit '{|} second [a {b c} d e]
== ~null~ ; anti
It would be nice if there were some way to do array slices and be able to do evaluation on those slices, so that the delimiters wouldn't be visible to that evaluation. Usual gripe about Rebol's informality making that mostly impractical.