Re: if statement not working
-------Phoenix-Boundary-07081998-
Hi Kat, you wrote on 3/22/02 2:50:39 PM:
>> How about a new operator '=~'
>First thought: ~ like "fuzzy logic"? Hmmm, better write that as a real
>optional include at this point, Rob will never sign onto it.
We already know that Rob will sign on to almost nothing
I think using an operator to provide this option is both more
efficient and safer than using a new type. (not to mention easier).
I was going to use '==' but then '==' and '=' seem backwards to
me.
There is great scope for artistry here-- how about (=) or
>> 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
>Since you specified [2..3], why pad s some more? And with what?
> Better to look at what t actually has, and deliver what is in
> the envelope of [2..3] and no more. If [2..3] doesn't exist,
> then return {}. If you asked to borrow a book that i don't have,
> i won't pad out a empty box of non-existant book with some
> random selection of book parts.
If I ask you for a book and you are missing the last chapter, I
might appeciate getting what you have.
Your [2..3] confused me, so to make the sample clearer:
sequence t = "abcd"
sequence s = t[3..6]
I can see 4 possible results:
1) ""
2) "cd"
3) "cd "
4) Fatal Error
I like 2), i.e. do the best you can.
>> if s[2..4] =~ '123' then
>> -- comparison fails if s is too short
>> -- (or uninitialized!)
>
>In this case, if s is too short, it's not equal. You did a test
> there, not an extraction or assignment, it obviously fails,
> but shouldn't bomb the whole program.
By 'fails', I meant that the boolean test fails (returns false)
>> 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.
>
>Nononononono! In this case, if t has 6 elements, Eu should
> grab the [2..6] of them for s, making s have 5 elements.
With a moment's reflection, I agree.
Karl Bochert
-------Phoenix-Boundary-07081998---
|
Not Categorized, Please Help
|
|