On Monday, 23 February 2015 at 09:51:07 UTC, Manu wrote:
This is going to sound really stupid... but do people actually
use
exceptions regularly?
I'd say exception are exceptional in most code. That being said,
unless the compiler can PROVE that no exception is gonna be
thrown, you are stuck with having to generate a code path for
unwinding that decrement the refcount.
It means that you'll have code bloat (not that bad IMO, unless
you are embeded) but more importantly, it means that most
increment/decrement can't be optimized away in the regular path,
as you must get the expected count in the unwinding path.
Moreover, as you get some work to do on the unwind path, it
becomes impossible to do various optimizations like tail calls.
I think Walter is right when he says that switft dropped
exception because of ARC.
I've never used one. When I encounter code that does, I just
find it
really annoying to debug. I've never 'gotten' exceptions. I'm
not sure
why error codes are insufficient, other than the obvious fact
that
they hog the one sacred return value.
Return error code have usually been an usability disaster for the
simple reason that the do nothing behavior is to ignore the error.
The second major problem is that you usually have no idea how
where the error check is done, forcing the programmer to bubble
up the error where it is meaningful to handle it.
I'll agree though that this can't be changed at this point in
the game.
You say that's a terminal case? Generating code to properly
implement
a decrement chain during unwind impacts on the non-exceptional
code
path?
Yes as you can't remove increment/decrement pairs as there are 2
decrement path (so there is pair).
I agree. I would suggest if ARC were proven possible, we would
like, switch.
I'd like to see ARC support in D, but I do not think it makes
sense as a default.
3. Memory safety is a requirement for any ARC proposal for D.
Swift ignores
memory safety concerns.
What makes RC implicitly unsafe?
Without ownership, one can leak reference to RCed object that the
RC system do not see.