[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A very basic thing I don't get
- From: Mark Hamburg <mark@...>
- Date: Sat, 1 Oct 2011 12:53:30 -0700
On Oct 1, 2011, at 12:15 PM, Stefan Reich wrote:
> Hm. Well. Undefined is not very cool. Maybe your program happens to
> rely on 'undefined' (it might not notice as there is not really an
> error message) - and then we try to run it in, say, Kahlua and then it
> doesn't work anymore.
> Isn't it a lot smarter to have well-defined operators for all common
> operations? I mean, we're talking about the length of a list here. Not
> something exotic or so. You use that thing every day, all the time.
> One nil in there, and the result is undefined? Is that safe?
> I don't really think so.
> And if it isn't - why don't we join forces and solve that little problem?
Boundedly undefined behavior is a common choice in processor designs and programming languages. It allows greater latitude in implementation and optimizations. For example, there are plenty of pieces of C that are implementation specific -- e.g., when exactly increment and decrement operators are evaluated relative to the expression in which they occur. The policy is essentially that the language (or processor or...) isn't designed to support particular usage patterns but it won't blow up if those patterns are used.
The # operator is actually quite well defined in that you can count on particular properties of its result. It's just that in an array with holes the value isn't uniquely defined.