REBOL3 tracker
  0.9.12 beta
Ticket #0002081 User: anonymous

Project:



rss
TypeWish Statusreviewed Date12-Oct-2013 15:59
Versionr3 master CategoryNative Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary Make REDUCE/INTO and COMPOSE/INTO work when targeting any-string
Description Given that you can do:

>> foo: "foo"
>> head insert foo reduce [1 + 2]
== "3foo"

You should be able to do:

>> foo: "foo"
>> head reduce/into [1 + 2] foo
** Script error: reduce does not allow string! for its out argument

As error message shows, you currently can't.
Example code

			

Assigned ton/a Fixed in- Last Update17-Feb-2014 21:10


Comments
(0004071)
BrianH
15-Oct-2013 00:15

REDUCE/into and COMPOSE/into are primarily meant for efficiency, by making intermediate blocks less necessary when doing incremental block construction. However, due to implementation constraints they only reduce the overhead of allocating intermediate blocks in the heap, which reduces GC pressure. They actually use the stack as an intermediate block, and just don't allocate another intermediate block in the heap.

Nonetheless, getting rid of this second intermediate block may increase efficiency in the operations that are equivalent to the INSERT something-stringish REDUCE-or-COMPOSE block code pattern. As long as we can do this efficiently, it shouldn't break the model to allow it. And it would allow us to make other mezzanine functions more efficient or flexible as well, like (RE)JOIN or REPEND. It probably won't help much with the other */into functions since they're using chained inserts, but we'll see.

We would need to figure out a way to share code with the existing INSERT action, to make it able to take its value parameter from the stack. It's a reshuffle, but it could help increase Rebol's efficiency and flexibility.

Date User Field Action Change
17-Feb-2014 21:10 BrianH Category Modified Unspecified => Native
17-Feb-2014 21:10 BrianH Status Modified submitted => reviewed
15-Oct-2013 00:16 BrianH Comment : 0004071 Modified -
15-Oct-2013 00:15 BrianH Comment : 0004071 Added -
14-Oct-2013 03:23 fork Summary Modified Make INSERT/INTO and COMPOSE/INTO work when targeting any-string => Make REDUCE/INTO and COMPOSE/INTO work when targeting any-string
14-Oct-2013 03:23 fork Description Modified -
12-Oct-2013 15:59 fork Ticket Added -