dockimbel/Red — pull request #421 by hostilefork (2013-03-04 08:00:47+00:00)
Title: Build binary compatible hello.red in R2 and R3 for Elf

This is incomplete work but my original goal was not to get all the regression tests running, but just get a byte-for-byte compatible hello.red executable. Now, as per Kaj's suggestion it's not necessary to hold it up when there are people who are in a good (and likely better) position to help. It should not be actually pulled into master until the test regressions are fixed. But pushing it seemed like the right thing to do at this point.

One important thing is that there is an esoteric bug in R3 which I isolated, and which BrianH is working on a "real fix" for. I just poked in a workaround temporarily. Here is the modification I made to [c-word.c around line 238](https://github.com/rebol/r3/blob/master/src/core/c-word.c#L238)... I just wrapped the while loop in an IF:

if (LEN_BYTES(VAL_SYM_NAME(words+h)) == len) {
while ((n = Compare_UTF8(VAL_SYM_NAME(words+h), str, len)) >= 0) {
...
}

You'll need that or the real fix for Compare_UTF8, for binary compatibility of the R2/R3 build of hello.red.

Performance-wise it suffers because I did not try to tackle a map! rewrite, since defining `hash!` as `block!` was easier. That's something that wouldn't be too hard to do, but more prudent to get the test suite passing again.

I threw most of my miscellaneous routines for R2/R3 support [into the r2-forward.r file](https://github.com/dockimbel/Red/blob/master/red-system/utils/r2-forward.r) just because it was included already and I didn't want to add new files if I could avoid it. But what we actually want is going to be a mixture of R2/Forward enhancements and the creation of R3/Backward.

These StackOverflow questions pertain to the documentation of issues of R2/R3 compatibility, sorted in rough order of importance:

http://stackoverflow.com/questions/15077974/how-to-use-unicode-codepoints-above-uffff-in-rebol-3-strings-like-in-rebol-2

http://stackoverflow.com/questions/14203426/can-parse-on-binary-in-rebol-2-capture-a-binary-instead-of-a-string-like-in

http://stackoverflow.com/questions/14525958/into-behavior-difference-in-rebol-2-parsing-vs-rebol-3

http://stackoverflow.com/questions/14532596/why-doesnt-rebol-3-honor-quoted-function-parameters-that-are-parenthesized

http://stackoverflow.com/questions/14405471/how-can-i-work-with-a-single-byte-and-binary-byte-arrays-in-rebol-3

http://stackoverflow.com/questions/14368508/weird-behavior-with-select-and-the-and-operators-returns-junk-or-none

http://stackoverflow.com/questions/14352264/difference-between-rebol-2-and-rebol-3-when-mixing-some-in-parse-with-change

http://stackoverflow.com/questions/14352039/expand-the-full-path-of-a-file-in-rebol-without-get-modes

http://stackoverflow.com/questions/14330738/what-does-positional-pick-on-an-object-do-in-rebol-2-and-whats-the-equivalent

http://stackoverflow.com/questions/14319411/how-to-convert-a-binary-to-a-char-in-rebol-2

http://stackoverflow.com/questions/14208269/common-way-of-testing-for-membership-in-a-map-working-in-both-rebol-2-and-3

If possible I'd like to have discussions/feedback about those questions and techniques on StackOverflow, at least as much of the discussion as we can.

Viva la Redolution...! :-)