Nadim Khemir <[EMAIL PROTECTED]> wrote: :>(None of the examples in C-Cookbook, by the way, use a static variable.) :No because they strive to be good examples.
I don't think leaving out all mention of such things is necessarily the best way to promote best practice. :I don't know how much C you wrote in your life A fair bit. :if you use a static variable in a function or a module: :- you can't use the function/module in multithreaded code :- you can't use the module without having full control over the call :sequence :- even if you have a single thread, you can't have two instances of your :object/module/structure (whatever it is) and guaranty it will work as :expected (even if you can have complete control you will be sharing your :module won't you?) :- your dog will get instantly momified and your mother in law will pay you a :visit every day (in fact she will move into your life) That's all fine. This is one-off throwaway code to solve a problem. The problem, in this case, is a recursive calculation calling itself billions of times, so every cycle I can shave off helps. I'll probably end up rewriting the whole thing in C, but I'd like to maximise the speed I can get without doing that first. I was hoping that I'd encountered a well known issue, but since not I'll go try to make a more formal test case. Hugo
