TRIM has a mean number of refinements:
rebol2>> help trim
USAGE:
TRIM series /head /tail /auto /lines /all /with str
DESCRIPTION:
Removes whitespace from a string. Default removes from head and tail.
TRIM is an action value.
ARGUMENTS:
series -- (Type: series port)
REFINEMENTS:
/head -- Removes only from the head.
/tail -- Removes only from the tail.
/auto -- Auto indents lines relative to first line.
/lines -- Removes all line breaks and extra spaces.
/all -- Removes all whitespace.
/with
str -- Same as /all, but removes characters in 'str'. (Type: char string)
Whenever we see this many refinements on a function, we tend to ask ourselves...
"...Should This Be A Dialect?"
If we imagine TRIM is a string operation, then we could make it arity-1, and give it distinct meaning when you pass a BLOCK!.
Let's say you don't pass a block, then trim str could clear out leading and trailing whitespace. Maybe even trimming interstitial whitespace down to just a single space. I dunno if there's a good default meaning.
But then, what about:
>> str: --[ Your string here ]--
>> trim [~ str]
== --[Your string here ]--
>> trim [str ~]
== --[ Your string here]--
>> trim [~ str ~]
== --[Your string here]--
>> trim [~str~]
== --[ Your string here ]--
>> trim [~ ~str~ ~]
== --[Your string here]--
I'm choosing ~ here because it's not a WORD!... if I used something like * then you could have a situation where that's assigned to a string. We could use _ for space, but it seems more like it's adding spacing than striking it...
The idea of then connecting that to using quasiforms to mean "strip out interstitial spacing of the attached term" is interesting.
That's not necessarily a great specific idea, but I think the gist is pretty solid.
Compare:
>> trim [~ str ~]
== --[Your string here]--
>> trim:head:tail str
== --[Your string here]--
Have other things to work on, but just thought I'd mention this, because it occurs to me every time I have to maintain TRIM.