Difference between revisions of "DIP76"
WalterBright (talk | contribs) m (formatting) |
m (links) |
||
(One intermediate revision by one other user not shown) | |||
Line 22: | Line 22: | ||
|- | |- | ||
|Links: | |Links: | ||
+ | |[http://forum.dlang.org/post/mfvi86$10ml$1@digitalmars.com NG Discussion] — [https://issues.dlang.org/show_bug.cgi?id=14519 RFE] | ||
|} | |} | ||
Line 33: | Line 34: | ||
== Benefits == | == Benefits == | ||
− | * Becomes nothrow, which enables code that uses it to become nothrow. Nothrow code does not need to produce exception unwinding wrappers, which | + | * Becomes nothrow, which enables code that uses it to become nothrow. Nothrow code does not need to produce exception unwinding wrappers, which can improve the performance of using ref counted objects. |
− | can improve the performance of using ref counted objects. | ||
* Becomes @nogc, because the thrown exception is allocated on the GC. | * Becomes @nogc, because the thrown exception is allocated on the GC. | ||
* Becomes consistent with the behavior of std.utf.byDchar(). | * Becomes consistent with the behavior of std.utf.byDchar(). |
Latest revision as of 20:53, 26 May 2015
Title: | Autodecode Should Not Throw |
---|---|
DIP: | 76 |
Version: | 1 |
Status: | Draft |
Created: | 2015-04-06 |
Last Modified: | 2015-05-26 |
Author: | Andrei Alexandrescu and Walter Bright |
Links: | NG Discussion — RFE |
Contents
Abstract
When the autodecoder encounters invalid UTF, it throws an exception. This proposal changes that so it replaces the invalid UTF with the Replacement Character.
Benefits
- Becomes nothrow, which enables code that uses it to become nothrow. Nothrow code does not need to produce exception unwinding wrappers, which can improve the performance of using ref counted objects.
- Becomes @nogc, because the thrown exception is allocated on the GC.
- Becomes consistent with the behavior of std.utf.byDchar().
- Will be somewhat faster.
- Current industry practice has evolved towards using replacement characters for bad UTF rather than failing.
Breaking Existing Code
This can break existing code, although it seems highly unlikely that any programs actually require the decoding to throw on invalid UTF.
Deprecation Path
There doesn't seem to be any deprecation path for this change. It will have to be abrupt.
NG Announcement
Copyright
This document has been placed in the Public Domain.