f*******y 发帖数: 988 | | X****r 发帖数: 3557 | 2 谁不建议使用就问谁啊。
如果你这个是对于早先有人贴的Google Style Guide所问的,
你看了上面每条规定所对应的详细解释吗?
Google的理由并不是对所有人都成立的。 | z******i 发帖数: 59 | 3 Performance problem.
RTTI: dynamic cast is expensive
exception: extra codes are generated for stack unwinding. Even if they are
not used, extra code size means:
1. Load code from main memory to instruction cache. cache pollution.
2. CPU is pipe-lined, CPU still needs to decode the assembly codes.
3. In order to preserve stack, compiler might not be able to optimize the
local variables to register. Big performance hit. | r*********r 发帖数: 3195 | 4 太复杂,属于让你 shoot your own foot 部分,禁了比较好,
程序出错少。尤其对于古狗那些比较傻的。 | r*********r 发帖数: 3195 | 5 i think exception has a more damaging problem.
that is, it will cause memory leak, when the exceptional path is taken.
especially when exceptions are thrown from constructors and destructors.
using RAII may solve the problem if the exception is thrown by constructor.
but the ones thrown by destructors are truly problematic.
【在 z******i 的大作中提到】 : Performance problem. : RTTI: dynamic cast is expensive : exception: extra codes are generated for stack unwinding. Even if they are : not used, extra code size means: : 1. Load code from main memory to instruction cache. cache pollution. : 2. CPU is pipe-lined, CPU still needs to decode the assembly codes. : 3. In order to preserve stack, compiler might not be able to optimize the : local variables to register. Big performance hit.
| g*****y 发帖数: 7271 | 6 I actually quite disagree this opinion. When discussing the good/bad of
exception. You have to think about when you should use it? If it is not good
, what are the alternatives? Do the alternatives solve the problem of
exception?
You should use exception when you have errors that cause the function cannot
finish its task. For example, you cannot get the memory you need from new/
malloc. If you do not use exception, you usually return error code. You
still have different excution path for errors
【在 r*********r 的大作中提到】 : i think exception has a more damaging problem. : that is, it will cause memory leak, when the exceptional path is taken. : especially when exceptions are thrown from constructors and destructors. : using RAII may solve the problem if the exception is thrown by constructor. : but the ones thrown by destructors are truly problematic.
|
|