rebol/rebol — pull request #162 by hostilefork (2013-10-02 17:34:33+00:00)
Title: Simplify TO BLOCK! and complex construct via MAKE BLOCK! (CC #2056)

[CC #2056](http://curecode.org/rebol3/ticket.rsp?id=2056) was a general rallying call to creating a clean philosophy of what TO vs. MAKE were supposed to do. This addresses the particular case of TO BLOCK! vs MAKE BLOCK!.

Previously, both TO BLOCK! and MAKE BLOCK! ran through the same function `Make_Block_Type()` with a flag indicating whether the action was A_TO or A_MAKE. This made the two functions enigmatically similar with unusual exceptions. This splits the routines into a very simple `To_Block_Type()` which either copies the values of a source block into a new block subtype, or wraps a non-block value inside of a block subtyped type... and then a `Make_Block_Type()` function which does more complicated things with its arguments.

The most immediately-noticeable impact of this change is that TO BLOCK! of a string will wrap the string inside of a block. This more closely parallels how values like INTEGER! or DATE! were handled before. To get the tokenization into Rebol values as it used to work, you will have to use MAKE BLOCK!. This required changes to mezzanine routines for LOAD.

More generally, MAKE BLOCK! no longer falls through to copying blocks if given a block as input. Instead, a block input to MAKE BLOCK! is reserved for future expansion as a "block allocation dialect". *(Currently, the only internal creation parameter make supports is an integer specifying a preallocation count for an empty block... e.g. MAKE BLOCK 10. But if more settings were desired, a block such as **make block! [min-size: 10 max-size: 20]** could be used to specify the information.)* If mere duplication of a block is needed, COPY can be used to get the same type or **to output-block-type input-block** if the output block type does not match the input type.

Another difference is that previously TO BLOCK! of a typeset would provide a block containing a list of those types, while MAKE BLOCK! would not do anything with it. In the spirit of this change, TO BLOCK! will now merely wrap the typeset in a block...while MAKE BLOCK! does the more complex operation.

For clarity, the parameters in the C functions were renamed to better reflect the parameters for the TO and MAKE natives, as well as the tricky re-use of the type REBVAL to hold the result. This also renames the second parameter of the TO native to "value" in order to differentiate it better from the "spec" taken by MAKE.

This causes two tests in the core-tests suite to fail. [This one](https://github.com/rebolsource/rebol-test/blob/master/core-tests.r#L82):

[[] == to block! ""]

and [this one](https://github.com/rebolsource/rebol-test/blob/master/core-tests.r#L1571):

; context-less get-word
e: try [do to block! ":a"]
e/id = 'not-defined

In both cases, the problem is remedied by changing the TO into a MAKE.