Re: if statement not working

new topic     » goto parent     » topic index » view thread      » older message » newer message

-------Phoenix-Boundary-07081998-

Hi David Cuny, you wrote on 3/22/02 7:04:39 AM:

>To reiterate:
>
>0. The goal is to write safe string handling code.
>1. Slices (by themselves) are unsafe when working with strings.
>2. Guarded slices are unsafe because the guard isn't coupled to the string.
>3. Euphoria doesn't provide any built-in routines for creating substrings.
>

How about a new operator '=~' that acts like '=' except that it
plows on ahead in the face of errors:
    s =~ t[2..4]
    -- s is padded to length 3 if necessary

    if s[2..4] =~ '123' then
    -- comparison fails if s is too short
    -- (or uninitialized!)

I suppose the postfix '~' could also be applied elsewhere:
    s = t[2..8]~  --s has 6 elements even if t has 4
But I haven't thought too much about that.


Karl Bochert

-------Phoenix-Boundary-07081998---

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu