forked from rebolsource/r3
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRINT/FAIL new design, recursion, |, BINARY! UTF8
This adds features to PRINT and FAIL, and offers the functionality to make a string via FORM/NEW (because there is speculation that FORM may wind up being the word taken for this behavior, despite breaking legacy compatibility with the quoted-vs-non-quoting default). Largely this is folding a native implementation of what was called "COMBINE" into the basic behavior of PRINT. Changes are: BINARY! is not molded as a Rebol constant, rather interpreted as UTF8; if Rebol molding is desired that must be requested explicitly: >> print ["Hello" #{52656E2D43} "World"] Hello Ren-C World >> print ["Hello" mold #{52656E2D43} "World"] Hello #{52656E2D43} World Blocks can be used as in PARSE for grouping or recursion. Also as in PARSE, this creates the opportunity for stack overflows (but if one is running a general evaluation anyway, you could have already done that if you wanted). >> x-rule: ["The value of x is" space x] == ["The value of x is" space x] >> print [(x: 10 |) x-rule newline (x: 20 |) x-rule] The value of x is 10 The value of x is 20 By default, the top level of the block is separated by spaces while nested blocks are not: >> print ["Line" "One" ["Line" "Two"]] Line One LineTwo This may be overridden by /DELIMIT, which is able to take either a single delimiter or a block of delimiters--with each element of the block corresponding to a depth: >> print/delimit [ "Level" ["Level" ["Level" "Three"] "Two"] "One" ] ["1" "2" "3"] Level1Level2Level3Three2Two1One When the block runs out of delimiters but there is an extra level of depth, it will repeat the last delimiter. NONE! or BAR! may be used to suppress this. Hence the default delimiter is [#" " |]. The behavior of BAR! is not yet customizable, but follows the same logic--to insert different characters at different depths, but to also suppress other delimiting. At the outermost level it acts as a newline while inner levels it acts as a space, by default: >> print [["a" "b"] | "c" "d" | ["e" | "f"]] ab c d e f Included in the design is the suppression of delimiting when content does not add to the output. >> print/delimit ["the" {} ["brown" () "fox"]] "; " the; brown; fox A quoted version is also provided: >> print/quote [a b | [1 + 2]] a b 1+2
- Loading branch information
1 parent
7c34552
commit bdecddd
Showing
6 changed files
with
435 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.