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: John Cowan
Subject: Re: [Chicken-hackers] substring function and bounds checks
Date: Tue, 5 Feb 2013 19:35:02 -0500
User-agent: Mutt/1.5.20 (2009-06-14)

Peter Bex scripsit:

> Scheme is about correctness.  If you provide invalid indices, you get
> errors.  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.

In fact, R5RS and R7RS in no way require this kind of correctness.
(substring "foo" 0 10) is the equivalent of a domain error at the
value level, and both standards say that domain errors are up to the
implementation to handle as they see fit.  Chicken is definitely a "safe"
implementation as most are, but "unsafe" ones that return "foo" in this
case, or even crash, are entirely within the remit of the standards.
(R6RS is a different matter, but Chicken doesn't do R6RS, and even
implementations that do attempt compliance often aren't fully safe in
their error behavior.)

What Scheme is really about, if it has to be said to be about something,
is implementation choice.  Schemes provide and extend the language in
different ways, and you pick the one that provides the levels of speed,
safety, size, compilation speed, debuggability, or whatever other factors
you want.

-- 
Take two turkeys, one goose, four               John Cowan
cabbages, but no duck, and mix them             http://www.ccil.org/~cowan
together. After one taste, you'll duck          address@hidden
soup the rest of your life.
        --Groucho



reply via email to

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