Author: Dann Corbit
Date: 12:13:40 06/21/04
Go up one level in this thread
On June 20, 2004 at 07:44:25, Ross Boyd wrote: >On June 20, 2004 at 07:20:11, Uri Blass wrote: > >>On June 20, 2004 at 06:00:58, Ross Boyd wrote: >> >>>My engine (coded in C) uses longjmp() to terminate a search. >>> >>>Is there any disadvantage or hidden overhead in this approach? >>> >>>I notice other engines use a flag which is tested at every node of the search. >>>Surely there's an overhead in doing it that way???? >>> >>>I suppose the main drawback of longjmp() is portability. Most languages other >>>than C don't support it. >>> >>>Am I missing something? >>> >>>Ross >> >>Tscp also is using longjmp() >>I did not read most of the code of other programs. > >Yes, and that's where TRACE inherited it. :-) > >> >>I do not know if most languages do not support it. >>Basic that was the first language that I wrote small programs with it has the >>goto command that is similiar. >> >>I also do not understand the connection between other languages and portability. >> >>Do you think to translate trace to program that is not written in C? > >Yes, by portability I meant cross-language (not cross platform). >I have no plans to translate TRACE to another language. :-) > >Mainly, I was wondering why most don't use longjmp(). It seems to me longjmp() >has less overhead than testing everywhere whether to return to root. And it >keeps the code simple and efficient. It is important to know that longjmp is not compatible with C++ exceptions (the standard definitely says not to use both in a C++ program.) Some compilers do allow it, but it is very dangerous to do so. So there is a caveat if you plan to port to C++ some day in the future. I very much like the C++ try/catch. The main reason is that it puts you into a proper mode of thinking for program construction. Once you get used to programming that way, your programs become very robust at handling resource problems.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.