REBOL3 tracker
  0.9.12 beta
Ticket #0002051 User: anonymous

Project:



rss
TypeWish Statussubmitted Date19-Aug-2013 14:43
Versionr3 master CategoryMezzanine Submitted byabolka
PlatformAll Severitytweak Prioritynormal

Summary Rename SPLIT's /INTO refinement
Description SPLIT currently has an /INTO refinement, that toggles between splitting into parts of length N and splitting into N parts (cf. the example code).

While aptly named in and of itself, this non-standard usage of /INTO conflicts with the intention to use `/INTO outbuffer` as a common refinement to pre-supply a result buffer to functions (to avoid allocating intermediate storage). This latter usage is currently implemented in e.g. AJOIN, COLLECT, COMPOSE, EXTRACT, REDUCE, or REWORD.

So SPLIT's /INTO refinement should be renamed, to avoid conflict with the standard /INTO usage.
Example code
;; Split into parts of length 2:
>> split [a b c d e f] 2  
== [[a b] [c d] [e f]]

;; Split into 2 parts:
>> split/into [a b c d e f] 2
== [[a b c] [d e f]]

Assigned ton/a Fixed in- Last Update15-Oct-2013 03:05


Comments
(0003945)
fork
20-Aug-2013 21:05

As evidenced by the above comments in the example code, /INTO would be a troublesome name that could apply to both scenarios...

A name that seems to only apply to the "/INTO" case could be /EVENLY..., although it would have to be explained as "Split into N equally-sized parts as best possible (with at most one non-empty piece of an unequal size to the others)"

>> split/evenly [a b c d e f] 2
== [[a b c] [d e f]]

>> split/evenly [a b c d e f] 7
== [[a] [b] [c] [d] [e] [f] []]

>> split/evenly [a b c d e f] 4
== [[a] [b] [c] [d e f]]
(0003948)
rgchris
21-Aug-2013 06:56

Is it certain that `split/into` shouldn't be default and defer the current default to a `split/skip` or `split/length`? To say `split "something" 4`, it might be expected that it splits into four parts. `split/skip "something" 4` would slice into four-sized pieces.
(0003949)
fork
21-Aug-2013 07:24

+1 for the switch and calling the old default behavior split/skip (as proposed by @onetom)

The current default skipping behavior is pretty Rebol specific. "I split the rope in two" means something in English, and it does not mean you split the rope in many pieces of size 2

split/length has the problem as with /into... are you splitting with the intent of producing a result which will have that length? Or are you splitting into pieces which have that length? It's ambiguous.

/skip is unambiguous, has precedent, and not contentious with English usage.
(0003951)
BrianH
23-Aug-2013 17:03

I agree with changing the default, but how about calling the new option /by instead? This would be more helpful when you do multi-level splitting, where the value you're splitting by would be an array compatible dimensions block, rather than a select compatible record size.
(0004075)
Gregg
15-Oct-2013 03:05

+1 for the switch and calling the old default behavior split/skip.

Brian, I think it will do what you want without /BY, because of how block args are processed. Or I'm misunderstanding.

Date User Field Action Change
15-Oct-2013 03:05 Gregg Comment : 0004075 Added -
23-Aug-2013 17:03 BrianH Comment : 0003951 Added -
21-Aug-2013 07:24 Fork Comment : 0003949 Added -
21-Aug-2013 06:56 rgchris Comment : 0003948 Added -
20-Aug-2013 21:05 Fork Comment : 0003945 Added -
19-Aug-2013 14:43 abolka Description Modified -
19-Aug-2013 14:43 abolka Code Modified -
19-Aug-2013 14:43 abolka Category Modified Unspecified => Mezzanine
19-Aug-2013 14:43 abolka Severity Modified minor => tweak
19-Aug-2013 14:43 abolka Type Modified Bug => Wish
19-Aug-2013 14:43 abolka Ticket Added -