From: Eero Saynatkari Date: 2006-10-13T14:02:54+09:00 Subject: Re: Silent out-of-index problems--how much of a problem are they really? --++alDQ2ROsODg1x+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2006.10.13 13:34, Kenneth McDonald wrote: > As a Python user starting to mess around with Ruby, one of my biggest=20 > concerns is the fact that so many operations on lists 'fail silently'=20 > (return nil) when given list indices that are out of bounds. In=20 > particular, I worry that this might produce hard-to-track down errors,=20 > as the problem might not show up until one tries to do something with=20 > the returned value(s); and by that may be somewhere far away in the=20 > code. Certainly the guilty list access won't show up in the call stack. >=20 > On the other hand, it's often thought that dynamic languages will result= =20 > in lots of difficult-to-find problems due to the lack of strong typing,= =20 > but both Python and Ruby users know that's not the case. >=20 > So my question is, _in practice_, how difficult is it to track down=20 > index-out-of-bounds-errors in Ruby? It can certainly be a godawful=20 > problem in C, and I'm pretty sure it would be in Python, too, if=20 > exceptions weren't thrown. And in Ruby, how does one track done where=20 > such errors actually occur? In Python, I can simply look at the stack tra= ce. >=20 > This isn't a criticism of Ruby. (Well, one aspect maybe). I'm looking at= =20 > Ruby because there are a lot of things (documentation tools,=20 > consistency, gems, others) that it does better than Python. But I do=20 > worry about silent index errors. I can honestly say that I have never had this issue. I can see that it might be worrying but it is just like any other language feature--when you know it, you plan for it, you write your code with it in mind. And this is not to say it is a terrible inconvenience to have to do this. The code seems to be more natural than with error handling. Oh--Arrays, not lists :) --++alDQ2ROsODg1x+ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFLx1t7Nh7RM4TrhIRAjuGAKCs7ndZ5yk8nnKEvslg0RfMy1XMlwCgqx5s ci/Twds1F5nX4sO/Qcp3nNQ= =EJWX -----END PGP SIGNATURE----- --++alDQ2ROsODg1x+--