Re: Permanently "global" ?

From: Chung Leong (chernyshevsky_at_hotmail.com)
Date: 02/16/04


Date: Sun, 15 Feb 2004 21:32:47 -0500

What you have are constants. In general, it's best to avoid using variables
as constants (because variables are not constant). Constants always have
global scope.

You can't create your own super globals. You can hijack one of the existing
ones though:

$_ENV = $glb;

Uzytkownik "mrbog" <dterrors@hotmail.com> napisal w wiadomosci
news:cbd4bb52.0402141810.359d24c5@posting.google.com...
> I have an array/hash that stores path information for my app. As in,
> what directory this is in, what directory that's in, what the name of
> the site is, what the products are called, etc. It's called $glb.
>
> So, every function so far looks like this:
>
> function something() {
> global $glb;
> }
>
> over and over and over
>
> How do I make $glb just always be global? I'm assuming there's a way
> to do this, otherwise let me know and I'll parachute out of this
> language and run back home to perl.
>
> thanks
> mrb
>
>
>
>
> ------------------------------------------
> Signature:
> Never buy the services of newsfeed.com. I am a paying customer but
> I'm using google to post messages, so that I can avoid their damn
> advertisement showing up in every post I make.
> ------------------------------------------



Relevant Pages

  • Re: Allocation of a multidimensional array of structures
    ... so I've tried debugging my program ... Or to turn the question around, why should I use that prototyping ... just good practice and helps avoid undefined behavior. ... Well, while I'm aware that it's better to avoid using globals, it's ...
    (comp.lang.c)
  • Re: Allocation of a multidimensional array of structures
    ... multidimensional array allocation code: ... In case you're refering to writing void lut_alloc; ... Well, while I'm aware that it's better to avoid using globals, it's ...
    (comp.lang.c)
  • Re: Pass locatioin to Secondary Form
    ... that I am going to avoid the globals and already have recoded a couple ... passing some limited variables to another form. ... would be passing the location of a second form. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Code Feedback Wanted (Generating more garbage)
    ... David Steuber wrote: ... To avoid 'global' variables, you can create a ... closure with local variables and only those functions which need access ... This gives you the convenience of not having to pass the 'globals' as ...
    (comp.lang.lisp)