Smart slicing
Neal Becker
ndbecker2 at gmail.com
Sun Mar 23 05:35:46 PDT 2008
bearophile wrote:
> Trevor Parscal Wrote:
>> Allowing out-of-bounds indexes hides bugs. An out of bounds index should
>> always be an error which is considered exceptional.
>
> I (like all all Ruby and Python programmers) use such things all the time,
> and only once in a while it actually produces a bug in my programs, so I
> presume you are wrong.
>
>
>> If you handle the index wrapping yourself, it's obvious to everyone that
>> in that particular case that would be an OK thing to do - in all other
>> cases, it could potentially be an error..
>
> In my post I am talking about using an alternative (standard) syntax fur
> such usages (to keep speed up, not to remove bugs).
>
I use my own vector/matix code in python. I made sure that out-of-bounds
indexes are not silently ignored. This is a very valuable feature.
y[a:b:c] = z[d:e]
I rely on the error checking here to tell me when I mis-calculated. It has
found many errors for me.
More information about the Digitalmars-d
mailing list