[racket-dev] `string-split'

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Apr 19 11:35:04 EDT 2012

An hour and a half ago, Ryan Culpepper wrote:
> Instead of trying to design a 'string-split' that is both
> miraculously intuitive and profoundly flexible, why not design it
> like a Model-T

Invalid analogy: the issue is not flexibility, it's making something
that is simple (first) and useful (second) in most cases.


An hour and a half ago, Michael W wrote:
> (TL;DR: I'd suggest two functions: one (string-words str) function
> that does Eli's way, and one (string-split str sep) that does it
> Laurent's way).

I don't think that we argued on what it should do, rather it looks
like we're both looking for whatever option looks best...


> >   -> (string-split " st  ring")
> >   '("" "st" "" "ring")
> > 
> > which is why I think that the above is a better definition in terms of
> > newbie-ness.
> 
> No, every other language I've worked with does that.
> [...]

The examples you're quoting are the equivalents of our `regexp-split',
which works in a similar way and is not going to change.  We're
talking about some watered-down version that is easier to use.


Just now, Laurent wrote:
>     (TL;DR: I'd suggest two functions: one (string-words str)
>     function that does Eli's way, and one (string-split str sep)
>     that does it Laurent's way).
> 
> That would be a good option to me, considering that "my way" is with
> remaining ""s in the output list.  The question remains if a string
> can be accepted for sep, in which case the empty string must be
> considered, as pointed out in the Lua discussion. Though a single
> char should be sufficient for nearly all simple cases.

I think that I have a good conclusion here, I'll post on a new thread.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.