Re: Standard Euphoria Library Project
- Posted by Colin Taylor <ctaylor at racsa.co.cr> Feb 07, 2001
- 549 views
I agree with Ralf (and David). Euphoria is designed to elegantly handle precisely this situation. Why would you add totally unnecessary code to a routine, when the routine already works correctly for all legal values of i (1 <= i <= length(s))? To answer Kat's point, s = {} will crash because there is no legal value possible for i. - Colin Taylor ----- Original Message ----- From: Chris Bensler <bensler at mailops.com> To: <EUforum at topica.com> Sent: Wednesday, February 07, 2001 9:04 AM Subject: RE: Standard Euphoria Library Project > You shouldn't be allowed to try and access an out of bounds subscript.. > It may not crash, but why would you want it to do that? IMHO, it should > crash.. that's what error checking is for.. > > Chris > > Fam. Nieuwenhuijsen wrote: > > > David Cuny wrote: > > > > > > <SNIP> > > > > function remove( integer i, sequence s) > > > > -- remove ith element from s > > > > return s[1..i-1] & s[i+1..length(s)] > > > > end function > > > <SNIP> > > > > > > What if the user tries to remove the first or last item? > > > i would end up being 0 or greater than the length of >the sequence.. > > > > Yes, *but* Euphoria won't crash. When you slice from one above the > > length of > > the sequence or when you slice to zero it will return an empty seq > > rather > > than crash. > > > > Come on people. This is trivial beginners stuff. > > > > Ralf N. > > nieuwen at xs4all.nl > > > > > >