Re: left, right? head, tail? which one?

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

CChris wrote:
> 
> Performing bound checking in an include file is a waste of time, since the
> backend
> will perform some bound checking regardless. Testing twice doesn't add any
> value
> and wastes CPU. Even more so as thee operations easily occur in loops.

Bounds checking was the wrong word. What I mean to say is: I want up to the
first 30 items in a sequence. That's all I need. That's all I want to display.
So, to do that currently you must:

if length(s) > 30 then
    s = s[1..30]
end if
puts(1, s)


Now, you can simply:

puts(1, head(s, 30))


This is so common of an operation, I am very surprised we are having this much
troubles agreeing on it's usefulness.

> So let's have these builtin, so as to both spare useless typing and useless
> testing. Removing the extra bound checking has the added benefit of making the
> code leaner, hence clearer.

You cannot have what I did above built in. It was my mistake saying bounds
checking. You want the following to err out, as it does currently, because
Euphoria already does bounds checking (correct use of the term this time).

sequence s
s = "ABC"
puts(1, s[1..30])


That needs to err out, as it does.

--
Jeremy Cowgar
http://jeremy.cowgar.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu