in reply to Re: Re: Re: Help - I'm a C programmer
in thread Help - I'm a C programmer
But if you want to do that then you probably wanted to use a variable other than errno.
Remember that the purpose of errno ($! to Perl programmers) is to pass a very specific type of error information implicitly between code that otherwise knows little about each other. Having each library define its own little custom error reporting tool just results in turning error handling into such a mess that nobody will bother to do it.
Now I agree with both telling beginning programmers the naive rule, and telling more experienced programmers the fact that it isn't always true. But for me the litmus test is simple. The question is, "Is this something that I want to have all of my code be aware of?" If I don't want to always be thinking of it, then it shouldn't be global. If I don't want to always be thinking of it within this package, then it shouldn't be a package global either.
So as you see, I am not religious about saying, "NO GLOBALS". However I don't use very many of them...
|
|---|