Re: New slice operator
CChris wrote:
>
> No, no and no!
> Do you really think a function that checks whether the next word is "while"
> should error out if the line is shorter than 5 chars? You wind up with this
> }}}
<eucode>
> function Equals(sequence s,integer i,sequence pattern)
> if i<1 or i>length(s)-length(pattern)+1 then
> return 0
> else
> return equal(s[i..i+length(pattern)-1],pattern)
> end if
> end function
> </eucode>
{{{
> Look at the amount of generated code (use Matt's ildisasm out of curiosity),
> and wonder why we get more code where less many checks are actually needed.
> Both hard (the current way) and soft slice assignments are needed. I'd vote
> for Ricardo's ~ suggestion.
>
In the new standard lib, there is head(), tail() now that do what you are
suggesting. head("next", 10) -- "next"
--
Jeremy Cowgar
http://jeremy.cowgar.com
|
Not Categorized, Please Help
|
|