On 29/03/14 12:36 AM, comex wrote:
> On Sat, Mar 29, 2014 at 12:19 AM, Daniel Micay <danielmi...@gmail.com> wrote:
>>> This is unfair.  You're mixing up static checks such as
>>> exhaustiveness, freezing, and lifetimes, which have no performance
>>> impact (or at least, the performance impact caused by their
>>> limitations would be mitigated only by fundamentally rearchitecting
>>> the user code, not flipping a check off), with dynamic checks such as
>>> array bounds, RefCell, and division, which have an impact and can be
>>> flipped off.
>>
>> These do often have a performance impact despite being static checks.
>> The borrow checker forbids many valid patterns, and forces either a less
>> efficient solution or using `unsafe`. This is no different from how you
>> are forced to choose between safe indexingand unsafe indexing.
> 
> As I said, if you want to use the more efficient solution in that
> case, you have to rewrite the code to be unsafe-only anyway, so there
> is no (well, very little) downside to using special syntax rather than
> making the existing syntax do something different.  With dynamic
> checks, it is not usually necessary to rewrite.

A rewrite is usually going to be required, because the code was not
written with unsafe indexing in mind. Since sequential access is covered
well by iterators, most indexing in Rust is using dynamically generated
indexes which are not usually carefully checked. The failure already
handles checking, so it would be redundant to do it manually except to
report a higher-level error, but the libraries and compiler don't do
much of that.

> This is one of the arguments I was not disagreeing with.  But from the
> pragmatic perspective of getting numbers for Science, I doubt any
> actual Rust code depends on this distinction.

A lot of code in the compiler simply leaves out error checking and
relies on getting an ICE from the failure. It would take a long time to
translate everything into proper error messages. The standard library
also *often* assumes preconditions are true and relies on bounds
checking to catch any errors. This is the standard way to write code, so
it's not correct to assume that a bounds check failure is a logic error
made by the programmer who wrote the code. They are just normal runtime
failures.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to