In the "MOLD and LOAD Parity" thread, @rgchris suggests something I have been wanting to do (but hadn't) which is to make LOAD always return a BLOCK!.
Now that is done:
GitHub Commit: LOAD of code always BLOCK!, LOAD-VALUE for 1 item
But...What About Script Headers?
If I'd just blindly flipped a switch that /ALL was true, we'd have gotten the historical behavior that LOAD/ALL includes headers as part of the data:
rebol2>> load "Rebol [] 1 2 3"
== [1 2 3]
rebol2>> load/all "Rebol [] 1 2 3"
== [Rebol [] 1 2 3]
So I didn't do that. Even though a block is always returned now, it still does header processing.
But there's a catch:
>> load "rebol [%.r %.r3] ren-c [%.r %.reb] red [%.red %.reds]"
** syntax Error: script header is not valid:
So now, how are you supposed to LOAD a string that starts with the (legitimate) WORD! Rebol? More broadly we want more signals than this, based on the dialect or sublanguage...that would be any word (or path?) What can be done about this?
The Header Needs A Special Signal
I'm quite certain it's a design flaw that the header signal can be conflated with what could be legal data.
Contrast with something that didn't have that property:
>> load/all {$Rebol [Title: "stuff"] no contention here}
== [no contention here]
>> load/all {3.0-Rebol [Title: "stuff"] non symbolic option}
== [non symbolic option]
I know a symbol might be a bit off-putting, but everything "pleasant" is already taken in-band for the mainline of the data format.
^Rebol [
Title: {My Script}
]
$Rebol [
Title: {My Script}
]
\Rebol [
Title: {My Script}
]
Rebol=[
Title: {My Script}
]
rebol>> [
Title: {My Script}
]
Rebol> [
Title: {My Script}
]
Okay, I actually like that "prompt-looking" last idea. Rebol> seems nice and light enough... it's even kind of "pointing at" the header block to say it's special and not part of the data. And we've pretty clearly ruled out Xyz> as a WORD!. It can cover any name vs. encoding a word like "Rebol" specifically.
LOAD/HEADER could slipstream whatever was in front of the >
to be in-band in the returned header.
>> [data hdr]: load {StyleTalk/3.0> [Title: "Whatever"] your data here}
== [your data here]
>> hdr
== make object! [
Format: 'StyleTalk/3.0
Title: "Whatever"
]
But maybe allowing paths that opens too many cans of worms (Rebol/<tag-in-path>> [...]
) and it should have to just be a WORD! otherwise, with everything else you need broken out in the header.
Looks good to me. Thoughts?