Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!brl-adm!brl-smoke!smoke!rbj@icst-cmr.ARPA From: rbj@icst-cmr.ARPA (Root Boy Jim) Newsgroups: net.lang.c Subject: Re: Register Addresses Message-ID: <2053@brl-smoke.ARPA> Date: Wed, 9-Jul-86 13:05:59 EDT Article-I.D.: brl-smok.2053 Posted: Wed Jul 9 13:05:59 1986 Date-Received: Thu, 10-Jul-86 05:11:03 EDT Sender: news@brl-smoke.ARPA Lines: 56 > Good point. We certainly have introduced another glitch here, but one we > are all familiar with. Consider in FORTRAN that when you call a subroutine > as CALL FOO(ARG). Your poor variable (passed by reference) is subject to > modification by FOO. To avert this, you can CALL FOO(ARG + 0). This > forces a temporary location to be generated for the expression, thereby > forcing a call by value. Are you arguing that because Fortran is gross, it is okay for C to be gross also? Yitch. No, I think fortran does the right thing here. > But back to C. I have traded absolute pointer accuracy for temporary > pointer convenience. That is, the address of a register variable is > only valid for the life of the callee. In other words, you are breaking the semantics of C. This is a very bad thing, certainly not worth it for the rather minor gain in convenience or efficiency that you propose. Let the programmer assign the register variable to an auto variable and pass the auto variable's address -- it is in the tradition of C to make programmers perform optimizations like this if they really want them. > But Wait! That's a Mimic! Register variables are really fast auto > variables, so after `f' returns, your static_p is worthless anyhow. > > It seems I have merely narrowed the scope a bit. Is it worth it? > Possibly. Scope glitches seem less limiting than storage class ones. This is an issue of lifetime, not scope. Okay, scope in the time domain :-) Also, a glitch where something that should be allowed isn't and causes an error message (taking the address of a register variable) is MUCH better than a glitch where something that should be allowed, and is according to the manual, quietly fails (using static_p). Except that I've never wanted to do what you propose, and I have often wanted the address of a register. We all know registers are different from `regular' (auto) variables. It's just a question of what differences. Taking the address of any auto variable is risky business; you can easily forget if it's valid or not. Why should it be surprising that registers are more transient? Do you have a Zippy quote database, from which a line is randomly selected for each letter/news item you send out? Sort of a Zippy "fortune"? Make that `Pinhead Fortune'. Yow! It comes with GNU EMACS. (Root Boy) Jim Cottrell I just forgot my whole philosophy of life!!!