This:
> put char 3 to end of word of container1 into container2
reminded me of one of the pretty simple things I've had trouble doing, I
think in SuperTalk, but maybe I'm thinking of AppleScript:
put char 3 to LAST of line 7 into whatsLeft
It seems like I'm always having to do something along the lines of:
put the number of chars of line 7 into lastChar
put char 3 to lastChar of line 7 into whatsLeft
or
put char 3 to (the number of chars of line 7) of line 7 into whatsLeft
and even then there are sometimes problems parsing (like, is it "to" or
"thru", or "char x to y" or "charS x to y", etc.)
This is an interesting and recurrent discussion (maybe "Re: " should be a
delimiter...), and suggests to me that it's important to a lot of people.
XTalk's string handling is in many ways very nice (principally its
proximity to English), but there are clearly things it doesn't do as well
as we would like, above and beyond delimiter handling, and the worries over
delimiter persistence. It feels to me like we're "stuck in a groove"
(whatever metaphor will we find to replace that?) with this delimiter thing
- maybe we could try to tackle a broader set of string-manipulation goals?
I'd like a top priority to preserve the language's readability. Say,
something like perl's feature set, with xTalk syntax, would be very nice
indeed.
Two tacks for this task: any perlers out there, tell us what's really cool
that you can do easily in perl, but not in xTalk. And everyone, how about
contributing some simple descriptions of things you want to do to text?
(the HTML-parsing examples earlier in this thread are a good start). My
ideal would be that the descriptions of what you want the language to do
would become the language (how much more English-like can you get?) But
I'm sure we'll fall somewhat short of that ideal. Still, it's something to
shoot for...
To get things rolling, here's something I did earlier today using BBEdit's
grep feature.
I had entered names into a bibliography last-first:
Smith, Mary K., Jones, Albert, and Johnson, Gene.
Only the proper publication format was (sigh) first-first:
Mary K. Smith, Albert Jones, and Gene Johnson.
I'm not good enough with grep to handle the final person automatically in
the same grep pattern with the first ones, but here's how I got all but the
first:
replace
([^,\r]*), ([^,\r]*),
with
\2 \1,
That is, replace
any sequence of characters, none of which is a comma or a carriage return,
followed by a comma and a space, followed by another sequence of
characters, none of which is a comma or a carriage return, followed by
another comma and a space
with
the second sequence followed by a space followed by the first sequence
followed by a comma and a space.
Whew. Maybe English-like isn't such a great idea. But then, of course,
another way of expressing this in English is: change the order of the names
from last-first to first-first. (leaving aside the issue that first-first
= 0)
I don't know. I've rambled on enough for tonight.
Looking for that perfect language,
--Carl