Steven Schveighoffer wrote:

On 5/31/17 9:37 AM, Adam D. Ruppe wrote:
On Wednesday, 31 May 2017 at 13:04:52 UTC, Steven Schveighoffer wrote:
What are your thoughts? Have you run into this? If so, how did you
solve it?

I don't use vibe, but my cgi.d just catches RangeError, kills the
individual connection, and lets the others carry on. Can you do the same
thing?

There are a couple issues with this. At least from the perspective of vibe.d attempting to be a mainstream base library.

1. You can mark a function nothrow that throws a RangeError. So the compiler is free to assume the function won't throw and build faster code that won't properly clean up if an Error is thrown.

2. Technically, there is no guarantee by the runtime to unwind the stack. So at some point, your workaround may not even work. And even if it does, things like RAII may not work.

-Steve

that is, the question reduces to "should out-of-bounds be Error or Exception"?

i myself see no easy way to customize this with language attribute (new/delete disaster immediately comes to mind). so i'd say: "create your own array wrapper/implementation, and hope that all the functions you need are rangified, so they'll be able to work with YourArray".

Reply via email to