How is a try catch block evaluated?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I wonder how a try-catch block is evaluated in matlab. In particular, is the try-catch block evaluated in runtime or compile time?
Also, is a try-catch block expensive?
If someone have a link to any documentation that would be much appreciated.
(Btw, I know that try-catch is not the best solution in most cases. Still I would like to know how it works, since I have used it in some code).
0 件のコメント
採用された回答
Sean de Wolski
2014 年 8 月 22 日
My understanding is that the JIT does work with try/catch and that they do not affect performance as long as no exceptions are thrown. As soon as an exception is thrown, MATLAB deals with handling the exception, where performance is not as critical.
0 件のコメント
その他の回答 (1 件)
Adam
2014 年 8 月 22 日
It is evaluated at runtime. There is no compilation in Matlab so most things are done at runtime (excluding Mex compilation and similar).
I may be misunderstanding the question though. Even in C++ it is evaluated at runtime, because you don't know at compile time if something will throw an exception. If it would always throw an exception known at compile time then I'd imagine that's some bad coding design.
2 件のコメント
Adam
2014 年 8 月 22 日
Yes, true, I was rolling in the JIT compilation with runtime activity, but should have said there is no pre-compilation.
参考
カテゴリ
Help Center および File Exchange で C Shared Library Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!