Is this kosher?

6600pete at hub.UUCP 6600pete at hub.UUCP
Thu Dec 7 11:18:51 AEST 1989


>From article <21144 at mimsy.umd.edu-, by chris at mimsy.umd.edu (Chris Torek):
--- f() { char array[12-; ... }
 
-- What's the use of declaring such a thing beyond passing a pointer to it to
-- another module?
 
- ...you need some sort of stable object if it is intended to last
- beyond the activation of the function that contains it.
 
Right. I wasn't thinking that one would do anything but make the declaration
global. I suppose in a large file requiring lots of "stable objects" this
would be necessary, but it didn't occur to me.
 
-----------------
 
-- (BTW, IMHO, this one use of the declaration runs counter to
-- intuitive programming practices because it peppers the .c file with things
-- that go in the binary executable image file instead of on the stack.)
 
- Some people disapprove of this practise on principle, since it leads to
- strange results in cases like
-
-       printf("time1: %stime2: %s", ctime(&t1), ctime(&t2));
-
- since ctime() tends to use static storage.
 
- [ placed a little bit out of context ]
- I do not understand this question.
 
Oh yes you did! :-) That was my idea exactly.
 
------------------
 
--- Some entities---global variables and
--- all functions---*always* have static duration.  The confusion comes in
--- here, as the `static' keyword can be applied to them, this time
--- changing not their duration (which is already static) but rather their
--- linkage.  Static globals get internal linkage, which means that their
--- names do not appear to exist outside the one file...
 
-- IMHO, this is a weakness in the standard. Has it been bashed out before?
 
- How can it be a weakness in the standard when it was required by K&R-1?
 
Well, I don't know all that much about the way the committee operated;
I take it from this sentence that they took K&R as gospel and didn't
mess with it.
 
- It *could* be considered a weakness in C, that this keyword
- (`static') was overloaded to also mean `private' in various
- circumstances.
 
- This is not to say that avoiding keywords for the sake of avoiding
- keywords is necessarily a good thing, or that I agree with the choice
- of `static' as a modifier to imply `private'.
 
That is exactly my point. I am marking this Followup-to: comp.std.c,
which I don't read, because obviously we are in agreement on this issue.
I'm not interested in trying to change the ANSI committee's mind, because
this is the very first thing I have ever found in C that I didn't like.
I _would_ appreciate it if someone would mail me a clue as to why this
keyword was overloaded and no alias for it ("here"? :-) ) was added.
-------------------------------------------------------------------------------
Pete Gontier   : InterNet: 6600pete at ucsbuxa.ucsb.edu, BitNet: 6600pete at ucsbuxa
Editor, Macker : Online Macintosh Programming Journal; mail for subscription
Hire this kid  : Mac, DOS, C, Pascal, asm, excellent communication skills



More information about the Comp.lang.c mailing list