Re: String?
Pete Lomax wrote:
>
> On Tue, 01 Jun 2004 20:00:15 +0000, StewartML <Stewart at isoclass.co.uk>
> wrote:
>
> <snip>
> >if you ever see the need to output the integer values of a string,
> That particular need could be easily met, eg:
> sequence s
> string t
> t="hello"
> s=repeat(0,length(t))
> for i=1 to length(t) do
> s[i]=t[i]
> end for
>
> As an application programmer, I would have no qualms with having to do
> something like that to "rip apart" a string, and of course if you do
> need such in several places, it is trivial to code as a function.
I would have thought that all one needed to do was ...
sequence s
string t
t="hello"
s=t
This is like what one does for integers and atoms.
atom x
integer y
y=1
x=y
As a string is really a subset of a sequence, converting it to a sequence
should be a trival effort for the interpreter.
> >or vice versa, then you could just assign it to the relevant data type,
> I think you can guess how I think a sequence could easily be converted
> into a proper string (with integer(), >0, and <256 checks, of course)
Your 'proper string' is still only good for certain subsets of strings. It
wouldn't work for Unicode strings. And ASCII or EBCDIC strings either as you
exclude the NUL character.
The NUL is a valid character. For example many printers and modems need
it in their control strings.
> It may be tempting to think you can automate such conversions, but I
> think that will (may) cause problems, and is not really needed.
>
> (btw, thanks - that just cleared up a few things for me)
>
> >
> >The major problem i have with sequences is the fact that you need to use
> >equal() for simple strings.
> Tell me about it
Apart from the way upper() and lower() are
> currently implemented (which cannot in anyones mind be the best), just
> how often are =, !=, <, <=, >, >= actually used as sequence ops?
I'm with you on this one though. The upper/lower functions are only good
for ASCII encoding. Try this on for size ...
? lower({74.5, 104.01})
? upper({74.5, 104.01})
RDS is concerned that some requested features for Euphoria might be
little used and thus not really worth the trouble of adding them...such
as using relationship operators as if they were sequence operations
--
Derek Parnell
Melbourne, Australia
|
Not Categorized, Please Help
|
|