chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] substring function and bounds checks


From: Michele La Monaca
Subject: Re: [Chicken-hackers] substring function and bounds checks
Date: Wed, 6 Feb 2013 00:55:16 +0100

On Wed, Feb 6, 2013 at 12:18 AM, Jim Ursetto <address@hidden> wrote:
> On Feb 5, 2013, at 4:11 PM, Michele La Monaca wrote:
>
>> Maybe this is not the right list for that, sorry. But is there a good
>> reason for this [error on out-of-bounds substring access] behavior?
>
> I think it's along the lines of (cdr '()) being an error in
> Scheme instead of NIL as in Lisp.
>
> Jim

Hi Peter, Morizt, Jim,

thanks for your answers.

What I can say... Well, maybe one day I will see the light, in the
meanwhile I would just have preferred a more useful substring
function. I really think that the one provided by chicken is simply
not on par with other languages, sorry.  The semantic of a
commonly-found substring function "give me at most N chars starting
from a certain position in the string" is the most useful according
me. I don't see any evil in that. The chicken (scheme?) alternative
"give me exactly N chars or blow up" is rather limited in scope to me.

> Scheme is about correctness.  If you provide invalid indices, you get errors.

Well, in the real world you can't always predict input and therefore
you must do checks.  Either you leave this burden to the user or you
kindly provide this even-cobol-has-it feature.

>This will help you detect bugs early on instead of just keep going on with a
>bad result of an incorrect computation until some other thing fails much
>farther along.  This kind of thing also tends to sneak in vulnerabilities, as
>you never *really* know what your code will do in the face of inconsistencies.
>"fail early and noisily" is good design.

To me, this only means more bloated, unreadable code in the best case,
unfriendly crashes in the worst one.

Regards,
Michele



reply via email to

[Prev in Thread] Current Thread [Next in Thread]