Re: global variables are bad?



Richard G. Riley schrieb:
On 2006-03-11, Richard Heathfield <invalid@xxxxxxxxxxxxxxx> wrote:
Richard G. Riley said:
"Richard"posted the following on 2006-03-11:
Richard G. Riley said:

"Michael"posted the following on 2006-03-11:

There is no such thing as a global variable in C.

http://www.google.com/search?q=global+variables+in+c

http://www.google.com/search?q=tooth+fairy (nearly four million hits).

Just cos it's on Google, doesn't mean it exists.

You dont say? But when we find x thousand courses which are quite
happy to see "global variable" talked about in C then does it seem
quite right to start pretending it doesnt apply anymore in ng?

The word "variable" isn't all that useful, and the term "global variable" is less useful still.

No. Did
you read the initial reply?

Yes.

I did not think that reply in anyway
clarified anything.

You could have posted a direct reply.
You just could have expanded on mine and said that you consider
it too technical to be of any use to a newbie -- and be done.

For me, it was important to clarify that there are three
conceptual sides to it:
- Linkage
- Storage duration
- Ease or difficulty of seeing whether the implemented design
is the intended one, let alone correct

The former two are joined to the latter but may give toothaches
on their own. If I failed to carry this point over, then shame
on me. If you understood it but did not clarify it to suffice
your standards, shame on you.
In addition, it _is_ important to know what you are talking
about. The concepts mentioned should help the OP find his way
through it and also find out which side leads to which problem.
It may very well be that he decides to use a "global" variable
with internal linkage because this is exactly what he needs --
after having thought about why he does not want the uncertainties
involved in an object with external linkage and potential problems
when linking.


Did you think that was constructive for a newbie?

Yes. No point lyin' to 'em.

One has to be practical. Not too clever for ones own good sometimes.

This is true.
Nothing ever is simple, though, so I consider it fair to tell
people a little bit more.
A perfect reply certainly would be one of Chris Torek type (useful,
clear, concise, written nicely) but I certainly am not up to that
as I am neither a teacher nor a native speaker.


Yoou dont know or agree with the common meaning of "global variable" in
C?

The term has no universally recognised meaning in C.

Neither do lots of things : but the art is in recognising the meaning
from a newbie. Any half decent programmer worth his salt knows and
recognises what is meant by a global variable and in that context C
certainly does support them and the reasons for not using them are as
prevalent as in other languages : which is, fater all, what the OP was
asking. I dont know, maybe I'm getting too old for this : there was a
time when people wanted to help : not just get one upsmanship points
on who can read the standards the best.

The latter was not my intention. I post here to help and to
learn. I certainly do not pride myself on my often spotty knowledge
of the standard. You will guaranteedly find a couple of times
within the last month where I made a mistake and was glad because
it was corrected.
If you are saying that my reply was insufficient: You were free
to improve it. Next time I will take what you said into account
when answering a similar question.
If you are saying that I did it intentionally to show off, then I
think you are just once more out to look for an unnecessary fight
to pick -- and you are plain wrong.


Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
.



Relevant Pages

  • Re: Informed Decisions?
    ... At least I think that's what they're saying. ... or not your conclusion is correct, you don't understand the reasons ... grim by your standards, and conclude that laissez-faire worked badly. ... that different institutions would have given more attractive results--at ...
    (rec.arts.sf.fandom)
  • Re: Making C better (by borrowing from C++)
    ... needs to relax a but from some of the pedantry being enforced by ... Are you saying that fighting with Jacob Navia is "quality"? ... list which standards are permitted and if they are serious about not having ...
    (comp.lang.c)
  • Re: OT: anti-American Lefty Kills Recruiter, Left says nothing
    ... clarify your position, you say that what you said was not what you said.. ... and start to say that the questioner is saying something that he is not ... statement of your opinion. ... year olds that gay sex is natural is NOT OK. ...
    (rec.gambling.poker)
  • Re: One failed terrorist dead
    ... assume my standards can or do extend beyond myself to embrace dissenting voices in their absolute righteousness. ... You continually saying such tripe as that does not maker it true. ... You're just an ambivalent fool with no idea what you ...
    (uk.politics.misc)
  • Re: One failed terrorist dead
    ... assume my standards can or do extend beyond myself to embrace dissenting ... You continually saying such tripe as that does not maker it true. ... You're just an ambivalent fool with no idea what you ...
    (uk.politics.misc)