rebol/rebol — pull request #166 by hostilefork (2013-10-03 22:19:52+00:00)
Title: Default splice matching block types else use explicit /SPLICE (CC #2057)

This implements the simplifying principle that splicing of any-block types for operations such as INSERT, APPEND, and CHANGE only happens if the block types match. Otherwise you have to ask for it explicitly:

>> append [a b c] [d e f]
== [a b c d e f]

>> append [a b c] 'd/e/f
== [a b c d/e/f]

>> append/splice [a b c] 'd/e/f
== [a b c d e f]

For the moment, /splice overrides /only and does not signal an error, if for some reason you use both:

>> append/only/splice [a b c] 'd/e/f
== [a b c d e f]

The PARSE functions for CHANGE and INSERT required modification as well to support this. If you have `x: [1 2 "foo" "baz" "bar" 3 4]` then this is how it goes:

>> parse x [some [to string! change [some string!] [mumble]]] probe x
[1 2 mumble 3 4] ;-- as before

>> parse x [some [to string! change [some string!] only [mumble]]] probe x
[1 2 [mumble] 3 4] ;-- as before

>> parse x [some [to string! change [some string!] (mumble)]] probe x
[1 2 (mumble) 3 4] ;-- new behavior, dropped parens before by default

>> parse x [some [to string! change [some string!] splice (mumble)]] print x
[1 2 mumble 3 4]

If your x was instead in parens, then this would be different, e.g. with `x: quote (1 2 "foo" "baz" "bar" 3 4)`

>> parse x [some [to string! change [some string!] (mumble)]] probe x
(1 2 mumble 3 4)

>> parse x [some [to string! change [some string!] [mumble]]] probe x
(1 2 [mumble] 3 4)