in reply to Re: Re: Help - I'm a C programmer
in thread Help - I'm a C programmer
For me, the amount of globals I use depends very much on the type of code I am writing. (See useful discussion on styles of code @ Why I like functional programming).
For e.g. an object class, I would expect no globals to be used in the implementation.
For e.g. an event loop (driven my user input), where you have large numbers of entry points into the code, you don't want to handle the passing of the state around everywhere, specially when the state gets large.
The "globals" though should be carefully restricted to the smallest possible scope so that they don't pollute. It should be rare that the scope is "main", for any Packages in Perl.
Taking the errno example, I took the view recently that it was better
to hide the implementation of errors and provide an error() function
that would provide the most recent error, rather than expose the implementation
of errors within the package. Now I can change the implementation later without breaking
existing user code.
--
Brovnik
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Help - I'm a C programmer
by Sifmole (Chaplain) on Jun 18, 2001 at 16:21 UTC |