[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SRFI-13 final version

This page is part of the web mail archives of SRFI 13 from before July 7th, 2015. The new archives for SRFI 13 contain all messages, not just those from before July 7th, 2015.

shivers@xxxxxxxxxx writes:
>    One minor whinge concerning SRFI-13:
>    We still don't have string-split.
>    <grovel mode=abject>
>    Please, please, please, please, please, please...
>    </grovel>
> You're covered, dude. You just say
>     (string-tokenize s char-set:graphic)

Well, my current deal (I'm feeding the code-repository wombat
a source-code control system written in Scsh) needs something like:

	(string-split s "@")

but path manipulators want

	(string-split s ":") - or - (string-split s ";")

And when I port Scsh's nifty filename-manipulations I'll be wanting
the ever-lovin'

	(string-split s "/")

I know that Oleg and I aren't a majority, but hey, this is a fairly
common thing to do. I even implemented it (not, of course, in full
Shiverian generality) in the time that I was waiting for a response.

(define (string-split s delimiter)
   (let ((sl (string-length s))
	 (dl (string-length delimiter)))
      (let unfold ((index 0) (strings '()))
	 (let ((start (string-contains s delimiter index)))
	    (if start
		(unfold (+ start dl)
			(cons (substring s index start) strings))
		(reverse (cons (substring s index sl) strings))

but even string-tokenize which admitted a predicate function parameter
type would make it semantically easy (as in: not involving SRFI-14) to
write all these little snippets.

> And, by the way, we *definitely* need to get a good parser/unparser thing
> defined. A number->string converter that takes all the field-width, padding,
> and other options that a full PRINTF implementation would use, a regexp SRFI,
> a LALR parser macro like Manuel Serrano's got in bigloo, etc. 

Absolutely. The read/rp read/lalrp stuff in Bigloo is one of it's
bigger wins. It's amazing how quickly you can write syntactically
aware tools for less-privileged languages using it.

david rush
Did mentioning Scsh gain me any points?