Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2919
          for JMS@ARIZMIS; Fri, 18-APR-1986 22:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/18/86 at 23:43:59 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014522; 19 Apr 86 0:19 EST
Received: from USENET by SMOKE.BRL.ARPA id a004803; 18 Apr 86 23:55 EST
From: Tim Smith <tim%ism780c.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: An amusing piece of code
Message-ID: <1723@ism780c.UUCP>
Date: 15 Apr 86 21:34:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <360@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes:
>
>Assuming that you can't put BCD-common-code into a function, I
>agree with everyone else that you should use [forward-referencing!]
>goto's here, and [again] cite Prof. Knuth's _Structured_Programming_
>_with_Goto's_.  One major problem is that this code jumps into blocks
>[the effect of case C: and case D: ].  This is something that X3J11
>warns about.  I thought K&R did, too; but I can't find it.  It is
>generally a bad practice, although most compilers seem to allow it
>without too much trouble.
     
At least in one case, jumping into blocks has been blessed by DMR,
so I am not too worried about that.
     
The problem with the goto versions is that one then has to think of a
name for the label, and make sure one uses the same name in two places.
Yuck-o!
     
Here is a suggested form that should satisfy the goto supporters, and
still not make me have to think of a name for the label:
     
#define GOTO_THERE      if(0){
#define THERE           }
     
    switch(v) {
case A; A-code; break;
case B; B-code; GOTO_THERE;
case C: C-code;   GOTO_THERE;
case D: D-code;
          THERE;        /* the ; looks sort of like a : */
        THERE;
        BCD-common-code; break;
case E: E-code; break;
    }
     
In real programs, one might have several groups of cases, each with
different common code.  Most of the methods suggested can get kind of
ugly, with gotos all over the place.  I think the best way is to probably
have two switches, one after the other:
     
    switch(v) {
case A:         A-code; break;
case B:         B-code; break;
case C:         C-code; break;
case D:         D-code; break;
case E:         E-code; break;
    }
    /*
     * handle common code
     */
    switch(v) {
case B:
case C:
case D:         BCD-common-code(); break;
    }
     
This can be easily expanded, and I think it is pretty readable.  Not that
it can be expanded with a third switch to handle a third level of common
code, etc.
--
Tim Smith       sdcrdcf!ism780c!tim || ima!ism780!tim || ihnp4!cithep!tim

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2965
          for JMS@ARIZMIS; Fri, 18-APR-1986 22:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/18/86 at 23:46:48 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014535; 19 Apr 86 0:20 EST
Received: from USENET by SMOKE.BRL.ARPA id a004839; 18 Apr 86 23:57 EST
From: Raver Dave <dave%ur-helheim.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: Re: ... C builtin functions?
Message-ID: <601@ur-helheim.UUCP>
Date: 16 Apr 86 17:36:45 GMT
Xref: seismo net.lang:2421 net.lang.c:8745
To:       info-c@BRL-SMOKE.ARPA
     
In article <359@uvacs.UUCP> rwl@uvacs.UUCP (Ray Lubinsky) writes:
>> >C has standard built-in functions????
>>
>> It looks like a function invocation, and is known and understood
>> by the compiler...
>
>The thing is, sizeof() evaluates to a constant *at run time*, just like
>'c'<<3  or  BUFSIZ  .  That makes it a pretty trivial function.  All it
>really does is give you a portable, automatic facility for referring to
>system dependencies.
>
>Ray Lubinsky    University of Virginia, Dept. of Computer Science
     
< *  italics mine * >
     
sizeof and BUFSIZ and a good implementation of  'c' << 3 resolve to
constants at *compile time*.  No run time *evaluation* is necessary.
     
     
     
--
"The Faster I Go the Behinder I Get"
--Lewis Carroll
     
Dave Carlson
     
{allegra,seismo,decvax}!rochester!ur-valhalla!dave

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3280
          for JMS@ARIZMIS; Fri, 18-APR-1986 23:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 00:12:34 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014609; 19 Apr 86 0:36 EST
Received: from USENET by SMOKE.BRL.ARPA id a004594; 18 Apr 86 23:47 EST
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <961@umcp-cs.UUCP>
Date: 16 Apr 86 22:41:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <577@ur-helheim.UUCP> badri@ur-helheim.UUCP
(Badri Lokanathan) writes:
>There are several ways of creating infinite loops:
     
Namely, `while (1)' and `for (;;)'.  (There are others, but these
seem to be the nominal standard.)
     
>... is there any reason (other than personal preferance) why one
>would prefer to use any particular form?
     
Some compilers generate a `test the constant 1' for the former
sequence, and no test for the latter; but I imagine that by now
this is rather rare.
     
>I personally prefer the while(1) form since it seems to make better reading.
     
Oddly enough, I prefer the other form, but for the same reason.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3326
          for JMS@ARIZMIS; Fri, 18-APR-1986 23:18 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 00:17:25 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014612; 19 Apr 86 0:37 EST
Received: from USENET by SMOKE.BRL.ARPA id a004615; 18 Apr 86 23:48 EST
From: "Roger J. Noe" <rjnoe%riccb.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Array of pointers to functions
Message-ID: <663@riccb.UUCP>
Date: 14 Apr 86 23:32:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>         just what do you folks *do* when you try to construct a
> declaration in C?  This question is *not* rhetorical, nor intended as an
> insult.... I'd really like to know how folks go about constructing
> variable and type declarations in C.  Please mail me your methods...
> I'll post a summary if the response warrants it.
> --
> Wayne Throop at Data General, RTP, NC
     
Tough luck, Wayne, I feel like posting this.  See article <662@riccb.UUCP>
in net.sources.  It's a shell program to convert words to C declarations or
casts, somewhat similar to the CDECL seen on the net before but somewhat more
portable and easier to modify.  Hope it's some use to somebody.  I welcome
comments and suggestions regarding it.
--
"Listen, in order to maintain airspeed velocity a swallow needs to beat
 its wings forty-three times every second.  Right?"
    Roger Noe            ihnp4!riccb!rjnoe

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3627
          for JMS@ARIZMIS; Fri, 18-APR-1986 23:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 00:44:19 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014623; 19 Apr 86 0:44 EST
Received: from USENET by SMOKE.BRL.ARPA id a005340; 19 Apr 86 0:18 EST
From: robison@uiucdcsb.ARPA
Newsgroups: net.lang.c
Subject: Re: Byte order (or you are both wro
Message-ID: <139200027@uiucdcsb>
Date: 15 Apr 86 22:23:00 GMT
Nf-ID: #R:rochester.ARPA:17162:uiucdcsb:139200027:000:461
Nf-From: uiucdcsb.CS.UIUC.EDU!robison    Apr 15 16:23:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
> CHALLENGE:  Come up with a scheme for representing numbers, and a sorting
> scheme in which numbers sort naturally.  Your scheme must deal with variable
> length character strings and variable size numbers.  That is, you cannot
> requires strings to be padded with nulls, or numbers to be padded with zeros.
     
...
-4 = AAAAZ
-3 = AAAZ
-2 = AAZ
-1 = AZ
 0 = M
 1 = Z
 2 = ZZ
 3 = ZZZ
 4 = ZZZZ
...
     
Arch D. Robison
University of Illinois at Urbana-Champaign

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3947
          for JMS@ARIZMIS; Sat, 19-APR-1986 00:10 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 01:10:24 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014619; 19 Apr 86 0:40 EST
Received: from USENET by SMOKE.BRL.ARPA id a005175; 19 Apr 86 0:12 EST
From: richw@ada-uts
Newsgroups: net.lang.c
Subject: Re: #define kinda stuff
Message-ID: <10200041@ada-uts>
Date: 15 Apr 86 14:24:00 GMT
Nf-ID: #R:cwruecmp.UUCP:1458:ada-uts:10200041:000:1849
Nf-From: ada-uts!richw    Apr 15 09:24:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
I don't have any suggestions, but I might be able to provide some
insight...
     
I think it depends on your implentation of C.  You see, it depends
on what the "lexical analyzer" of your particular compiler does to
the text in the C-preprocessor lines.  It would seem that when you
say:
     
    #define foo <text here>
     
that this has the same effect as doing a global replace, as editors
do, of "foo" with "<text here>".  However, at least some compilers
I know of first cut up "<text here>" into lexical tokens, i.e. it
breaks up the text into identifiers, strings, special C symbols
(like '{' and '}'), and so on.  This sequence of TOKENS, (not simply
the sequence of characters) is then used wherever "foo" is encountered
(this is actually more efficient since lexical analysis of "<text here>"
is then only performed once for each occurence of "foo").
     
The important point, though, is that most lexical analyzers throw
away comments.  So, if your compiler does this, I see little hope of
EVER being able to re-define C's comment delimiters.  Judging by your
description of the various things you tried, it seems as if your
compiler does indeed lex the text of a define, so if I were you
I'd give up and REALLY start hacking with "sed" or something.
     
By the way, you'd think that what C is supposed to do here is well-
defined.  Well, unless the standard that ANSI's working on does so,
I know of no such clear definition.  A while ago, I played with the
idea of writing a lexer for C and discovered that there were some
ambiguities (within Kernighan & Ritchie, at least) as to what
#define REALLY means.
     
You might want to check Harbison & Steele; that C text might make
mention of this sort of thing (I, unfortunately, don't own a copy,
but I've looked at it and it's usually more specific than K&R about
most things).
     
Hope this helped,
Rich Wagner

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4059
          for JMS@ARIZMIS; Sat, 19-APR-1986 00:23 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 01:16:50 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014663; 19 Apr 86 1:02 EST
Received: from USENET by SMOKE.BRL.ARPA id a005724; 19 Apr 86 0:32 EST
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Funxions
Message-ID: <2554@utcsri.UUCP>
Date: 13 Apr 86 08:58:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2524@brl-smoke.ARPA> rbj@icst-cmr (root) writes:
>> That may be the original practice, but the X3J11 (ANSI C) drafts, now quite
>> clearly say that all functions defined in the library are reserved (ie, you
>> can't redefine them), and may be builtin to the compiler.  I believe that the
>> /usr/group standard (& probably P1003) reserved every function from all major
>> UNIX* variants.  It may be that redefining these reserved library functions
>> will continue to work in *YOUR* implementation, but it's not guaranteed.
>>
>Before I flame at the bogosity of this proposed madness, I will entertain
>suggestions as to why this decision was made. Fire away.
>
>On another note, `sizeof' is NOT a builtin funxion. It is merely a funny
>way of writing an implementation defined constant.
>
Many thoughts. First of all, when I read the suggestion that sizeof might
be a builtin function, I definitely took that as a gag, and I am tired of
reading about why it isn't. Secondly, Jim, you may be interested to know
( if you don't know already ) that, in Britain, the correctn't know already )
 that, in Britain, the correct spelling of
'connection' is 'connexion'. :-)
     
Why should library functions be reserved? I haven't seen X3J11 so I don't
know which or how many functions they are going after, but on the
surface it seems a good idea to reserve things like getc and printf
and fopen and so forth. It will make it easier to port stuff - but on
the other hand, like any standard, it may well stifle improvement.
I don't think it would be smart to reserve the whole friggin'
library, though - this is just silly. Does this include things like
getenv and getppid and symlink that may not have meaning on a
non-UN*X system?
     
Suppose you had an OS where getc(f) could be done by sticking f
in a register and executing a processor trap. A compiler recognizing
built-ins could generate in-line code for this.
     
On  related point ( I'll explain why ), do y'all remember "Weird C
behaviour"? One of the problems being that printf was being passed the
wrong types?
     
Well, lint can't catch this sort of thing because it is told by
/*VARARGS*/ to keep its cotton-picken hands off any call of printf.
Anyway, in order to check this, it needs to know (1) that printf,fprintf,
sprintf are special cases, (2) how to interpret printf format strings.
The format may be known only at run-time: printf(fmt_string,...).
However, in view of the facts that printf's are frequent, and that mistakes
in parameter types are fairly common, and that 95% of printf calls have
string constants for formats, I would like to see lint do this. If
the format parameter was not a string constant, you would be on your
own of course. The following is a borderline case:
     
    printf( c<' '|| c>'\176'? "\\%3o":"%c", c);
     
It would probaby be asking too much for lint to recognize what was
going on, and then check *both* format strings - but it would be nice.
I do the above sort of thing once in a while. Anyway, so whaddya think?
     
Of course, the same sort of thing can be done for scanf - although
this is used less commonly.
     
If 'printf' and friends were to become *quote* built-in *unquote*
functions, this addition to lint would be even more justified.
Can you imagine redefining printf and then having lint tell you
that your format string was out to lunch?
     
Now for something completely different...
From: g-rh@cca.UUCP (Richard Harter)
>    Grumble, grumble.  Sorry, this is a real practical problem.
>    Let me give some context.  Suppose you are doing a high speed
>    sort of character strings.  Being a clever fellow you have
>    read the glossed over parts of the literature and have seen
>    that a math sort is O(n) rather than O(n log n).  You also
>    notice that it is cheaper to compare 4 bytes at once with
>    an 32-bit integer compare than to make 4 byte compares.
     
I'm not sure on this - isn't it ridiculous to do a mathsort of 32-bit
ints? In O(n) above ( for the mathsort) doesn't n become 2^32 rather
than the list size? If so, it would of course be even sillier for
larger ( i.e. reasonably-sized ) char strings.
     
'Bye for now...
--
"If you aren't making any mistakes, you aren't doing anything".
----------------------------------------------------------------------
Greg Smith     Unive

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4554
          for JMS@ARIZMIS; Sat, 19-APR-1986 00:56 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 01:49:33 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014852; 19 Apr 86 1:54 EST
Received: from USENET by SMOKE.BRL.ARPA id a006885; 19 Apr 86 1:16 EST
From: cjl%iuvax.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Array of pointers to functions
Message-ID: <9500031@iuvax.UUCP>
Date: 14 Apr 86 17:14:00 GMT
Nf-ID: #R:brl-smok:-239800:iuvax:9500031:000:951
Nf-From: iuvax!cjl    Apr 14 12:14:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
> I'm confused.  How do you specify an array of pointers to functions?  Do
> you do it:
>           int (*foo[])();
> or do you do it:
>           int ((*foo)())[];
     
  If C enforces postfix notations for all its declarations, the world will
be more peaceful. Two of its declarators use postfix notation ( [] and () ),
while pointer uses prefix notation ( * ). Confusion about declarator precedence
will disappear IF we CHANGE the syntax of pointer declarator to a postfix
notation. So when we speak "an array of pointers to functions", we
can write down immediately as "int foo [] * ()". To face the reality
in the C world, we translate the above back into " (* (foo [])) () ".
(Parentheses are used here to avoid the precedence problem.)
Remembering the rule that postfix declarators has higher priority than
prefix declarators, we can save some of the parentheses as
" (* foo []) () ".
     
     
C.J.Lo
UUCP : ...!iuvax!cjl
ARPA : cjl@Indiana@CSNet-Relay

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4670
          for JMS@ARIZMIS; Sat, 19-APR-1986 01:01 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 01:57:37 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014708; 19 Apr 86 1:18 EST
Received: from USENET by SMOKE.BRL.ARPA id a005946; 19 Apr 86 0:43 EST
From: Lawrence Crowl <crowl@ROCHESTER.ARPA>
Newsgroups: net.lang.c
Subject: Re: Byte order (or you are both wro
Message-ID: <17312@rochester.ARPA>
Date: 17 Apr 86 18:39:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>I wrote:
>> CHALLENGE:  Come up with a scheme for representing numbers, and a sorting
>> scheme in which numbers sort naturally.  Your scheme must deal with variable
>> length character strings and variable size numbers.  That is, you cannot
>> requires strings to be padded with nulls, or numbers to be padded with zeros.
     
Arch D. Robison wrote:
>...       -4 = AAAAZ   -3 = AAAZ   -2 = AAZ   -1 = AZ
>  0 = M    1 = Z        2 = ZZ      3 = ZZZ    4 = ZZZZ ...
>
     
An interesting solution.  I totally failed to consider unary notations.  Just
to keep the answers honest, I will add the requirement that some efficient
form of representation be used.  Radix notation is efficient, but you are not
required to use it.  For extra credit, extend your notation to deal with
non-integral values.  This is easy under current notation if the integral
part is the same.
P
--
     
Lawrence Crowl             716-275-5766        University of Rochester
                                               Computer Science Department
...!{allegra,decvax,seismo}!rochester!crowl    Rochester, New York,  14627

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4754
          for JMS@ARIZMIS; Sat, 19-APR-1986 01:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/19/86 at 02:06:50 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014870; 19 Apr 86 2:00 EST
Received: from USENET by SMOKE.BRL.ARPA id a007403; 19 Apr 86 1:36 EST
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: define kinda stuff
Message-ID: <1818@ihlpg.UUCP>
Date: 16 Apr 86 22:46:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> David Eppstein (eppstein@cs.columbia.edu, seismo!columbia!cs!eppstein)
> writes (11 Apr 86 21:12:26 GMT)
> > Obviously the right way to do this is the following:
> >
> >     #define  cat(a,b)  a/**/b
> >     #define  (-:       cat(/,*)
> >     #define  :-)       cat(*,/)
> The problem is to define '(-:' as '/*' (start of comment), and :-) '*/'.
> Please correct me, but I feel this will not work. Either the cat-definition
> will look like 'ab' when it is expanded - obviously wrong -, or it will
> look like 'a/**/b', which is wrong also. If you get '//**/*' as the
> expansion, this surely isn't a start of a comment.
> The whole thing boils down to whether the preprocessor does recursive
> deletion of comments, which it never has as far as I know. For example:
>
> /*    if (variable != 21) {         /* Test for ... */
> has always been a comment-line, where the first '/*' is an easy
> way to discard the whole line. If you put another '*/' at the end of
> the line, the 'syntax error' is very near...
     
Ignoring the unportability of a preprocessor which accepts macros that are
not identifiers.
     
The assumption the above works on is that BOTH the preprocessor and the
compiler extract comments.  This is a VALID assumption which is very often
violated in the name of efficiency.  The compiler SHOULD strip comments
even if the preprocessor does since you should not assume it will be
preprocessed by a comment stripping preprocessor.  But, SHOULD and does are
different words.
     
--j.a.tainter

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5030
          for JMS@ARIZMIS; Sun, 20-APR-1986 10:21 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/20/86 at 09:36:00 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022204; 20 Apr 86 10:25 EST
Received: from USENET by SMOKE.BRL.ARPA id a022063; 20 Apr 86 10:07 EST
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: define kinda stuff
Message-ID: <2584@utcsri.UUCP>
Date: 18 Apr 86 18:49:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2604@brl-smoke.ARPA> see@NTA-VAX.ARPA (Stein-Erik Engbr}ten) writes:
>The problem is to define '(-:' as '/*' (start of comment), and :-) '*/'.
>
>> Obviously the right way to do this is the following:
>>
>>     #define  cat(a,b)  a/**/b
>>     #define  (-:       cat(/,*)
>>     #define  :-)       cat(*,/)
>
>The preprocessor doesn't allow '(-:' as a definition-name
>(Berkeley 4.2/4.3).
>
>However, the program below doesn't do what it is supposed to either.
>When the preprocessor has finished, you just get 'main() {'.
>
>-->#define cat(a,b)        a/**/b
>-->#define start_comm        cat(/,*)
>-->#define end_comm        cat(*,/)
>-->
>-->main()
>-->{
>-->    start_comm   This is a comment   end_comm
>-->    cat(pri,ntf)("This is a nice one...\n");
>-->    printf("Hello...\n");
>-->}
True.
>
>When in a comment, no expansion is done!
>
>How do we then define something which is to end a comment? I would say
>it is impossible, but is eager to hear of anybody who thinks otherwise.
>
>Stein-Erik Engbr}ten
     
The following method is stolen from one of the winners of last years'
obfuscated-C-code contest ( Col. G. L. Sicherman <decvax!sunybcs!colonel>):
     
------------------- funny.c ----------------
#define b *
#define start_comm        /b
#define end_comm        b/
     
main()
{
    start_comm   This is a comment   end_comm
    printf("Hello...\n");
}
     
-------- cc -E funny.c: --------------------
     
# 1 "funny.c"
     
     
     
     
main()
{
        /*   This is a comment       */
    printf("Hello...\n");
}
     
I guess it works because the pre-processor doesn't *know* it is
in a comment. The '/*' doesn't appear until *after* the 'b' is expanded,
and by then the pre-processor is past the '/', so the comment is not
recognized. The following also works (and was used in Col Sicherman's
winning entry):
     
#define toggle_comment /b/
     
Of course, this method causes the pre-processor to pass your comments
to the compiler proper.
     
( By the way, Col Sicherman won the 'worst abuse of the preprocessor'
category ).
--
"If you aren't making any mistakes, you aren't doing anything".
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1805
          for JMS@ARIZMIS; Sun, 20-APR-1986 16:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/20/86 at 17:47:08 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024195; 20 Apr 86 18:30 EST
Received: from USENET by SMOKE.BRL.ARPA id a024846; 20 Apr 86 17:44 EST
From: "Bennett E. Todd III" <bet%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <1444@ecsvax.UUCP>
Date: 18 Apr 86 19:04:54 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
I've always been fond of:
     
    ...
    #define EVER ;;
    ...
        for (EVER) {
    ...
     
I know, it's terminally "cute".
-Bennett
--
     
Bennett Todd -- Duke Computation Center, Durham, NC 27706-7756; (919) 684-3695
UUCP: ...{decvax,seismo,philabs,ihnp4,akgua}!mcnc!ecsvax!duccpc!bet

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9464
          for JMS@ARIZMIS; Tue, 22-APR-1986 04:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/22/86 at 05:32:17 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014562; 22 Apr 86 6:09 EST
Received: from USENET by SMOKE.BRL.ARPA id a018854; 22 Apr 86 5:51 EST
From: Lawrence Crowl <crowl@ROCHESTER.ARPA>
Newsgroups: net.lang.c
Subject: Re: Byte order (or you are both wrong)
Message-ID: <17420@rochester.ARPA>
Date: 21 Apr 86 13:32:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2568@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>In article <17162@rochester.ARPA> crowl@rochester.UUCP (Lawrence Crowl) writes:
>>CHALLENGE:  Come up with a scheme for representing numbers, and a sorting
>>scheme in which numbers sort naturally.  Your scheme must deal with variable
>>length character strings and variable size numbers.  That is, you cannot
>>requires strings to be padded with nulls, or numbers to be padded with zeros.
>How about prepending the digit count to big-endian digit strings?
>so 32 and 126 become 232 and 3126, and a lexical comparison gives
>3126 > 232. Of course, leading zeroes in the significand cannot be used. ...
The problem with this scheme is that it assumes a constant size "length" field.
This is the best that I have yet seen though.
     
>>Note that many part numbering schemes have intermixed letters and digits.
>But what significance do letters have? do you want them to be ignored,
>or to be assigned a dictionary order with the numbers?
This is part of the problem!
     
>P.S. this rather obscure scenario hardly seems reason to state that
>little- and big-endians are both wrong.
     
Sort the following list of "words": 302, 3B2, -42, 132, 26, AD, ab, 74LS00
     
--The damn poster program wants more lines.
--It says "more included lines than new next".
--I've said all I want to say.
--You want more lines?
--Take this!
--Feed it to your line eater!
--Burp!
--
     
Lawrence Crowl             716-275-5766        University of Rochester
                                               Computer Science Department
...!{allegra,decvax,seismo}!rochester!crowl    Rochester, New York,  14627

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9841
          for JMS@ARIZMIS; Tue, 22-APR-1986 05:06 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/22/86 at 06:02:13 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014641; 22 Apr 86 6:38 EST
Received: from USENET by SMOKE.BRL.ARPA id a019375; 22 Apr 86 6:11 EST
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: void *
Message-ID: <728@bentley.UUCP>
Date: 22 Apr 86 03:45:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1883@ucsfcgl.UUCP> ucsfcgl!arnold (Ken Arnold%CGL) writes:
>Purists will note that I really should say
>    ptr = (some_type *) malloc(10 * sizeof *ptr);
>But eventually malloc() will be of type "void *".
     
Okay, enlighten me.  When I first saw the idea of "void *" I thought it was
to be a name for the most restrictive pointer type ("ALIGN *" for those who
know the malloc source).  Then when I rechecked, I found that it was a new
name for the least restrictive pointer type, "char *".  Now you seem to say
that the cast operator is unnecessary in your example.  I'd like some more
detail about this beast.  Specifically, suppose we have the following:
    void  *v;
    char  *c;
    short *h;
    ALIGN *a;
Of the 12 nontrivial assignment statements, which ones will ANSI C accept
without a cast?  What will lint accept (with/without cast)?
     
Currently lint warns about things like h=c because it doesn't know whether c
is aligned properly for use as a short pointer.  Thus every nontrivial use of
malloc, even with the appropriate cast, generates a lint warning.  This is
why I thought that "void *" was going to mean "ALIGN *", which would be the
appropriate return value for malloc().  (Also more efficient, on word-based
machines.)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0127
          for JMS@ARIZMIS; Tue, 22-APR-1986 07:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/22/86 at 06:12:36 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa14648; 22 Apr 86 6:39 EST
Received: from USENET by SMOKE.BRL.ARPA id a019394; 22 Apr 86 6:12 EST
From: George Robbins <grr%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Infinite loops
Message-ID: <116@cbmvax.cbmvax.cbm.UUCP>
Date: 21 Apr 86 20:05:31 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <117@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>
>do ... while(1);
>while(1) ...
>for(;;) ...
>
>are all widely-used idioms for unconditional looping in C.
>I personally prefer the latter, but the choice is just a
>matter of taste.  Any reasonable compiler will generate
>efficient code for all three constructs.
     
#define loop for(;;)
     
This is a clean way to do it, but be aware that there is no obvious stopping
point, and soon C purists will soon be declaring that your code has been tainted
by exposure to noxious influences from Algol 68 or worse...
     
--
George Robbins - now working with,    uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing    arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department    fone: 215-431-9255 (only by moonlite)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0233
          for JMS@ARIZMIS; Tue, 22-APR-1986 07:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/22/86 at 06:21:12 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014651; 22 Apr 86 6:40 EST
Received: from USENET by SMOKE.BRL.ARPA id a019428; 22 Apr 86 6:13 EST
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Wayne Throop's declaration poll
Message-ID: <731@bentley.UUCP>
Date: 22 Apr 86 04:44:00 GMT
Keywords: e2c
To:       info-c@BRL-SMOKE.ARPA
     
In article <1436@homxb.UUCP> homxb!gemini (Rick Richardson) writes:
>There was a memo on "e2c" and "c2e" at AT&T several years back.
>You could type at it:
>    array of pointers to functions returning pointers to ints
>And it would tell you what the declaration should look like.
     
Trouble is, many people who can't get the declaration right without
help would also have trouble phrasing it correctly in English.  In
particular, many people say "pointer to array of x" when they mean
"pointer to first element of array of x", which is "pointer to x".
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3819
          for JMS@ARIZMIS; Tue, 22-APR-1986 12:48 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/22/86 at 13:46:01 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028364; 22 Apr 86 14:24 EST
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a000640; 22 Apr 86 14:11 EST
Date:     Tue, 22 Apr 86 14:11:01 EST
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       KW Heuer <kwh%bentley.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  void *
     
You're mixing two features of malloc().  Malloc() should return (void *),
which is a generic pointer type to/from which all other pointer types
may be cast without loss of information.  (This is the only use of
(void *), and it is the only universal pointer type; other pointer
casts can be non-portable.)  Malloc() ALSO guarantees that the pointer
it returns is suitably aligned for safe casting to ANY pointer type.
This is a property of malloc(), not of (void *).

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5264
          for JMS@ARIZMIS; Tue, 22-APR-1986 15:56 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/22/86 at 16:40:35 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004100; 22 Apr 86 17:24 EST
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa04750; 22 Apr 86 16:54 EST
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a003584; 22 Apr 86 16:37 EST
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02558; Tue, 22 Apr 86 16:37:56 est
Date: Tue, 22 Apr 86 16:37:56 est
From: root <rbj@ICST-CMR.ARPA>
Message-Id: <8604222137.AA02558@icst-cmr.ARPA>
To: info-c@BRL.ARPA, roger@LL-SST.ARPA
Subject: Re: C Builtin Funxions
Cc: zben@UMD2.ARPA
     
> From roger@ll-sst Sun Apr 20 15:31:29 1986
>
>     In article <2564@brl-smoke.ARPA>, rbj@icst-cmr.ARPA (root) writes:
>     > Some of us know what we're doing. One sees lots of redefinitions of
>     > things like `putc' in {VM,}UNIX code. It is often desirable to use
>     > high level funxions (printf) while hacking up a lower level one.
>
>     Of course, you realize redefining putc will have no effect on printf...
>
>         Wayne
>
> > Silly me! I *axually* believed the UNIX documentation! I quote from
> > man 3 printf:
> >
> > ... Characters generated by printf are printed by putc(3S).
>
> "*Axtually* the documentation is correct!" [The sound of one defending
> sacred writ from the unfaithful.]  But, well, it's true.  Printf does
> call putc, but [I quote from man 3 putc]:
>
> ... BUGS
>     Because it is implemented as a macro, \fIputc\fR ...
>
> [a great place to find it documented, no?] and, better, but still not
> in a place it will jump out at you, [man 3s intro]:
>
> ... The in-line macros \fIgetc\fR and \fIputc\fR(3S) handle characters
>     quickly.  The higher level routines [list including printf] all use
>     \fIgetc\fR and \fIputc\fR ...
>
> Once putc has been expanded in-line, redefining it elsewhere won't have
> full effect.  Just as in your better example, you'd have to recompile
> printf (and then where's portability? ...).
>
> Yrs,    Roger    <roger@ll-sst.arpa>
     
Silly me! I *axually* goofed! I got confused between `putc' and `putchar',
which altho defined as a macro, is also a real funxion as well because it
predated the stdio library. Sigh.
     
Allow me to start from square one and appeal to the higher principles I
was attempting to demonstrate by my errant example.
     
I don't want the compiler taking the liberty of expanding ANY funxions
inline unless I direct it do do so via a macro or some kind of #pragma
that specifys inline expansion! Compilers DO NOT know about specific
funxion calls!
     
Someone suggested that `putc' could put the char into a register and
make a system call. So could `putc.s'.
     
As for portability, I SUPPLIED the funxion with my code, so it does
EXACTLY what I say it does. If it is legal portable C, it ports!
     
As to my friend Ben Cranston's suggestion that I should use
`myprintf' and `myputchar', this is a very good idea, lest we
forget what the funxion really does. However, this may not always
be an option where objects but no source is available. Hiya Ben!
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8090
          for JMS@ARIZMIS; Tue, 22-APR-1986 23:02 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/22/86 at 23:35:04 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005778; 23 Apr 86 0:19 EST
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a008797; 23 Apr 86 0:09 EST
Date:     Wed, 23 Apr 86 0:04:53 EST
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       root <rbj@ICST-CMR.ARPA>
cc:        info-c@BRL-SMOKE.ARPA
Subject:  Re:  lint
     
>> Perhaps he should have said "There is really no justification
>> for doing C software development on a system other than UNIX"?
     
> Come on Doug, you don't *really* believe this, do you?
     
Sure I do.  Just because you build Chevrolets for a living
doesn't mean you can't drive to work in a Mercedes.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9483
          for JMS@ARIZMIS; Wed, 23-APR-1986 02:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 03:14:40 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006442; 23 Apr 86 3:59 EST
Received: from USENET by SMOKE.BRL.ARPA id a009481; 23 Apr 86 3:44 EST
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Sorting ANYTHING
Message-ID: <453@bu-cs.UUCP>
Date: 22 Apr 86 02:31:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
>If you're going to sort a small number of things, it doesn't really
>matter what you use. If you're sorting lots of stuff, use a system
>sort and save the maintainer the headache of reading *your* sort.
>
>    (Root Boy) Jim Cottrell        <rbj@cmr>
     
Or, if your system doesn't have a sort (or a useable sort) go to the
library and find Quicker Sort in the ACM Collected Algorithms and copy
the Fortran and Publication Algol code and go re-do it in whatever
language you like, won't take long and it's short enough it requires
no deep understanding. I did this for a bunch of people in a Chem dept
who were using the VMS1.6 SORT command and saved them something like
98% of the time for sorting matrix elements (like from 30 minutes to
30 seconds or something like that) and became an instant hero...and I
stole the code! Use the terrain.
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4322
          for JMS@ARIZMIS; Wed, 23-APR-1986 12:19 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 11:45:17 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015775; 23 Apr 86 11:32 EST
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a017042; 23 Apr 86 11:19 EST
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA04449; Wed, 23 Apr 86 11:18:50 est
Date: Wed, 23 Apr 86 11:18:50 est
From: root <rbj@ICST-CMR.ARPA>
Message-Id: <8604231618.AA04449@icst-cmr.ARPA>
To: gwyn@BRL.ARPA
Subject: Re:  lint
Cc: info-c@BRL-SMOKE.ARPA
     
    >> Perhaps he should have said "There is really no justification
    >> for doing C software development on a system other than UNIX"?
     
    > Come on Doug, you don't *really* believe this, do you?
     
    Sure I do.  Just because you build Chevrolets for a living
    doesn't mean you can't drive to work in a Mercedes.
     
What are you hinting at?
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6572
          for JMS@ARIZMIS; Wed, 23-APR-1986 15:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 16:07:50 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012659; 23 Apr 86 10:11 EST
Received: from USENET by SMOKE.BRL.ARPA id a015086; 23 Apr 86 9:54 EST
From: david%ztivax.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Infinite Loops
Message-ID: <8200004@ztivax.UUCP>
Date: 22 Apr 86 11:36:00 GMT
Sender: notes%unido.uucp@BRL.ARPA
Nf-ID: #N:ztivax:8200004:000:110
Nf-From: ztivax!david    Apr 22 12:36:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
Another terminally cute infinite loop which was used in ratfor:
     
repeat {
    ...
} until (hell_freezes_over)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7179
          for JMS@ARIZMIS; Wed, 23-APR-1986 16:24 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016657; 23 Apr 86 12:15 EST
Received: from USENET by SMOKE.BRL.ARPA id a017763; 23 Apr 86 11:48 EST
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <1299@mmintl.UUCP>
Date: 22 Apr 86 01:00:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1444@ecsvax.UUCP> bet@ecsvax.UUCP (Bennett E. Todd III) writes:
>    #define EVER ;;
>    ...
>        for (EVER) {
>    ...
>
>I know, it's terminally "cute".
     
No, no, no.  It's INterminally cute.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6618
          for JMS@ARIZMIS; Wed, 23-APR-1986 16:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012728; 23 Apr 86 10:14 EST
Received: from USENET by SMOKE.BRL.ARPA id a015090; 23 Apr 86 9:54 EST
From: "Eugene D. Brooks III" <brooks@LLL-CRG.ARPA>
Newsgroups: net.lang.c
Subject: Re: lint
Message-ID: <1391@lll-crg.ARpA>
Date: 23 Apr 86 06:12:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>    Perhaps he should have said "There is really no justification
>    for doing C software development on a system other than UNIX"?
>
>Come on Doug, you don't *really* believe this, do you?
>
>    (Root Boy) Jim Cottrell        <rbj@cmr>
>    "One man gathers what another man spills"
     
I can't speak for Doug, but
     
Not for money, love, drugs or sex would I do software development
on a system other than UNIX.  The rest of you guys can suffer if
you want to but I have seen enough pain in my lifetime.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6781
          for JMS@ARIZMIS; Wed, 23-APR-1986 16:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 16:18:07 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013413; 23 Apr 86 10:33 EST
Received: from USENET by SMOKE.BRL.ARPA id a015250; 23 Apr 86 9:59 EST
From: herndon%umn-cs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: net.lang.english?
Message-ID: <1700008@umn-cs.UUCP>
Date: 21 Apr 86 03:26:00 GMT
Nf-ID: #N:umn-cs:1700008:000:330
Nf-From: umn-cs!herndon    Apr 20 21:26:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
  Am ie too lait to joyn thu funnetik spelling kraiz?
Seereeyuslee, this bizines uv spelling wurds kyootly seemz
not too help kompreehenshun graitly.  It duz, howevur, maik
reeding poestings kwiet inturesting, and purhaps for that
reezun shood be enkurrajd.
  Shood ie enkuruj a deebait, or hav ie sed eenuf?
     
     
                Roburt Hurndun

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6848
          for JMS@ARIZMIS; Wed, 23-APR-1986 16:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013507; 23 Apr 86 10:35 EST
Received: from USENET by SMOKE.BRL.ARPA id a015401; 23 Apr 86 10:02 EST
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Good code for sometimes shared case
Message-ID: <2594@utcsri.UUCP>
Date: 21 Apr 86 04:14:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2600045@ccvaxa> aglew@ccvaxa.UUCP writes:
     
>Structured programming != Gotoless programming
     
Right on.
What was really ironic about the original posting ( using if(0){...} )
was that it was obviously an attempt to avoid those satanic g*t*'s, and
therefore wind up with structured code. However, the structure of the
if's was twisted around the structure of the switch statement, so the
result was worse (less structured) than being honest and using goto's.
That was made possible by the lax rules applied to 'case' labels in C
(as opposed to, say, Pascal).
It was, in a way, analogous to
    while con1 ... if con2 ... end_while .. end_if
Which could be made to work as a 'while' with a 'break' if compilers
would allow it. I am not, of course, saying that they should. How about
producing a warning if a case label is not *directly* inside the {}'s
of the switch?
--
"If you aren't making any mistakes, you aren't doing anything".
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7404
          for JMS@ARIZMIS; Wed, 23-APR-1986 16:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 16:56:37 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa18458; 23 Apr 86 13:13 EST
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a018904; 23 Apr 86 12:55 EST
Received: from acc.arpa by AOS.BRL.ARPA id a017549; 23 Apr 86 12:47 EST
Date: 23 Apr 86 09:42:00 PST
From: art@ACC.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject: non UNIX C development
To: info-c <info-c@BRL.ARPA>
Reply-To: art@ACC.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
     
> Not for money, love, drugs or sex would I do software development
> on a system other than UNIX.  The rest of you guys can suffer if
> you want to but I have seen enough pain in my lifetime.
     
Unfortunately the real world has LOTS of non UNIX systems, many of
which have or are getting C compilers.  I would rather promote the
development of decent languages and development tools for those
systems than assume that everything can or will be done under UNIX.
     
Since lint is based on a modified compiler front-end, I wonder why
more of the C compiler vendors haven't developed lint-like (or even
lint-compatible) tools based on their compiler technology.
     
                    <Art@ACC.ARPA>
     
P.S. I frequently do use various UNIX variants as well as some non-UNIX
systems.
     
------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7521
          for JMS@ARIZMIS; Wed, 23-APR-1986 16:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 17:03:39 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022631; 23 Apr 86 15:31 EST
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a022934; 23 Apr 86 14:56 EST
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA04996; Wed, 23 Apr 86 14:56:59 est
Date: Wed, 23 Apr 86 14:56:59 est
From: root <rbj@ICST-CMR.ARPA>
Message-Id: <8604231956.AA04996@icst-cmr.ARPA>
To: brooks@LLL-CRG.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: lint
     
    >    Perhaps he should have said "There is really no justification
    >    for doing C software development on a system other than UNIX"?
    >
    >Come on Doug, you don't *really* believe this, do you?
    >
    >    (Root Boy) Jim Cottrell        <rbj@cmr>
    >    "One man gathers what another man spills"
     
    I can't speak for Doug, but
     
    Not for money, love, drugs or sex would I do software development
    on a system other than UNIX.  The rest of you guys can suffer if
    you want to but I have seen enough pain in my lifetime.
     
Ah, the beauty of ambiguity. Let's play `Comverses & Inverses'.
I read his statement as `If you don't have UNIX, don't use C'.
I beg to differ. If I was stuck on VMS for some reason, I would much
rather use C than Fortrash, Trashcal, ADA, or Ignorance (Bliss).
     
I leave it up to Doug to explain his analogy with automobiles.
     
I agree with 3 out of your 4 criteria. I have enuf money, love, & sex,
but I'm running out of drugs :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6698
          for JMS@ARIZMIS; Wed, 23-APR-1986 16:27 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 16:16:08 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012827; 23 Apr 86 10:16 EST
Received: from USENET by SMOKE.BRL.ARPA id a015100; 23 Apr 86 9:55 EST
From: Sam Kendall <sam%delftcc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Followup to Very Tough C Riddle
Message-ID: <140@delftcc.UUCP>
Date: 22 Apr 86 02:35:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Here is the followup to my "Very Tough C Riddle".  The riddle was posted
about a hundred years ago.  Thanks to harvard!draves, Ron Natalie
<ron@BRL-TGR.ARPA>, Tony Li <Tli@Usc-Eclb>, vu44!jack, enmasse!mike,
hadron!jsdy@seismo.ARPA (Joseph S. D. Yao), qtlon!ist!istbt!rb, and
callan!tim (Tim Smith) for replying, and my apologies for the long delay
in posting this followup.
     
Here is the original note:
     
>    Is the token sequence
>
>        [ ] [ ]
>
>    legal anywhere in a C program as defined in K&R?  If so, where
>    and why?  If not, why not?
>
>    Warning: some may consider the solution debatable, although I
>    will endeavor to prove them wrong, i.e., I am pretty sure I
>    have the correct answer.
     
    Now, on to the solutions.  The answer is YES, contrary to plenty of
replies!  (Except that the word "anywhere" in the note should be
"somewhere", as Tim Smith pointed out.)  To see this, we don't have to
depend on my debatable solution; qtlon!ist!istbt!rb provided a clear
solution that no one else (including myself) thought of:
     
>    How about:
>
>        /* [ ] [ ] */
>        "  [ ] [ ] "
>
>    or (more seriously):
>
>        #define FRED [ ] [ ]
>
>    where FRED does not appear elsewhere.
     
In the FRED line, `[ ] [ ]' is indisputably a token sequence, for K&R
section 12.1 gives the syntax of such lines as `#define identifier
token-string'.  (The reason, of course, that rb isn't serious about the
first two is that in a comment or a string, the brackets are not a
"token sequence", only part of a single token.)
     
     Even though it's not necessary for the riddle's solution, let's
take a look at the other possibility, which is for there to be a formal
parameter declaration of the form
     
        type formal[][];
     
Tony Li and Joe Yao mentioned this possibility, but they didn't think
it was legal.  The passage mentioned in K&R that many people think
prohibits any adjacent pairs of empty brackets is this:
     
        When several adjacent "array of" specifications are adjacent, a
        multi-dimensional array is created; the constant expressions
        which specify the bounds of the arrays may be missing only for
        the first member of the sequence.  (section 8.4)
     
The passage that may allow `[ ] [ ]' for formal parameters is this
(first elipsis mine):
     
        ...  [D]eclarations of formal parameters declared "array of ..."
        are adjusted to read "pointer to ...".  (section 10.1)
     
This passage is why, in my interpretation,
     
        type formal[][];
     
"is adjusted to read"
     
        type (*formal)[];
     
This second type is "pointer to array of unknown length".  However
strange the idea of a pointer to an object of unknown length, note that
this type is legal according to section 8.4, as quoted above.  There is
a sequence of one "array of" specification, and the bounds are missing
only for the first (and only) member of the sequence.  (Aside: this type
is also usable, since you don't need to know the length of an array to
access it.  I have seen it, for you trivia fans, used erroneously in the
System V Release 0 semop(2) man page and lint library entry.  A question
for debate: should it be legal in ANSI C?  I can see both sides of the
question.)
     
     The question, then, is whether 8.4 supercedes 10.1, whether the
type of a formal argument has to be legal before as well as after it is
rewritten.  I was going to argue that it does not have to be, and if I
were in a debate, I would keep going.  But I have convinced myself that
the question is, at best, up in the air.  No sane programmer would
intentionally write a formal argument declaration with `[ ] [ ]', even
with one pair of braces hidden by typedefs.  Even as an academic
exercise -- which is all this article is, of course -- I can't stomach
arguing for this dark corner of C.  There is an interesting question
about whether to consider dark corners to be in a language or not, but
that question is beyond the scope of this article.
     
----
Sam Kendall            { ihnp4 | seismo!cmcl2 }!delftcc!sam
Delft Consulting Corp.        ARPA: delftcc!sam@NYU.ARPA

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8214
          for JMS@ARIZMIS; Wed, 23-APR-1986 17:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/23/86 at 18:26:22 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025362; 23 Apr 86 19:08 EST
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a026426; 23 Apr 86 18:10 EST
Received: from (MAILER)TCSVM.BITNET by WISCVM.WISC.EDU on 04/23/86 at
  17:12:34 CST
Received: by TCSVM (Mailer X1.22) id 0752; Wed, 23 Apr 86 12:34:54 CST
Date:         Wed, 23 Apr 1986 12:19 CST
From:           Dan Smith <SYSBDES%TCSVM.BITNET@wiscvm.ARPA>
Subject:      Re:Re: C work under/not under Unix
To:  INFO-C@BRL-SMOKE.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
     
    >> Perhaps he should have said "There is really no justification
    >> for doing C software development on a system other than UNIX"?
     
    > Come on Doug, you don't *really* believe this, do you?
     
I'm just leaping in on the discussion,  but as someone who has done
C software development on CP/M-80/86 and MSDOS before I could afford
a Unix machine,  I can tell you that even C minus the Unix is a pleasure
when compared to what's loose in the world of Micros (and even Mainframes)
Of course you end up re-inventing the wheel alot with little utilities to
fake some Unix feature,  but it is still VASTLY better then changing mental
gears for different languages on different machines.  Even now I use the
WATCOM C compiler at work when I have a chance even tho its pretty much a
bust as far as standard lib functions working the expected way.  Compared to
the everpopular LBT assembler (Large Blue Thing) I'll live with weirdness in
order to get a sorta Unix environment to do projects.
     
                        Dan Smith (aka MadMan)
                        BITNET:     SYSBDES@TCSVM
                        ARPA:       SYSBDES%TCSVM.BITNET@WISCVM.WISC.EDU
                        UUCP:       You Tell Me??
                        Ma Bell:    (504) 865-5631
                        Real Paper: Tulane University
                                    Tulane Computer Services
                                    Attn: Dan Smith, Systems Group
                                    6823 St. Charles Ave.
                                    New Orleans,  LA 70118-5698

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6054
          for JMS@ARIZMIS; Fri, 25-APR-1986 14:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/25/86 at 14:52:55 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025824; 25 Apr 86 13:24 EST
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a025527; 25 Apr 86 12:23 EST
Received: from bbn-prophet.arpa by AOS.BRL.ARPA id a024151; 25 Apr 86 12:20 EST
Date:     Fri, 25 Apr 86 12:10:59 EST
From:     Dan Franklin <dan@BBN-PROPHET.ARPA>
To:       LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
cc:       INFO-C@BRL.ARPA
Subject:  Re:  WHAT DOES NARGS() DO?
     
The short answer is, nargs() does nothing, now, and you are unlikely to
find it on any modern "UNIX brand operating system." Don't use it.  To
quote the 6th edition manual page, "altogether it is best to avoid using
this routine and depend on, for example, passing an explicit argument count."
     
In 6th edition UNIX, nargs() returned the number of arguments on the
stack.  Well, not quite: it returned the number of *words* of arguments on
the stack; you needed to know already whether the arguments were ints (1
word) or doubles (4 words) or the new-fangled, partially-implemented
"long" datatype (also 2 words).
     
Even in 6th edition nargs() was falling out of favor, as the manual page
implies.  Its main problem then was that it didn't work in separate I & D
space, which was becoming quite popular as programs grew too large to fit
in 64kbytes (48kbytes for text and data).  It was also a bit sluggish, and
those of us who looked inside it never really felt comfortable with it
either.  As the old "dragon book" said in a footnote, "... argument counts
are obtained by a method we shall not discuss." The method was to peek at
the instruction stream immediately following the JSR and decode the
instructions to see how many words were popped off the stack immediately
following the call.  There was a potential off-by-one problem because the
top of the stack was normally kept "empty"; you could call a routine with
one argument without doing a push of the argument.  So the compiler chose
one of two equivalent forms of addressing for the destination to indicate
to nargs() whether or not it should add 1 to the number of popped words.
     
Nargs() understood that the compiler might pop the stack using either
explicit stack pointer arithmetic or instructions that popped the stack as
a side effect ("cmp (sp)+, (sp)+" was good for two words).  To handle some
kinds of optimization, nargs() was capable of following jump instructions.
I think it stopped at the first instruction that wasn't a kind of pop or a
jump.
     
In separate I&D space this didn't work because in user mode on a PDP-11, a
program couldn't read its own instruction space: instructions and data
occupied the same "addresses".  In theory you could use the MFPI (move
from previous instruction space) instruction to get around this, but in
practice you would find that DEC had specially prohibited this, even when
both the current and previous instruction spaces were user mode.  I think
this was intended as a kind of "security".  Some organizations solved the
problem by cutting a trace on one of the processor boards, which was all
it took to make nargs() work using MFPI.
     
It is amusing to note that the wait() system call in the V6 library
used nargs() to determine whether it was being called with 0 or 1
arguments.  The first time we tried running a program that used wait()
in separate I&D space, we got quite a surprise!
     
    Dan

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5095
          for JMS@ARIZMIS; Sat, 26-APR-1986 18:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/26/86 at 19:34:32 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009042; 26 Apr 86 20:23 EST
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a012531; 26 Apr 86 20:12 EST
Received: from cit-hamlet.arpa by AOS.BRL.ARPA id a009019; 26 Apr 86 20:12 EST
Received: from Xhmeia.Caltech.Edu by Hamlet.Caltech.Edu with DECNET ;
          Sat, 26 Apr 86 17:13:58 PST
Date:    Sat, 26 Apr 86 17:08:27 PST
From:     zar%Xhmeia.Caltech.Edu@cit-hamlet.ARPA
Subject: VAX VMS C Question
To:       info-c@BRL.ARPA
X-ST-Vmsmail-To: ST%"info-c@brl.arpa",ST%"info-vax@sri-kl.arpa"
     
I'm trying to convert some C code I have to VAX-11 C and there appears to
be no VAX-11 C system routine FGETS (three args ; buf, sizofbuf, filepointer).
Has someone already made this so I don't have to do it myself (I'm not a
real C programmer). Please reply directly to me and thanks in advance.
     
                        Zar (Dan Zirin)
                        ZAR%XHMEIA@HAMLET.CALTECH.EDU
                        (ZAR%XHMEIA@HAMLET.ARPA)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6045
          for JMS@ARIZMIS; Sat, 26-APR-1986 22:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/26/86 at 23:07:26 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009325; 26 Apr 86 23:56 EST
Received: from USENET by SMOKE.BRL.ARPA id a013365; 26 Apr 86 23:41 EST
From: mcdaniel@uiucdcsb.ARPA
Newsgroups: net.lang.c
Subject: Re: net.lang.english?
Message-ID: <139200029@uiucdcsb>
Date: 22 Apr 86 03:05:00 GMT
Nf-ID: #R:umn-cs:1700008:uiucdcsb:139200029:000:59
Nf-From: uiucdcsb.CS.UIUC.EDU!mcdaniel    Apr 21 21:05:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
Goe too net.lang too diskuss thyss.  net.lang.c iz fore C.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6080
          for JMS@ARIZMIS; Sat, 26-APR-1986 22:12 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/26/86 at 23:09:48 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009327; 26 Apr 86 23:56 EST
Received: from USENET by SMOKE.BRL.ARPA id a013523; 26 Apr 86 23:47 EST
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Jumping into blocks
Message-ID: <737@bentley.UUCP>
Date: 23 Apr 86 16:34:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <275@copper.UUCP> copper!stevesu (Steve Summit) writes:
>Most people agree that goto's are pretty acceptable for handling
>error conditions.  For instance:
>
>    if(stbuf.st_uid != getuid()) {
>nope:        printf("I don't think you want to delete this file.\n");
>        return;
>    }
>    if(strcmp(name, "vmunix") == 0) goto nope;
>    unlink(name);
>    return;
     
As has been pointed out, this particular example can be handled easily with
the || operator.  But here's a real example I keep running into:
     
    while (argc > 1 && argv[1][0] == '-') {
        switch (argv[1][1]) {
        ...
        default:
usage:        fputs("usage: a.out [flags] args\n", stderr);
        exit(1);
        }
        --argc;  ++argv;
    }
    if (!aflag && !bflag && !cflag) goto usage;
     
A trivial variation is to have "goto usage" after "default:" and put the
actual usage message inside the "if" -- this makes it a forward goto, but
still into a block.
     
So, assuming that goatooze are acceptable for error handling, but jumping
into a block is forbidden, what's the best way to write this?  Use two
braches, and hide the common code at the bottom of main()?  Set an error
flag and test it outside the while?  (Ugh, that requires an artificial
boolean *and* a break statement.)  Make usage() a non-returning function
instead of a label?  (My usual preference.)  Duplicate the code?
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6245
          for JMS@ARIZMIS; Sat, 26-APR-1986 22:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/26/86 at 23:34:33 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009419; 27 Apr 86 0:24 EST
Received: from USENET by SMOKE.BRL.ARPA id a013966; 27 Apr 86 0:06 EST
From: Pete Holzmann <pete%octopus.uucp@BRL.ARPA>
Newsgroups: net.wanted,net.lang.c
Subject: WANTED: 68K C crosscompiler}i that runs on miscellaneous machines...
Message-ID: <203@octopus.UUCP>
Date: 24 Apr 86 01:39:14 GMT
Xref: seismo net.wanted:9289 net.lang.c:8868
To:       info-c@BRL-SMOKE.ARPA
     
     
     
I'm looking for a good (ANSI?... optimizing... etc) cross compiler for
the 68000/68010/68020. I need one that will run on DG MVxxxx machines, and
hopefully PC's (obviously two different compilers). Professional developmnet
quality products are needed (lint, etc).
     
What is available? Has anybody used such products from MicroTec}i or
Whitesmiths?
     
Please mail any responses. I'll summarize if there is interest!
     
--
  OOO   __| ___      Peter Holzmann, Octopus Enterprises
 OOOOOOO___/ _______ USPS: 19611 La Mar Court, Cupertino, CA 95014
  OOOOO \___/        UUCP: {hplabs!hpdsd,pyramid}!octopus!pete
___| \_____          Phone: 408/996-7746

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8275
          for JMS@ARIZMIS; Sun, 27-APR-1986 03:44 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 04:37:42 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010131; 27 Apr 86 6:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016619; 27 Apr 86 6:01 EDT
From: "Bob Mabee, Software" <rfm%frog.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Float Double Parameters
Message-ID: <844@frog.UUCP>
Date: 22 Apr 86 19:58:40 GMT
Keywords: BCPL
To:       info-c@BRL-SMOKE.ARPA
     
In article <139200025@uiucdcsb> kenny@uiucdcsb.CS.UIUC.EDU writes:
>                        When BCPL was built for the
>635, it borrowed the existing Fortran library and hence had to adopt the
>convention that all float's are promoted to double's for parameter passing.
     
When DMR put an obsolete version of BCPL on the GE 645, it had no support
for floating-point operations.  We added floating-point operators and
constants during the port from CTSS to the 360.  Later I wrote a new code
generator for the GE 645 (the first BCPL to generate binary directly), and
added the floating-point operators here too, and transcendentals written in
BCPL.  Other functions would have come from the PL/I Multics environment,
which did support single precision.
     
In any case, BCPL is typeless and would not have known to convert number
formats on function calls.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8449
          for JMS@ARIZMIS; Sun, 27-APR-1986 03:56 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 04:55:16 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010158; 27 Apr 86 6:41 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017059; 27 Apr 86 6:18 EDT
From: Ben Cranston <zben%umd5.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Funxions
Message-ID: <929@umd5.UUCP>
Date: 24 Apr 86 01:59:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <205@brl-smoke.ARPA> rbj@icst-cmr.ARPA (root) writes:
>As to my friend Ben Cranston's suggestion that I should use
>`myprintf' and `myputchar', this is a very good idea, lest we
>forget what the funxion really does. However, this may not always
>be an option where objects but no source is available. Hiya Ben!
     
Oh, good, I had so hoped you would not be offended by my implicit criticism
of your earlier posting.  I had taken precautions against my being taken too
seriously, but the postnews software removed my precaution from the header
of the message:
     
Organization: Great Eastern Cow College Home for the Terminally Analytical
     
Remember, "When Source is outlawed, only outlaws will have Source"...
     
>    (Root Boy) Jim Cottrell        <rbj@cmr>
--
"We're taught to cherish what we have   |          Ben Cranston
 by what we have no longer..."          |          zben@umd2.umd.edu
                          ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8414
          for JMS@ARIZMIS; Sun, 27-APR-1986 03:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 04:53:20 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010156; 27 Apr 86 6:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016881; 27 Apr 86 6:11 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  void *
Message-ID: <743@bentley.UUCP>
Date: 24 Apr 86 18:59:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <200@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>You're mixing two features of malloc().  Malloc() should return (void *),
>which is a generic pointer type to/from which all other pointer types
>may be cast without loss of information.  (This is the only use of
>(void *), and it is the only universal pointer type; other pointer
>casts can be non-portable.)  Malloc() ALSO guarantees that the pointer
>it returns is suitably aligned for safe casting to ANY pointer type.
>This is a property of malloc(), not of (void *).
     
I realize that; it's just that I was expecting the new datatype to
correspond to this property of malloc(), so malloc() wouldn't have to
be a special case.  I probably shouldn't have brought up this (ALIGN *)
issue in the same posting.
     
It's *not* true that (void *) can always be cast into another pointer
type without loss of information.  For example, "intp = voidp;" may
drop bits if "voidp" was initialized to an improperly aligned object.
What's true is that any pointer may be assigned *to* a void pointer,
and that *same* value may be safely copied back.  (Currently this is a
guaranteed feature of (char *).)
     
To rephrase my original question, what does this have to do with the
explicit use of the cast operator?  Is "intp = voidp;" going to be as
acceptable as the (more correct, to me) syntax "intp = (int *)voidp;"?
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8489
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:01 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 04:59:17 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010161; 27 Apr 86 6:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017279; 27 Apr 86 6:27 EDT
From: Ken Arnold%CGL <arnold%ucsfcgl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: void *
Message-ID: <9831@ucsfcgl.UUCP>
Date: 24 Apr 86 19:36:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <728@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>In article <1883@ucsfcgl.UUCP> ucsfcgl!arnold (Ken Arnold%CGL) writes:
>>Purists will note that I really should say
>>    ptr = (some_type *) malloc(10 * sizeof *ptr);
>>But eventually malloc() will be of type "void *".
>
>Okay, enlighten me.  When I first saw the idea of "void *" I thought it was
>to be a name for the most restrictive pointer type ("ALIGN *" for those who
>know the malloc source).  Then when I rechecked, I found that it was a new
>name for the least restrictive pointer type, "char *".  Now you seem to say
>that the cast operator is unnecessary in your example.  I'd like some more
>detail about this beast.  Specifically, suppose we have the following:
>    void  *v;
>    char  *c;
>    short *h;
>    ALIGN *a;
>Of the 12 nontrivial assignment statements, which ones will ANSI C accept
>without a cast?  What will lint accept (with/without cast)?
     
Well, as *I* understand it (and my draft is, of course, out of date),
(void *) can be cast to any other pointer type without complaint.
So
     
    ptr = malloc( ... );
     
would be as legal as
     
    int_var = float_var;
     
i.e., the conversion would be automatic and silent (because it is
guaranteed to work properly).  Presumably, any other pointer assignment
would generate a warning unless accompained by a cast (and I sure hope
it is silent if I explicitly cast it).
     
        Ken Arnold

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8599
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:11:46 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010174; 27 Apr 86 6:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017467; 27 Apr 86 6:35 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: varargs
Message-ID: <5336@alice.uUCp>
Date: 22 Apr 86 06:00:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Must va_alist be the only thing in the argument list?  (If this is not
> true, I don't see how to implement varargs with this compiler.)  (The
> example in the documentation seems to back up my assumption.)
     
Yes, va_alist must be the only thing in the argument list.  However,
you can use #define to make va_alist expand into something bigger.
That possibility, in fact, is the reason that va_alist must be the
only thing in the argument list.
     
> Is it leagal to pass a the rest of an argument list to another
> function expecting it?  If so, should it be passed as a pointer to a
> variable of type va_list?  (Without this capability, I supose I'll
> have to document this as a non-portable use of varargs.)
     
Yes, it is legal.  You may pass either a pointer to a va_list or
the entire va_list itself.  Passing the pointer is recommended, because
on some implementations the va_list may be quite large
and therefore slow to copy.  If you do pass the pointer, using
va_arg in the subroutine will advance the argument list pointer
as seen by the caller.
     
> I assume va_start be done in the original function.  (Dito the first
> va_alist comment.)  Does va_end have to be done in the original
> function also?  (va_end does nothing in my implementation.)
     
It should be.  (va_end does nothing in every implementation I've seen)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8671
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:18:12 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010178; 27 Apr 86 7:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017523; 27 Apr 86 6:36 EDT
From: roe%toram.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <140@toram.UUCP>
Date: 21 Apr 86 16:07:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <577@ur-helheim.UUCP> badri@ur-helheim.UUCP (Badri Lokanathan)
 writes:
>My question is the following: is there any reason (other
>than personal preferance) why one would prefer to use any particular form?
>I personally prefer the while(1) form since it seems to make better reading.
>Even better, I sometimes define TRUE to be 1 and then use while(TRUE).
     
Unless you have a very unique optimizer, it is usually better to use the
for(;;) form rather than the while(1) form.  Reason is:  while(1) is
ALWAYS evaluated (ie. : is 1 TRUE? if so, continue) before each iteration,
whereas for(;;) compiles as a simple branch or jump instruction with no
test and no conditional branch.
     
simply loops with no checks.
     
     
--
     
                Roe Peterson
                {linus,ihnp4,decvax}!utzoo!toram!roe
     
                All that glitters is spray-paint.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8639
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:17:51 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010176; 27 Apr 86 6:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017484; 27 Apr 86 6:35 EDT
From: Mark Rosenthal <mbr%aoa.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards,net.unix
Subject: Help using dbx
Message-ID: <461@aoa.UUCP>
Date: 22 Apr 86 23:48:47 GMT
Xref: seismo net.lang.c:8875 net.unix-wizards:17878 net.unix:8077
To:       info-c@BRL-SMOKE.ARPA
     
     
I posted the following article some weeks ago.  I fear it may have dropped
into the bit-bucket, so I am reposting it.
     
It appears that most vendors have given up on 'sdb' in favor of 'dbx' or
some derivative of 'dbx'.  I find that although 'dbx' is generally more
powerful than 'sdb' it lacks some capabilities that I used to depend on quite
heavily.  If anyone is familiar with how to do the following with 'dbx',
please let me know.  You will earn my undying gratitude.
     
Note that I have not used sdb in over a year.  The examples I give below are
from my own faulty memory and may not be 100% accurate.
     
By the way, I am running 'dbx' on a Sun workstation.
     
1.  I'd like to be able to specify the format in which a variable is to be
    displayed.  If I have a variable (char *cp), I could do the following
    with 'sdb':
     
    me:    cp/x        or:    cp/s        or:    cp/
    sdb:    0x7fff3ec        string            string
     
    With 'dbx', the dialogue is something like:
     
    me:    print cp
    dbx:    0x7fff3ec
    me:    0x7fff3ec/s
    dbx:    string
     
    Having to type back into dbx what it just typed at me is a pain.
     
2.  The man page for 'dbx' claims that the command to display a memory location
    is:
     
    [address] / [count] [mode]
     
    where everything but the "/" is optional, and that "if no address is
    specified, the address following the one displayed most recently is used".
    Unfortunately, there is also a "/" command which searches the source file
    for a string.  Typing "/" reports:
     
    "No saved search string"
     
    rather than showing me the next location.  This makes it quite a chore to
    examine an array.  Arrays of structures are even worse.
     
3.  With 'sdb', I could display lines of code relative to the current line.
    'dbx' appears to limit me to specifying absolute line numbers.  This means
    that anytime I hit a breakpoint and want to see some context, I have to
    read the current line number from the screen, do some quick arithmetic,
    and type "list from_line,to_line".  The concentration required to do that
    is a distraction from the problem I am trying to solve, namely finding and
    fixing bugs in a program.  A symbolic way of referencing dbx's line counter
    would solve the problem, but I can find no mention of any such capability
    in the documentation.  I'd like to be able to do something like:
     
    alias w list .-5,.+5
     
    and then just type "w" to see context around the current line.
     
4.  A common construct in C is a linked list of structures.
     
    struct foo
    {
        struct foo *next;
        int    data;
        char    *moredata;
        /* Etc., etc., etc. */
    };
     
    struct foo *foobar;
     
    Let's say my code malloc()s instances of foo, and links them in to the list
    beginning at foobar.  I am at a breakpoint, and I want to examine the list.
     
    I don't remember the exact sequence I used with sdb, but it went something
    like:
     
    me:    foobar/        show the value of foobar
    sdb?:    0x7ff2ea
    me:    .->/        show what the last displayed value points at
                    (i.e. foobar->next)
    sdb?:    0x7e3720
    me:    +/d        show the next location in decimal
                    (i.e. foobar->data)
    sdb?:    3
    me:    +/s        show the next location as a string pointer
                    (i.e. foobar->moredata)
    sdb?:    string data
    me:    -        back up one location (to foobar->data)
    sdb?:    3
    me:    -        back up one location (to foobar->next)
    sdb?:    0x7e3720
    me:    .->/        show what the last displayed value points at
                    (i.e. foobar->next->next)
    sdb?:    0x748238
    me:    +/d        show the next location in decimal
                    (i.e. foobar->next->data)
    sdb?:    2
    me:    +/s        show the next location as a string pointer
                    (i.e. foobar->next->moredata)
    sdb?:    more chars
    me:    -        back up one location (to foobar->next->data)
    sdb?:    2
    me:    -        back up one location (to foobar->next->next)
    sdb?:    0x748238
    me:    .->/        show what the last displayed value points at
                    (i.e. foobar->next->next->next)
    sdb?:    0        end of list
    me:    +/d        show the next location in decimal
                    (i.e. foobar->next->next->data)
    sdb?:    1
    me:    +/s        show the next location as a string pointer
                    (i.e. foobar->next->next->moredata)
    sdb?:    still more chars
     
    To do the same thing with dbx, the best I've been able to come up with
    so far is:
     
    me:    print foobar
    dbx:    0x7ff2ea
    me:    print foobar->data
    dbx:    3
    me:    print foobar->moredata
    dbx:    string data
    me:    print foobar->next
    dbx:    0x7e3720
    me:    print foobar->next->data
    dbx:    2
    me:    print foobar->next->moredata
    dbx:    more chars
    me:    print foobar->next->next
    dbx:    0x748238
    me:    print foobar->next->next->data
    dbx:    1
    me:    print foobar->next->next->moredata
    dbx:    still more chars
    me:    print foobar->next->next->next
    dbx:    0        end of list
     
    Note that the sequence of commands I type to sdb is relatively simple,
    and stays the same no matter how far through the list I've gone:
     
    me:    foobar/
    me:    .->/
    me:    +/d
    me:    +/s
    me:    -
    me:    -
    me:    .->/
    me:    +/d
    me:    +/s
    me:    -
    me:    -
    me:    .->/
    me:    +/d
    me:    +/s
     
    whereas with dbx, I have to retype the entire sequence from the starting
    point every time:
     
    me:    print foobar
    me:    print foobar->data
    me:    print foobar->moredata
    me:    print foobar->next
    me:    print foobar->next->data
    me:    print foobar->next->moredata
    me:    print foobar->next->next
    me:    print foobar->next->next->data
    me:    print foobar->next->next->moredata
    me:    print foobar->next->next->next
     
    This makes a list of length 4 a pain to deal with, and a list of length 16
    prohibitive.  Linked lists with hundreds of elements are not uncommon.
    Do the authors of 'dbx' really intend that I should have to type:
     
print foobar->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->next->next->next->next->next->next->next->next->next->next->next->next->
next->data
     
    to get to the 128'th (or did I only type next 127 times?) item in a list?
    There MUST be a better way.  Can somebody PLEASE enlighten me.
     
Sorry.  I got a bit carried away there.  I'll be alright in a second.
     
--
     
    Mark of the Valley of Roses
    ...!{decvax,linus,ima,ihnp4}!bbncca!aoa!mbr
    ...!{wjh12,mit-vax}!biomed!aoa!mbr

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8834
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:34:53 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010292; 27 Apr 86 7:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017898; 27 Apr 86 6:50 EDT
From: Jim Giles <jlg@LANL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: Re: Re: ... C builtin functions?
Message-ID: <2323@lanl.ARPA>
Date: 25 Apr 86 00:10:56 GMT
Xref: seismo net.lang:2455 net.lang.c:8878
To:       info-c@BRL-SMOKE.ARPA
     
In article <562@nsc-pdc.UUCP> joemu@nsc-pdc.UUCP (Joe Mueller) writes:
>Sizeof is an operator, not a function. It's perfectly legal to say
>"sizeof foo" (without the parens).
     
An operator is a syntactic form that invokes a function!  SIZEOF is clearly
a function: it has a domain (actually two domains - data types and variables)
and it has a range (the non-negative integers) and it provides a mapping
from one to the other.  Since that is the mathematical definition of the
word 'function', it is clear that SIZEOF is one.  Now, it is true that
the syntactic description of C uses the term 'function' in a slightly
more restrictive way.  But the guy that wrote the syntactic description
of C just picked 'function' as a convenient name for a grammar rule.  If
you take it too literally, you will start saying absurd things like "'+'
is an operator and not a function."  Most people I know would be quite
surprised about that!
     
J. Giles
Los Alamos

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8911
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:40:13 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010337; 27 Apr 86 7:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017983; 27 Apr 86 6:53 EDT
From: Jim Ruppert <jim%eeg.uucp@BRL.ARPA>
Newsgroups: net.unix-wizards,net.lang.c
Subject: am I in the background?
Message-ID: <124@eeg.UUCP>
Date: 24 Apr 86 23:26:46 GMT
Keywords: signal isatty background
Xref: seismo net.unix-wizards:17884 net.lang.c:8879
To:       info-c@BRL-SMOKE.ARPA
     
     
I'm new to usenet news, so forgive me if this has been covered before...
     
How can a process tell if it is running in the background?  I've tried
using isatty() and signal(), but to no avail.  Any suggestions?
--
----
    Jim Ruppert, EEG Systems Laboratory
    1855 Folsom St, San Francisco, Ca 94103 (415) 621-8343
    {ihnp4,dual,qantel}!ptsfa!eeg!jim

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8870
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:35:42 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010268; 27 Apr 86 7:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017828; 27 Apr 86 6:48 EDT
From: Rex Ballard <rb%ccird2.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: varargs
Message-ID: <792@ccird2.UUCP>
Date: 24 Apr 86 23:11:22 GMT
Xref: seismo net.lang.c:8877 net.unix-wizards:17882
To:       info-c@BRL-SMOKE.ARPA
     
In article <5302@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes:
>> I have always heard that varargs is not very portable.  Is this really
>> true?  If you know of any machine that is running 4.X BSD, System III/V,
>> Xenix or any other real unix that doesn't support varargs, please let
>> me know.
>
>If you find any machine with a sensible architecture that cannot
>be made to support varargs, I would greatly like to hear about it.
>
The concern about about varargs is brought up in "Software Tools" by
Kernigan and Plauger.  The main concern is that certain systems and
languages have the caller push the arguments, and have the callee destroy
them when they are finished.  This is common practice in Fortran and
Pascal.  The big concern with C is that there might be a compiler out
there which has C/Pascal|Fortran compatibility.  Since these compilers
seem to be the exception rather than the rule, and newer versions of
these languages are tending to follow C conventions, this is not likely
to be a problem for *most* environments.
     
I have heard that there are a few "peculiar"
compilers available for the Atari ST, Mac, and Amiga, which, although
not "kosher", CAN support most varargs situations.  The problems that
can occur are "intelligent" compilers which put arguments directly
into registers rather than on the stack.  Appearantly, this can be
a real problem if you wish to "intercept" a system call at the
application side.  Why do so many of the micro operating systems
insist on putting arguments in registers!!!.  Even MS-DOS expects
arguments in registers rather than on the stack.
     
The C frame is a more sensible archetecture, but not the only one.
Since you specifically asked about UNIX based systems, you can be
relatively unconcerned.
     
There are non-portable ways to USE varargs.  The classic is to put
a long indicator into the "format argument" and pass an int. Do this
with a couple of arguments where ints are 16 bits, and longs are 32 bits,
and you will return to "never never land".  The normal usages
(printf, scanf,...) aren't usually a problem, but there are a few
"mix and match" functions using varargs which selectively mix and match
various modifiable stack addresses, and will "core dump" the whole
system.
     
try this: (comments are for 16 bit ints, 32 bit longs, 32 bit pointers).
     
main()
{
    /* top of frame = return address */
    int i;
    long l;
    scanf("%d %d",&i);    /* second argument missing, clobbers frame */
    scanf("%d",i);    /* cute "poke" of i, can demolish code or core dump */
    scanf("%ld",&i);    /* extra 16 bits is usually frame pointer or return
               address */
    scanf("%d",l);    /* 16 bits of "garbage" plus your number possibly
               munged beyond recognition due to byte ordering */
}
     
Lint will pass it, assuming printf is declared /*VARARGS*/, and the
compiler won't even sneeze.  But running it will give you "buss error
core dumped" or something equally nasty.  This is one of the few areas
where lint will not protect you.
     
Anyone figured out a syntax checker for these functions?
Of course, you should use a syntax checker for any of these functions.
     
Another cute trick I've seen is using varargs to pass integers to
functions which assign to pointers. Such as:
     
main()
{
    int read();
    init(0x20L,&read);    /* set exception vector */
}
     
/*VARARGS*/
init(a,b)
char **a,*b,**i;
{
    *a=b;    /* poke absolute value with a valid address */
}
     
This is the ultimate in unportability, but is frequently "hidden" in
"hostile" PC programs, typically to mount new device drivers and
remove them when the code is complete.  Just try plugging one of these
into unix unmodified :-).

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8952
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:44 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:42:17 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010339; 27 Apr 86 7:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018049; 27 Apr 86 6:55 EDT
From: Donn Seeley <donn%utah-cs.uucp@BRL.ARPA>
Newsgroups: net.unix-wizards,net.lang.c
Subject: C bug of the week
Message-ID: <3763@utah-cs.UUCP>
Date: 23 Apr 86 09:45:05 GMT
Xref: seismo net.unix-wizards:17885 net.lang.c:8880
To:       info-c@BRL-SMOKE.ARPA
     
/*
 * If you have a Reiser 'cpp', try running 'lint' on this program.
 * Observe the amusing errors.  It's not too hard to guess what's
 * going wrong...
 */
     
# define    X    /* Watch
               lint
               get
               very
               confused */
     
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
     
#ifdef notdef
int i = 1;
#endif
     
syntax error
     
#ifdef notdef
Donn Seeley    University of Utah CS Dept    donn@utah-cs.arpa
40 46' 6"N 111 50' 34"W    (801) 581-5668    decvax!utah-cs!donn
#endif

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9008
          for JMS@ARIZMIS; Sun, 27-APR-1986 04:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:46:29 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010351; 27 Apr 86 7:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018084; 27 Apr 86 6:56 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards,net.unix
Subject: Re: Help using dbx
Message-ID: <3578@sun.uucp>
Date: 25 Apr 86 01:55:48 GMT
Xref: seismo net.lang.c:8881 net.unix-wizards:17886 net.unix:8079
To:       info-c@BRL-SMOKE.ARPA
     
> By the way, I am running 'dbx' on a Sun workstation.
     
Which is different from the 4.2BSD "dbx", which is in turn different from
the 4.3BSD "dbx", so note that this discussion applies only to the Sun
version.
     
> 1.  I'd like to be able to specify the format in which a variable is to be
>     displayed.
     
To print the variable "foo" in a particular format, &foo/<format> should
suffice.
     
> If I have a variable (char *cp), I could do the following with 'sdb': ...
     
In this case, you don't want to display "cp", you want to display what "cp"
points to.  The Sun UNIX 3.2 version (probably the 3.0 version as well) will
print what a "char *" points to, as a string, as well as its value.  If you
say "print *cp", it will print the char that "cp" points to.
     
> 2.  The man page for 'dbx' claims that the command to display a memory
> location is: ...
> ... rather than showing me the next location.  This makes it quite a chore
> to examine an array.  Arrays of structures are even worse.
     
The fact that the man page says anything indicates you definitely don't have
3.0.  I don't know what 3.0 added.
     
First, why are you using the display command to examine an array?  "print
array[N]" seems sufficient to examine the Nth element.  If the entire array
is small enough that printing it in its entirety is reasonable, try "print
array".
     
Second, if you've just displayed a location using "/", you don't want to use
something like a naked "/" to display the same location again.  You want to
display the next location, which can be done (at least in 3.0 and later
releases) using "+/".
     
> 3.  With 'sdb', I could display lines of code relative to the current line.
>     'dbx' appears to limit me to specifying absolute line numbers.  This
>     means that anytime I hit a breakpoint and want to see some context, I
>     have to ...
     
"l" by itself will, after hitting a breakpoint, print the line the
breakpoint occurred on and the next 10 lines.  Repeating the "l" will step
through the file.  Unfortunately, this doesn't give you a window *around*
the breakpoint.  If you have "dbxtool", and are doing your debugging on a
workstation, you can use that.
     
> 4.  A common construct in C is a linked list of structures. ...
> (discussion of stepping through the list)
     
What's needed here is a notion of variables inside "dbx", so that you can
have an alias which prints whatever <variable> points to and sets <variable>
to <variable>->next.  This is a more general solution than what "sdb"
offers; I can imagine data structures which "sdb" would not be able to scan
through conveniently.
     
Unfortunately, "dbx" doesn't have this notion.  The 4.3BSD one might.
Perhaps "dbx" should have more such programming-language characteristics, so
that it could be "programmed" to display more complicated data structures.
     
I also note from this an other examples that you seem to be using "sdb" and
"dbx" as a symbolic debugger which knows about source lines, but not one
which knows about data structures.  "dbx" can be used that way, but it
wasn't really intended to be so used.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.arpa

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9099
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:01 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 05:59:53 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010440; 27 Apr 86 7:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018203; 27 Apr 86 7:00 EDT
From: Lawrence Crowl <crowl@ROCHESTER.ARPA>
Newsgroups: net.lang.c
Subject: Re: Byte order
Message-ID: <17610@rochester.ARPA>
Date: 25 Apr 86 21:21:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1298@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
]In article <17312@rochester.ARPA> crowl@rochester.UUCP (Lawrence Crowl) writes:
]]CHALLENGE:  Come up with a scheme for representing numbers, and a sorting
]]scheme in which numbers sort naturally.  Your scheme must deal with variable
]]length character strings and variable size numbers.  That is, you cannot
]]require strings to be padded with nulls, or numbers to be padded with zeros.
]
]Basically, you use a unary notation (pure or modified) to indicate how long
]the number is, and the number follows.  Using the scheme above, 257 would
]be ZZZ257.  One and a half would be Z15.  This is essentially floating point
]notation. ...  This has to be modified a bit to deal with negative numbers. ...
]Also, for negative numbers, the digits should be in (9's) complement form. ...
]This can of course be done somewhat better.  A higher radix can be used, and
]the exponent encoding can be further optimized.  But the point is to describe
]the approach, not to work out all the details.
     
This seems good to me.  If there are no radical alternatives, lets close the
issue.
--
     
Lawrence Crowl             716-275-5766        University of Rochester
                                               Computer Science Department
...!{allegra,decvax,seismo}!rochester!crowl    Rochester, New York,  14627

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9132
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:02:54 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010442; 27 Apr 86 7:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018556; 27 Apr 86 7:09 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Optimization error?
Message-ID: <2593@utcsri.UUCP>
Date: 21 Apr 86 03:56:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3109@reed.UUCP> joey@reed.UUCP (Joe Pruett) writes:
>I contend that if the compiler could figure out that flag could
>get set to 1, then it should also figure out that flag might not
>bet set to anything, and at least issue a warning, but it should
>not optimize the expression away.
>
>Is this a bug, or a misfeature, or an inherent gotcha with fancy
>optimization?
     
I would say that a run-time bug in your code has propogated its way
into compile-time - an inherent gotcha.  To determine in general that
the flag may not be set is probably (?) similar to the halting problem
- it can't be done (* In General *) so it will only be detected for
simple cases. Lint apparently looks at the textual order of operations
 - the following draws a warning:
     
    int i,j;
    for(i=1;i<=2;++i){
        if(i==2) printf("j = %d\n", j );
        j = 123;
    }
     
Lint will say that j is used before it is set. An example can be set up
with goto's { goto b; a: use(j); return; b: j=0; goto a;}. In this
case it is more obvious that the code is ok but Lint will still warn.
--
"If you aren't making any mistakes, you aren't doing anything".
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9236
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:08:39 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010446; 27 Apr 86 7:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018656; 27 Apr 86 7:12 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  A simple non-portable expression tha
Message-ID: <6612@utzoo.UUCP>
Date: 23 Apr 86 00:11:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> No, the compiler is not free to associate right-to-left in an
> expression
>     long + int + int.
> Addition associates left-to-right, and the integral widening
> conventions apply, so the middle term must be converted to long
> and added to the leftmost term before the rightmost term is
> added.  The compiler is allowed to reorder this only if it
> guarantees the same answer as would be obtained by following
> the rules...
     
Sorry, Doug, not so.  Not in the draft standard, anyway, unless serious
changes have been made since my last copy (November).  Yes, there is a
statement early on to the effect that "the compiler can do things any
way it pleases if the results are the same".  However, somewhat later,
in C.3, we also find:
     
    An expression involving more than one occurrence of the same
    commutative and associative binary operator (*, +, &, ^, |)
    may be regrouped arbitrarily... provided the types of the
    operands or of the results are not changed by this regrouping.
     
Note that no mention is made of the types of intermediate values, unless
that ambiguous reference to "results" instead of "result" is meant to
imply it.  And there is no constraint that the value of the expression
be unchanged.
--
Support the International
League For The Derision        Henry Spencer @ U of Toronto Zoology
Of User-Friendliness!        {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9201
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:07:14 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010444; 27 Apr 86 7:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018646; 27 Apr 86 7:12 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  A simple non-portable expression tha
Message-ID: <2609@utcsri.UUCP>
Date: 22 Apr 86 16:26:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <130@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>No, the compiler is not free to associate right-to-left in an
>expression
>    long + int + int.
>Addition associates left-to-right, and the integral widening
>conventions apply, so the middle term must be converted to long
>and added to the leftmost term before the rightmost term is
>added.  The compiler is allowed to reorder this only if it
>guarantees the same answer as would be obtained by following
>the rules.  On machines where integer overflow is ignored,
     
If this is strictly true, then the widening semantics are applied to
the expression tree before any reassociation is done:
     
long L; int I1,I2;
     
    L+I1+I2,  parses as (L+I1)+I2,
          after widening is (L+(long)I1)+(long)I2
     
The compiler can still do this as L + ( (long)I1+(long)I2), though,
since everything is now the same width and so the result won't be affected.
     
>the opportunity arises more frequently than on those where
>it traps.  However, in this example, information could be
>lost by overflow if the compiler treated the expression as
>    long + (int + int)
>so it is not allowed to do that.
     
What if you *write* L+(I1+I2)? If the widening semantics *are* applied
before any reassociation is done, the result is L+(long)(I1 + I2),
using an integer add for I1+I2, which presumably may not be re-ordered
because the result would be affected - besides it is no longer of the
form a+(b+c).
     
However, I tried this ( using 16-bit short ints for I1,I2 ) on our
native vax compiler and on our 68K compiler. Both produced identical code
for (L+I1)+I2 and L+(I1+I2) and L+I1+I2: specifically, ((long)I1+L)+(long)I2.
I guess the a+b+c is recognized as a special case, and all three are widened
to a common width regardless of the original associativity.
     
Interestingly, writing the expression as L+(short)(I1+I2) had no effect on
the vax code, but forced the 68K compiler to do a 16-bit add of I1 and I2
before adding L. The 68K code is what I would expect - although deliberate
use of casts as %65536 operators is pretty shaky stuff.
     
A final question - It seems that L+I1+I2 will work regardless of if and
where you put the ()'s, since a 'chained' addition is treated as a
special case. But is this a feature of the language, or of the
compiler? Any 'portability' which is based on a non-essential compiler
feature is not really true portability, is it...?
--
"If you aren't making any mistakes, you aren't doing anything".
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9289
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:13:55 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010448; 27 Apr 86 7:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018667; 27 Apr 86 7:13 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Signed Characters
Message-ID: <6610@utzoo.UUCP>
Date: 22 Apr 86 20:43:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> If restricted to only one flavor [of bytes], I would choose signed any day.
> It it easier on a PDP-11 to mask the high byte if unwanted than to
> generate it (sign extend) if needed.
     
But one ends up doing the masking a lot more often.  I believe Dennis has
said that he now regrets the concession to the hardware of making char
signed in the original C implementation.
--
Support the International
League For The Derision        Henry Spencer @ U of Toronto Zoology
Of User-Friendliness!        {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9388
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:19:28 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010453; 27 Apr 86 7:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018705; 27 Apr 86 7:15 EDT
From: Richard Harter <g-rh%cca.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Byte order (or you are both wrong)
Message-ID: <7485@cca.UUCP>
Date: 24 Apr 86 05:34:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <17162@rochester.ARPA> crowl@rochester.UUCP (Lawrence Crowl) writes:
>
>CHALLENGE:  Come up with a scheme for representing numbers, and a sorting
>scheme in which numbers sort naturally.  Your scheme must deal with variable
>length character strings and variable size numbers.  That is, you cannot
>requires strings to be padded with nulls, or numbers to be padded with zeros.
     
Presented without endorsement:
     
Addressing nomenclature -- big endian (i.e. msb is bit 0, etc.)
     
Item is divided into five parts:
     
Part I - sign bit (0 is negative, 1 is postive)
     
Part II - Size of field size in unary, i.e. string of 1's terminated by 0
     
Part III - Field size, in binary (Field size is size of field to left of
           implicit decimal point.
     
Part IV -  Portion of string to left of implied decimal point, encoded in
       bytes.
     
Part V  - Portion of string to right of implied decimal point, encoded in
          ternary, using two bits per ternary digit, as follows:
     
    00   Sentinel, terminating right field
    01   ternary 0
        02   ternary 1
    03   ternary 2
     
All numbers are represented as ascii characters.
     
The point of the ternary representation (or something equivalent) is
that it provides for a sentinel for variable length strings that sorts
lexicographically.
     
If an integer is to be considered as a number and compared in that fashion
it goes in the left field -- if it is to be considered as a character string
it goes in the right field.
     
    I believe that this representation meets the challenge.
I sincerely hope that I never have to work with it.
     
    Richard Harter, SMDS Inc.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9473
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:31:58 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010545; 27 Apr 86 7:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019075; 27 Apr 86 7:28 EDT
From: John Rose <rose@THINK.ARPA>
Newsgroups: net.lang.c,net.arch
Subject: Re: Byte order (retitled)
Message-ID: <5056@think.ARPA>
Date: 25 Apr 86 20:02:09 GMT
Xref: seismo net.lang.c:8889 net.arch:3239
To:       info-c@BRL-SMOKE.ARPA
     
In article <1117@psivax.UUCP> friesen@psivax.UUCP (Stanley Friesen) writes:
>In article <2590@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>>
>>I strongly disagree. If you have long *x, then (char)*x ( as opposed to
>>*(char*)x ) is the low-order byte of the pointed-to long and is
>>portable.
>
>    What I was trying to say is that *both* should be portable and
>equivalent.
>.....
>    And I am saying that the following *should* be portable, and
>that any implementation that it doesn't work on is brain-damaged.
>
>    register int i;
>    unsigned char bytes[ sizeof( long )];        /* lo-byte first */
>    long input;
>    register char *cvptr;
>
>    for(cvptr = (char *)&input, i = 0; i < sizeof(long); i++)
>        bytes[i] = cvptr[i];
>
>                Sarima (Stanley Friesen)
     
Well, this is certainly false for all existing C's on big-endian machines.
Even if you make the pointer "(char *)&input" point to the last byte of
the datum, when you index on it, say by referencing "cvptr[1]", you get
bytes *past* the last byte of the long datum.
     
But the funny thing is, a C compiler *could* be designed to make Sarima's
code work on a big-endian machine.  Pointer ordering and arithmetic could
be defined, in a self-consistent way, *backwards* from the machine-word
ordering.  Arrays and structs would be allocated backward in memory.
(As a bonus, conversion between pointers and ints could involve a negation,
but portable C makes no such requirements.)  In essence, the abstract
addressing structure imposed by this hypothetical compiler would turn
our misguided big-endian machine into a virtual little-endian.
     
This hack fails for the waverers, such as PDP-11's.  (However, you
could complement the 1s bit before and after index arithmetic?)
Be wrong, but be consistent!
     
Disclaimers:  This was not a serious suggestion to the compiler designers
of the world.  It certainly has nothing to do with the official policy
of Thinking Machines Corporation.  :-) :-) :-)
     
[P.S. Sarima, if this was your meaning all along, sorry to steal your
      thunder; I must have missed an article.]
     
[P.P.S. Local work crunch precludes retro-flame on &array responses.
    But stay tuned, netters.]
--
----------------------------------------------------------
John R. Rose             Thinking Machines Corporation
245 First St., Cambridge, MA  02142    (617) 876-1111 X270
rose@think.arpa                  ihnp4!think!rose

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9566
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:39 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:38:22 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010548; 27 Apr 86 7:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019182; 27 Apr 86 7:31 EDT
From: wex%milano.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Sets in C
Message-ID: <1376@milano.UUCP>
Date: 23 Apr 86 16:12:54 GMT
Sender: wex%milano.uucp@BRL.ARPA
To:       info-c@BRL-SMOKE.ARPA
     
Does anyone out there have a package for doing Pascal-like sets in C?
I want to be able to call functions like IN, etc.
     
Please reply directly to me, as I am not a regular reader of this group.
Thanks!
     
--
Alan Wexelblat
ARPA: WEX@MCC.ARPA
UUCP: {ihnp4, seismo, harvard, gatech, pyramid}!ut-sally!im4u!milano!wex
** REJECT THE IMPOSITION OF THE NEW SOCIAL ORDER !! **

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9598
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:40:56 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010648; 27 Apr 86 8:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019679; 27 Apr 86 7:48 EDT
From: Sam Kendall <sam%delftcc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  void * [also malloc]
Message-ID: <141@delftcc.UUCP>
Date: 25 Apr 86 17:21:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <200@brl-smoke.ARPA>, gwyn@BRL.ARPA writes:
> Malloc() should return (void *),
> which is a generic pointer type to/from which all other pointer types
> may be cast without loss of information.  (This is the only use of
> (void *), and it is the only universal pointer type; other pointer
> casts can be non-portable.)
     
Can anyone tell me when a `void *' could have a different representation
than a `char *'?  Since `sizeof (char)' is always 1 according to both
practical considerations and the draft standard, a char must be the
smallest addressable object.  Also according to practical considerations
(and the draft standard, I think) all objects consist of an integral
number of chars.  So there is nothing a `void *' can point at that a
`char *' cannot.
     
A `void *' and a `char *' could have different representations, although
I cannot think of a good reason.  But I think casts to `char *', and
from `char *' with proper alignment, are portable.  `void *', then,
is just a convenience for the human mind and for typecheckers.  That's
okay with me.
     
> Malloc() ALSO guarantees that the pointer
> it returns is suitably aligned for safe casting to ANY pointer type.
> This is a property of malloc(), not of (void *).
     
I've always wondered about something here: why is the return value of
malloc guaranteed to be aligned for any object, even one bigger than
the allocated area?  Currently, `malloc(1)' must return a maximally
aligned pointer!  This prevents an implementation which does something
space-efficient with small allocations.
     
----
Sam Kendall            { ihnp4 | seismo!cmcl2 }!delftcc!sam
Delft Consulting Corp.        ARPA: delftcc!sam@NYU.ARPA

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9629
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:44 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:43:38 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010650; 27 Apr 86 8:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019709; 27 Apr 86 7:49 EDT
From: John Owens <jso%edison.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: Re: structured assembler (BASIC)  [Really: C builtin functions?]
Message-ID: <705@edison.UUCP>
Date: 24 Apr 86 16:29:55 GMT
Xref: seismo net.lang:2460 net.lang.c:8892
To:       info-c@BRL-SMOKE.ARPA
     
> You are sort of right,  but sizeof qualifies as a builtin function,
> even though it is a compile-time function vs run-time.   Anyone disagree?
>
> Paul Guthrie                `When the going gets weird,
> ihnp4!ihdev!pdg                 The weird turn pro'
>                       - H. Thompson
     
Yes.  Try this on your favorite C compiler and tell me if you still
think that "sizeof" is a function as opposed to an operator.
     
main()
{
    int a;
    printf("%d\n",sizeof a);    /* note no parentheses */
}
     
    John Owens @ General Electric Company    (+1 804 978 5726)
    edison!jso%virginia@CSNet-Relay.ARPA        [old arpa]
    edison!jso@virginia.EDU                [w/ nameservers]
    jso@edison.UUCP                    [w/ uucp domains]
    {cbosgd allegra ncsu xanth}!uvacs!edison!jso    [roll your own]

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9696
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:48 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:47:12 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010718; 27 Apr 86 8:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020123; 27 Apr 86 8:05 EDT
From: Joe Mueller <joemu%nsc-pdc.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: Re: Re: ... C builtin functions?
Message-ID: <562@nsc-pdc.UUCP>
Date: 21 Apr 86 17:48:45 GMT
Xref: seismo net.lang:2462 net.lang.c:8894
To:       info-c@BRL-SMOKE.ARPA
     
> > >C has standard built-in functions????
>
> > Well, how about sizeof(foo)?
> >
> > It looks like a function invocation, and is known and understood
> > by the compiler...
>
> The thing is, sizeof() evaluates to a constant at run time, just like
> 'c'<<3  or  BUFSIZ  .  That makes it a pretty trivial function.  All it
> really does is give you a portable, automatic facility for referring to
> system dependencies.
> --
     
Sizeof is an operator, not a function. It's perfectly legal to say
"sizeof foo" (without the parens).

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9661
          for JMS@ARIZMIS; Sun, 27-APR-1986 05:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 06:46:21 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010664; 27 Apr 86 8:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020085; 27 Apr 86 8:03 EDT
From: Chris Robertson <chris%toram.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Jumping into blocks
Message-ID: <149@toram.UUCP>
Date: 25 Apr 86 16:45:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <737@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>In article <275@copper.UUCP> copper!stevesu (Steve Summit) writes:
>>Most people agree that goto's are pretty acceptable for handling
>>error conditions.  For instance:
>>
>>    [example deleted]
>
> ... But here's a real example I keep running into:
>
>    [example deleted]
>
>So, assuming that goatooze are acceptable for error handling, but jumping
>into a block is forbidden, what's the best way to write this?  Use two
>braches, and hide the common code at the bottom of main()?  Set an error
>flag and test it outside the while?  (Ugh, that requires an artificial
>boolean *and* a break statement.)  Make usage() a non-returning function
>instead of a label?  (My usual preference.)  Duplicate the code?
     
What's wrong with a flag and and "break"s?  "Break" after an error condition
is perfectly obvious, especially when the error test is right after the
loop.  Or duplicate the code, when it's so trivial.  What's a couple of
lines in the interest of readability?  Sure "goto"s can sometimes make
complicated things more readable (e.g., saving putting great chunks
of code in several nests of "if"s), but why on earth use it to make a
nice, straightforward error test obscure?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9865
          for JMS@ARIZMIS; Sun, 27-APR-1986 06:02 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 07:01:20 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010828; 27 Apr 86 8:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020269; 27 Apr 86 8:10 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: structured assembler (BASIC)  [Really: C builtin functions?]
Message-ID: <5341@alice.uUCp>
Date: 24 Apr 86 20:58:43 GMT
Xref: seismo net.lang:2463 net.lang.c:8895
To:       info-c@BRL-SMOKE.ARPA
     
> Any operator which maps its args into a unique value in its range
> defines an operation which is a function.  Just because you can
> say a + b doesn't mean that (plus a b) [resp., plus(a, b)] is not
> a function.  Similarly, sizeof(i), whether or not you use parens
> (and I always do) is an operator which, of course, is a function.
     
> Were you talking about details of implementation, perhaps?
     
The C definition of "function" is not the same as the mathematical
definition.  A C function is a part of a program.  A mathematical
function is a set of ordered pairs that meet certain conditions.
     
That said, note that sizeof(i) is syntactically a constant.  This
would not be true if sizeof were a function.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0025
          for JMS@ARIZMIS; Sun, 27-APR-1986 06:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 07:05:16 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010840; 27 Apr 86 8:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020529; 27 Apr 86 8:18 EDT
From: "Wayne A. Christopher" <faustus%cad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  void * [also malloc]
Message-ID: <219@cad.UUCP>
Date: 26 Apr 86 20:29:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <141@delftcc.UUCP>, sam@delftcc.UUCP (Sam Kendall) writes:
     
> I've always wondered about something here: why is the return value of
> malloc guaranteed to be aligned for any object, even one bigger than
> the allocated area?  Currently, `malloc(1)' must return a maximally
> aligned pointer!  This prevents an implementation which does something
> space-efficient with small allocations.
     
"Maximally aligned" generally means aligned to a multiple of the wordsize of
the machine, so you don't lose much space (malloc ususally allocates an
extra word anyway before the space for a pointer anyway...)  I guess that
you wouldn't lose much if you allowed malloc(1) to return an unaligned
byte, but it isn't worth the trouble...
     
    Wayne

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0026
          for JMS@ARIZMIS; Sun, 27-APR-1986 06:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 07:05:20 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010831; 27 Apr 86 8:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020321; 27 Apr 86 8:12 EDT
From: Tom Keller <mc68020%gilbbs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  void *
Message-ID: <194@gilbbs.UUCP>
Date: 26 Apr 86 08:34:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <200@brl-smoke.ARPA>, gwyn@BRL.ARPA (VLD/VMB) writes:
> You're mixing two features of malloc().  Malloc() should return (void *),
> which is a generic pointer type to/from which all other pointer types
> may be cast without loss of information.  (This is the only use of
> (void *), and it is the only universal pointer type; other pointer
> casts can be non-portable.)  Malloc() ALSO guarantees that the pointer
> it returns is suitably aligned for safe casting to ANY pointer type.
> This is a property of malloc(), not of (void *).
     
   Well, that's just great!  The C compiler on my system doesn't understand
such niceties as void.  So what do we do?  (do *NOT* tell me to get another
compiler, there *IS* no other compiler available for this system!)
     
--
Disclaimer:  I hereby disclaim any and all responsibility for disclaimers.
     
tom keller
{ihnp4, dual}!ptsfa!gilbbs!mc68020
     
(* we may not be big, but we're small! *)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0068
          for JMS@ARIZMIS; Sun, 27-APR-1986 06:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 07:09:25 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010932; 27 Apr 86 8:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020896; 27 Apr 86 8:30 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Address of array
Message-ID: <2629@utcsri.UUCP>
Date: 25 Apr 86 04:07:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <153@brl-smoke.ARPA> gwyn@BRL.ARPA writes:
>typedef struct { whatever-you-need } jmp_buf[1];
>
>solves the problem of the way setjmp()'s parameter is used,
>with completely type-correct implementation (in the
>"whatever-you-need" part).  Too bad setjmp() was defined
>as taking an array parameter in the first place.
     
I've been wondering about this... Why would you need to define jmp_buf
as a structure? It seems (1) it is impossible to write setjump or
longjmp in C (2) the contents of the buffer are completely
non-portable, so any program that looks at or alters them is
non-portable (3) you can't do anything useful with them anyway, from C.
All jmp_buf is is a certain amount of space, as far as C needs to be
concerned. I think point (3) is a bit shaky - the contents just might
be useful in certain inherently non-portable code. And it would be
nice, I agree, if jmp_buf had been defined as a structure - if only to
allow easy copying of jmp_buf records. A definition might look like
`typedef struct{ char *dummy[11];} jmp_buf;'.  But are there cases where
a structure was used out of necessity?
     
--
"For every action there is an equal and opposite malfunction"
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0100
          for JMS@ARIZMIS; Sun, 27-APR-1986 06:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 07:11:32 CST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010934; 27 Apr 86 8:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020992; 27 Apr 86 8:33 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: arguments in registers
Message-ID: <1205@umcp-cs.UUCP>
Date: 27 Apr 86 05:41:39 GMT
Xref: seismo net.lang.c:8905 net.unix-wizards:17910
To:       info-c@BRL-SMOKE.ARPA
     
In article <155@cbmvax.cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>[Passing arguments in registers] would be fine if C had nested
>procedures or inlines or something, but a disaster otherwise.
     
In fact, a compiler is free to optimise any function into inline code,
so long as it provides a `regular' version of those that can be called
from external modules.  For example, given the following as a complete
C module, the compiler can eliminate the routine `local1' completely,
but not `local2' nor `global':
     
    static int
    local1()
    {
        static int count;
     
        return (++count);
    }
     
    static void
    local2()
    {
        void ext0(), ext1();
     
        switch (local1()) {
        case 0:
            ext0();
            break;
     
        case 1:
            ext1();
            break;
        }
    }
     
    void
    global(ppfv)
        void (**pfv)();
    {
     
        *pfv = local2;
    }
     
[Aside to Joe Yao:  Hello!  I just used `M' in vi again.]
     
Here the routine `local1' is not accessible outside this module,
so a compiler may elide it completely and replace the call in
`local2' with a direct reference to an unnamed static variable.
However, `local2' is externally accessible, since global() (which
is itself reachable) sets the supplied pointer to point at local2.
(A really clever compiler will discover unreachable local functions
and remove them, which may reveal more unreachable locals.)
     
One can also come up with examples wherein a good compiler might
provide a function externally yet also expand calls to it in line
within that module:
     
    int
    do_the_obvious(a, b)
        int a, b;
    {
     
        return (a > b ? a : b);
    }
     
    void
    something()
    {
        register int *p, *q;
        ...
        otherproc(do_the_obvious(*p++, *q++));
        ...
    }
     
There is no reason a compiler cannot pretend the call to
`do_the_obvious' was a built-in `max' function, and generate
something like this Vax code:
     
    _do_the_obvious: .globl _do_the_obvious
        .word    0        # only scratch regs used
        movq    4(ap),r0    # get a and b into r0 and r1
                    # assume return a
        cmpl    r0,r1        # if a > b, skip this:
        bgtr    0f
        movl    r1,r0        # return b
    0:    ret
     
    _something: .globl _something
        ...
        movl    (r11)+,r0    # get *p++
        movl    (r10)+,r1    # get *q++
        cmpl    r0,r1        # if the value from *p is greater
        bgtr    0f        # than that from *q, skip this:
        movl    r1,r0        # move the from-*q value to r0
    0:    pushl    r0        # result onto stack
        calls    $1,_otherproc    # go run otherproc
        ...
     
Incidentally, I have not seen any optimising C compilers myself;
are there any available that would have done what I did above?
(Just curious.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2765
          for JMS@ARIZMIS; Sun, 27-APR-1986 17:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 19:03:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014550; 27 Apr 86 19:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027492; 27 Apr 86 19:40 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V15#3
Message-ID: <1007@hou2d.UUCP>
Date: 18 Apr 86 14:58:16 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Fri, 18 Apr 86       Volume 15 : Issue   3
     
Today's Topics:
              #import could solve the #include problem?
                              C wishlist
                     Unary + and evaluation order
----------------------------------------------------------------------
     
Date: Mon, 14 Apr 86 18:50:42 PST
From: hoptoad!gnu (John Gilmore)
Subject: #import could solve the #include problem?
To: cbosgd!std-c
     
I keep running across the problem that one include file may need
inclusions from another (especially if typedefs, like ino_t, are used).
There is no clean solution (yes, I've seen the setups with:
     
#ifndef TYPES_H_INCLUDED
#define TYPES_H_INCLUDED
  <the header file>
#endif
     
and even if you do that to all your header files and all the system
include files (and merge it back in every time a new release of the system
comes out), your code which assumes this setup will not be portable
to anywhere else.
     
It occurred to me that the solution is in hand, though; cpp has enough
information to know whether the file has been previously included.
There's just no way to ask it.  So I propose a way to ask.
     
#import "filename"
     
would have the same effect as #include "filename" unless this include file has
already been imported before in this source file.
     
On Unix systems, the file could be defined by its device/inode #s
(same definition "mv" uses to avoid moving a file on top of itself).
On other systems, string compares or whatever would work.
     
I suggest that the #import <file.h> form *not* be implemented; I never
saw what was wrong with #include "file.h" since it will be found in the
standard directories anyway.  (Anybody who puts "stdio.h" in their
current directory and then wants to include /usr/include/stdio.h is
begging for her code to break next year when somebody else maintains
it.)
     
------------------------------
     
Date: Wed, 16 Apr 86 13:03:43 est
From: decvax!bellcore!linus!raybed2!rayssd!rayssdb!cec (Campbell)
Subject: C wishlist
To: rayssd!raybed2!linus!decvax!bellcore!ulysses!cbosgd!ihnp4!houxm!hou2d!osd
     
Just a short time ago, there was a bit of discussion on net.lang.c on how
to get a C function to handle 2 or more argument arrays.  Of course, the
solution is to force the (poor) programmer to enter in the math necessary
to get an equivalent index to a 1 argument array (ie. vector).  I really
don't see why C should not be able to handle the following:
     
    int f(a,n)
    int n;
    int a[n][n];
    {
    }
     
where "n" is a user-specified number "upstairs".  Obviously, if instead
of "n" there was a constant (f(a), etc.), then C will automagically use
that constant.  Why it can't say "I'll use the user-supplied location
for my expansion of indices into a vector index if the user wishes" instead
of "I insist: gimme a number, or I won't work!!!" escapes me.  It seems that
such an extension would be simple.
     
    An example of use-cycle follows:
     
    1) I write a linear equation solver (Ax=b).  I would like to
       pass n (int a[n][n]) and then do the calculations using
       a[i][j] (int i,j;).  I can't because of an unnecessary C restriction.
     
    2) After I got the program debugged, and if it was worthwhile,
       I would then expend the effort to cast the program into pointer use
       for speed.  The latter form is not as readable, but it is faster.
     
I admit that, given the example, that the actual linear equation solver that
I wrote does not use index expansion.  Nonetheless, it would be lots easier
to do this cycle the way I mentioned for, say, double QR iterations to solve
for matrix eigenvalues.
     
I have a hard enough time as it is convincing FORTRASH types that C is better.
Give 'em one nit and their tunnel vision hits...
     
------------------------------
     
Date: Sat, 12 Apr 86 14:32:23 est
From: unc!rti-sel!dg_rtp!throopw
Subject: Unary + and evaluation order
To:
     
As I understand it, the proposed standard overloads the (new) unary +
operator, so that it is *not* analogous to the unary -.  In particular,
it states that +E restricts the order of subexpression evaluation, so
that subexpressions inside E cannot be regrouped with subexpressions
outside E.
     
All well and good... this is better than requiring explicit temporaries.
However, there was already a unary operation that (at least in K&R) had
the semantic of "assignment to a temporary", and which therefore could
have legitimately been used to restrict evaluation order without the
potentially confusing overloading of the + operator.  This is, of
course, the cast.
     
The definition of the cast in the draft standard doesn't seem to state
whether (type)E allows regrouping of subexpressions of E outside the
cast, but I suspect that it *does* allow it if the cast is nil (that is,
a conversion where the bits of E don't need to change) and doesn't if
the cast is non-nil, making this aspect of casting implementation
dependant.  (Again, this last is my interpretation, and isn't explicitly
mentioned in the standard.)
     
I'd recommend that the surprising overloading of + be dropped in favor
of the less-surprising overloading of cast.  This would make the
operation of cast a little less implementation dependant, remove a
confusing overloading of +, and in general conform more closely to K&R
at no cost to newly added functionality.  The only substantial negative
point I can think of is that using casts for order-of-evaluation
tinkering implies that the tinkerer knows the types of the
subexpressions tinkered with.  This doesn't seem a severe constraint to
me... the tinkerer had *better* know what is going on.
     
Has this proposal been made and rejected already?  Does it seem
reasonable?  Are there strong reasons for using + and not using cast?
How about weak reasons?  What is the capital of Sri Lanka?  What is the
principle export of Brazil?  If a chicken and a half lays an egg and a
half in a day and a half...  (oops sorry, little carried away there :-)
     
--
(Evil Android Duplicate Prof grabs Our Hero, who, thinking quickly, asks)
"Professor, what is the capital of Sri Lanka?"
"<zzzzztt> Miami. <crackle>"
        from _The_Annihilator_ (an example of truely *bad* cinema)
--
Wayne Throop at Data General, RTP, NC
<the-known-world>!mcnc!rti-sel!dg_rtp!throopw
     
------------------------------
     
End of mod.std.c Digest - Fri, 18 Apr 86 09:56:26 EST
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2858
          for JMS@ARIZMIS; Sun, 27-APR-1986 17:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 19:20:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014592; 27 Apr 86 20:11 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a027784; 27 Apr 86 20:00 EDT
Date:     Sun, 27 Apr 86 19:54:09 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       roe%toram.uucp@BRL.ARPA
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Infinite loops
     
Actually, any decent C compiler will optimize away "while(1)",
so that it will be no less efficient than "for(;;)".

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3011
          for JMS@ARIZMIS; Sun, 27-APR-1986 18:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 19:59:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014764; 27 Apr 86 20:54 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id aa28255; 27 Apr 86 20:41 EDT
Date:     Sun, 27 Apr 86 20:40:39 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  A simple non-portable expression tha
     
"provided the types of the operands ... are not changed by this
regrouping" to me covers the case of a change in "widening" also.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3123
          for JMS@ARIZMIS; Sun, 27-APR-1986 18:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 20:16:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014827; 27 Apr 86 21:06 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a028324; 27 Apr 86 20:52 EDT
Date:     Sun, 27 Apr 86 20:46:45 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Sam Kendall <sam%delftcc.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  void * [also malloc]
     
The idea is, conversion to/from (void *) is legal,
but conversion to/from (char *) would generate a warning.
     
Little would be gained by relaxing the alignment constraint
when malloc()ing very small objects (less than the alignment
quantum).  Even malloc(1) actually will use up much more than
one byte of storage, for the bookkeeping overhead.  It is
simpler to leave malloc() defined the way it is; why add
complexity when it doesn't gain much?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3270
          for JMS@ARIZMIS; Sun, 27-APR-1986 18:54 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 20:49:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014929; 27 Apr 86 21:27 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a028484; 27 Apr 86 21:13 EDT
Date:     Sun, 27 Apr 86 20:58:39 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Tom Keller <mc68020%gilbbs.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  void *
     
If your C compiler doesn't understand "void" (which has been in
the language for years; X3J11 did not invent it, just (void *)),
or lacks bit fields, enums, struct assignment, __LINE__, decent
library routines, etc., then I would think you would want to get
it fixed.  Even the compiler on my Apple //e understands most of
these (as well as (void *))!  Didn't you pay for vendor support?
     
I have a header file I #include in my applications, that is set
up on different systems to compensate for such things and to
provide a uniform set of extensions such as boolean data type.
Here are some relevant excerpts for a relatively puny system:
     
typedef char    *pointer;        /* generic pointer (void *) */
#define    const        /* nothing */    /* (undefine for ANSI C) */
#define    signed        /* nothing */    /* (undefine for ANSI C) */
#define    volatile    /* nothing */    /* (undefine for ANSI C) */
#define    strchr    index            /* 7th Edition UNIX, 4.2BSD */
#define    strrchr    rindex            /* 7th Edition UNIX, 4.2BSD */
#define    void    int            /* K&R Appendix A followers */

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3320
          for JMS@ARIZMIS; Sun, 27-APR-1986 19:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 21:04:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014955; 27 Apr 86 21:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028661; 27 Apr 86 21:29 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.unix-wizards,net.bugs.4bsd,net.lang.c
Subject: Re: C startup in /lib/crt0.o
Message-ID: <327@brl-smoke.ARPA>
Date: 28 Apr 86 01:28:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <100@cstvax.UUCP> simon@cstvax.UUCP (Simon Brown) writes:
>
>I see that the C startup routine _start in /lib/crt0.o under 4.2BSD
>is a bit over-protective, in that it calls routine _exit (rather than
>the system-call __exit) when it terminates.
>
>Does anyone know why? (or care, for that matter).
>I suppose it does no harm really (except load in 4k of stdio-library
>garbage, which I could really cope without!).
     
Return from main() is legally required to be equivalent to invoking
exit(), not _exit(), with parameter equal to the return value of main().
     
If your C library is set up correctly, exit() should not force stdio
code to be linked in (although some of the other C library routines
you invoke might use stdio).  The _cleanup() function exists in two
places in reasonable UNIX C libraries; once in a stdio module and once
in a stub module just to vacuously satisfy the call when stdio isn't used.
     
The X3J11 onexit() function provides an even better solution, but it
has met with stiff opposition from IEEE 1003.1 members, for some
reason.  They also seem to have trouble with exit() and _exit().
I don't understand the objections; it seemed okay to me.  Perhaps
they're unaware of the point explained in my previous paragraph.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3584
          for JMS@ARIZMIS; Sun, 27-APR-1986 19:55 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/27/86 at 21:52:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015160; 27 Apr 86 22:32 EDT
Received: from brl-tgr.arpa by SMOKE.BRL.ARPA id a029254; 27 Apr 86 22:13 EDT
Received: from mitre-bedford.arpa by TGR.BRL.ARPA id a000415;
          27 Apr 86 22:05 EDT
Full-Name: James R. Vanzandt
Message-Id: <8604280206.AA19841@mitre-bedford.ARPA>
Organization: The MITRE Corp., Bedford, MA
To: info-c@BRL-TGR.ARPA
Cc: jrv@MITRE-BEDFORD.ARPA
Subject: lint query
Date: Sun, 27 Apr 86 22:06:02 -0500
From: "James R. Van Zandt" <jrv@MITRE-BEDFORD.ARPA>
     
I'm aware of four lint-type programs for checking C code on an MS-DOS machine:
     
PC-LINT   Tecware                              $ 99
PC-Lint   Gimpel Software                      $139
Pre-C     Phoenix Computer Products Corp.      $395
Lint      Wizard Systems Software, Inc.        $450  (bundled with compiler)
     
Can anyone report experience with these or others, or point to
published reviews?
     
Please send messages to me directly, as I don't monitor info-c.  If
there's sufficient interest, I'll be glad to post a summary.
     
                                   - Jim Van Zandt

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3738
          for JMS@ARIZMIS; Sun, 27-APR-1986 20:25 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 04/27/86 at 22:19:41 CDT
Received: from Hamlet.Caltech.Edu by SRI-KL.ARPA with TCP; Sat 26 Apr 86
  17:12:59-PST
Received: from Xhmeia.Caltech.Edu by Hamlet.Caltech.Edu with DECNET ;
          Sat, 26 Apr 86 17:14:18 PST
Date:    Sat, 26 Apr 86 17:08:27 PST
From:     zar%Xhmeia.Caltech.Edu@Hamlet.Caltech.Edu
Subject: VAX VMS C Question
To:       info-vax@sri-kl.arpa
X-ST-Vmsmail-To: ST%"info-c@brl.arpa",ST%"info-vax@sri-kl.arpa"
     
I'm trying to convert some C code I have to VAX-11 C and there appears to
be no VAX-11 C system routine FGETS (three args ; buf, sizofbuf, filepointer).
Has someone already made this so I don't have to do it myself (I'm not a
real C programmer). Please reply directly to me and thanks in advance.
     
                        Zar (Dan Zirin)
                        ZAR%XHMEIA@HAMLET.CALTECH.EDU
                        (ZAR%XHMEIA@HAMLET.ARPA)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4992
          for JMS@ARIZMIS; Mon, 28-APR-1986 01:22 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 04/28/86 at 03:14:15 CDT
Received: from ucbvax.berkeley.edu by SRI-KL.ARPA with TCP; Sun 27 Apr 86
  05:13:46-PDT
Received: by ucbvax.berkeley.edu (5.48/1.11)
    id AA15490; Sun, 27 Apr 86 05:10:56 PDT
Date: Sun, 27 Apr 86 05:10:56 PDT
From: ihnp4!ttrdc!levy@ucbvax.berkeley.edu
Message-Id: <8604271210.AA15490@ucbvax.berkeley.edu>
Received: by ihnp4.ATT.COM id AA17302; 27 Apr 86 07:02:05 CDT (Sun)
To: ucbvax!info-vax
     
Subject: problem with VMS C getenv() with a Fortran main
     
Fellow VMessers:
     
I am having difficulty trying to get the VMS C getenv() to work correctly
(actually, at all!) when the main program is a Fortran routine.  It works
fine if the main routine is in C, even if there are Fortran routines in
the calling chain between the main C routine and the C routine that uses
getenv().  However, if the main routine is a Fortran routine, getenv() will
blow up with an access violation.
     
Example:
     
C
C  BLOWUP.FOR
C
      CALL EXPLODE
      END
     
/* explode.c */
explode()
{
    char *c;
    char *getenv();
    c = getenv("USER");   /* Here is where the access violation happens */
    if (c) printf("USER=%s\n",c);
    else printf("No value for environment variable USER\n");
}
     
$ FORTRAN BLOWUP
$ CC EXPLODE
$ LINK BLOWUP,EXPLODE,SYS$LIBRARY:CRTLIB/LIB
$ RUN BLOWUP
     
%SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=00000000,
 PC=0000105F, PSL=03C00004
%TRACE-F-TRACEBACK, symbolic stack dump follows
module name     routine name                     line       rel PC    abs PC
     
     
                                                           0000105F  0000105F
EXPLODE         EXPLODE                             6      00000012  0000101F
BLOWUP$MAIN     BLOWUP$MAIN                         4      00000009  00001009
     
If I make the Fortran main program into a subroutine and use a C main()
to call THAT, it works just fine.
     
I have a feeling that the C startup routines are doing something to make
getenv() work, but I would rather hope that getenv() would at least return
a null pointer to indicate that it does not know what to do, instead of
blowing up.  What I was really hoping to do was to use it as a semi-portable
way of getting at logical names (which getenv() appears to do under VMS C
for strings other than three or four special ones such as "USER") that
I could also use under Unix by setting the appropriate environment variable
from the shell before invoking the program.
     
So is there, perhaps, a routine that I could call from my Fortran program
(or the C subroutine that uses getenv()) which would keep getenv() from
blowing up when I use it later?  If it is of any information, I am using
a version 1 edition of vax11c (I have heard that the version 2 edition is
much better, but I haven't had a chance to get it yet).
     
Thanks much, in advance.
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy
     
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6755
          for JMS@ARIZMIS; Mon, 28-APR-1986 07:44 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/28/86 at 09:38:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023286; 28 Apr 86 10:26 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a005871; 28 Apr 86 9:42 EDT
Received: from lll-crg.arpa by AOS.BRL.ARPA id a021495; 28 Apr 86 9:34 EDT
Received: by lll-crg.ARPA id AA27484; Mon, 28 Apr 86 06:34:12 pdt
    id AA27484; Mon, 28 Apr 86 06:34:12 pdt
Date: Mon, 28 Apr 86 06:34:12 pdt
From: cuuxb!rsb@LLL-CRG.ARPA
Message-Id: <8604281334.AA27484@lll-crg.ARPA>
To: lll-crg!bentley!kwh@LLL-CRG.ARPA
Subject: Re: Jumping into blocks
Cc: lll-crg!info-c@BRL.ARPA
     
>>So, assuming that goatooze are acceptable for error handling, but jumping
>>into a block is forbidden, what's the best way to write this?  Use two
>>braches, and hide the common code at the bottom of main()?  Set an error
>>flag and test it outside the while?  (Ugh, that requires an artificial
>>boolean *and* a break statement.)  Make usage() a non-returning function
>>instead of a label?  (My usual preference.)  Duplicate the code?
     
I've seen two variations that *I* prefer:
     
    1) If you're in a condition that calls for bailing out, use a function
       that prints an error message (to the appropriate place) and call
       exit(). This is what I tend to use for usage/fatal error kinds of
       situations.
     
    2) In some (kernel) routines, one may have several "error" conditions
       that have a common set of "cleanup procedures" (like setting an
       error code or some such thing) before returning. In this case,
       several "gohtoose" that wind up at the bottom of the routine seem
       the neatest (well, least sloppy) way of doing it.
     
I've used the other variations that you mentioned, but wouldn't in anything
that anyone else would have to see/support.
     
    Rich Brown
    Downers Grove, IL
     
P.S.    I take that back. I've never jumped into a block like that. I think
    I would put that under the heading of "tacky".
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7837
          for JMS@ARIZMIS; Mon, 28-APR-1986 09:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/28/86 at 11:26:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029858; 28 Apr 86 12:14 EDT
Received: from bbn-prophet.arpa by SMOKE.BRL.ARPA id a009341;
          28 Apr 86 12:02 EDT
Date:     Mon, 28 Apr 86 12:00:47 EDT
From:     Dan Franklin <dan@BBN-PROPHET.ARPA>
To:       Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  C startup in /lib/crt0.o
     
I don't know why P1003.1 might object to onexit(), but I always
thought it was a bit bizarre that it could not be declared correctly
in C.  It requires a recursive typedef
     
    typedef onexit_t onexit_t(onexit_t);
     
which would, if it worked, define "onexit_t" to be a function whose
sole argument, and return value, were of type "onexit_t".  (The usage
is that a caller supplies it with a function to be invoked on exit, and
gets back some other function that the caller must arrange to be invoked
on exit.)
     
Even more odd is that the purpose of this unusual calling sequence is to
permit a program to cascade an indefinite number of functions to be
performed before exiting, but X3J11 still specifies that the
implementation must support the registration of at least 32 functions
(April 1985 draft, but I bet this hasn't changed).  If the number of
functions can be finite and small, then obviously you can define onexit()
to take one argument which is a function to call; no funny return value,
no additional arrangements to be made by the caller.  The routine would
just keep a static array of functions to call.  And it could be declared
in C.  The additional benefit to be gained by the current "generalization"
to any number of functions seems marginal to me.
     
    Dan Franklin

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9493
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 12:01:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003368; 29 Apr 86 12:40 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id aa18997; 29 Apr 86 12:32 EDT
Date:     Tue, 29 Apr 86 12:22:08 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Tom Lanning <trl%cbrma.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  oops, corrupted memory again!
     
If you check the malloc source code, you'll see that it can be
compiled with debugging checks turned on; the version in the C
library has them disabled.  I suggest keeping the debugging
malloc.o around somewhere like /usr/lib so everyone can get it
when needed.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8535
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 10:36:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000595; 29 Apr 86 11:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015077; 29 Apr 86 10:19 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  void *
Message-ID: <766@bentley.UUCP>
Date: 28 Apr 86 20:16:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <194@gilbbs.UUCP> gilbbs!mc68020 writes:
>   Well, that's just great!  The C compiler on my system doesn't understand
>such niceties as void.  So what do we do?  (do *NOT* tell me to get another
>compiler, there *IS* no other compiler available for this system!)
     
What I've done in the past is "typedef int void;" or "cc -Dvoid=int" when
trying to port new code to old compilers.  Now suddenly void takes on a
new meaning.  Hmm, I'd say your best bet (other than getting a compiler
that understands at least the current standard) is to process any such
sources with a sed script (or something smarter) to change "void *" to
"char *" and other "void" to "int".
     
Actually, I don't think "void *" will start showing up in programs for
a while after it becomes "standard".  Maybe someone will upgrade your
compiler in the meantime?
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6863
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 07:48:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019768; 29 Apr 86 8:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009919; 29 Apr 86 7:46 EDT
From: Don Steiny <steiny%scc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite Loops
Message-ID: <645@scc.UUCP>
Date: 26 Apr 86 05:38:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
**
     
    This loop looked strange to me, but I felt kind of silly
when I realized that it is perfectly good C.
     
     
    main()
    {
        main();
    }
     
It loops until it overflows the stack.
--
scc!steiny
Don Steiny @ Don Steiny Software
109 Torrey Pine Terrace
Santa Cruz, Calif. 95060
(408) 425-0382

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7613
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 09:18:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027776; 29 Apr 86 10:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013867; 29 Apr 86 9:47 EDT
From: Bennett Broder <ben%catnip.uucp@BRL.ARPA>
Newsgroups: net.micro,net.micro.pc,net.lang.c,net.unix-wizards
Subject: Help with C-kermit on SCO Xenix V
Message-ID: <294@catnip.UUCP>
Date: 26 Apr 86 16:37:46 GMT
Keywords: It isn't working
Xref: seismo net.micro:15200 net.micro.pc:8485 net.lang.c:8919
  net.unix-wizards:17939
To:       info-c@BRL-SMOKE.ARPA
     
I recent obtained a copy of C-kermit 4.2(030) PRERELEASE #2, 5 March 85.
We have been using this version at work on a Perkin Elmer 3250XP and an
AT&T 3B5, and so I wasn't expecting any problem bringing it up on Xenix.
Well the package compiles without error, and appears to work okay, until
you attempt to do a transfer.  Then it can't even seem to get past the
header packet, and keeps printing SS%S%S%S%S% and the like on the screen.
Looking at the debugging output from both ends show that the Xenix machine
is computing the checksum incorrectly.  Please, can anyone help???
     
     
--
     
Ben Broder
{ihnp4,decvax} !hjuxa!catnip!ben
{houxm,topaz}/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7672
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 09:22:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027857; 29 Apr 86 10:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013878; 29 Apr 86 9:47 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <763@bentley.UUCP>
Date: 27 Apr 86 19:27:12 GMT
Xref: seismo net.lang.c:8920 net.lang.c++:175
To:       info-c@BRL-SMOKE.ARPA
     
In article <4495@cbrma.UUCP> cbrma!trl (Tom Lanning) writes:
>    Are there any "malloc" routines that check for modification of
>malloc's link pointers by the "user's" code?   Close to 70% of by bugs
>are stack/memory problems were I use more space than I allocated.
     
As mentioned in the man page, the malloc() code has a compile-time option
for strict checks on the arena.  (This is not too useful if you have no
source code, of course.)
     
In C++, you can define a datatype that works like a pointer but does
run-time bounds checking; this requires changing your declarations from
"char *" to "vector" (or whatever).
     
Now, if only somebody would invent an architecture where all objects,
including dynamicly allocated objects, are isolated in memory, then any
subscript error would cause an immediate memory fault.  You'd still be
vulnerable to completely wild pointers (but less likely in a huge address
space), and overflow of an array inside a structure might be untrappable,
but otherwise it sounds like a great machine to do your debugging on.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8057
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 09:56:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028696; 29 Apr 86 10:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014673; 29 Apr 86 10:09 EDT
From: Don Libes <libes%nbs-amrf.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: multitasking in one process (4.2BSD)
Message-ID: <269@nbs-amrf.UUCP>
Date: 27 Apr 86 14:09:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     I an not aware of the situation for C++, but there is a stand alone
>     Multitasking package avaiable for C (for free).  It runs under Unix,
>     is compatible with dbx, and can be set to interleave the execution of
>     the arbitrary number of tasks every instruction if so desired.  It
     
I had the mispleasure of porting an application on a standalone
68000 to a Sun.  Only problem was that the application was a set of
multitasking procedures that shared a lot of data structures.
     
For efficiency, my only choice was to get the whole mess to run as
one UNIX process.  The result is an operating system in a process.
     
Unlike what is described above, scheduling is based upon timers,
ASTs (ala VMS) or waiting for an event.  While a bitch to debug
itself (mainly because of the 4.2 software timers), you can play
with your whole system under dbx, watching every process.
     
It's certainly free.  Let me know if anyone is interested.  If
there are enough requests, I might even document it and send it to
mod.sources.
     
Don Libes         {seismo,umcp-cs}!nbs-amrf!libes

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8371
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 10:22:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000650; 29 Apr 86 11:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015274; 29 Apr 86 10:24 EDT
From: "Daniel M. Frank" <dan%prairie.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++,net.arch
Subject: Re: oops, corrupted memory again!
Message-ID: <117@prairie.UUCP>
Date: 28 Apr 86 15:58:11 GMT
Xref: seismo net.lang.c:8931 net.lang.c++:177 net.arch:3247
To:       info-c@BRL-SMOKE.ARPA
     
-------------
     
>Now, if only somebody would invent an architecture where all objects,
>including dynamicly allocated objects, are isolated in memory, then any
>subscript error would cause an immediate memory fault.
     
   If I'm not mistaken, this was done on the iAPX432, using a capability-
based addressing scheme.  Dimmed the lights.  You could probably construct
such an environment on the 80286, but no one does, probably for efficiency
reasons.
     
   You're probably better off with a language that compiles checks into
the code, and an option to turn off those checks once you're confident
(?!) of the program.  With a capability-based architecture, you pay the
price all the time, whether you want to or not.
     
     
--
    Dan Frank
        ... uwvax!geowhiz!netzer!prairie!dan
        -or- dan@caseus.wisc.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5871
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 04:38:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015948; 29 Apr 86 5:23 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a008208; 29 Apr 86 4:43 EDT
Received: from nta-vax.arpa by AOS.BRL.ARPA id a015878; 29 Apr 86 4:38 EDT
Date: Tue, 29 Apr 86 10:41:45 -0200
From: Stein-Erik Engbr}ten <see@NTA-VAX.ARPA>
Posted-Date: Tue, 29 Apr 86 10:41:45 -0200
Message-Id: <8604290841.AA25304@nta-vax.ARPA>
Received: by nta-vax.ARPA (5.31/3.21)
    id AA25304; Tue, 29 Apr 86 10:41:45 -0200
To: info-c@BRL.ARPA
Subject: Include the va_end!
     
In message <5336@alice.uUCp> Andrew Koenig (<ark@alice.uucp>)
writes:
     
>> I assume va_start be done in the original function.  (Dito the first
>> va_alist comment.)  Does va_end have to be done in the original
>> function also?  (va_end does nothing in my implementation.)
>
>It should be.  (va_end does nothing in every implementation I've seen)
     
I have found an implementation which needs the va_end. It caused
me a great deal of trouble - the source I was compiling (the
SYSTEM_V source for curses!) had left out the va_end ("It doesn't
do anything, so why bother...").
     
The implementation is on the Pyramid 90x machine, the System V
part of it (it runs both 4.2 and System V at the same time!),
where va_end is defined to be an '}'.
     
So please, everybody - even if 'nobody' defines the va_end,
include it all the same!
     
Stein-Erik Engbr}ten

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3068
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/28/86 at 21:11:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014844; 28 Apr 86 21:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005372; 28 Apr 86 21:42 EDT
From: Tom Lanning <trl%cbrma.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: oops, corrupted memory again!
Message-ID: <4495@cbrma.UUCP>
Date: 24 Apr 86 00:40:43 GMT
Keywords: malloc free stack tools core
Xref: seismo net.lang.c:8906 net.lang.c++:173
To:       info-c@BRL-SMOKE.ARPA
     
     
    Are there any "malloc" routines that check for modification of
malloc's link pointers by the "user's" code?   Close to 70% of by bugs
are stack/memory problems were I use more space than I allocated.  Tracking
this kind of problem is horrible.  Once you get a core, if you get a core,
you only know that malloc's data was corrupted; you do not know where or
when.  Since malloc's structures and algorithms are "hidden", a developer
can not easily use the "stop when this address has been modified" feature
of sdb.
    This problem is not unique to my code, I know others that are
plagued by these bugs also.  A programmer only needs one of these bugs
in a large piece of software to waste a week of effort.  I am aware of
all the things I can and should do to prevent this, but what I am looking
for is a tool or procedure to ** quickly ** locate where and when corruption
is taking place.
    I am interested in any tools, recommendations, or routines that may
help.  Thanks.
     
     
     
                Tom Lanning
                AT&T Bell Laboratories
                Columbus Ohio  614-860-4153
--
     
  Tom Lanning   AT&T Bell Laboratories   Columbus OH   43213     614-860-4153

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3336
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/28/86 at 21:47:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014922; 28 Apr 86 22:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005393; 28 Apr 86 21:42 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Byte order (retitled)
Message-ID: <2637@utcsri.UUCP>
Date: 25 Apr 86 21:59:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1117@psivax.UUCP> friesen@psivax.UUCP (Stanley Friesen) writes:
>In article <2590@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>>...
>    And I am saying that the following *should* be portable, and
>that any implementation that it doesn't work on is brain-damaged.
>
>    register int i;
>    unsigned char bytes[ sizeof( long )];        /* lo-byte first */
>    long input;
>    register char *cvptr;
>
>    for(cvptr = (char *)&input, i = 0; i < sizeof(long); i++)
>        bytes[i] = cvptr[i];
>
Sorry - I thought you were suggesting that big-endian pointer conversions
should set the lower bits (when pointing to a smaller object) and clear
them (when pointing to a larger one). What you are actually saying is
that any implementation which is not strictly little-endian is 'brain-
damaged' (Including (a) PDP11 _longs_, (b) 68000). I will agree that (a)
is brain-damaged, but I think the adjective is a little strong for (b).
I am a little-end fan myself, but I can face reality, and the reality is
there will be big-endian machines around that are still worth using, and
that the 'problem' can be dealt with so easily that one needn't damn
the 68K to eternal flames on this one point.
     
--
"For every action there is an equal and opposite malfunction"
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7998
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 09:53:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028625; 29 Apr 86 10:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014428; 29 Apr 86 10:02 EDT
From: Martin Minow <minow%decvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <208@decvax.UUCP>
Date: 27 Apr 86 23:40:02 GMT
Keywords: malloc free stack tools core
Xref: seismo net.lang.c:8927 net.lang.c++:176
To:       info-c@BRL-SMOKE.ARPA
     
A requestor asks for tools to verify that malloc'ed memory hasn't
been crashed.  Decus C provides the following functions that
could be adapted to your system:
     
    isalloc(pointer)    returns 0, 1, -1 depending on whether
                the argument is not malloc'ed memory,
                is a pointer returned by malloc, or
                is a recently freed malloc result.
     
    $$mchk()        Checks all memory allocated by malloc,
                crashes the program if the chains are
                corrupt.
     
    $$link()        Prints the memory list on stderr (called
                by $$mchk() above.
     
The implementation of $$mchk and isalloc depend on the way in which
memory is organized and must be adapted to your specific system.
Decus C uses the same organization as Unix V6 -- a linked list
of pointers ascending in memory.  $$mchk() will fail if the contents
of a pointer is less than its address, unless the contents is the
"memory head" location (in which case, the memory chain is correct).
     
Depending on how your operating system's malloc was written, an
$$mchk equivalent could be either very easy or impossible.
     
Martin Minow
decvax!minow

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8862
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:37 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 11:09:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001286; 29 Apr 86 11:21 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a015633; 29 Apr 86 10:34 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA11663; Tue, 29 Apr 86 10:35:31 edt
Date: Tue, 29 Apr 86 10:35:31 edt
From: root <rbj@ICST-CMR.ARPA>
Message-Id: <8604291435.AA11663@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Re: Byte order (retitled)
     
> In article <1117@psivax.UUCP> friesen@psivax.UUCP (Stanley Friesen) writes:
> >In article <2590@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
> >>...
> >    And I am saying that the following *should* be portable, and
> >that any implementation that it doesn't work on is brain-damaged.
> >
> >    register int i;
> >    unsigned char bytes[ sizeof( long )];        /* lo-byte first */
> >    long input;
> >    register char *cvptr;
> >
> >    for(cvptr = (char *)&input, i = 0; i < sizeof(long); i++)
> >        bytes[i] = cvptr[i];
> >
> Sorry - I thought you were suggesting that big-endian pointer conversions
> should set the lower bits (when pointing to a smaller object) and clear
> them (when pointing to a larger one). What you are actually saying is
> that any implementation which is not strictly little-endian is 'brain-
> damaged' (Including (a) PDP11 _longs_, (b) 68000). I will agree that (a)
> is brain-damaged, but I think the adjective is a little strong for (b).
> I am a little-end fan myself, but I can face reality, and the reality is
> there will be big-endian machines around that are still worth using, and
> that the 'problem' can be dealt with so easily that one needn't damn
> the 68K to eternal flames on this one point.
>
> "For every action there is an equal and opposite malfunction"
> ----------------------------------------------------------------------
> Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
     
To all you Big Endian fans out there: What's your problem? You guys
are the ones saying that the first byte is the most significant, so
why are y'all bitchin that you don't get the low byte like on *sane*
machines? Axually, I like the 680[012]0 also. Byte order doesn't really
bother me either way except as an academic issue.
     
I don't see the need or the possibility for your example to be both
portable and work the way you described. The two are at odds.
Remember, C does what you tell it to do, not what you think it should do.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7221
          for JMS@ARIZMIS; Tue, 29-APR-1986 10:37 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 08:25:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020859; 29 Apr 86 8:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009974; 29 Apr 86 7:47 EDT
From: "Richard M. Geiger" <rmg%mips.uucp@BRL.ARPA>
Newsgroups: net.unix,net.lang.c,net.lang.pascal,net.lang.f77
Subject: UNIX OS / Language Validation Suites (summary)
Message-ID: <456@mips.UUCP>
Date: 27 Apr 86 00:42:52 GMT
Xref: seismo net.unix:8097 net.lang.c:8918 net.lang.pascal:568 net.lang.f77:528
To:       info-c@BRL-SMOKE.ARPA
     
Original Posting:
     
> From postnews Mon Mar 31 12:02:39 1986
> Subject: UNIX OS / Language Test & Validation Suites
> Newsgroups: net.lang.f77,net.lang.c,net.lang.pascal,net.unix
> Distribution: net
>
> I am interested in the availability, either commercially or in the public
> domain, of test suites covering the following areas:
>
>    - UNIX kernel (BSD / SYSV) & Utilities
>    - Compilers
>       - C
>       - Pascal
>       - Fortran 77
>
> I already know of the SVVS and Perennial products. Please send mail
> if you know of any others; I will summarize & post if volume warrants.
>
> And, of course, the usual apologies if this topic has been covered
> recently... If there is already a summary out there somewhere, please
> mail me a copy!
>
> Thanks.
     
I received informative responses from:
     
From: glacier!sun!ihnp4!cray!hrp         Hal Peterson
From: glacier!hplabs!hp-sdd!ncr-sd!steves        Steve Schlesinger
From: decwrl!seismo!mcvax!ukc!trh@SRI-IU.ARPA    Tim Hopkins
From: decwrl!amdcad!scgvaxd!tcville!pete!arndt   Peter A. Arndt
From: decwrl!sun!convex!tork                     Bill Torkelson
jensen@uiowa (CSNET)                             Nancy Jensen
     
Thanks to you all.
     
If anyone knows of any other public domain or commercially available
testing or validation tools covering these areas, please let me know!
     
     
Summary of Responses:
     
UNIX kernel / utilities:
------------------------
     
  Package:    Perennial UNIX Validation Suite
     
  Supplier:    Perennial
        Suite 450
        4677 Old Ironsides Drive
        Santa Clara, CA  95054
        (408) 727-2255
     
  This suite is available in both BSD 4.2 and SYSV flavors. Includes tests
  of system calls, library functions, and commands.  Also, there are a few
  "exerciser" tests which stress the file system and virtual memory.  Many
  of the command tests (ls, sed, awk, etc.) are *extremely* cursory, testing
  the absolute minimum level of functionality, such as "can I invoke this
  command and get a good return status?". Parts of the software which are
  the most machine dependent, (requiring the greatest porting effort), are
  tested more thoroughly. This is the only suite I presently know of aimed
  at validating 4.2 ports. I would love to hear of any others.
     
     
  Package:    System V Verification Suite
     
  Supplier:    AT&T Information Systems
        for ordering information contact:
     
            AT&T Information Systems
            Customer Information Center
            P.O. Box 19901
            Indianapolis, Indiana  46219
     
  This is the official validation tool for System V ports. It is intended to
  verify that a given SYSV port conforms to the SVID (System V Interface
  Definition). SVVS comes complete with an AT&T license agreement under
  which I am not allowed to say anything more about it... But what the heck,
  I'll go out on a limb and say (at least) that looks like a very good
  package from what I've seen so far, both of SVVS and of other OS
  validation suites. The suite follows the structure of the SVID, and knows
  about dependencies, so that the test programs employ only features which
  have previous validated (within reason).
     
     
  Package:    AIM Benchmarks / Tuning tools
     
  Supplier:    AIM Technology
            4655 Old Ironsides Drive
            Suite 390
            Santa Clara, CA  95054
     
  While these aren't really meant as validation tools, they may be of use.
  From what little I know, the AIM benchmarks are a commonly used basis
  for performance comparisons between different UNIX systems.
     
     
Pascal Suites:
--------------
     
  Package:     Pascal Validation Suite
        a.k.a. "Tasmanian" Pascal Validation Suite
        a.k.a. "SALE"
        a.k.a. British Standard Institution Pascal Validation Suite
     
  Suppliers:    Richard J Cichelli
        Software Consulting Services
        901 Whittier Dr.
        Allentown, PA  18103
        (215) 797-9690
     
        I was also given another phone number for Software
        Consulting Services:
     
        (215) 837-8484
     
        And yet another address and phone for S.C.S.:
     
        Ben Franklin Technology Center
        Suite 10
        Murray H. Goodman Campus
        Lehigh University
        Bethleham, PA  18015
        (215) 861-7920
     
  This seems to be the only Pascal suite around... and it seems to have been
  around in several incarnations. The original version grew out of work by
  B.A. Wichmann and A.H.J. Sale at the University of Tasmania.  It appears
  to now be under the control of the British Standards Institute. The suite
  tests against the the ISO 7185 (BS 6192) Pascal standard.  The last
  address above may the the one to try first; I picked it up from a genuine
  printed document sent me by Nancy Jensen. I am very interested in learning
  about any Pascal suites which validate to ANSI Pascal.
     
     
C Suites:
---------
     
  HCR C Test Suite
     
  Supplier:     Human Computing Resources
                10 St. Mary Street
                Toronto, Ontario, Canada M4Y 1P9
                (416) 922-1937
     
  An extensive C test & validation suite. This is apparently a tool which
  was originally developed by HCR to test their C compiler products, and
  later became a product in its own right. It is organized into three major
  divisions, called the breadth, minor depth, and major depth suites.  The
  version I have seen tests conformity to K&R ("...tempered by what the
  System V VAX C compiler accepted, with obvious bugs removed."), pending
  the official acceptance of the ANSI C standard. The suite appears to be a
  very thorough set of tests, and comes with a menu-driven user interface.
  In all, HCR says the suite runs for about 60 hours on a VAX 11/750.
     
     
  Package:    metaWare C validation suite
     
  Supplier:    Frank DeRemer and Tom Pennello
        (Anybody have an address for these guys?)
     
  Hal Peterson reports that this suite sells for $750, and that the
  people listed as supplier are "with the ANSI C committee, X3J11".
  Perhaps they could be reached in care of X3J11?
     
     
  Package:    C-Lance
     
  Supplier:    RAPA (Ralph Phraner)
        (415) 752-8590
     
  Hal Peterson reports that this suite sells for $10K.
     
     
  Package:    Perennial C Compiler Validation Suite
     
  Supplier:    Perennial
        Suite 450
        4677 Old Ironsides Drive
        Santa Clara, CA  95054
        (408) 727-2255
     
  Available in VAX/VMS and MS-DOS, as well as UNIX versions. Validates
  against ANSI standard. $10K.
     
     
FORTRAN 77 Suites:
------------------
     
  Package:    1978 FORTRAN Compiler Validation Suite (FCVS78)
     
  Supplier:    Federal Software Testing Center
        Two Skyline Place
        5203 Leesburg Pike
        Falls Church, VA  22041
     
        Available through U.S. Dept. of Commerce
        National Technical Information Service
        (I don't have the NTIS address)
     
  A validation package for compilers conforming to the ANS FORTRAN X3.9-1978
  (FORTRAN-77) standard. "The tests are progressively complex exercises of
  statement combinations representing typical language usage. They can be
  used to evaluate compiler usability and conformance to the 1978 FORTRAN
  Standard, and can aid in precise identification of compiler flaws. The
  test case outputs are tailored to each of the tests involved in order to
  aid in the specific diagnosis of instances of nonconformance or of compiler
  errors." - from the FCVS78 abstract.
     
     
  Package:    (name of package?)
     
  Supplier:    CCTA (Central Computer and Telecommunications Agency)
        (in the U.K.)
     
  Hal Peterson mentioned this one. If anybody has more complete information,
  please send it to me!
     
If you know of any packages which should be on this list but aren't, please
send me mail. If there are any significant additions, I will add them to the
list and repost.
     
Once again, thanks to all who responded.
     
*** The information given above reflects my own opinions only, which are
*** not necessarily those of MIPS Computer Systems.
     
     
     
     
--
--
-Richard Geiger
     
UUCP:    {decvax,ucbdvax,inhp4}!decwrl!mips!rmg
DDD:    (408) 720-1700
USPS:    MIPS Computer Systems, 930 E. Arques Ave., Sunnyvale, CA  94086

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0223
          for JMS@ARIZMIS; Tue, 29-APR-1986 11:31 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 13:15:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009001; 29 Apr 86 13:50 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a020029; 29 Apr 86 13:29 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA12149; Tue, 29 Apr 86 13:29:33 edt
Date: Tue, 29 Apr 86 13:29:33 edt
From: root <rbj@ICST-CMR.ARPA>
Message-Id: <8604291729.AA12149@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, nbs-amrf!libes@seismo.ARPA
Subject: Re:  multitasking in one process (4.2BSD)
     
> >     I an not aware of the situation for C++, but there is a stand alone
> >     Multitasking package avaiable for C (for free).  It runs under Unix,
> >     is compatible with dbx, and can be set to interleave the execution of
> >     the arbitrary number of tasks every instruction if so desired.  It
>
> I had the mispleasure of porting an application on a standalone
> 68000 to a Sun.  Only problem was that the application was a set of
> multitasking procedures that shared a lot of data structures.
>
> For efficiency, my only choice was to get the whole mess to run as
> one UNIX process.  The result is an operating system in a process.
>
> Unlike what is described above, scheduling is based upon timers,
> ASTs (ala VMS) or waiting for an event.  While a bitch to debug
> itself (mainly because of the 4.2 software timers), you can play
> with your whole system under dbx, watching every process.
>
> It's certainly free.  Let me know if anyone is interested.  If
> there are enough requests, I might even document it and send it to
> mod.sources.
>
> Don Libes         {seismo,umcp-cs}!nbs-amrf!libes
     
I once did a similar thing, except it was pretty much round robin
and each task checked it's input queue each cycle for work to do.
All we had to to was save our regs on our stack, point to the next
proc entry, switch stack ptrs (need assembly for this) restore
regs and go! Even this provided it's share of education tho!
     
How strange to be sending this cross town & back when I am only
a few hundred feet away from you physically (B358 Bldg 223).
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1521
          for JMS@ARIZMIS; Tue, 29-APR-1986 13:37 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 15:26:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015126; 29 Apr 86 16:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024120; 29 Apr 86 15:52 EDT
From: "Wayne A. Christopher" <faustus%cad.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <229@cad.UUCP>
Date: 28 Apr 86 18:35:53 GMT
Keywords: malloc free stack tools core
Xref: seismo net.lang.c:8937 net.lang.c++:179
To:       info-c@BRL-SMOKE.ARPA
     
In article <4495@cbrma.UUCP>, trl@cbrma.UUCP (Tom Lanning) writes:
     
>     Are there any "malloc" routines that check for modification of
> malloc's link pointers by the "user's" code?   Close to 70% of by bugs
> are stack/memory problems were I use more space than I allocated.
     
You could compile the 4.3 malloc() with the -DRCHECK flag, which checks
that you haven't modified the areas beyond your segment when you free it.
Also, if you're REALLY paranoid, write your own malloc that puts lots of
padding around the allocated areas and checks that none of the padding
areas has been changed every time you call malloc() or free().
     
    Wayne

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3515
          for JMS@ARIZMIS; Tue, 29-APR-1986 17:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 19:17:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015554; 29 Apr 86 16:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024360; 29 Apr 86 15:58 EDT
From: Chris Shaw <cdshaw%watdragon.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: Re: Re: Re: Re: Re: Re: ... C builtin functions
Message-ID: <925@watdragon.UUCP>
Date: 27 Apr 86 22:22:37 GMT
Xref: seismo net.lang:2470 net.lang.c:8938
To:       info-c@BRL-SMOKE.ARPA
     
     
This discussion is getting really boring. (Yes I know I can "n" past them,
but that's not the point). Could people who have a burning desire to
talk this to death please stop (or do so by mail) ?
I'm getting rather sick of sizeof blah.
     
     
Chris Shaw    watmath!watrose!cdshaw  or  cdshaw@watmath
University of Waterloo
Bogus as HELL !!!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3604
          for JMS@ARIZMIS; Tue, 29-APR-1986 17:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 19:30:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015591; 29 Apr 86 16:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024723; 29 Apr 86 16:08 EDT
From: Guido van Rossum <guido%boring.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Funxions
Message-ID: <6889@boring.UUCP>
Date: 25 Apr 86 02:04:57 GMT
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <3186@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes:
>>[plea for lint to check printf formats]
>Ok, there *is* a way to do this.  One of the europeans (that guy that
>had been doing Hack) posted a tool for aiding lint last year sometime.
>[rough explanation of the idea]
     
This code is still available; I can mail it to interested parties.  The
author is called Andries Brouwer (and currently not at our institute but
in Denmark).  I've also heard that system 5 lint has this built-in;
there's even a directive /*PRINTFLIKE*/ so you can define your own.
     
>>... The following is a borderline case:
>>        printf( c<' '|| c>'\176'? "\\%3o":"%c", c);
>I dunno what it would do with this case...
     
It gives up here.  There is a limit to what you can check.
     
>One thing that occurs to me... do char's always get casted to ints
>when they're arguments to functions?????
     
Yes, definitely.  And so do shorts.  This is supposed to be standard
knowledge amongst posters to this group!  (At least posters that answer
questions.)
     
--
    Guido van Rossum, CWI, Amsterdam <guido@mcvax.UUCP>

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3723
          for JMS@ARIZMIS; Tue, 29-APR-1986 17:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/29/86 at 19:36:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015601; 29 Apr 86 16:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024751; 29 Apr 86 16:08 EDT
From: Kay Dekker <kay%warwick.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <475@snow.warwick.UUCP>
Date: 26 Apr 86 07:49:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <7097@cca.UUCP> dewitt@cca.UUCP (Mark DeWitt) writes:
>After three years of C programming I'm just starting to use lint, so
>please no negative reinforcement by flaming about how stupid my questions
>are, lest I give up on it entirely :-).
     
Mark, I'm not flaming you, but I *am* worried!  If you've been programming
in C for 3 years and not using lint then EITHER 1) Your system doesn't *have*
lint.  You have my profound sympathy. OR 2) Nobody ever taught you about
using lint.  I wonder why not? OR 3) You never realised that using lint
was important.  You must have wasted many hours (that you could have spent
playing Rogue or whatever :-)) chasing problems down that lint might well
have indicated to you.
     
People, what are *we* doing wrong when somebody can spend 3 years programming
in a particular language and only then start using one of the most important
development tools for it?
     
It's got to the point when if I'm doing program surgery and someone comes up
saying that their program "doesn't work", if they haven't brought a
line-numbered listing of the source AND a lint output, I don't really want
to start looking for the problems.
                            Kay.
--
"I AM; YOU ARE; HELLO: all else is poetry"
            ... mcvax!ukc!warwick!kay

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0767
          for JMS@ARIZMIS; Wed, 30-APR-1986 08:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/30/86 at 10:30:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029447; 30 Apr 86 11:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011920; 30 Apr 86 10:08 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Jumping into blocks
Message-ID: <1324@mmintl.UUCP>
Date: 28 Apr 86 22:40:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <737@bentley.UUCP> kwh@bentley.UUCP writes:
>So, assuming that goatooze are acceptable for error handling, but jumping
>into a block is forbidden, what's the best way to write this?  Use two
>branches, and hide the common code at the bottom of main()?
     
Yes.  Exception handlers belong at the bottom of the routine.  It isn't
"hidden" there -- that's the first place I would look for it.  I would
describe it as being hidden in your code (for whichever case it is being
jumped to).
     
Duplicating the code is also acceptable.  It depends mostly on a comparison
of two considerations: (1) how likely are there to be more instances where
the code is to be used in later versions of the routine, and (2) how likely
is it that later versions will want a different error message for the two
cases?
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1656
          for JMS@ARIZMIS; Wed, 30-APR-1986 10:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/30/86 at 11:14:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001719; 30 Apr 86 12:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001881; 30 Apr 86 11:54 EDT
From: Sam Kendall <sam%delftcc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: oops, corrupted memory again!
Message-ID: <142@delftcc.UUCP>
Date: 29 Apr 86 15:06:17 GMT
Keywords: malloc free stack tools core
To:       info-c@BRL-SMOKE.ARPA
     
In article <4495@cbrma.UUCP>, trl@cbrma.UUCP writes:
>     Are there any "malloc" routines that check for modification of
> malloc's link pointers by the "user's" code?   Close to 70% of by bugs
> are stack/memory problems were I use more space than I allocated.  Tracking
> this kind of problem is horrible.
> ....
>     This problem is not unique to my code, I know others that are
> plagued by these bugs also.  A programmer only needs one of these bugs
> in a large piece of software to waste a week of effort.
> ....
>     I am interested in any tools, recommendations, or routines that may
> help.  Thanks.
     
The Bcc Compiler, a tool made by Delft Consulting Corp., catches bugs of
this sort (as one case of "pointer out of bounds") and tells you exactly
where in your source the transgression occurred.  An item about Bcc was
recently posted to mod.newprod.  Please contact me for more info.
     
Also, if you have source, you can recompile malloc to check its internal
pointers stringently.  At least you could on V7, and I doubt anyone has
removed this capability.  This won't locate your bug, but it might help.
     
----
Sam Kendall            { ihnp4 | seismo!cmcl2 }!delftcc!sam
Delft Consulting Corp.        ARPA:  delftcc!sam@NYU.ARPA
432 Park Avenue South        Phone: +1 212 243-8700
New York, NY  10016

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1848
          for JMS@ARIZMIS; Wed, 30-APR-1986 10:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 04/30/86 at 11:25:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001732; 30 Apr 86 12:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001889; 30 Apr 86 11:54 EDT
From: Sam Kendall <sam%delftcc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Alignment of malloc return value (Re:  void * [also malloc])
Message-ID: <143@delftcc.UUCP>
Date: 29 Apr 86 18:18:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <219@cad.UUCP>, faustus@cad.UUCP writes:
> In article <141@delftcc.UUCP>, sam@delftcc.UUCP (Sam Kendall) writes:
> > Currently, `malloc(1)' must return a maximally
> > aligned pointer!  This prevents an implementation which does something
> > space-efficient with small allocations.
>
> "Maximally aligned" generally means aligned to a multiple of the wordsize of
> the machine, so you don't lose much space (malloc ususally allocates an
> extra word anyway before the space for a pointer anyway...)  I guess that
> you wouldn't lose much if you allowed malloc(1) to return an unaligned
> byte, but it isn't worth the trouble...
     
Doug Gwyn <gwyn@brl.arpa> responded similarly to faustus@cad.UUCP, so
I'll elaborate on what I meant.
     
A common allocation algorithm, not used in standard UNIX malloc(3) but
perhaps available in sVr2's malloc(3X) or 4.2 BSD's malloc(3), is to
preallocate a contiguous set of pages for each blocksize below some
small threshold.  Thus one set of pages would be allocated for 1-byte
blocks, another set of pages for 2-byte blocks, and so on.  (Above the
threshold, some other algorithm is used.)  You can tell by the address of
an area how large it is, simply by checking which set of pages it is
in.  You can keep track of which blocks are allocated by using a bitmap.
If you are allocating many small blocks, this algorithm surely is "worth
the trouble", since it is extremely fast and wastes no space.  It is
particularly good on a paging OS.
     
The current man pages for malloc(3) and malloc(3X) prohibit such an
algorithm, because they say that
     
        Each of the allocation routines returns a pointer to space
        suitably aligned (after possible pointer coercion) for storage
        of any type of object.
     
And this implies: even one larger than the allocated space.  This is
true for V7 malloc, but not for the algorithm described above.  I'm just
suggesting that the man page be corrected to say, "...  small enough to
fit in the allocated space", or something like that.  I wasn't very
clear about this suggestion in my previous posting; thanks to alice!ark
<Andrew Koenig> for clarifying this.
     
There is a more general point lurking here: a man page should describe a
function's _interface_.  The man page may note additional constraints
imposed by the current _implementation_, but notes on the implementation
should be separated from the description of the interface.  The C
language sometimes encourages people to confuse the abstraction
(interface) with the implementation, and I think I see this confusion
reflected in the way UNIX is documented.  AT&T has taken some steps to
correct this confusion, probably as a side effect of writing the System
V Interface Definition.  Berkeley, on the other hand, gets worse with
each release.
     
So my complaint about malloc's man pages on various UNIX systems is
really that they describe the current implementations too specifically
(and perhaps incorrectly).  The DESCRIPTION should say less, leaving
room for other implementations.  Notes about the current implementation
should be in a separate NOTES section of the man page.
     
----
Sam Kendall            { ihnp4 | seismo!cmcl2 }!delftcc!sam
Delft Consulting Corp.        ARPA: delftcc!sam@NYU.ARPA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8010
          for JMS@ARIZMIS; Wed, 30-APR-1986 23:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/01/86 at 01:34:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023683; 30 Apr 86 23:25 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a013797; 30 Apr 86 22:54 EDT
Received: from juliet.caltech.edu by AOS.BRL.ARPA id a023578;
          30 Apr 86 22:43 EDT
Date:     Wed, 30 Apr 86 19:43:32 PDT
From:     "William E. Woody" <woody@juliet.caltech.edu>
Message-Id: <860430194332.01s@Juliet.Caltech.Edu>
Subject:  LINT
To:       info-c@juliet.caltech.edu
Comment:  Some assembly required.
     
>
>  You people fail to realize that some of us out here don't like lint.
>  It complains too much about what I do....
>
>         (Root Boy) Jim Cottrell        <rbj@cmr>
     
  Here here!  Though (whenever possible) I try to run my code through lint,
I think I only use about a fifth of what lint complains (screams, shouts,
moans, groans) about.  And running my code through lint is not a happy
little chore that I do just before running my code and going to sleep at
night; it's a horrible little task (akin to turning homework into the
mean little ol' silver haired english teacher, knowing she's going to slash
my entire paper apart).
     
  But that fifth of information lint does cough up is extremely nice; sometimes
when you're tired and have about three million four byte structures bouncing
about in your code and it's four in the morning and the program must be
finished at nine; your girlfriend left you for your roommate and no
companies on the west coast is willing to offer you a summer job between
school years, it sure is nice to know that you accidently put an extra '*'
before one of your pointers (a silly typo, I know) which will blow up and
burn away the mainframe your working on.  (And when your roommate is the
sysman, WATCH OUT!)
     
  By the way, does anyone know if a public domain LINT exists?  Or an
inexpensive one for my little Macintosh here?  Unprotected memory sure is
a pain to find when you mess up the pointers.
         - William Woody
      NET  Woody%Romeo@Hamlet.Caltech.Edu
   USNAIL  1-54 Lloyd, Caltech / Pasadena, CA 91126
         - William Woody
      NET  Woody%Romeo@Hamlet.Caltech.Edu
   USNAIL  1-54 Lloyd, Caltech / Pasadena, CA 91126

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7970
          for JMS@ARIZMIS; Wed, 30-APR-1986 23:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/01/86 at 01:32:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023334; 30 Apr 86 21:49 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a012352; 30 Apr 86 21:10 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA14539; Wed, 30 Apr 86 11:03:53 edt
Date: Wed, 30 Apr 86 11:03:53 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8604301503.AA14539@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, warwick!kay@seismo.ARPA
Subject: Re: questions from using lint
     
> In article <7097@cca.UUCP> dewitt@cca.UUCP (Mark DeWitt) writes:
> >After three years of C programming I'm just starting to use lint, so
> >please no negative reinforcement by flaming about how stupid my questions
> >are, lest I give up on it entirely :-).
>
> Mark, I'm not flaming you, but I *am* worried!  If you've been programming
> in C for 3 years and not using lint then EITHER 1) Your system doesn't *have*
> lint.  You have my profound sympathy. OR 2) Nobody ever taught you about
> using lint.  I wonder why not? OR 3) You never realised that using lint
> was important.  You must have wasted many hours (that you could have spent
> playing Rogue or whatever :-)) chasing problems down that lint might well
> have indicated to you.
>
> People, what are *we* doing wrong when somebody can spend 3 years programming
> in a particular language and only then start using one of the most important
> development tools for it?
>
> It's got to the point when if I'm doing program surgery and someone comes up
> saying that their program "doesn't work", if they haven't brought a
> line-numbered listing of the source AND a lint output, I don't really want
> to start looking for the problems.
>                             Kay.
> --
> "I AM; YOU ARE; HELLO: all else is poetry"
>             ... mcvax!ukc!warwick!kay
     
You people fail to realize that some of us out here don't like lint.
It complains too much about what I do. I refuse to go any further
than generating no compiler warnings. I know what I'm doing. When I
goof, I'll fix it myself. I refuse to add extra casts to keep lint happy.
     
Before you start flaming my style, let me say I am quite good.
I am also quite philosophical and attentive to coding style.
My outlook is just different. I program for myself. If it is applicable
to you, fine. I have my own criteria which I rarely see embraced by
others waving standardization flags.
     
Most of the code I have written was intrinsically non-portable. I *do*
appreciate portability as a spectrum concept, but not as a binary one.
     
This is just me. I'm not sure I would recommend my methods to anyone
else, especially novices. My experience was obtained with more than a
few battle scars. There are probably easier ways.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "I'm alright, Jack, keep your hands off of my stack"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9435
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/01/86 at 23:47:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015005; 1 May 86 20:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004727; 1 May 86 19:49 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <854@ttrdc.UUCP>
Date: 29 Apr 86 23:50:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <140@toram.UUCP>, roe@toram.UUCP writes:
>In article <577@ur-helheim.UUCP> badri@ur-helheim.UUCP (Badri Lokanathan)
 writes:
>>My question is the following: is there any reason (other
>>than personal preferance) why one would prefer to use any particular form?
>>I personally prefer the while(1) form since it seems to make better reading.
>>Even better, I sometimes define TRUE to be 1 and then use while(TRUE).
>Unless you have a very unique optimizer, it is usually better to use the
>for(;;) form rather than the while(1) form.  Reason is:  while(1) is
>ALWAYS evaluated (ie. : is 1 TRUE? if so, continue) before each iteration,
>whereas for(;;) compiles as a simple branch or jump instruction with no
>test and no conditional branch.
>                Roe Peterson
     
What very unique optimizer?  Here's what I get (SysV 3B20, cc -S [note no -O]):
     
$ cat > while1.c
main()    /* while1.c */
{
    register int a=0;
    while (1) a++;
}
^D$ cc -S while1.c
$ cat while1.s
    .file    "while1.c"
    .data
    .text
    .align    4
    .def    main;    .val    main;    .scl    2;    .type    044;    .endef
    .globl    main
main:
    save    &.R1
    addw2    &.F1,%sp
    movw    &0,%r8
.L14:
    addw2    &1,%r8
    jmp    .L14
    ^^^^^^^^^^^^
.L13:
.L12:
    ret    &.R1
    .set    .R1,1
    .set    .F1,0
    .def    main;    .val    .;    .scl    -1;    .endef
    .data
$ cc -c while1.s
$ dis while1.o
        ****   DISASSEMBLER  ****
     
     
disassembly for while1.o
     
section    .text
main()
       0:  7a10                          save    &0x1,&0x0
       2:  346c 0000 0000 000b           addw2   &0x00000,%sp
       a:  1508                          movw    &0x0,%r8
       c:  1118                          addw2   &0x1,%r8
       e:  9002                          br      -0x2 <c>
                         ^^^^^^^^^^^^^^^^
      10:  7b10                          ret     &0x1
      12:  dede                          nop
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9478
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/01/86 at 23:55:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015036; 1 May 86 20:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004596; 1 May 86 19:44 EDT
From: Vicarious Oyster <oyster%uwmacc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Why we don't use lint
Message-ID: <2167@uwmacc.UUCP>
Date: 30 Apr 86 15:12:51 GMT
Followup-To: net.cse
To:       info-c@BRL-SMOKE.ARPA
     
In article <475@snow.warwick.UUCP> kay@warwick.UUCP (Kay Dekker) writes:
>In article <7097@cca.UUCP> dewitt@cca.UUCP (Mark DeWitt) writes:
>>After three years of C programming I'm just starting to use lint, so
>>please no negative reinforcement by flaming about how stupid my questions
>>are, lest I give up on it entirely :-).
>
>Mark, I'm not flaming you, but I *am* worried!  If you've been programming
>in C for 3 years and not using lint then EITHER 1) Your system doesn't *have*
>lint.  You have my profound sympathy. OR 2) Nobody ever taught you about
>using lint.  I wonder why not?
...
>People, what are *we* doing wrong when somebody can spend 3 years programming
>in a particular language and only then start using one of the most important
>development tools for it?
     
   Here's how getting a CS degree worked at the large state university
I attended (no names, and no peeking at the message header :-):
     
   Course #1:  "Oh, you're majoring in CS-- we'll teach you Simula."
   Course #2:  "OK, now we'll teach you assembly language, but we won't
   spend much time on it 'cause you already know how to program."
   Course #3:  "Well, I think it's about time you learn about data
   structures.  Frankly, I don't know *how* you managed so long without
   them <chuckle>!  Incidentally, Simula is passe, do your assignments in
   Pascal.  We'll spend 2-3 lectures teaching it to you."
   Course #4:  "OK, time to write an OS/compiler/database.  You'll be
   using C, the greatest language ever conceived.   There'll be a 30
   minute tutorial on C tomorrow night at 7:00."
   etc...
     
So by the time one graduates, having barely enough time to get the
languages straight, let alone finish assignments, is it any wonder that
most CS degree holders ] have never even heard of lint?
Of course, it may not be *quite* as bad as I made it seem, and it may
have gotten better in the last 5 years (but then again, I didn't mention
learning things like Modula and LISP, either).  Of course, the people
in the department will tell you, quite correctly, that universities do
not teach programming, they teach Computer Science.  However, I daresay
most computer scientists will be earning their livelihood by programming.
My opinion is that there should be *at least* a week-long workshop on
programming in the real world, but this is getting a bit far afield from
the C language, so I'll desist.  Also, follow-ups have been directed
somewhere else, just to keep the C readers happy.
     
     
 - Joel Plutchak
   uucp: {allegra,ihnp4,seismo}!uwvax!uwmacc!oyster
   ARPA: uwvax!uwmacc!oyster@rsch.wisc.edu
     
Can you say "opinion"?  I *knew* you could!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0627
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:06 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/02/86 at 01:50:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015115; 1 May 86 20:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004638; 1 May 86 19:45 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: arguments in registers
Message-ID: <776@bentley.UUCP>
Date: 30 Apr 86 15:44:33 GMT
Xref: brl-sem net.lang.c:842 net.unix-wizards:1011
To:       info-c@BRL-SMOKE.ARPA
     
In article <1205@umcp-cs.UUCP> umcp-cs!chris (Chris Torek) writes:
>Incidentally, I have not seen any optimising C compilers myself;
>are there any available that would [inline expand]?
     
Yes.  I once got "caught" trying to time a call to nullf().
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0507
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015057; 1 May 86 20:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005011; 1 May 86 20:00 EDT
From: herndon%umn-cs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <1700011@umn-cs.UUCP>
Date: 25 Apr 86 03:27:00 GMT
Nf-ID: #R:ur-helhe:-57700:umn-cs:1700011:000:120
Nf-From: umn-cs!herndon    Apr 24 21:27:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
  For the infinite loop, I like the sequence
     
#define ever ;;
     
...
     
   for(ever) {
        ...
   }
     
                Robert Herndon

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0421
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015046; 1 May 86 20:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004929; 1 May 86 19:58 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c++,net.lang.c
Subject: Re: System V preprocessor problem with <generic.h>
Message-ID: <779@bentley.UUCP>
Date: 30 Apr 86 19:50:41 GMT
Xref: brl-sem net.lang.c++:163 net.lang.c:846
To:       info-c@BRL-SMOKE.ARPA
     
In article <3597@sun.uucp> sun!guy (Guy Harris) writes:
>>     #define name2(a,b)    a/**/b
>It has, however, two problems:
>
>    1) If you run your code through "lint", it won't work
     
I tried this example with "cpp -C" and it worked fine.  I'd guess that
cpp strips all comments in preprocessor directives regardless of "-C".
     
>    2) It is not a guaranteed property of the C language, but a
>       quirk of the implementation, so it will not work in
>       general.
     
Agreed.  Any application that depends on being able to do this is treading
on thin ice.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0565
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015071; 1 May 86 20:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005060; 1 May 86 20:02 EDT
From: herndon%umn-cs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: oops, corrupted memory again!
Message-ID: <1700012@umn-cs.UUCP>
Date: 29 Apr 86 21:05:00 GMT
Nf-ID: #R:cbrma:-449500:umn-cs:1700012:000:614
Nf-From: umn-cs!herndon    Apr 29 16:05:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
  You didn't post your address!  A (partial) solution to the
problem of not freeing/allocated memory was published in
SIGPLAN Notices a few years back.  Look in the May 1982 issue
for "A Technique for Finding Storage Allocation Errors in
C-language Programs", by David R. Barach, David H. Taenzer,
and Robert E. Wells.
  The technique used in the article is fairly simple, and is
more oriented towards finding allocation errors.  Depending
on the severity of your errors, their technique might be
applicable.
     
                Robert Herndon
                ...!ihnp4!umn-cs!herndon
                herndon@umn-cs
                herndon.umn-cs@csnet-relay.ARPA

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0468
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015052; 1 May 86 20:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005007; 1 May 86 20:00 EDT
From: herndon%umn-cs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: C Builtin Funxions
Message-ID: <1700010@umn-cs.UUCP>
Date: 25 Apr 86 03:19:00 GMT
Nf-ID: #R:brl-smok:-252400:umn-cs:1700010:000:1259
Nf-From: umn-cs!herndon    Apr 24 21:19:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
  I feel compelled to go on record as being VERY MUCH AGAINST
having reserved procedure names in C.  For those of us who have
ever written stand-alone code for PDP-11s, VAXen, ..., it is
a simple matter, as things stand, to compile our programs,
and then have them linked with our own versions of 'putc',
'read', etc. stashed in stand-alone libraries.
  One of the (in my opinion) great strengths of the C language
is that it does not have 'built-in' functions.  As a result,
it has somehow managed to avoid the imbroglio that Pascal
has gotten into.  If one user doesn't like the interface that
'printf' provides, or a whole bunch of users don't, they
are free to write their own functions and use those instead.
In addition, porting the C compiler to a different OS on the
same machine only requires that the libraries be re-written
(almost always).  Building those functions into the language
implies that there will be much code for special casing those
functions.
  On the flip side, the language may not be as efficient.
If the compiler writers want to allow these procedures to
be built-in to allow in-line procedures, I think this should
be an option (DEFAULT=OFF), and then the capabilities of
the language will be compromised as little as possible.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0384
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/02/86 at 01:34:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015042; 1 May 86 20:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004925; 1 May 86 19:57 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <778@bentley.UUCP>
Date: 30 Apr 86 19:44:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <838@ihwpt.UUCP> ihwpt!knudsen writes:
>(1) Found out this weekend that you can't say:
>    boolvar ||= boolean_expression
     
An interesting expression.  The left side of the assignment would have to be
evaluated first, and if already set, do nothing.  I presume the reason this is
omitted is because it's normally written "if (v || e) v=1;" or "if (!v && e)
v=1;" rather than "v = v || e".
     
Btw, you can't have *all* operators extended with "=".  How would you write
"v = v < e;"?  (Not that it's useful.)
     
>(2) There isn't any ^^ (XOR) operator either, as in
>    if(divisor <0) ^^ (dividend <0)
>        quotient = -quotient;
     
There is, but it's spelled "!=".  (Presumably more efficient than "^", though
I think either one should work with a smart compiler.)
     
>(3) There is no boolean data type.  No big gripe;
>lots of us say "typedef short bool" in our .h files.
     
I'd assume either "char" (for space) or "int" (for time).  "short" probably
gives you the worst of both worlds.
     
However, a true boolean datatype would have a couple of advantages:
     
o  Multiple flag variables with local scope and no address operator (e.g.
   variables declared "register bool") could be packed into a single word.
     
o  "++x" and "--x" could be defined as "set" and "clear"; "x++" and "x--"
   would then be "test and (set|clear)".  This would obviate such things as
   "if (!flag) { flag=1; printmsg(); }".
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4281
          for JMS@ARIZMIS; Fri,  2-MAY-1986 09:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/02/86 at 09:19:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022045; 2 May 86 10:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005305; 2 May 86 9:42 EDT
From: Landon Noll <chongo%nsc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Third International Obfuscated C Code Contest Rules
Message-ID: <3529@nsc.UUCP>
Date: 30 Apr 86 14:03:29 GMT
Keywords: rules,1986,obfuscate,contest,oops
To:       info-c@BRL-SMOKE.ARPA
     
GOAL:  To write the most Obscure working C program following the rules below:
     
RULES:    1) The source must be 1024 bytes or less.  NO exceptions!
     
    2) Include in your letter:
        a) Name (or anonymous), Company/School, City, State and Country.
        b) Your path from a major network site, if applicable.
        c) A brief statement of what the program should do.
        d) The Machine(s)/Operating system(s) on which it runs.
        e) Enclose your source between the following lines:
        ---start of program---
        <place obfuscated source of 1024 bytes or less here>
        ---end of program---
     
    3) The entry should be written in common C. (K&R + common extensions)
     
    4) The program must be of original work.  All programs must be
       in the public domain.  All copyrighted programs will be rejected.
     
    5) Entries must be received between 31-Mar-86 and 30-May-86 0:00 GMT.
       Email your entries to:
     
                decwrl!nsc!obfuscate
     
       Entries sent by UUCP Email will be confirmed starting 1-May-86.
       People are encouraged to submit entries via Email, however one may
       mail entries the following address:
     
        International Obfuscated C Code Contest
        National Semiconductor
        Attn: Landon Noll      Mail Stop: 7c266
        1135 Kern Ave.
        Sunnyvale, CA 94086
        U.S.A.
     
AWARDS:    Winners of each category and the best of Show will be posted to
    net.announce as well as being published in the May 86 issue of the
    "Micro/Systems Journal".  Winners also get to receive international
    fame/flame for their efforts!
     
JUDGING: Awards will be given to the best entry in a number of categories.
     The actual category list will vary depending on the types of entries
     we receive.  At the moment, we are considering using the following:
     
        * The most obscure algorithm
        * The worst abuse of the C preprocessor
        * The strangest source layout
        * The best small one line program
        * The most useful program
        * <anything else we need to give recognition to a good entry>
     
    Judging will be done by myself, Larry Bassel and other local people
    who are willing to help out.
     
    We will attempt to run each of them on a Vax 785/4.2BSD system.
    Don't let the lack of such a system stop you!  Try to avoid operating
    system/machine specific code if you do not have such a system.
    Extra points will be given for programs which:
     
        a) pass lint without complaint
        b) do something quasi-interesting
        c) are portable
     
    A larger program size was selected to allow for a wider range of
    program ideas.  However if you don't need 1024 bytes don't use them.
    Given two programs with similar techniques and similar levels of
    obfuscation, we will tend to favor the more concise entry.
     
POLL:    We want to know what you think is the most poorly coded utility
    released with 4.xBSD and/or Sys V.  The top results plus the
    best flameage will be posted along with the contest results.
    To vote, please    follow the guidelines below:
     
    1) Include at the top of the letter:
        a) Name (or anonymous), Company/School, City, State and Country.
        b) Your path from a major network site, if applicable.
        c) the name of the poorly coded utility
        d) the name of the operating system on which it is found
        e) the line:    <<<FLAME ON>>>
        f)         up to 1024 bytes of flameage of the source
        g) the line:    <<<FLAME OFF>>>
     
    2) Confine your vote to the standard set of commands.  I.e., don't
       flame about local commands or user contributed software.
     
    3) Submit your votes via Email to:
     
           for 4.xBSD:  decwrl!nsc!bsd_util
           for Sys V:   decwrl!nsc!sysV_util
     
       or, you may send your votes by letter to the same address used by
       the contest.  Please place your votes on different sheets of paper.
     
chongo <C> /\cc/\

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8459
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:27 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/02/86 at 16:57:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002563; 2 May 86 16:59 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a017164; 2 May 86 16:48 EDT
Date:     Fri, 2 May 86 16:46:16 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       herndon%umn-cs.uucp@BRL.ARPA
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  C Builtin Funxions
     
X3J11 was not proposing to permit built-in functions in a
stand-alone conforming C implementation.  They would be
permitted in a hosted implementation, however.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8107
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:28 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 13:23:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004876; 3 May 86 14:13 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a026443; 3 May 86 14:02 EDT
Date:     Sat, 3 May 86 13:52:52 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Larry McVoy <larry%geowhiz.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  faster malloc anyone?
     
Your new() function doesn't appear to do anything that the SVR2
malloc() doesn't, except fail to properly align storage.  If the
malloc() function in your C library has dismal performance, then
fix it so that all programs can benefit.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7835
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:31 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 13:02:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004761; 3 May 86 13:57 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a025751; 3 May 86 13:20 EDT
Date:     Sat, 3 May 86 13:12:19 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Root Boy Jim <rbj@ICST-CMR.ARPA>
cc:       gwyn@BRL.ARPA, rbj@ICST-CMR.ARPA, info-c@BRL-SMOKE.ARPA,
          warwick!kay@seismo.ARPA
Subject:  Re:  questions from using lint
     
Failure to examine the value returned by a function is probably an error;
at the very least, a deliberate decision should be made to ignore it
(which is the PROPER use of the (void) cast).  This does not apply to
assignments.  "Lint" makes the proper distinction between these cases.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5872
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:44 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 09:47:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002615; 3 May 86 8:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022623; 3 May 86 8:02 EDT
From: Walter Bright <bright%dataiodataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  A simple non-portable expression tha
Message-ID: <972@dataioDataio.UUCP>
Date: 28 Apr 86 17:23:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2609@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>However, I tried this ( using 16-bit short ints for I1,I2 ) on our
>native vax compiler and on our 68K compiler. Both produced identical code
>for (L+I1)+I2 and L+(I1+I2) and L+I1+I2: specifically, ((long)I1+L)+(long)I2.
>I guess the a+b+c is recognized as a special case, and all three are widened
>to a common width regardless of the original associativityy
     
Shorts in C are always converted to ints before they are used. On the
vax and most 68k compilers, ints are the same as longs. Therefore, this
isn't any 'special case' recognized by the compiler.
     
Different code for (L+I1)+I2 and L+(I1+I2) will only be generated if
ints are smaller than longs.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6201
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003511; 3 May 86 10:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024259; 3 May 86 9:52 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++,net.arch
Subject: Re: oops, corrupted memory again!
Message-ID: <2393@watmath.UUCP>
Date: 1 May 86 15:53:40 GMT
Xref: seismo net.lang.c:8997 net.lang.c++:195 net.arch:3274
To:       info-c@BRL-SMOKE.ARPA
     
>    You're probably better off with a language that compiles checks into
> the code, and an option to turn off those checks once you're confident
> (?!) of the program.  With a capability-based architecture, you pay the
> price all the time, whether you want to or not.
     
Many years ago I worked with a language in which all arrays had to
have dimensions that were a power of two (like 4.2 malloc).  The
code which indexed into the array simply anded the index with the
appropriate bit mask.  This was very fast, yet it guaranteed that
any bad indexes wouldn't corrupt anything except the array being
addressed.  As a side-effect, one could use this feature to cycle
continuously through an array or could even use negative indexes
without any extra overhead.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6154
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003509; 3 May 86 10:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024252; 3 May 86 9:52 EDT
From: Eric Werme <werme%alliant.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Who are Tartan Labs?
Message-ID: <238@alliant.UUCP>
Date: 1 May 86 05:11:24 GMT
Keywords: C Reference Book
To:       info-c@BRL-SMOKE.ARPA
     
In article <1415@homxb.UUCP> gemini@homxb.UUCP (Rick Richardson) writes:
>I have seen bits and pieces of references to Tartan Labs.
>Could somebody tell me what their product line is, etc.
     
Apologies for not being super-specific,  but Tartan Labs is a spinoff
from Carnegie-Mellon University.  The people include several compiler
people who have much experience writing highly optimizing compilers
(they designed and imlplemented BLISS). One is a C for VAXes.
     
The reason I'm posting this is that they also produced a book entitled
"The C Reference Manual" that is a wonderful compilation of information
on C that any serious user or compiler writer should have next to K&R,
especially if they are interested in portable code.  The book covers
all sorts of weird cases that you just can't answer from K&R.  Available
in better bookstores on the East and West coasts.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0664
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/02/86 at 20:33:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002761; 2 May 86 17:54 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a018008; 2 May 86 17:49 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06467; Fri, 2 May 86 17:48:05 edt
Date: Fri, 2 May 86 17:48:05 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605022148.AA06467@icst-cmr.ARPA>
To: bentley!kwh@ICST-CMR.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re:  void *
     
> Actually, I don't think "void *" will start showing up in programs for
> a while after it becomes "standard".  Maybe someone will upgrade your
> compiler in the meantime?
>
> Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
Don't bet on it. There are a *lot* of people just dying for ANSI C to
hit the streets so they can sneer at people who don't have one :-)
Hey, with computers you gotta take whatever status symbols you can get.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"
     
                                      ~
P.S. I am in favor of ANSI C. Si si senor! See?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8200
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:50 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002293; 2 May 86 16:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015899; 2 May 86 16:04 EDT
From: Jan Steinman <jans%tekecs.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <7232@tekecs.UUCP>
Date: 29 Apr 86 17:25:10 GMT
Xref: brl-sem net.lang.c:858 net.lang.c++:167
To:       info-c@BRL-SMOKE.ARPA
     
In article <763@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>Now, if only somebody would invent an architecture where all objects,
>including dynamicly allocated objects, are isolated in memory, then any
>subscript error would cause an immediate memory fault.  You'd still be
>vulnerable to completely wild pointers (but less likely in a huge address
>space), and overflow of an array inside a structure might be untrappable,
>but otherwise it sounds like a great machine to do your debugging on.
>
Sounds suspiciously like the Smalltalk virtual machine to me!
     
:::::: Artificial   Intelligence   Machines   ---   Smalltalk   Project ::::::
:::::: Jan Steinman        Box 1000, MS 60-405    (w)503/685-2956 ::::::
:::::: tektronix!tekecs!jans    Wilsonville, OR 97070    (h)503/657-7703 ::::::
--
:::::: Artificial   Intelligence   Machines   ---   Smalltalk   Project ::::::
:::::: Jan Steinman        Box 1000, MS 60-405    (w)503/685-2956 ::::::
:::::: tektronix!tekecs!jans    Wilsonville, OR 97070    (h)503/657-7703 ::::::

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6844
          for JMS@ARIZMIS; Tue,  6-MAY-1986 12:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 11:10:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004151; 3 May 86 11:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025182; 3 May 86 11:41 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: structured assembler (BASIC)  [Really: C builtin functions?]
Message-ID: <1354@mmintl.UUCP>
Date: 30 Apr 86 23:19:36 GMT
Xref: seismo net.lang:2483 net.lang.c:8999
To:       info-c@BRL-SMOKE.ARPA
     
In article <5341@alice.uUCp> ark@alice.UUCP writes:
>The C definition of "function" is not the same as the mathematical
>definition.  A C function is a part of a program.  A mathematical
>function is a set of ordered pairs that meet certain conditions.
>
>That said, note that sizeof(i) is syntactically a constant.  This
>would not be true if sizeof were a function.
     
Good grief!  I am getting very tired of this.  You can think of sizeof as
a function if you want to, and you can think of it as not being a function
if you want to.  For some purposes (I haven't noticed any purpose in the
discussion so far) one is more useful; for others, the other is.
     
Now will everybody please SHUT UP about the subject?
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5916
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:02 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002732; 3 May 86 8:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023141; 3 May 86 8:21 EDT
From: "Don E. Davis" <ded%aplvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <219@aplvax.UUCP>
Date: 2 May 86 16:22:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>You people fail to realize that some of us out here don't like lint.
>It complains too much about what I do. I refuse to go any further
>than generating no compiler warnings. I know what I'm doing. When I
>goof, I'll fix it myself. I refuse to add extra casts to keep lint happy.
>
>    (Root Boy) Jim Cottrell        <rbj@cmr>
     
(Root Boy) is not alone, though with a name like that he should be. ;-)
I know several excellent programmers who never use lint.  Personally,
I use lint some, but it is not my religion.  I do think
programmers should be familiar with lint but I don't think we
should run screaming into the sea because someone never heard of it.
     
If they haven't heard of hack, now -- that's a different story!
     
     
     
--
     
                    Don Davis
                    JHU/APL
                ...decvax!harpo!seismo!umcp-cs!aplcen!aplvax!ded
                ...rlgvax!cvl!umcp-cs!aplcen!aplvax!ded

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8056
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 13:21:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004766; 3 May 86 13:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026090; 3 May 86 13:46 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Array of pointers to functions
Message-ID: <717@steinmetz.UUCP>
Date: 1 May 86 21:04:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Another way to build unusual declarations is by repeated typedefs. The
previous posting gave as an example "array of pointers to function
returning integer", which is "int (*foo[])()".
     
To build this up:
typedef int fri();        /* function returning int */
typedef fri *pfri;        /* prointer to function ret. int */
typedef pfri apfri[20];        /* array (size 20) of ... */
     
Then:
apfri foo; /* declares the array */
--
    -bill davidsen
     
    seismo!rochester!steinmetz!--\
       /                               \
ihnp4!              unirot ------------->---> crdos1!davidsen
       \                               /
        chinet! ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4638
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 07:20:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002494; 3 May 86 8:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022218; 3 May 86 7:47 EDT
From: Steve Weil <weil%dataiodataio.uucp@BRL.ARPA>
Newsgroups: net.unix-wizards,net.lang.c
Subject: Need help with symbol table and relocation info in .o files
Message-ID: <978@dataioDataio.UUCP>
Date: 29 Apr 86 20:35:24 GMT
Xref: seismo net.unix-wizards:18022 net.lang.c:8984
To:       info-c@BRL-SMOKE.ARPA
     
This is a sticky one.  I am working on a large program with several
sections supported by different people.  It is too large to debug using
DBX or CDB when the whole program is compiled with the -g option.  I am
trying to write a utility which will take a partial link (a .o file
which is the result of ld -r) and will strip off the symbols which are
there solely for the debugger, but which will leave the symbols needed
for the final link.  (This is to avoid recompiling everything without
the -g flag.)
     
I have written a program which will do this successfully for a plain .o
file (from cc -c), but it does not work on partial links.  When I load
I get errors like "local symbol botch", or just core dumps.
     
Apparently, there is some relocation information associated with some
of the symbols I am removing.  The manual pages and include files do
not give me enough detail to understand what I need to do.  Can anyone
tell me a basic algorithm for keeping the relocation data consistent as
I remove symbols?  Specifically, does the r_address field in the
relocation data correspond to the n_value field in the nlist
structure?
     
Any help of any sort would be greatly appreciated.
     
Steve Weil
entropy!dataio!weil

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6061
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:07 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003501; 3 May 86 10:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023979; 3 May 86 9:43 EDT
From: Ben Cranston <zben%umd5.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <942@umd5.UUCP>
Date: 2 May 86 23:38:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <219@aplvax.UUCP> ded@aplvax.UUCP (Don E. Davis) writes:
     
>In article <*> Root Boy Jim writes:
>>You people fail to realize that some of us out here don't like lint.
>>It complains too much about what I do. ...
     
>I know several excellent programmers who never use lint.  ...
     
Hmm, I remember a certain Cobol compiler that had an 'E' option to generate
error messages - because it generated such a quantity of informational
diagnostics but its users wanted "clean compiles".  I can see Cobol types
complaining about this, but US?
     
I'll be perfectly happy when I can understand what lint is saying to me,
and convince myself that it is just being paranoid.
     
Dare I suggest this: a filter for lint output that only lets the real bad
errors through?  Dare I suggest THIS: that it would be easier if every line
from lint had an identification tag like this:
     
BCD325I: Bad C construct at line 2543342
     
(No, No, anything but EBCDIC!)
     
--
"We're taught to cherish what we have   |          Ben Cranston
 by what we have no longer..."          |          zben@umd2.umd.edu
                          ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4604
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:10 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 07:18:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002483; 3 May 86 8:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021942; 3 May 86 7:40 EDT
From: Richard Harter <g-rh%cca.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <7595@cca.UUCP>
Date: 30 Apr 86 06:54:20 GMT
Keywords: Paranoia, malloc
Xref: brl-sem net.lang.c:865 net.lang.c++:168
To:       info-c@BRL-SMOKE.ARPA
     
In article <> faustus@cad.UUCP (Wayne A. Christopher) writes:
>In article <4495@cbrma.UUCP>, trl@cbrma.UUCP (Tom Lanning) writes:
>
>>     Are there any "malloc" routines that check for modification of
>> malloc's link pointers by the "user's" code?   Close to 70% of by bugs
>> are stack/memory problems were I use more space than I allocated.
>
>You could compile the 4.3 malloc() with the -DRCHECK flag, which checks
>that you haven't modified the areas beyond your segment when you free it.
>Also, if you're REALLY paranoid, write your own malloc that puts lots of
>padding around the allocated areas and checks that none of the padding
>areas has been changed every time you call malloc() or free().
>
    We wrote our own, partly out of paranoia an partly out of a
probably misguided belief that we could write a more efficient allocator.
The main thing that we did was to put all pointers and links in an entirely
separate area from the space being allocated.  This wins in that pointers
never get overwritten -- it loses in that the program does not crash
immediately on range errors.  We added a one word pad on each end for
overwrite testing (can be turned off) and legitimacy tests on all returns
of space.   We also put in a option to store where requests were coming
from.  (Hasn't been used in years.)  The upshot is that space request/free
problems are rare and easily found.  However this doesn't avoid the problem
of incorrectly dimensioned arrays which are handled by the system and can
lead to very peculiar bugs.
     
        Richard Harter, SMDS Inc.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6108
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003507; 3 May 86 10:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024139; 3 May 86 9:48 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Lint
Message-ID: <2376@watmath.UUCP>
Date: 30 Apr 86 13:33:53 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> /* VARARGS */ and /*VARARGS0*/ both cause the first arg to be type-checked.
> Another 'bug' is that /* VARARGS */ is used for all varargs functions in
> llib-lc, where VARARGS1 should be used for printf, VARARGS2 for sprintf and
> fprintf, etc. grumble, grumble.
     
/*VARARGS*/ causes all the parameters in the function definition to be
type-checked.  This is nearly always what you want.  The dummy definition
for printf and fprintf in the lintlibrary file is something like:
    /*VARARGS*/ printf(fmt) char*fmt; {return 0;}
    /*VARARGS*/ fprintf(stream,fmt) FILE*stream; char*fmt; {return 0;}
This causes LINT to compare the types of ALL the parameters with the
supplied arguments.  i.e. printf's first argument must be char*, and
it can take any type of arguments after that.
     
That /*VARARGS0*/ is treated the same as /*VARARGS*/ is in fact a bug
in LINT (if there is a number, it is stored as its negative value in
the 4.2 implementation, so -0 looks just like 0 which means that there
wasn't any number given).
     
One would almost never define a function with three parameters and
tell lint to check only the type of the first one or two.  There seems
to be little point to ever doing such a thing.  Unfortunately that is
what LINT takes the # in /*VARARGS#*/ to mean.  A much more useful
meaning to the # would be to define the minimum number of arguments
that the caller must supply.  e.g.
    /*VARARGS1*/ func(n,a,b,c){return 0;}
would check the types of all four parameters (if arguments were passed
for them) and would complain if there wasn't at least one argument in
the call.  But as I said, this is NOT what LINT does.  In fact one can
call fprintf() with no arguments and get not a peep from LINT, regardless
of whether fprintf() is defined with /*VARARGS*/ or /*VARARGS2*/
     
Anyway, I believe that under X3J11's version, there won't be any need
for such a lint directive.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8309
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 13:47:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004900; 3 May 86 14:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026097; 3 May 86 13:46 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structured assembler (BASIC)  [R
Message-ID: <718@steinmetz.UUCP>
Date: 1 May 86 21:20:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1700007@umn-cs.UUCP> herndon@umn-cs.UUCP writes:
>
>  I disagree.  Sizeof is definitely NOT a function.  It is a builtin
>of the C language, but it is not and could not be written as a function
>(well...), just as return is definitely not a function.
     
Actually sizeof is a unary operator. It applies to the following object, when
object is defined as:
    a variable name
    a variable type (including all struct and pointer types)
    the object of indirection of a pointer type
     
Examples:
  int ka, kb[10], *kc;
  struct foo sa, *sb;
     
All the same (part 1):
  sizeof int
  sizeof (int)
  sizeof ka
  sizeof (ka)
  sizeof *kc
  sizeof (*kc)
(however, sizeof kb == 10*sizeof int)
     
All the same (part 2):
  sizeof struct foo
  sizeof (struct foo)
  sizeof sa
  sizeof (sa)
  sizeof *sb
  sizeof (*sb)
--
    -bill davidsen
     
    seismo!rochester!steinmetz!--\
       /                               \
ihnp4!              unirot ------------->---> crdos1!davidsen
       \                               /
        chinet! ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8268
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 13:46:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004898; 3 May 86 14:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026044; 3 May 86 13:44 EDT
From: "M.J.Shannon" <mjs%sfsup.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Funxions
Message-ID: <239@sfsup.UUCP>
Date: 1 May 86 11:32:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1700010@umn-cs.UUCP> herndon@umn-cs.UUCP writes:
>
>  I feel compelled to go on record as being VERY MUCH AGAINST
>having reserved procedure names in C.  For those of us who have
>ever written stand-alone code for PDP-11s, VAXen, ..., it is
>a simple matter, as things stand, to compile our programs,
>and then have them linked with our own versions of 'putc',
>'read', etc. stashed in stand-alone libraries.
> ...
>In addition, porting the C compiler to a different OS on the
>same machine only requires that the libraries be re-written
>(almost always).  Building those functions into the language
>implies that there will be much code for special casing those
>functions.
     
Nowhere is it required that the compiler have any special knowledge of the
reserved names in the library.  Yes, *some* compilers will undoubtedly have
*some* special knowledge of *some* of those names, but the ANSI spec does
*NOT* *require* the compiler to know anything about any reserved library
names.
     
Please, do NOT flame about statements that are not made in the spec.
There are enough statements that ARE made in the spec that may be worth
flaming about (although I hope that rational discusssion, rather than
flames, result).  If you don't have a copy of the current state of the
proposed standard, GET ONE!  I'm sure that any number of members of the
committee (many of whom read this newsgroup) can either provide the
proper procedure for obtaining it, and possibly an official copy.  (I
don't have this information, so please don't reply to me for it.  Perhaps
Larry Rosler can repost the appropriate information.)
     
    Marty Shannon
UUCP:    ihnp4!attunix!mjs
Phone:    +1 (201) 522 6063
     
Disclaimer: I speak for no one.
     
"If I never loved, I never would have cried." -- Simon & Garfunkel
--
    Marty Shannon
UUCP:    ihnp4!attunix!mjs
Phone:    +1 (201) 522 6063
     
Disclaimer: I speak for no one.
     
"If I never loved, I never would have cried." -- Simon & Garfunkel

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7928
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/02/86 at 16:04:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025536; 2 May 86 12:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008701; 2 May 86 11:51 EDT
From: John Owens <jso%edison.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: goto jumps into loops
Message-ID: <712@edison.UUCP>
Date: 29 Apr 86 19:54:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In respose to the program by
>     Dave Harmon
>     dmh@mit-borax.arpa
>     dmh@borax.lcs.mit.edu
where he asks for a way to avoid a goto in his loop (translated from Pascal).
     
     
How about something like.....
     
     
#include <stdio.h>
#include "/usr/dmh/nastydefs"
#define MAX NUM_KEYWORDS   /*The highest element in use by the application*/
     
wrtlist (listp)
set *listp;
{
  unsigned char i;
  set list;
     
  list = *listp;
  for (i=0; i <= MAX; i++) {
    if (in(i,&list)) {
    unsigned char save_i;
    printf(" %d",i);
    save_i = i;
    while (++i <= MAX && in(i,&list))
        ;
    if (i > save_i + 1)
        printf("-%d",i-1);
    /* doesn't matter that we'll i++ here, since we know !in(i,&list) */
    }
  }
  printf("\n");
  return(0);
}
     
     
[No guarantees, but you get the idea.]
     
               John Owens
        edison!jso%virginia@CSNet-Relay.ARPA
General Electric Company        Phone:    (804) 978-5726
Factory Automation Products Division    Compuserve: 76317,2354
           houxm!burl!icase!uvacs
...!{           decvax!mcnc!ncsu!uvacs    }!edison!jso
         gatech!allegra!uvacs

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8970
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:22 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/06/86 at 14:36:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008994; 4 May 86 11:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002792; 4 May 86 11:42 EDT
From: Dan Gold <ccrdan%ucdavis.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Who are Tartan Labs?
Message-ID: <312@ucdavis.UUCP>
Date: 4 May 86 01:32:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <1415@homxb.UUCP> gemini@homxb.UUCP (Rick Richardson) writes:
> >I have seen bits and pieces of references to Tartan Labs.
> >Could somebody tell me what their product line is, etc.
>
> Apologies for not being super-specific,  but Tartan Labs is a spinoff
> from Carnegie-Mellon University.  The people include several compiler
> people who have much experience writing highly optimizing compilers
> (they designed and imlplemented BLISS). One is a C for VAXes.
>
> The reason I'm posting this is that they also produced a book entitled
> "The C Reference Manual" that is a wonderful compilation of information
> on C that any serious user or compiler writer should have next to K&R,
> especially if they are interested in portable code.  The book covers
> all sorts of weird cases that you just can't answer from K&R.  Available
> in better bookstores on the East and West coasts.
     
Slight correction and more specifics on the book:
Title:        C: A REFERENCE MANUAL
Authors:    Samuel P. Harbison/Guy L. Steele Jr.
        of Tartan Laboratories
Publisher:    Prentice-Hall (Software Series)
Cost:        ~$20.00
     
The book offers a lot of useful information on the standard features of most
C compiliers and points out potential pitfalls and improvements for
portability.
     
Dan Gold
University of California, Davis
     
UUCP: ...{ucbvax,lll-crg,lll-lcc,sdcsvax,dual}!ucdavis!minnie!ccrdan
ARPA: ...ucdavis!minnie!ccrdan@ucbvax.BERKELEY.EDU

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8602
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/02/86 at 17:07:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002720; 2 May 86 17:32 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a017667; 2 May 86 17:27 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06405; Fri, 2 May 86 17:26:28 edt
Date: Fri, 2 May 86 17:26:28 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605022126.AA06405@icst-cmr.ARPA>
To: gwyn@BRL.ARPA, rbj@ICST-CMR.ARPA
Subject: Re:  questions from using lint
Cc: info-c@BRL-SMOKE.ARPA, warwick!kay@seismo.ARPA
     
    Re: "lint" not being as smart as Root Boy Jim
     
Gee, I hope not. After it's *only* a *program* (and I'm not? :-)
     
    That's really silly.  I write C code such that I expect absolutely
    NO warnings from "lint" (except for malloc pointer type-cast, which
    is unavoidable at present); then if I get any "lint" warnings, they
    indicate BUGS that must be fixed.  This is tremendously helpful.
     
Not really. I will give you one good example of a technique that is NOT a
bug, altho it may make you shudder somewhat. I have ranted about C using
a one statement model for its control statements instead of an explicit
end statement. Compound statements are bounded by braces instead. Yuk!
Fortunately, there is the comma operator. This allows the following:
     
    Most People            Your's Truly
     
    if (c) {            if (c)
        w = y;                w = x,
        y = z;                y = z;
    }                /* look ma, no brace */
     
Other things you will see in my code are:
     
    if (argc < 2)
        exit((printf("usage: foo bar\n"),1));
or even:    exit(1,printf("usage: foo bar\n"));
     
Sufficeth to say that I use a lot of commas in my code. Unfortunately,
I cannot do this if either statement is a control struxure, *except* return.
     
    Most People            Your's Truly
     
    if (c) {            if (c)
        w = y;                return w = x,
        return;
    }                /* look ma, no brace */
     
When I want to return a *real* value, I use `return(exp)' using *explicit*
parens. I only do this in void funxions of course. I cannot see *any*
implementation doing either of the following:
     
    1) barfing because I returned an *extra* value sometimes
    2) barfing because I added an extra argument
     
Now you may claim that this is `bad programming practice', but I claim
that it is just a convention, just like #defines are usually capitalized.
You may not like either one, but I claim this is portable. And, it is
meaningful to me.
     
    I find that there are very few "inherently nonportable" applications.
    Even when an application is designed to use specific hardware,
    portable programming techniques contribute to better code quality.
     
This is probably true. He who lives by the trick usually dies by it.
On the other hand, I just tried to port the System V date to BSD, and
it mumbled somthing about timezones not being defined. My point is
that even the simplest things usually require *some* diddling.
     
    Lint-free coding comes naturally after a bit of practice.  I find
    it no burden at all, and hardly have to think about it.  Indeed,
    it helps organize my use of complicated data types so that I get
    the code right (and portable!) the first time.
     
Yes, but it all depends on what you're willing to put up with. I find it
terribly ugly having to cast printf's or close's to void. And as
someone pointed out, assignments return a value too, so should we cast
them to void as well? Oh yeah, assignment is `different'.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8251
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002296; 2 May 86 16:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016232; 2 May 86 16:11 EDT
From: Chuck Forsberg WA7KGX <caf%omen.uucp@BRL.ARPA>
Newsgroups: net.micro,net.micro.pc,net.lang.c,net.unix-wizards
Subject: Re: Help with C-kermit on SCO Xenix V
Message-ID: <329@omen.UUCP>
Date: 30 Apr 86 11:52:42 GMT
Keywords: It isn't working
Xref: brl-sem net.micro:619 net.micro.pc:950 net.lang.c:859
  net.unix-wizards:1036
To:       info-c@BRL-SMOKE.ARPA
     
In article <294@catnip.UUCP> ben@catnip.UUCP (Bennett Broder) writes:
>I recent obtained a copy of C-kermit 4.2(030) PRERELEASE #2, 5 March 85.
>We have been using this version at work on a Perkin Elmer 3250XP and an
>AT&T 3B5, and so I wasn't expecting any problem bringing it up on Xenix.
>Well the package compiles without error, and appears to work okay, until
>you attempt to do a transfer.  Then it can't even seem to get past the
>header packet, and keeps printing SS%S%S%S%S% and the like on the screen.
>Looking at the debugging output from both ends show that the Xenix machine
>is computing the checksum incorrectly.  Please, can anyone help???
>
The Microsoft C compiler has a few problems with right shifts such as used
in the Kermit CRC calculations.  Here is something that should work better.
(From Professional-YAM, the most powerful COMM program for the PC)
     
     
/*  C H K 1  --  Compute a type-1 Kermit 6-bit checksum.  */
     
chk1(pkt)
char *pkt;
{
    register chk;
     
    chk = chk2(pkt);
    return((((chk & 0300) >> 6) + chk) & 077);
}
     
     
/*  C H K 2  --  Compute the numeric sum of all the bytes in the packet.  */
     
chk2(pkt)
register char *pkt;
{
    register chk;
     
    for (chk = 0; *pkt; ++pkt)
        chk += (kparity ? (*pkt & 0177) : (*pkt & 0377));
    return chk;
}
     
     
/*  C H K 3  --  Compute a type-3 Kermit block check.
 *
 * Calculate the 16-bit CRC of a null-terminated string using a byte-oriented
 * tableless algorithm invented by Andy Lowry (Columbia University).  The
 * magic number 010201 is derived from the CRC-CCITT polynomial x^16+x^12+x^5+1.
 * Note - this function could be adapted for strings containing imbedded 0's
 * by including a length argument.
*/
chk3(s)
char *s;
{
    register unsigned int c, q;
    LONG crc = 0;
     
    while ((c = *s++) != '\0')
    {
        if (kparity)
            c &= 0177;
        else
            c &= 0377;
        q = (crc ^ c) & 017;        /* Low-order nibble */
        crc = (crc >> 4) ^ (q * 010201);
        q = (crc ^ (c >> 4)) & 017;    /* High order nibble */
        crc = (crc >> 4) ^ (q * 010201);
    }
    return(crc);
}
     
   Chuck Forsberg WA7KGX  ...!tektronix!reed!omen!caf   CIS:70715,131
   Author of Professional-YAM communications Tools for PCDOS and Unix
 Omen Technology Inc     17505-V NW Sauvie Island Road Portland OR 97231
Voice: 503-621-3406 TeleGodzilla: 621-3746 300/1200 L.sys entry for omen:
omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
omen!/usr/spool/uucppublic/FILES lists all uucp-able files, updated hourly

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6294
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 10:12:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003600; 3 May 86 10:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024468; 3 May 86 10:00 EDT
From: Larry McVoy <larry%geowhiz.uucp@BRL.ARPA>
Newsgroups: net.unix,net.unix-wizards,net.lang.c
Subject: faster malloc anyone?
Message-ID: <433@geowhiz.UUCP>
Date: 2 May 86 22:54:25 GMT
Xref: seismo net.unix:8148 net.unix-wizards:18032 net.lang.c:8998
To:       info-c@BRL-SMOKE.ARPA
     
[ munch.  Does this bug still exist???? ]
     
I was looking at the src for [cm]alloc() and came to the (hasty) conclusion
that they take to long for little memory requests.  It seems that they are
leftover from the days of 256K unix systems where every byte counted.  With
workstations typically having gigabytes of vm and 2-4 megs of phys mem, it
seems that we might sacrifice some memory for speed.  In particular, if you
want to save strings (5-80 bytes), it seems wasteful to do a lot of work for
each call to strsav().  So, I wrote the following little chunks of code and
am requesting comments.  Can anyone point out why these are a *bad* idea
(aside from the obvious upper bound problem)?  Another problem is that
free() won't work on these blocks...
     
new.h:
# define    BLKSIZ        8096
char* new();
     
utils.c:
/* utils.c -- strsav(), new() */
# include    "new.h"
     
    char*
strsav(s)
    register char* s;
{
    char* strcpy();
    register char* t;
     
    t = new(strlen(s) + 1);    /* strings smaller than BLKSIZ */
    return strcpy(t, s);
}
     
     
/*------------------------------------------------------------------02/May/86-*
 * new(size) - fast(??) memory allocator
 *
 * Inputs    -> (int)
 *
 * Returns   -> (char*)
 *
 * Results   -> The memory is allocated in big contiguous blocks via calloc(3).
 *        If the requst can fit in what's left of a block, then a block
 *        of the size requested is returned.  Otherwise, the rest of the
 *        block is discarded & a new block is allocated.
 *
 * Warning   -> This would seem to work great for little stuff.  Don't use it
 *        for big blocks.  Absolute largest allocatable block is BLKSIZ.
 *        For speed NO CHECK IS PERFORMED TO SEE IF THE REQUEST IS LESS
 *        THAN BLKSIZ.  BLKSIZ is guaranteed to be 1k or bigger (usually
 *        much bigger).
 * Revisions:
 *----------------------------------------------------------------------larry-*/
    char*
new(size)
    register unsigned size;
{
    register char* blk;
    static char* block = NULL;
    static unsigned bytes_left = 0;
     
    if (bytes_left < size)
    if (!(block = calloc(1, BLKSIZ)))
        syserr("calloc in new");
     
    blk = block;
    block += size;
    bytes -= size;
}
--
Larry McVoy
-----------
Arpa:  mcvoy@rsch.wisc.edu
Uucp:  {seismo, ihnp4}!uwvax!geowhiz!geophiz!larry
     
"Just remember, wherever you go -- there you are."
     -Buckaroo Banzai

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0281
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:31 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/05/86 at 17:37:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005335; 3 May 86 15:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027184; 3 May 86 15:41 EDT
From: "J. Eric Roskos" <jer%peora.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++,net.arch
Subject: Re: oops, corrupted memory again!
Message-ID: <2129@peora.UUCP>
Date: 2 May 86 13:09:37 GMT
Xref: seismo net.lang.c:9008 net.lang.c++:196 net.arch:3278
To:       info-c@BRL-SMOKE.ARPA
     
> >Now, if only somebody would invent an architecture where all objects,
> >including dynamicly allocated objects, are isolated in memory, then any
> >subscript error would cause an immediate memory fault.
>
>    If I'm not mistaken, this was done on the iAPX432, using a capability-
> based addressing scheme.  Dimmed the lights.  You could probably construct
> such an environment on the 80286, but no one does, probably for efficiency
> reasons.
     
One problem with the 432's approach was that it was very extreme; I don't
think it's good to say "the 432 tried these approaches and it was too slow,
therefore the checking can't be efficiently implemented."
     
I posted some comments in here (net.arch) about a week ago on apparently
the same subject, but nobody replied in net.arch to it (although I got a
couple of replies by mail).  Of the people who replied by mail, one (whose
technical knowledge I have a high opinion of) pointed out that C compilers
exist where subscript/pointer checking is done in software, and that thus
it would seem likely that similar checking could be done in hardware.
     
The way you could do it (which was a point the 2 people replying seemed to
agree upon) was that, associated with all pointers, you should have a
"minimum address" and "maximum address" for the object being pointed to.
Bear in mind that in C array names are just constant pointers, so
constructs like a[i] can use this method as well as plain pointer
references such as *p.  If p is a pointer of type t, then to use p you
will have to first assign it a value by referencing an existing object, or
by creating a new one:
     
    typedef <whatever> t;
    t  a[100];
    t  *p;
     
    p = a;                  (1)
    p = &a[40];             (2)
    p = (t *)malloc(300);   (3)
     
In case 1 and 2, you can easily set p.base to &a[0], and p.bound to
&a[99], and set p.pointer to &a for (1) and to &a[40].  So p then carries
around with it the range of valid addresses it can point to.  (Note that
nothing says anything about what a pointer in C has to look like, so
p can easily be a 3-word struct-like object, and if you were building a
new machine to support such things, you could make the machine have
3-word address registers).
     
In case 3, you could have malloc set the base and bound -- though if
malloc is written in C then you'd have to provide some way to reference
the base and bound fields from within the language -- so things like
malloc would also work.  I had originally thought that some
counterexamples existed, but one of the respondants (John Gilmore) pointed
out that really the counterexamples involved essentially semantically
inconsistent uses of the pointers (e.g., having 2 pointers around and
changing the bounds on 1 of them).
     
In any case, if you change p, e.g. p++, then you'd change what I called
p.pointer above, and leave p.base and p.bound alone.  If you generated an
effective address which was outside [p.base .. p.bound], then you'd
generate an addressing fault.
     
I don't think this checking would be that slow, although on a machine with
a narrow bus (especially those like the 8088 where you are already
fetching pointers through multiple bus cycles) fetching the range
attributes of the pointer would increase the bus time by a factor of 3.
It would also reduce the number of register variables you could have, if
you kept the bounds in registers also -- I think it would work best if you
had a machine that had registers set aside specifically for pointer
checking.  On a machine such as the 3280*, which does quadword reads from
memory because the data bus is very wide, the bus overhead would be much
less.  So the checking by this method would probably not be that bad
(certainly not as bad as the 432, which I believe had to sometimes fetch
several descriptor objects in order to validate references) at least on
larger machines (and after all, microprocessors are getting larger all the
time in terms of width of the bus, etc.).
     
-----
*I cite this machine because I'm more familiar with it; I suspect probably
 other machines like Vaxes have similarly wide buses.
--
E. Roskos

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5984
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:32 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002737; 3 May 86 8:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023255; 3 May 86 8:24 EDT
From: Rex Ballard <rb%ccird1.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Stack vs register args. Re: varargs
Message-ID: <395@ccird1.UUCP>
Date: 2 May 86 18:09:01 GMT
Xref: seismo net.lang.c:8991 net.unix-wizards:18027
To:       info-c@BRL-SMOKE.ARPA
     
In article <129@drilex.UUCP> dricej@drilex.UUCP (Craig Jackson) writes:
>
>Microcomputers pass things in registers, rather than on the stack, because
>stack operations are slow relative to register operations.  This is also
>typical of assembly language programming, rather than C language programming.
>Not everybody is willing to pay the high-level language penalty.
     
The reason I asked why people use registers rather than a vector (usually
the stack) to pass arguments to the O.S. is because the typical High Level
language interface "glue" is at least as costly as the low level version.
     
Assuming that the typical "C call" is:
    push arg 1
    push arg 2
       .
       .
    call <routine>;
    drop args  ; add constant to sp
     
For example,
     
    fd=open(fname,mode);
calls
open(fname,mode)    /* just added the overhead of a frame call */
{
    fd=sys(OPEN,fname,mode);
    return(fd);
}
     
which calls the assembler routine
     
sys:    ; figure out how many arguments should be put into registers
    ; logic to do this (usually a case statement in assembler)
    ; has been deleted
sysopn:
    mov 1(sp),r1
    mov 2(sp),r2
    mov 3(sp),r3
        .
        .
        .
    trap
    ;result is in r0
     
the alternative would be
    fd=open(fname,mode);
calls
     
open(fname,mode);
{
    fd=sys(OPEN,&fname);
}
calls assembler routine -
sys:
    trap SYS ;arguments are already on the stack
        ;second argument is the vector pointing to the "real arguments"
    ;result is in r0.
     
even more direct
    fd=open(fname,mode)
calls assembler routine -
open:    ; just saved one level of "framing overhead"
    trap OPEN    ; works exactly like this if there are enough
            ; trap vectors, otherwise would be a push/call macro
    ;result is in r0.
    ret
     
in assembler, since fname and mode are usually constants somewhere,
the "vector" could actually be static memory space.
     
fname:        db    "file.name"
mode:        dw    2
     
openargs:    dw    fname
        dw    mode
     
The assembler routine could call "open" as follows.
     
        mov    openargs,r0
        push    r0
        trap    OPEN
     
One of the side benefits is that you have registers available to
traverse the various transforms without corrupting the "frame".

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6941
          for JMS@ARIZMIS; Tue,  6-MAY-1986 13:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/03/86 at 11:25:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004175; 3 May 86 11:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025227; 3 May 86 11:42 EDT
From: Jim Williams <jim%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: A good use of a bad feature
Message-ID: <1298@umcp-cs.UUCP>
Date: 3 May 86 04:26:28 GMT
Keywords: case statement, tacky programs
To:       info-c@BRL-SMOKE.ARPA
     
While discussing various features and miss-features of C
with my friend Charley (mangoe) Wingate recently, we both
agreed that the fall through case statement is among the least
defensible of C's features.  I submit the program below as the
best use I have ever found for this feature.
     
--------------- CUT HERE ------------
/*
 * xmas.c - a program to print The Twelve Days of Christmas
 * using the C fall thru case statement.
 * If this wasn't my idea, I appologize to whomever I
 * got the idea from, but I wrote the program 5 years
 * ago and I don't remember now.
 *
 * Jim Williams, jim@maryland, 2 May 1986
 */
     
/*
 * If you have an ANSI compatible terminal then
 * #define ANSITTY.  It makes the five Golden rings
 * especially tacky.
 */
     
#define ANSITTY
     
#include <stdio.h>
     
char *day_name[] = {
    "",
    "first",
    "second",
    "third",
    "fourth",
    "fifth",
    "sixth",
    "seventh",
    "eighth",
    "ninth",
    "tenth",
    "eleventh",
    "twelfth"
    };
     
     
main()
{
    int day;
     
    printf("The Twelve Days of Christmas.\n\n");
     
    for (day=1; day<=12; day++) {
        printf("On the %s day of Christmas, my true love gave to me\n",
            day_name[day]);
     
        switch (day) {
        case 12:
            printf("\tTwelve drummers drumming,\n");
        case 11:
            printf("\tEleven lords a leaping,\n");
        case 10:
            printf("\tTen ladies dancing,\n");
        case 9:
            printf("\tNine pipers piping,\n");
        case 8:
            printf("\tEight maids a milking,\n");
        case 7:
            printf("\tSeven swans a swimming,\n");
        case 6:
            printf("\tSix geese a laying,\n");
        case 5:
#ifdef ANSITTY
            printf("\tFive [1;5;7mGolden[0m rings,\n");
#else
            printf("\tFive Golden rings,\n");
#endif
        case 4:
            printf("\tFour calling birds,\n");
        case 3:
            printf("\tThree French hens,\n");
        case 2:
            printf("\tTwo turtle doves, and\n");
        case 1:
            printf("\tA partridge in a pear tree.\n\n");
        }
    }
}
--
Jim \/\/illiams
jim@mimsy.umd.edu
umcp-cs!jim.UUCP

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2168
          for JMS@ARIZMIS; Tue,  6-MAY-1986 18:22 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009080; 4 May 86 12:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002810; 4 May 86 11:43 EDT
From: George Robbins <grr%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <183@cbmvax.cbmvax.cbm.UUCP>
Date: 3 May 86 23:52:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <942@umd5.UUCP> zben@umd5.UUCP (Ben Cranston) writes:
>In article <219@aplvax.UUCP> ded@aplvax.UUCP (Don E. Davis) writes:
>
>>In article <*> Root Boy Jim writes:
>>>You people fail to realize that some of us out here don't like lint.
>>>It complains too much about what I do. ...
>
>>I know several excellent programmers who never use lint.  ...
>
>Hmm, I remember a certain Cobol compiler that had an 'E' option to generate
>error messages - because it generated such a quantity of informational
>diagnostics but its users wanted "clean compiles".  I can see Cobol types
>complaining about this, but US?
>
     
The whole lint/cc issue is probably one of those little misfeatures of unix
that we just have to live with.  Sure there are historical reasons, and nice
efficiency arguments for keeping the two separate, but if lint was a default
pass of the compiler that could be disabled, or diminished by a switch, then
there would be a whole lot more people using lint, and generating more
portable code than otherwise.
     
One of the more traumatic things about being exposed to unix after working
with numerous other systems was that the stupid c compiler refused to give me
a nice clean listing with source, interspersed error messages, and optional
object code.  I'm not dumb, but trying to learn a debug a big program though
a 24-line window and my memory just doesn't make it...
     
--
George Robbins - now working with,    uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing    arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department    fone: 215-431-9255 (only by moonlite)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1990
          for JMS@ARIZMIS; Tue,  6-MAY-1986 18:23 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/06/86 at 19:04:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008997; 4 May 86 11:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002806; 4 May 86 11:42 EDT
From: George Robbins <grr%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  C Builtin Funxions
Message-ID: <182@cbmvax.cbmvax.cbm.UUCP>
Date: 3 May 86 23:18:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <498@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>X3J11 was not proposing to permit built-in functions in a
>stand-alone conforming C implementation.  They would be
>permitted in a hosted implementation, however.
     
Are you sure that the X3J11 committee hasn't been infiltrated by
unsatiated ADA persons?  :-)
     
This business of including the runtime routines in the language
standard brings out an awful log of worried frowns on the faces
of knowledgeable c/unix people.  Look at the problems that the
Pascal and Modula2 people are having with their 'offical' runtime
routines/libraries...
     
To minimize this criticism, the committee seems to be making a
big distinction between hosted and non-hosted environments that
doesn't map well into the real world.  Most of the people trying
to develop compilers for non-unix microcomputer operating systems
are trying to be as unix-like as possible, but just can't make
all the way because of operating system brain damage.
     
I would be much happier if there were two separate documents, so
that a vendor could clearly say that his compiler is fully X3J11
conforming, and his runtime support conforms to XJXXX with the
following exceptions.
     
One of the better things to come out of the COBOL standards efforts
was the notion of specifying a minimum core language, then defining
optional modules that were pretty close to the way the big boys (IBM)
had actually implemented their extensions.  This makes it fairly
easy for a vendor to communicate to a user just what his compiler
supports.
--
George Robbins - now working with,    uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing    arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department    fone: 215-431-9255 (only by moonlite)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2313
          for JMS@ARIZMIS; Tue,  6-MAY-1986 18:24 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009083; 4 May 86 12:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002889; 4 May 86 11:46 EDT
From: "Gary M. Samuelson" <garys%bunkerb.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <633@bunkerb.UUCP>
Date: 2 May 86 21:26:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <475@snow.warwick.UUCP> kay@warwick.UUCP (Kay Dekker) writes:
>In article <7097@cca.UUCP> dewitt@cca.UUCP (Mark DeWitt) writes:
>>After three years of C programming I'm just starting to use lint, so
>>please no negative reinforcement by flaming about how stupid my questions
>>are, lest I give up on it entirely :-).
     
>Mark, I'm not flaming you, but I *am* worried!...
     
And well you should be.
     
>People, what are *we* doing wrong when somebody can spend 3 years programming
>in a particular language and only then start using one of the most important
>development tools for it?
     
Good question.  I offer the following opinion:  generally, even though
most companies (and schools, for that matter) give lip service to
"proper" development techniques, in reality they reward those who
write sloppy, un-commented, ill-planned or un-planned code.
     
Did you not read the discussion about the teaching of programming?
Some, thank God, do pay some attention to issues such as style, but
most still look only at the output.  And many companies are worse
than schools.  Productivity is measured in lines of code -- which
means that if you are actually trying to *design* before writing
code, you aren't being productive.  Some places don't require
specifications; some do, supposedly, but any pile of paper with
the word "specification" on the top sheet will apparently do.
Fewer still understand the difference between a requirement (storing
data) and design (let's use a hard disk).
     
Some people -- in senior management positions, where they ought
to know better -- actually believe that "we can't afford" to do
things like impose coding standards, much less have design reviews
or even code reviews.  It is practically a proverb that "there's
never time to do it right, but there's always time to do it over."
Such short-sightedness -- the belief that having a program which does
*anything* resembling what the user wants is better than waiting
another week -- results in all sorts of trash being shipped Friday
only to be junked Monday.
     
Of course, part of the problem is that a lot of C programmers in
particular learned C from the Unix (tm) source.  I just picked 'rm.c',
more or less at random, and found exactly one comment:
     
    all files following a null option are considered file names
     
That's it.  It isn't even obvious that 'rm.c' removes files (I
suppose that one would eventually find that there is an 'unlink'
call in there somewhere, and figure it out).
     
>It's got to the point when if I'm doing program surgery and someone comes up
>saying that their program "doesn't work", if they haven't brought a
>line-numbered listing of the source AND a lint output, I don't really want
>to start looking for the problems.
>                            Kay.
     
Good for you!  That is the type of attitude required.  In many cases,
I would go even further and require that the line-numbered listing be
part of a cross-reference.
     
Also, when someone says, "This program doesn't work," it is often
revealing to ask, "what's it supposed to do?"  It is amazing --
and frustrating -- how often the person can give no clear answer.
     
Gary Samuelson
     
>"I AM; YOU ARE; HELLO: all else is poetry"
>            ... mcvax!ukc!warwick!kay
     
At last! someone who appreciates my poetry! :-)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7223
          for JMS@ARIZMIS; Wed,  7-MAY-1986 02:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/07/86 at 04:18:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009088; 4 May 86 12:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002997; 4 May 86 11:48 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Include the va_end!
Message-ID: <5381@alice.uUCp>
Date: 2 May 86 19:04:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> The implementation is on the Pyramid 90x machine, the System V
> part of it (it runs both 4.2 and System V at the same time!),
> where va_end is defined to be an '}'.
     
That implementation is simply wrong.  va_end is intended to be
executed (to free memory possibly acquired by va_start).  It
is **not** intended to be a syntactic entity.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7355
          for JMS@ARIZMIS; Wed,  7-MAY-1986 02:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009090; 4 May 86 12:12 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002998; 4 May 86 11:48 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA09404; Sun, 4 May 86 11:48:04 edt
Date: Sun, 4 May 86 11:48:04 edt
From: "UNIX 4.2 BSD" <root@ICST-CMR.ARPA>
Message-Id: <8605041548.AA09404@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, umcp-cs!jim@ICST-CMR.ARPA
Subject: Re:  A good use of a bad feature
     
    While discussing various features and miss-features of C
    with my friend Charley (mangoe) Wingate recently, we both
    agreed that the fall through case statement is among the least
    defensible of C's features.
     
    Jim \/\/illiams
    jim@mimsy.umd.edu
    umcp-cs!jim.UUCP
     
You will find much disagreement on that point, I'm afraid. Fall thru is
more flexible. You can always break, but often cases are related so that
a particular case requires a superset of another case. It is to DMR's
credit that he realized this feature. I sure wouldn't have thought of it.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7450
          for JMS@ARIZMIS; Wed,  7-MAY-1986 02:42 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009092; 4 May 86 12:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003037; 4 May 86 11:51 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: varargs
Message-ID: <5388@alice.uUCp>
Date: 2 May 86 21:14:00 GMT
Xref: seismo net.lang.c:9020 net.unix-wizards:18048
To:       info-c@BRL-SMOKE.ARPA
     
I think people are confusing two different meanings for the same term:
     
    1. the practice of writing programs that accept varying
    numbers of actual parameters by declaring a single formal
    parameter, taking its address, and incrementing that
    address in various devious ways.
     
    2. the practice of writing programs that accept varying
    numbers of actual parameters and access them using ONLY the
    facilities provided by <varargs.h> .  The particular
    implementation of these facilities may differ from one
    machine to another.
     
I said I don't know offhand of a machine that can't implement #2.
I am being deluged by descriptions of machines that can't implement #1.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7512
          for JMS@ARIZMIS; Wed,  7-MAY-1986 02:47 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009109; 4 May 86 12:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003082; 4 May 86 11:52 EDT
From: Tom Stockfisch <tps%sdchem.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <210@sdchema.sdchem.UUCP>
Date: 2 May 86 22:32:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <778@bentley.UUCP> kwh@bentley.UUCP writes:
>In article <838@ihwpt.UUCP> ihwpt!knudsen writes:
>>(2) There isn't any ^^ (XOR) operator either, as in
>
>There is, but it's spelled "!=".  (Presumably more efficient than "^", though
>I think either one should work with a smart compiler.)
>
     
Not quite the same.
    3 ^^ 4
would evaluate as 0,
    3 != 4
evaluates as 1.
     
-- Tom Stockfisch, UCSD Chemistry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7600
          for JMS@ARIZMIS; Wed,  7-MAY-1986 02:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009111; 4 May 86 12:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003131; 4 May 86 11:55 EDT
From: "R.B.Murray" <rbm%sfsup.uucp@BRL.ARPA>
Newsgroups: net.lang.c++,net.lang.c
Subject: Re: System V preprocessor problem with <generic.h>
Message-ID: <246@sfsup.UUCP>
Date: 2 May 86 17:19:51 GMT
Xref: seismo net.lang.c++:198 net.lang.c:9022
To:       info-c@BRL-SMOKE.ARPA
     
> In article <3597@sun.uucp> sun!guy (Guy Harris) writes:
> >>     #define name2(a,b)    a/**/b
> >It has, however, two problems:
> >
> >    1) If you run your code through "lint", it won't work
>
> I tried this example with "cpp -C" and it worked fine.  I'd guess that
> cpp strips all comments in preprocessor directives regardless of "-C".
>
> >    2) It is not a guaranteed property of the C language, but a
> >       quirk of the implementation, so it will not work in
> >       general.
>
> Agreed.  Any application that depends on being able to do this is treading
> on thin ice.
>
> Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
Agreed also.  I also don't believe there
is a standard and portable way to do this at the present time.
However, the current draft of the ANSI C standard has an
"offical" way to do this:
     
#define  name2(a,b)    a##b
     
The "##" is a (new) concatenation operator.
Of course, this is only useful once a standard exists and everybody
conforms to it.  Also, ANSI may change their minds on the syntax of
this feature.
     
Rob Murray AT&T
Summit, NJ

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7670
          for JMS@ARIZMIS; Wed,  7-MAY-1986 03:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009114; 4 May 86 12:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003198; 4 May 86 11:57 EDT
From: Brad Templeton <brad%looking.uucp@BRL.ARPA>
Newsgroups: net.micro,net.micro.pc,net.lang.c,net.unix-wizards
Subject: Re: Help with C-kermit on SCO Xenix V
Message-ID: <533@looking.UUCP>
Date: 3 May 86 00:19:29 GMT
Keywords: It isn't working
Xref: seismo net.micro:15267 net.micro.pc:8583 net.lang.c:9024
  net.unix-wizards:18049
To:       info-c@BRL-SMOKE.ARPA
     
In article <329@omen.UUCP> caf@omen.UUCP (Chuck Forsberg WA7KGX) writes:
>In article <294@catnip.UUCP> ben@catnip.UUCP (Bennett Broder) writes:
>>I recent obtained a copy of C-kermit 4.2(030) PRERELEASE #2, 5 March 85.
>>We have been using this version at work on a Perkin Elmer 3250XP and an
>>AT&T 3B5, and so I wasn't expecting any problem bringing it up on Xenix.
>>Well the package compiles without error, and appears to work okay, until
>>you attempt to do a transfer.  Then it can't even seem to get past the
>>header packet, and keeps printing SS%S%S%S%S% and the like on the screen.
>>Looking at the debugging output from both ends show that the Xenix machine
>>is computing the checksum incorrectly.  Please, can anyone help???
>>
The problem is indeed a bug in the MSC compiler involving shifts of
signed integers combined with ands.  The fix for kermit is simple enough,
make the int in CHK1 into an "unsigned int"
     
We're lucky on this one.  It turns out that the Kermit start packet
just happens to have a checksum that triggers this bug.  Even so it took
me several hours to track it down.
     
I'm going to report it to Microsoft as soon as I see it's not in the new
Beta release I just got.
     
     
--
Brad Templeton, Looking Glass Software Ltd. - Waterloo, Ontario 519/884-7473

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7889
          for JMS@ARIZMIS; Wed,  7-MAY-1986 03:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009117; 4 May 86 12:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003332; 4 May 86 12:03 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: A last word on arrays? Hah!
Message-ID: <389@hadron.UUCP>
Date: 3 May 86 14:44:46 GMT
Keywords: array, reference, parameter, struct
To:       info-c@BRL-SMOKE.ARPA
     
In article <310@dg_rtp.UUCP> throopw@dg_rtp.UUCP (Wayne Throop) writes:
    [attribution removed]
>I do have comment on John Rose's proposals.  ...
>>         (3) Interpret current C practice of converting array arguments
>>             to pointers as passing them by reference; make sizeof()
>>             work consistently.
>
>Well.  Sizeof is indeed peculiar.  For example,
>sizeof(formal_array_name) yeilds your machine's pointer size.
     
Ouch.  First off (see that nit?), it took me two (admittedly
fraction-of-a-second) passes to understand that you were talking
about what sizeof yields [sp!] on an array declared as a formal
a r g u m e n t .  I spent at least half a sec wondering how you
dressed your arrays to go formal!  Second, though (if it's a nit,
it's a MONSTER!), the reason it yields one of the pointer sizes
of your machine is that there is no such thing, really, as an
array argument.  It's fairly clear that when you declare a formal
argument to a function, the C compiler coerces it from array-of-X
to pointer-to-X.  You are therefore taking the size of a pointer,
and it returns the size of that pointer (which size may depend on
the type of the thing to which you are pointing).
     
As usual, this has been discussed to death in earlier articles.
If someone has a copy of my long-ish tutorial on this subject,
please send it to me.  I promise not to re-post it more often than
every year or two, and flag it so you can junk it.
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7951
          for JMS@ARIZMIS; Wed,  7-MAY-1986 03:24 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009133; 4 May 86 12:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003336; 4 May 86 12:03 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Infinite loops
Message-ID: <390@hadron.UUCP>
Date: 3 May 86 14:54:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <117@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>do ... while(1);
>while(1) ...
>for(;;) ...
>are all widely-used idioms for unconditional looping in C.
>I personally prefer the latter, but the choice is just a
>matter of taste.  Any reasonable compiler will generate
>efficient code for all three constructs.
     
Unfortunately, as I'm sure many readers of this group will agree,
not all compilers are reasonable.  The only one that consistently
doesn't generate useless code is for (;;) {...}.
     
BTW, given all these defines:  here are some "cute" ones of mine:
     
#define ever    (;;)    /* for ever ...; */
#define unless(x)    if (!(x))    /* unless (x) ...; */
#define until(x)    while (!(x))    /* until (x) ...;
                       do ... until (x); */
     
and of course    [ given #define OK 0 ]
     
#define streq(a,b)    (strcmp(a, b) == OK)
#define strneq(a,b,n)    (strncmp(a, b, n) == OK)
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8012
          for JMS@ARIZMIS; Wed,  7-MAY-1986 03:28 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/07/86 at 05:13:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009192; 4 May 86 12:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003340; 4 May 86 12:03 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: lint
Message-ID: <391@hadron.UUCP>
Date: 3 May 86 14:58:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <121@brl-smoke.ARPA> gwyn@brl.ARPA writes:
>In article <119@brl-smoke.ARPA> art@ACC.ARPA writes:
>>    [attribution omitted]
>>> There is really no justification for not using lint.
>>Just remember that not all machines that have a C compiler also have lint.
>>A full lint (or equivalent) implementation in the public domain would
>>be very welcome.
>Perhaps he should have said "There is really no justification
>for doing C software development on a system other than UNIX"?
     
For those poor sufferers who have to develop under other systems,
there are many implementations of lint and make under MS-DOS: some
were listed here a short time ago.  I believe DEC has them under
its VNX tools for VMS, too -- although if you are an all-DEC shop ...
get Ultrix instead!  Much better.
     
"Better?  Stronger ... faster ..." cheaper ... ($6M??)
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8080
          for JMS@ARIZMIS; Wed,  7-MAY-1986 03:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010067; 4 May 86 15:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004787; 4 May 86 15:40 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <203@brl-sem.ARPA>
Date: 4 May 86 17:20:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <390@hadron.UUCP>, jsdy@hadron.UUCP (Joseph S. D. Yao) writes:
>
> Unfortunately, as I'm sure many readers of this group will agree,
> not all compilers are reasonable.  The only one that consistently
> doesn't generate useless code is for (;;) {...}.
Joe, it is exactly this second guessing of compilers that get people in
trouble.  It is bad to make sweeping statements as to what is more efficient
because some compilers just do entirely unexpected, yet no more inefficient
things with code generation.
     
But the truth of the matter is, the PCC implementations get it right without
any optimization whatsoever.  Since most UNIX's use PCC as the base for their
C compilers, that generally solves the problem.
The original Ritchie compiler does miss it in the code generation, but the
optimzer removes the silly test.
     
Wait until the compiler comes out that does the following:
     
    for(;;)  { included code )
     
    L1:    NOP    /  init
    L2:    NOP    /  test
        INCLUDED CODE
        NOP    /  increment
        JUMP    L2
     
Frankly, if your compiler is so bad that it can't perform routine constant
elimination, than I doubt that you will really notice the extra performance
loss.  It's probably still multiplying out 60*60 for seconds in an hour
and other definitions.
     
-Ron

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9671
          for JMS@ARIZMIS; Wed,  7-MAY-1986 06:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/07/86 at 07:43:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011221; 5 May 86 0:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006688; 4 May 86 23:50 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re:  C Builtin Funxions
Message-ID: <530@brl-smoke.ARPA>
Date: 5 May 86 03:50:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <182@cbmvax.cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>To minimize this criticism, the committee seems to be making a
>big distinction between hosted and non-hosted environments that
>doesn't map well into the real world.  Most of the people trying
>to develop compilers for non-unix microcomputer operating systems
>are trying to be as unix-like as possible, but just can't make
>all the way because of operating system brain damage.
     
Although based on a subset of the UNIX implementation, the X3J11
hosted C specification does not require support functions that
cannot be implemented on almost any popular operating system.
For example, I am sure that a conforming hosted implementation
is possible on my Apple //e.  There aren't many more primitive
systems than that!
     
>I would be much happier if there were two separate documents, so
>that a vendor could clearly say that his compiler is fully X3J11
>conforming, and his runtime support conforms to XJXXX with the
>following exceptions.
     
"Exceptions" are pointless when the hosted runtime support is
implementatble on essentially every system.
     
All the library functions pertain to the hosted environment only.
Only the "raw" C language is required in the stand-alone environment.
It didn't take X3J11 long to agree that it was as important to
standardize the hosted environment library functions as to
standardize the raw language.  I think that is essential; most
C porting problems I've encountered have been library and header
interface incompatibilities, not raw language problems.
     
>One of the better things to come out of the COBOL standards efforts
>was the notion of specifying a minimum core language, then defining
>optional modules that were pretty close to the way the big boys (IBM)
>had actually implemented their extensions.  This makes it fairly
>easy for a vendor to communicate to a user just what his compiler
>supports.
     
That is easier for a language with built-in I/O facilities.  In the
case of C, either an implementation is a conforming hosted ditto or
it is a conforming stand-alone ditto (no library functions) or it
is nonconforming.  That's about the right number of levels as far
as I am concerned.  There's no need for more (although it would be
nice to have standardized library additions for a variety of
things; however, the X3J11 document describes the minimum useful
language, not a superset of everybody's wish lists).

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9751
          for JMS@ARIZMIS; Wed,  7-MAY-1986 06:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010335; 5 May 86 23:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028529; 5 May 86 23:46 EDT
From: Jim Carter <jimc@UCLA-LOCUS.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <12329@ucla-cs.ARPA>
Date: 2 May 86 23:20:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <778@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>Btw, you can't have *all* operators extended with "=".  How would you write
>"v = v < e;"?  (Not that it's useful.)
I think it's useful!  As written, of course, it's semantically invalid,
but what you really mean is "v <= e" (sic) or, to demonstrate where it's
really useful,
     array[horrendous] [subscript] [list] <= bigexpr;
  rather than
     if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
Now "<=" already means something else so this syntax is not acceptable.
How about "v < = e" with a mandatory blank?  This is atrocious human
engineering but at least is parseable.  Anybody have any better ideas?
--
James F. Carter            (213) 206-1306
UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024
UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc  ARPA:jimc@locus.UCLA.EDU

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9801
          for JMS@ARIZMIS; Wed,  7-MAY-1986 06:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018737; 5 May 86 10:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012278; 5 May 86 9:51 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Functions
Message-ID: <788@bentley.UUCP>
Date: 4 May 86 22:20:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1700010@umn-cs.UUCP> umn-cs!herndon writes:
>I feel compelled to go on record as being VERY MUCH AGAINST having reserved
>procedure names in C.  For those of us who have ever written stand-alone
>code for PDP-11s, VAXen, ..., it is a simple matter, as things stand, to
>compile our programs, and then have them linked with our own versions of
>'putc', 'read', etc. stashed in stand-alone libraries.
     
Fine, if you replace *all* of libc.  Otherwise you may find surprises (some
of the stdio function behave as though they call each other, but have been
optimized to use the system calls directly in some cases).
     
>One of the (in my opinion) great strengths of the C language is that it
>does not have 'built-in' functions.
     
After rethinking this question, I've decided that it *does*.  However, the
builtins are all punctuation ("%"), whereas the library functions are all
alphanumeric ("abs").  The only exception is "sizeof", which is something of
a special case anyway.  (Let's not quibble about "sizeof" again.  And yes, I
know "%" is an "operator", but doesn't that just mean "builtin function with
builtin syntax"?)
     
>If one user doesn't like the interface that 'printf' provides, or a whole
>bunch of users don't, they are free to write their own functions and use
>those instead.
     
As has been mentioned before, if you're changing the semantics it's wise to
change the name too.
     
>Building those functions into the language implies that there will be much
>code [within the compiler] for special casing those functions.
     
But the standard doesn't *require* them to be special-cased; you could port
the compiler by commenting out that code.
     
>On the flip side, the language may not be as efficient.  If the compiler
>writers want to allow these procedures to be built-in to allow in-line
>procedures, I think this should be an option (DEFAULT=OFF), and then the
>capabilities of the language will be compromised as little as possible.
     
If they make it an option, the default will probably be ON.
     
Here's my opinion.  Using punctuation for builtins (and alphanumerics for
library functions) is a nice way to keep them straight; let's keep it that
way.  If certain functions are so trivial that it's worthwhile for them to
be expanded inline (are there any besides abs(), min(), and max()?), then
they should have non-alphanumeric spellings; i.e. they should be operators.
     
I can feel the flames ("More operators?  It's getting as bad as APL!").
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9861
          for JMS@ARIZMIS; Wed,  7-MAY-1986 06:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011043; 6 May 86 4:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029545; 6 May 86 3:44 EDT
From: Griff Smith <ggs%ulysses.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <1250@ulysses.UUCP>
Date: 5 May 86 21:14:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <778@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
> >Btw, you can't have *all* operators extended with "=".  How would you write
> >"v = v < e;"?  (Not that it's useful.)
> I think it's useful! ...
... [ deleted usual arguments for "op-assign" operators ]
> James F. Carter            (213) 206-1306
> UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024
> UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc  ARPA:jimc@locus.UCLA.EDU
     
I think the quality of suggestions is degenerating rapidly.  This is a
blatant type clash.  The "op-assign" interpretation of " <= " is
self-contradictory nonsense.  The expression "v < e" has the
(nonexistent) type "boolean", which implies that the destination is
also boolean.  But that implies that you are using a boolean variable
in the " < " relation, which would be nonsense if "bool" were a real
type.
     
Instead of proposing yet another obfuscation of the language, why don't
we discuss ways that we can simplify and improve the clarity of our
coding style within the confines of the current language.  Better yet;
quit talking, and do something about it.
--
     
Griff Smith    AT&T (Bell Laboratories), Murray Hill
Phone:        (201) 582-7736
Internet:    ggs@ulysses.uucp
UUCP:        ulysses!ggs  ( {allegra|ihnp4}!ulysses!ggs )

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0026
          for JMS@ARIZMIS; Wed,  7-MAY-1986 06:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018834; 5 May 86 10:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012379; 5 May 86 9:54 EDT
From: "M.F.C.F. Operators" <operators%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <2417@watmath.UUCP>
Date: 3 May 86 20:22:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <453@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>Most of the code I have written was intrinsically non-portable. I *do*
>appreciate portability as a spectrum concept, but not as a binary one.
     
Good point.  There seems to be a lot of people confusing "portability"
and "machine-independance".  Some years ago Malcolm and Rogers defined
a measure they called the "portability index" of a program
     
               cost to modify the existing code for new environment
      index = -----------------------------------------------------
                Cost to recode from scratch an equivalent program
     
Where "cost" is appropriate function for your environment
time, money etc.
A machine independant program would have a portabily index of 0.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0088
          for JMS@ARIZMIS; Wed,  7-MAY-1986 07:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011047; 6 May 86 4:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029649; 6 May 86 3:47 EDT
From: Brandon Allbery <allbery%ncoast.uucp@BRL.ARPA>
Newsgroups: net.micro,net.micro.pc,net.lang.c,net.unix-wizards
Subject: C-Kermit: more problems (same version)
Message-ID: <1171@ncoast.UUCP>
Date: 4 May 86 15:10:30 GMT
Followup-To: net.micro,net.micro.pc,net.lang.c
Xref: seismo net.micro:15284 net.micro.pc:8606 net.lang.c:9056
  net.unix-wizards:18066
To:       info-c@BRL-SMOKE.ARPA
     
Expires:
     
Quoted from <329@omen.UUCP> ["Re: Help with C-kermit on SCO Xenix V"], by
 caf@omen.UUCP (Chuck Forsberg WA7KGX)...
+---------------
| In article <294@catnip.UUCP> ben@catnip.UUCP (Bennett Broder) writes:
| >I recent obtained a copy of C-kermit 4.2(030) PRERELEASE #2, 5 March 85.
+---------------
     
We have the same version.  The problem:  On some binary files, uploading from
a PC running MS-Kermit 2.27, a binary file will run into problems early on
(sometimes packet 3, sometimes packet 5, sometimes others, but always early).
The local (PC) Kermit times out with ``?Unable to receive acknowledge from
host''; but the host is in fact sending acknowledge packets.  I once ran debug
on the C-Kermit and didn't see anything unuaual (then again, I am not a Kermit
guru...).  I don't know of any tests with other than MS-Kermit 2.27, so it's
conceivable that the problem is on the PC end (but it works over long-distance
lines to BBSes supporting Kermit).
     
I will provide a debug output if it'll help.
     
--Brandon
--
decvax!cwruecmp!ncoast!allbery  ncoast!allbery@Case.CSNET  ncoast!tdi2!brandon
(ncoast!tdi2!root for business) 6615 Center St. #A1-105, Mentor, OH 44060-4101
Phone: +01 216 974 9210      CIS 74106,1032      MCI MAIL BALLBERY (part-time)
PC UNIX/UNIX PC - which do you like best?  See <1129@ncoast.UUCP> in net.unix.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0191
          for JMS@ARIZMIS; Wed,  7-MAY-1986 07:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019558; 5 May 86 10:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012645; 5 May 86 10:01 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Funxions
Message-ID: <1399@mmintl.UUCP>
Date: 3 May 86 12:01:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1700010@umn-cs.UUCP> herndon@umn-cs.UUCP writes:
>  On the flip side, the language may not be as efficient.
>If the compiler writers want to allow these procedures to
>be built-in to allow in-line procedures, I think this should
>be an option (DEFAULT=OFF), and then the capabilities of
>the language will be compromised as little as possible.
     
I agree that if one is going to consider certain functions as built-in,
there should be an option to make them external calls, instead.  I
don't agree that the default should be to make them external.  Most
users are interested in the efficiency; the additional effort, however
much it is, should be put on the smaller group.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0286
          for JMS@ARIZMIS; Wed,  7-MAY-1986 07:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011125; 6 May 86 4:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029746; 6 May 86 3:52 EDT
From: Don Libes <libes%nbs-amrf.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: multitasking in one process (4.2BSD)
Message-ID: <281@nbs-amrf.UUCP>
Date: 6 May 86 05:16:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> For efficiency, my only choice was to get the whole mess to run as
> one UNIX process.  The result is an operating system in a process.
> ...
> It's certainly free.  Let me know if anyone is interested.  If
> there are enough requests, I might even document it and send it to
> mod.sources.
     
Ok, enough.  I've gotten two dozen requests for this.  I now feel
very motivated to document this as promised and will do so over the
next few weeks.  I've also convinced my other half (Ed Barkmeyer)
to write up a description of the standalone 68k OS that this was
based on.  (He wrote it from scratch.  It's also free.)
     
Don Libes     {seismo,umcp-cs}!nbs-amrf!libes

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0335
          for JMS@ARIZMIS; Wed,  7-MAY-1986 07:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020103; 5 May 86 10:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012092; 5 May 86 9:48 EDT
From: Barry Margolin <barmar@mit-eddie.ARPA>
Newsgroups: net.lang.c
Subject: Re: A good use of a bad feature
Message-ID: <1853@mit-eddie.MIT.EDU>
Date: 4 May 86 06:48:32 GMT
Keywords: case statement, tacky programs
To:       info-c@BRL-SMOKE.ARPA
     
In article <1298@umcp-cs.UUCP> jim@umcp-cs.UUCP (Jim Williams) writes:
>... the fall through case statement is among the least
>defensible of C's features.
     
The only defense I can think of it is that it is more easily transformed
into the non-fall-thru version than the other way around.  All you have
to do is add lots of "break" statements.  If you want the effect of the
fall-thru style in a language that only executes one case, you must
either duplicate code or use lots of gotos in many cases.  Note that
this would not be so for your "12 Days of Christmas" program, because it
could easily be implemented as a for loop that invoked each appropriate
case in turn.  But in the cases where the alternatives are not indexed
so nicely it would not work.
     
However, I agree with you that it is not really a necesary feature.
--
    Barry Margolin
    ARPA: barmar@MIT-Multics
    UUCP: ..!genrad!mit-eddie!barmar

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9709
          for JMS@ARIZMIS; Wed,  7-MAY-1986 07:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011243; 5 May 86 0:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006822; 5 May 86 0:46 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <531@brl-smoke.ARPA>
Date: 5 May 86 04:46:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Barry, the point is, if you have a decent version of "lint",
then ANYthing it warns you about really could be an error.
It is not always obvious to the non-expert what the problem
could be, but I haven't seen more than a few actual errors
made by our SVR2+ "lint".  Therefore, if you really do want
your code to port without hassle, you should pay attention
to what "lint" tells you about your code.  Furthermore, for
this approach to be maximally helpful, you want to reduce
the not-really-a-problem messages so that real problems do
not get buried among the non-problems.  The main category
of "lint" messages that do not indicate bugs or possible
portability problems is the detection of unused variables,
functions, parameters, and function values.  Most of these
are probable errors in the code.  The one that seems to
bother people most is the flagging of unused function values.
The naive idea that one then sticks "(void)" in front of all
such function invocations "just to shut lint up" indicates a
misunderstanding of what lint is all about.  If one's own
functions do not return values, they should be declared of
type void.  If a function's value is sometimes important
and sometimes not (good examples of this are fairly rare),
then one should explicitly indicate discarding of the value,
which is the proper use of (void).  This shows whoever reads
the code that the matter has been thought about and indeed
the value is not needed in that invocation (it also forces
you to think about the matter when you write the code).  The
final instance involves standard library functions; I claim
that robust code really must check the majority of function
returns (strcpy() is a notorious exception, since it doesn't
tell one anything useful).  I just finished writing an MDQS
despooling slave both with and without using stdio for device
output; in order to detect problems with the output device
and perform appropriate error recovery, it was essential to
test the return values from putchar(), fflush(), and other
such functions that most programmers do not test.  The fact
that "lint" encourages one to program responsibly is good!
     
If you follow my recommendation and try to make your code
lint-free in the first place, then ANY noise from "lint"
will necessarily call your attention to a bug.  This is
extremely helpful, but it only works well if the expectation
is that there will be no "lint" output for correct code.
     
Now, if you want to just "hack around", then "lint" is not
for you; but if you're producing production-quality C code,
there is no excuse for delivering unduly linty code.
     
In answer to your question, yes, I think one has a right to
expect C source code deliverables (pretty rare these days)
to be lint-free.  Every time we get code that hasn't been
done that carefully, it doesn't work right and a lot of time
has to be spent fixing it.  This should be the vendor's
responsibility, not the customer's; but a vendor that ships
code like that probably won't be able to fix it properly
either.
     
P.S.  Unless your malloc() has type (void *), "lint"
warnings about incompatible pointer conversion will be
unavoidable, since "lint" doesn't realize that malloc()
arranges its (char *) return value to be maximally
aligned.  This is one of the few "lint" warnings that
correct code should produce, and it is easy to spot.
But beware the yo-yo who fails to declare the malloc()
function, invokes it (as a default int-valued function),
and casts the result to (char *); that's incorrect usage.
     
P.P.S.  Don't look to the UNIX sources for good examples
of lint-free code; some of them are good, but most are
horrible.
     
P.P.P.S.  I agree with the fellow who identified the
major problem as poor programming management.  C code
quality is only a small part of overall software quality.
All too often, one sees programmers writing code before
a proper job of analysis and design has been done.  I
also believe that is partly because semi-running code
makes it appear as though progress has been made,
while a complete design doesn't convey the same impression.
The only solution is to educate the management involved.
There are many good books (mostly from Yourdon, Inc.)
that can be used to help with this; my experience has
been that such educational efforts are only partially
successful, but that partially correct organization of
the software development process is better than none.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0521
          for JMS@ARIZMIS; Wed,  7-MAY-1986 07:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020270; 5 May 86 10:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012819; 5 May 86 10:07 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <1305@umcp-cs.UUCP>
Date: 5 May 86 04:37:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <210@sdchema.sdchem.UUCP> tps@sdchema.UUCP (Tom Stockfisch) writes:
     
[in reference to the `missing' ^^---boolean exclusive or---operator,
and kwh@bentley.UUCP's suggestion, `!=']
     
>Not quite the same.
>    3 ^^ 4
>would evaluate as 0,
>    3 != 4
>evaluates as 1.
     
If the left and right hand sides are both already boolean, `!=' works;
but the following macro always works:
     
    /* logical exclusive or */
    #define lxor(a, b)    (((a) != 0) != ((b) != 0))
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2035
          for JMS@ARIZMIS; Wed,  7-MAY-1986 08:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/07/86 at 10:41:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020289; 5 May 86 10:44 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012836; 5 May 86 10:07 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  using lint on `commercial' code
Message-ID: <1308@umcp-cs.UUCP>
Date: 5 May 86 04:51:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <531@bu-cs.UUCP> bzs@bu-cs.UUCP (Barry Shein) writes:
>A more interesting idea: Would it be reasonable to run a vendor's
>code you just bought through LINT and call their warranty dept if
>there was any serious bitching by lint?
     
The answer to that depends on the purpose for which the software
was sold (and bought).  In practice I suspect this would be entirely
unproductive:  You would spend all your time on the phone, and
never have a chance to use the software. . . .
     
Anecdote:  We had some Imagen software that was working on a Vax.
We moved the software to a Pyramid and it broke.  I ran lint on
the program in question.  Among the several hundred lines of other
errors, it pointed out the one that was causing the failure:
     
    struct foo {
        int i;
    } foo[128];
     
    caller()
    {
        ...
        callee(foo[n]);
        ...
    }
     
    callee(i)
        int i;
    {
        /* do something with i */
    }
     
This works on most machines; since the structure contains no `holes',
one member of that structure is the same size as one integer, and
the two can be treated as equivalent.  But the Pyramid has a register
window architecture, and passes `simple' arguments in registers,
reserving the data stack for `complex' arguments---such as (drum
roll please) structures.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2177
          for JMS@ARIZMIS; Wed,  7-MAY-1986 09:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020528; 5 May 86 10:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013016; 5 May 86 10:11 EDT
From: "Robert L. Fair" <cim2%pyuxv.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc,net.unix
Subject: Microsoft 'C' - Strange behaviour with doubles
Message-ID: <200@pyuxv.UUCP>
Date: 4 May 86 00:39:51 GMT
Xref: brl-sem net.lang.c:918 net.micro.pc:987 net.unix:619
To:       info-c@BRL-SMOKE.ARPA
     
Consider an array of 15 pointers to arrays of doubles:
     
    double (*parray[15])[];
     
The following code to 'malloc' the actual double array barfs on Microsoft 'C',
with a 'different levels of indirection' warning on the '='.
The code passes through LINT, and compiles OK on UN*X 5.2
     
    char    *malloc();
     
    parray[0] = (double*)malloc((unsigned)sizeof(double)*75);
     
Microsoft produces the same error if the coercion is (double**), (double),
or nothing at all !
     
Any ideas ?
     
Rob. Fair
{ihnp4|gamma|bambi}!pyuxv!cim2
     
Bell Communications Research
Piscataway
New Jersey
     
Subject:
Newsgroups: general

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2444
          for JMS@ARIZMIS; Wed,  7-MAY-1986 09:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009579; 5 May 86 19:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026487; 5 May 86 19:42 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <791@bentley.UUCP>
Date: 5 May 86 13:37:54 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <778@bentley.UUCP> I wrote:
>A true boolean datatype would have a couple of advantages:
>
>o  Multiple flag variables with local scope and no address operator (e.g.
>   variables declared "register bool") could be packed into a single word.
>
>o  "++x" and "--x" could be defined as "set" and "clear"; "x++" and "x--"
>   would then be "test and (set|clear)".  This would obviate such things as
>   "if (!flag) { flag=1; printmsg(); }".
     
I forgot to mention one other:
     
o  A function returning a bool could be implemented on some machines by
   setting the condition codes instead of storing a full integer value in
   the return register.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4824
          for JMS@ARIZMIS; Wed,  7-MAY-1986 14:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/07/86 at 15:22:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020556; 5 May 86 10:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013031; 5 May 86 10:11 EDT
From: Griff Smith <ggs%ulysses.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <1247@ulysses.UUCP>
Date: 4 May 86 15:29:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     Most People            Your's Truly
>
>     if (c) {            if (c)
>         w = y;                w = x,
>         y = z;                y = z;
>     }                /* look ma, no brace */
...
> Sufficeth to say that I use a lot of commas in my code. Unfortunately,
> I cannot do this if either statement is a control struxure, *except* return.
>
>     Most People            Your's Truly
>
>     if (c) {            if (c)
>         w = y;                return w = x,
>         return;
>     }                /* look ma, no brace */
>
> When I want to return a *real* value, I use `return(exp)' using *explicit*
> parens. I only do this in void funxions of course. I cannot see *any*
> implementation doing either of the following:
>
>     1) barfing because I returned an *extra* value sometimes
>     2) barfing because I added an extra argument
>
> Now you may claim that this is `bad programming practice', but I claim
> that it is just a convention, ...
...
>     (Root Boy) Jim Cottrell        <rbj@cmr>
     
"Thank you, Mr Cottrell.  It is refreshing when job applicants are so candid
during an interview; we will notify you of our decision in a few weeks..."
--
     
Griff Smith    AT&T (Bell Laboratories), Murray Hill
Phone:        (201) 582-7736
Internet:    ggs@ulysses.uucp
UUCP:        ulysses!ggs  ( {allegra|ihnp4}!ulysses!ggs )

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5848
          for JMS@ARIZMIS; Wed,  7-MAY-1986 16:28 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/07/86 at 17:28:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009598; 5 May 86 19:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026546; 5 May 86 19:44 EDT
From: Dave Bloom <dave@andromeda.rutgers.edu>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <278@andromeda.RUTGERS.EDU>
Date: 5 May 86 14:54:34 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>> People, what are *we* doing wrong when somebody can spend 3 years programming
>> in a particular language and only then start using one of the most important
>> development tools for it?
     
> Good question.  I offer the following opinion:  generally, even though
> most companies (and schools, for that matter) give lip service to
> "proper" development techniques, in reality they reward those who
> write sloppy, un-commented, ill-planned or un-planned code.
     
Just because you don't always use lint, doesn't mean your code is sloppy
or ill planned. Very often programs do *NOT* have to be portable... In
fact, sometimes code is easier to read if you haven't gone out of your
way to be portable.
     
Further more, the Lint S/N ration is frustrating, to say the least. And
many of us don't believe in muddling up code with void casts and the like
to keep lint happy....
--
      harvard\ pyramid\                      Dave Bloom
       seismo \  pyrnj \
     ut-sally  >!topaz  >!andromeda!dave       Office: (201) 648-5083
      allegra /   caip /
ihnp4!packard/    yogi/          "You're never alone with a schizophrenic...."

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5949
          for JMS@ARIZMIS; Wed,  7-MAY-1986 16:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009756; 5 May 86 20:32 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a026946; 5 May 86 20:25 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA09939; Mon, 5 May 86 20:24:55 edt
Date: Mon, 5 May 86 20:24:55 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605060024.AA09939@icst-cmr.ARPA>
To: cbmvax!grr@seismo.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: questions from using lint
     
> In article <942@umd5.UUCP> zben@umd5.UUCP (Ben Cranston) writes:
> >In article <219@aplvax.UUCP> ded@aplvax.UUCP (Don E. Davis) writes:
> >
> >>In article <*> Root Boy Jim writes:
> >>>You people fail to realize that some of us out here don't like lint.
> >>>It complains too much about what I do. ...
> >
> >>I know several excellent programmers who never use lint.  ...
> >
> >Hmm, I remember a certain Cobol compiler that had an 'E' option to generate
> >error messages - because it generated such a quantity of informational
> >diagnostics but its users wanted "clean compiles".  I can see Cobol types
> >complaining about this, but US?
> >
>
> The whole lint/cc issue is probably one of those little misfeatures of unix
> that we just have to live with.  Sure there are historical reasons, and nice
> efficiency arguments for keeping the two separate, but if lint was a default
> pass of the compiler that could be disabled, or diminished by a switch, then
> there would be a whole lot more people using lint, and generating more
> portable code than otherwise.
>
> One of the more traumatic things about being exposed to unix after working
> with numerous other systems was that the stupid c compiler refused to give me
> a nice clean listing with source, interspersed error messages, and optional
> object code.  I'm not dumb, but trying to learn a debug a big program though
> a 24-line window and my memory just doesn't make it...
>
> --
> George Robbins - now working with,    uucp: {ihnp4|seismo|caip}!cbmvax!grr
> but no way officially representing    arpa: cbmvax!grr@seismo.css.GOV
> Commodore, Engineering Department    fone: 215-431-9255 (only by moonlite)
     
BSD has a program called `error' that will insert the errors & then invoke
`vi' on all the sources. EMACS will do that as well.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0473
          for JMS@ARIZMIS; Thu,  8-MAY-1986 00:58 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 02:37:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010088; 5 May 86 22:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027639; 5 May 86 21:43 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc,net.unix
Subject: Re: Microsoft 'C' - Strange behaviour with doubles
Message-ID: <1314@umcp-cs.UUCP>
Date: 5 May 86 15:10:22 GMT
Xref: seismo net.lang.c:9046 net.micro.pc:8604 net.unix:8174
To:       info-c@BRL-SMOKE.ARPA
     
In article <200@pyuxv.UUCP> cim2@pyuxv.UUCP (Robert L. Fair) writes:
     
[concerning Microsoft C's warning on the assignment below]
     
>    double (*parray[15])[];
>    char    *malloc();
>
>    parray[0] = (double*)malloc((unsigned)sizeof(double)*75);
     
`parray' here is `array 15 of pointer to array of double'.
Indirection (parray[0]) yields `pointer to array of double';
so the proper cast is
     
    parray[0] = (double (*)[]) malloc(...);
     
but as cdecl says,
     
    Warning: Unsupported in C -- Pointer to array of unspecified
    dimension
     
Most likely your intent here is to create a fifteen element vector
of vectors, where the subsidiary vectors contain an unspecified
number of objects of type `double'.  (I am trying to avoid the
words `array' and `pointer', if it is not obvious.)  To accomplish
this, try the following:
     
    double *vecvec[15];
     
    vecvec[0] = (double *) malloc((unsigned) (j * sizeof (double)));
     
You can then reference vecvec[0][0 .. j-1] (if you will pardon the
Pascalesque notation), or *(vecvec[0]) through *(vecvec[0] + j - 1),
if you prefer.
     
More generally, given
     
    int i;            /* loop index */
    int *j;            /* bounds on each vec[i] */
    int n;            /* bound on vec[] */
    double **vecvec;    /* vector of vectors of doubles */
     
    /* create a vector of n objects of type t */
#define MAKEVEC(n, t) ((t *) malloc((unsigned) ((n) * sizeof (t))))
     
    n = ...;
    j = MAKEVEC(n, int);
    for (i = 0; i < n; i++)
        j[i] = ...;
    vecvec = MAKEVEC(n, double *);
    for (i = 0; i < n; i++)
        vecvec[i] = MAKEVEC(j[i], double);
     
you can then reference vecvec[i][0 .. j[i] - 1] for i in [0, n).
     
Of course, all of the above needs to ensure that malloc() succeeds;
if you leave out such tests, your program will work perfectly until
the first time you demonstrate it to someone important, at which time
it will bomb spectacularly.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1043
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 04:13:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010092; 5 May 86 22:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027667; 5 May 86 21:44 EDT
From: Brooks Gelfand <gelfand%valid.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <256@valid.UUCP>
Date: 5 May 86 19:43:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <7097@cca.UUCP> dewitt@cca.UUCP (Mark DeWitt) writes:
> >After three years of C programming I'm just starting to use lint, so
> >please no negative reinforcement by flaming about how stupid my questions
> >are, lest I give up on it entirely :-).
>
> Mark, I'm not flaming you, but I *am* worried!  If you've been programming
> in C for 3 years and not using lint then EITHER 1) Your system doesn't *have*
> lint.  You have my profound sympathy. OR 2) Nobody ever taught you about
> using lint.  I wonder why not? OR 3) You never realised that using lint
> was important.  You must have wasted many hours (that you could have spent
> playing Rogue or whatever :-)) chasing problems down that lint might well
> have indicated to you.
>
> People, what are *we* doing wrong when somebody can spend 3 years programming
> in a particular language and only then start using one of the most important
> development tools for it?
>
>                             Kay.
> --
> "I AM; YOU ARE; HELLO: all else is poetry"
>             ... mcvax!ukc!warwick!kay
     
I have been programming for many years (over 20) in many different
languages, and C is the only language that I can remember that
has a separate program (lint) to find and report compiler errors in
source code. All of the other languages I have used have this function
built into the compiler. Perhaps because UNIX is a programmers
system rather than a production system this was felt to be unnecessary.
In most production systems the programs spend more time executing than
compiling; while in a development system most of the time is spent editing
and compiling. Thus running lint each time would add to the load
on the system.
A suggestion, system adminstrators could replace the cc command
with a script that would invoke lint before the C compiler. Then
everyone would run lint and perhaps development time spent tracking
down bugs would decrease.
     
Brooks Gelfand

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1097
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010327; 5 May 86 23:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028392; 5 May 86 23:41 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <2692@utcsri.UUCP>
Date: 3 May 86 16:39:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <778@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>In article <838@ihwpt.UUCP> ihwpt!knudsen writes:
>>(1) Found out this weekend that you can't say:
>>    boolvar ||= boolean_expression
>
>An interesting expression.  The left side of the assignment would have to be
>evaluated first, and if already set, do nothing.  I presume the reason this is
>omitted is because it's normally written "if (v || e) v=1;" or "if (!v && e)
>v=1;" rather than "v = v || e".
>
Interesting - I was going to suggest if(e)v=1; but that's not the same thing.
I was surprised to find out recently that ` i >> = 1 ' is legal, as opposed to
`>>='. I really think this should produce at least a warning. (4.2BSD)
>
>>(2) There isn't any ^^ (XOR) operator either, as in
>>    if(divisor <0) ^^ (dividend <0)
>>        quotient = -quotient;
>
>There is, but it's spelled "!=".  (Presumably more efficient than "^", though
>I think either one should work with a smart compiler.)
     
If I had $0.02 for everything that people have said should be done by a smart
compiler... :-) :-) I know, that's what compilers are for.
     
But it's not quite the same thing. 2 ^^ 1 should be 0, and 2!=1 is 1, and 2^1
is 3. Of course, in the example given, that won't happen. In any case, you
can always say !a != !b.
     
On the subject of operators, someone said a while back that they had a
compiler with commented-out code to support '/\' and '\/' ( max and min )
operators - and that they had qualms about activating it and then writing
non-portable code. I suggest that they activate it, and then write
     
#define min(a,b) ((a)\/(b))
#define max(a,b) ((a)/\(b))
     
in a header, to allow portability. Presumably, the code produced by these
operators should be somewhat better than a>b?a:b. Of course, you still
have to avoid writing min( array[atoi(x1)], i+cindex[getc(file)]) :-).
     
--
"For every action there is an equal and opposite malfunction"
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1147
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010330; 5 May 86 23:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028414; 5 May 86 23:42 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: varargs
Message-ID: <2694@utcsri.UUCP>
Date: 3 May 86 17:01:05 GMT
Xref: seismo net.lang.c:9051 net.unix-wizards:18063
To:       info-c@BRL-SMOKE.ARPA
     
In article <236@chronon.chronon.UUCP> eric@chronon.UUCP (Eric Black) writes:
>In article <129@drilex.UUCP> dricej@drilex.UUCP writes:
>>
>>rb@ccird2 (Rex Ballard) wonders what kind of systems would not be able to
>>handle varargs. ...
>>... Therefore, a more proper question would be: is there any
>>architecture which is suitable for a C compiler, but not for varargs?
>
>Yes!  I can think of an example close to home... An architecture with
>a large (LARGE) number of registers, a sliding window to allow reference
>to a smaller register set locally within a procedure, and OS support
>for using the register set as a stack (handling overflow/underflow).
>The first <n> arguments are passed in registers via the overlapped
>sliding window, remaining have to be passed in memory.  The problem
>is that no choice of <n> will be correct; you can only make arbitrarily
>small the probability of it not being big enough...  and at the cost of
>additional expense elsewhere...
>I assert that this architecture, and the rest of what goes with this
>particular feature, is particularly well-suited for efficient execution
>of programs written in C.
>
I agree with your assertion. If this machine supports pointers to registers,
you could write a varargs. va_arg() would have to bump a pointer to the last
register arg to a pointer to memory, maybe by calling a 'va_bump' function.
If it doesn't support pointers to register args, then it is in a bit of
trouble with C because this is supposed to be legal:
     
    f(a) int a;
    {    wombat(&a);
    }
--
"For every action there is an equal and opposite malfunction"
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1188
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:33 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010332; 5 May 86 23:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028477; 5 May 86 23:44 EDT
From: John Rose <rose@THINK.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <5097@think.ARPA>
Date: 5 May 86 14:52:47 GMT
Xref: seismo net.lang.c:9052 net.lang.c++:202
To:       info-c@BRL-SMOKE.ARPA
     
In article <763@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>In article <4495@cbrma.UUCP> cbrma!trl (Tom Lanning) writes:
>>    Are there any "malloc" routines that check for modification of
>>malloc's link pointers by the "user's" code?   Close to 70% of by bugs
>>are stack/memory problems were I use more space than I allocated.
>
>As mentioned in the man page, the malloc() code has a compile-time option
>for strict checks on the arena.  (This is not too useful if you have no
>source code, of course.)
If you do have source code, here's another suggestion which has worked
very well for me.  Define an circular buffer which stores a record of
the last few hundred records of malloc/free/morecore history.  Make
sure your symbolic debugger can dump it for you.  This trick alone
has saved me hours of debugging time on quite a few occasions.
In my applications, someone would either (1) try to use freed storage,
or (2) go off the end of allocated storage, and usually these errors
occurred within a dozen history events after the call to (1) free or
(2) malloc.
     
>Now, if only somebody would invent an architecture where all objects,
>including dynamicly allocated objects, are isolated in memory, then any
>subscript error would cause an immediate memory fault.  You'd still be
>vulnerable to completely wild pointers (but less likely in a huge address
>space), and overflow of an array inside a structure might be untrappable,
>but otherwise it sounds like a great machine to do your debugging on.
>
>Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
It's called the "Lisp Machine".  All storage is allocated and manipulated
according to very strict typing rules, enforced in microcode.  If you walk
off the end of an array, you get an immediate break into the debugger,
with options to (a) abort, (b) re-invoke any stack frame, (c) return from
any stack frame, (d) extend the array in place, (e) anything else you
can specify in Lisp (the debugger, command loop, and application all
run in the same address space!  This is safe because of the enforcement
mentioned above).  The C compiler I'm using (Zeta-C from Zeta-Soft, Ltd.)
implements pointers (approximately) as ordered pairs of arrays and indexes.
     
The bounds-checking can be done in macrocode on a conventional machine.
The BCC compiler (from Delft Consulting?) does this by source-transforming
a C program so that pointers turn into small records carrying bounds
information.
     
Both systems (as far as I know) model the C runtime memory as a collection
of "floating" byte arrays.  Part of the justification for this is found in K&R
RefMan 7.6 "Pointer comparison is portable only when the pointers point to
objects in the same array."
     
[Disclaimer:  I have no professional connection with the Zeta-C or BCC
companies, although I do know the implementors of both products personally.]
--
----------------------------------------------------------
John R. Rose             Thinking Machines Corporation
245 First St., Cambridge, MA  02142    (617) 876-1111 X270
rose@think.arpa                  ihnp4!think!rose

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1236
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011127; 6 May 86 4:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029766; 6 May 86 3:52 EDT
From: "D.B. Robinson " <dbr%foxvax5.uucp@BRL.ARPA>
Newsgroups: net.wanted.sources,net.unix,net.lang.c
Subject: Re: Complex Arithmetic Library Wanted
Message-ID: <288@foxvax5.UUCP>
Date: 5 May 86 17:34:40 GMT
Keywords: Math, Complex, Library, Source, C++
Xref: seismo net.wanted.sources:2429 net.unix:8178 net.lang.c:9058
To:       info-c@BRL-SMOKE.ARPA
     
In article <665@ho95e.UUCP> wcs@ho95e.UUCP (Bill Stewart 1-201-949-0705
 ihnp4!ho95c!wcs HO 2G202) writes:
>In article <1032@cybvax0.UUCP> dbr@foxvax5.UUCP (Douglas Robinson) writes:
>>I  am interested in a set of "C" language functions, suitable for
>>linking to analytical  programs,  which  perform  complex  number
>>operations.  .....
>
>Such libraries can be useful, but a much better approach is to get C++,
>which allows you to define your own data types, and overload the
>standard operators to work with them.  Program development is a lot
 ...
>Your programs also run faster because the complex functions can be
>expanded in-line at compile time instead of using function calls.
     
I have heard mixed reviews of C++.  Yes it seems that it would be a
great productivity tool PROVIDING you have a 32Bit CPU and a compiler
with LARGE amounts of capacity (I've heard of people exhausting certain
limits on the 4.2BSD compiler on a VAX...).  Some of us still have to be
able to live with 16Bit processors (INTEL 8088/86/286) and some of us
even have to live in the small model domain (strictly 16 bit addressing
with split I/D).  Not everyone has a spare VAX in their basement (YET :->).
     
Douglas Robinson    jobs don't kill programmers, programmers kill jobs
The Foxboro Company
MS 04-3A        cybvax0!foxvax5!dbr
38 Neponset Avenue
Foxboro, MA 02035    617/543-8750

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1340
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:46 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028440; 6 May 86 10:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004722; 6 May 86 9:40 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#1
Message-ID: <1023@hou2d.UUCP>
Date: 4 May 86 16:21:26 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Sun,  4 May 86       Volume 16 : Issue   1
     
Today's Topics:
                           #import (4 msgs)
                                 /*/
----------------------------------------------------------------------
     
Date: Mon, 21 Apr 86 11:37:49 pst
From: sdcrdcf!trwrb!desint!geoff
Subject: #import
To: trwrb!sdcrdcf!cbosgd!std-c
     
In article <1007@hou2d.UUCP> John Gilmore (hoptoad!gnu) writes:
>
> I suggest that the #import <file.h> form *not* be implemented; I never
> saw what was wrong with #include "file.h" since it will be found in the
> standard directories anyway.  (Anybody who puts "stdio.h" in their
> current directory and then wants to include /usr/include/stdio.h is
> begging for her code to break next year when somebody else maintains
> it.)
     
This sounds find when you use 'stdio.h' as your example, but unfortunately
it requires that people be familiar with the names of *all* the include
files on their system.  Furthermore, if I'm writing code I hope to port
to BSD, it prevents me from having a subdirectory named 'net' that has a
bunch of include files that I don't even know the names of.
--
     
    Geoff Kuenning
    {hplabs,ihnp4}!trwrb!desint!geoff
     
------------------------------
     
Date: Mon, 21 Apr 86 12:04:58 est
From: ihnp4!mnetor!clewis (Chris Lewis)
Subject: #import
To: utcs!cbosgd!std-c
     
I disagree [with gnu's comments].
Many times I've needed to differentiate between <...> and
"..." include formats.  In a cross-compilation environment it is
frequently necessary to be able to differentiate between include files
from the "host", and those of the "target".  For example, trying to
cross-compile "size" where you want stdio.h from the host
(/usr/include/stdio.h), and a.out.h for the target (./a.out.h) - so you
can build a version of "size" that runs on the one machine to analyse
load modules for another machine.  At least being able to use "..." and
<...> forms allows you to document this fact - plus to ensure that you
aren't picking up the target's ./stdio.h by accident.  (you're going to
say "but the a.out.h include files should be the same anyways" - they
aren't - our host is BSDish, our target is SVR2ish)
     
Wouldn't it be simpler just to ensure that the cpp's "#include" never
picked up the same file twice?  (rather than inventing a new keyword)
I can't think of too many scenarios where you want to include the same
file twice in one compilation.
--
Chris Lewis,
UUCP: {allegra, linus, ihnp4}!utzoo!mnetor!clewis
BELL: (416)-475-8980 ext. 321
     
------------------------------
     
Date: Wed, 23 Apr 86 10:18:59 MST
From: utah-cs!utah-gr!thomas (Spencer W. Thomas)
Subject: #import
     
Problem is that "" means start searching on the directory where the file
with the #include statement is found (at least for Reiser cpp).  So, if
you have
     
a.h:
....
#include "b.h"
...
     
and you wish to redefine b.h, you must also copy a.h to your working
directory.  Working on the principal that only files being modified
should be copied, this is a >bad thing<.  If, on the other hand, a.h had
     
#include <b.h>
     
you could just make a local copy of b.h and put -I. on your cc line.
     
--
=Spencer   ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA)
     
------------------------------
     
Date: Tue, 22 Apr 86 12:47:39 est
From: Davidsen <seismo!rochester!steinmetz!davidsen>
Subject: #import
To: std-c@cbosgd.uucp.arpa
     
As much as I like the idea of "#import", I admit that I don't see the
reason for not implementing the <somthing> form. There are a number of
system includes which include other things, and if I want to be *SURE*
that the definitions I need are included, what better way to do it than
by use of the #import <xxx>? Computers are so much better than people
at that sort of thing. It also reduces the room for error when someone
creates a file by the same name as a system include. Other than that, I
feel that it is a very useful proposal.
     
In that vein, how about a #cdef?
Replace:
    #ifndef M_LIMIT
    #define M_LIMIT 407 /* default value */
    #endif
with:
    #cdef M_LIMIT 407 /* default if missing on cc line */
     
This seems to solve the same class of problem...
     
------------------------------
     
Date: Sun, 27 Apr 86 20:50:03 edt
From: decvax!minow (Martin Minow)
Subject: /*/
To: cbosgd!std-c
     
A note in net.lang.c suggested that the three-character string
"/*/" was a complete comment (containing both a comment start "/*"
and comment end "*/").  This isn't the case on Ultrix-32 (prais
be), and I wonder whether it would be in Draft standard.
     
Hopefully not.
     
Martin Minow
decvax!minow
     
------------------------------
     
End of mod.std.c Digest - Sun,  4 May 86 12:17:48 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1381
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:47 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004661; 6 May 86 13:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013296; 6 May 86 13:44 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <5401@alice.uUCp>
Date: 5 May 86 18:35:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>>Btw, you can't have *all* operators extended with "=".  How would you write
>>"v = v < e;"?  (Not that it's useful.)
> I think it's useful!  As written, of course, it's semantically invalid,
> but what you really mean is "v <= e" (sic) or, to demonstrate where it's
> really useful,
>     array[horrendous] [subscript] [list] <= bigexpr;
>  rather than
>     if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
> Now "<=" already means something else so this syntax is not acceptable.
> How about "v < = e" with a mandatory blank?  This is atrocious human
> engineering but at least is parseable.  Anybody have any better ideas?
     
You have suggested that
     
    v < = e
     
should mean
     
    if (v < e) v = e
     
but this is not parallel to the other `=' operators.  Instead,
if it means anything at all it should mean
     
    v = v < e
     
In other words, afterwards v is either 1 or 0 depending on the
value of e and the previous value of v.
     
But I can't imagine when I'd ever want to use this in practice.
Maybe we should just leave the language alone.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1444
          for JMS@ARIZMIS; Thu,  8-MAY-1986 02:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005217; 6 May 86 14:15 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a013637; 6 May 86 13:49 EDT
Received: from juliet.caltech.edu by AOS.BRL.ARPA id a003813; 6 May 86 13:27 EDT
Date:     Tue, 6 May 86 10:27:29 PDT
From:     "William E. Woody" <woody@juliet.caltech.edu>
Message-Id: <860506102602.046@Juliet.Caltech.Edu>
Subject:  Obfuscated C
To:       info-c@juliet.caltech.edu
Comment:  None.
     
  I understand that it would be very useful to have /\, \/, #import, ^^,
&#, and any other pair of non-alphanumeric character represent some special
operation that would be useful (and even _important_) for some application
or another.
     
  HOWEVER, as useful it would be to include other operators, Remember What
Happened to PL/1.  Because everyone in the design committee wanted something
and no-one wanted to say no! we stop adding commands/functions/operators
here, I have never seen a full implementation of PL/1 on any machine--the
original language specifications are too bloody big to have a compiler fit
on a single vax.
     
  I Like C to be reasonably easy to learn _and_ extremely powerful, as well.
But if we tack on new commands and operators at will, then everyone's program
will be a winner in the Obfuscated C contest!
     
         - William Woody
      NET  Woody%Romeo@Hamlet.Caltech.Edu
   USNAIL  1-54 Lloyd, Caltech / Pasadena, CA 91126
     
Boy I can feel the flames now! :-)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1591
          for JMS@ARIZMIS; Thu,  8-MAY-1986 03:07 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005268; 6 May 86 14:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013733; 6 May 86 13:52 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <794@bentley.UUCP>
Date: 6 May 86 13:43:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <390@hadron.UUCP> hadron!jsdy (Joseph S. D. Yao) writes:
>BTW, given all these defines:  here are some "cute" ones of mine: ...
>#define streq(a,b)     (strcmp(a, b) == OK)
     
A more general mechanism is
#define strrel(a,R,b)    (strcmp(a, b) R 0)
which allows you to write strrel(a,==,b).  Some consider this to be abuse
of the preprocessor.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1658
          for JMS@ARIZMIS; Thu,  8-MAY-1986 03:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005314; 6 May 86 14:19 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a013830; 6 May 86 13:52 EDT
Date:     Tue, 6 May 86 13:46:06 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Brooks Gelfand <gelfand%valid.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  questions from using lint
     
> C is the only language that I can remember that has a separate
> program (lint) to find and report compiler errors in source code.
     
First, the errors detected are not COMPILER errors but CODING errors.
     
Second, I supose you never heard of the PL/I checkout compiler
nor of "student Fortran compilers" such as WatFor?  Separate
compilers were used to generate production executable binary
once the program was debugged.
     
Third, "lint"ing is not necessary on every compilation.  I often rebuild
already de-linted software from source (e.g., when a library routine has
been improved).
     
Fourth, on small systems such as the PDP-11, making "lint" a separate
program makes it possible to have both better compilation and better
error checking without resorting to complicated multi-pass compilation.
     
Fifth, "lint" is rather portable (I use the same version on three
distinct architectures), whereas a code-generating compiler is
inherently machine-dependent.
     
In short, I see nothing wrong with the present set-up.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1762
          for JMS@ARIZMIS; Thu,  8-MAY-1986 03:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005389; 6 May 86 14:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013828; 6 May 86 13:52 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <795@bentley.UUCP>
Date: 6 May 86 13:44:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <12329@ucla-cs.ARPA> jimc@ucla-cs.ARPA (Jim Carter) writes:
>In article <778@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>>Btw, you can't have *all* operators extended with "=".  How would you write
>>"v = v < e;"?  (Not that it's useful.)
>
>I think it's useful!  As written, of course, it's semantically invalid,
     
Whoa!  The operator I was referring to was "v = v < e", which is the clear
generalization of "op=" on operator "<".  This is meaningful in C, because
the boolean result of "<" will be interpreted as an integer.  But it is not
generally useful, because one does not normally use a boolean argument to a
comparison operator like "<".
     
>but what you really mean is "v <= e" (sic) or, to demonstrate where it's
>really useful,
>     array[horrendous] [subscript] [list] <= bigexpr;
>  rather than
>     if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
     
Now we're discussing "if (v < e) v = e;" which means "v = max(v,e);".  This
is indeed a useful operation, but the operator is now "max" rather than "<".
     
>Now "<=" already means something else so this syntax is not acceptable.
>How about "v < = e" with a mandatory blank?  This is atrocious human
>engineering but at least is parseable.  Anybody have any better ideas?
     
Yes.  I already mentioned this in the discussion about builtins, but I think
it bears repeating.
     
Introduce a new operator "<>" for max (and "><" for min).
Add the corresponding assignment operator "<>=" (and "><=") with the above
meaning.
     
The symbol "<>" is currently meaningless in C, though basic and pascal users
would have a fit.  "|>" and "<|" may be better choices.  "\/" and "/\" would
mimic the mathematical notation, but there may be reasons to avoid the use
of backslash in program source.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1846
          for JMS@ARIZMIS; Thu,  8-MAY-1986 03:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007089; 6 May 86 15:08 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a016454; 6 May 86 14:59 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA29561; Tue, 6 May 86 14:59:14 edt
Date: Tue, 6 May 86 14:59:14 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605061859.AA29561@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Re: C Builtin Functions
     
> >I can feel the flames ("More operators?  It's getting as bad as APL!").
     
Hey, the more primitives, the better. I also like(d) TECO. Just because
a language is terse, doesn't mean it's unreadable. In my opinion, people
who laughed at the greek were just to lazy to learn the lingo. APL is
quite readable once you get used to it, especially with direct definition.
     
> Excuse me...in APL parlance (eg, the language used in the APL Draft Standard),
> things like "+", "-",etc. are called functions, as are user-defined functions.
> Operators are things which alter the effect of functions, such as "." in the
> context of "+.x", which causes an inner matrix product to be evaluated.
     
Interesting. Would the construct `+.FUNC' be legal also?
     
> (No, this doesn't belong in net.lang.c, but YOU STARTED IT!)
     
And I'm adding to it.
     
> Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
> {philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1919
          for JMS@ARIZMIS; Thu,  8-MAY-1986 03:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 05:22:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010515; 6 May 86 15:49 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a017358; 6 May 86 15:25 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a007213; 6 May 86 15:12 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA29608; Tue, 6 May 86 15:12:39 edt
Date: Tue, 6 May 86 15:12:39 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605061912.AA29608@icst-cmr.ARPA>
To: cbmvax!grr@seismo.ARPA
Subject: Error
Cc: info-c@BRL.ARPA
     
> Hi Jim:
     
Howdy.
     
>     Yeah, I've seen error - an amazing retrofit job!  One of those deals
> where the user has to do tricks to do a simple thing.
     
Actually, it is a testamonial to UNIX that such a thing CAN be done. Many
other systems wouldn't be able to coordinate such a task so efficiently.
What, pipe two (or more) separate programs together? Shocking!
     
>     I should point out that my shock occured maybe 10 years ago, and
> things a little better organized now.  I've spent time before and since
> working IBM stuff, and worse, so perhaps I'm permanantly brain damaged, but
> there are a few things about unix that are primitive...
>
>                 02:30;
>                 George Robbins
>                 ...!{ihnp4|seismo|caip}!cbmvax!grr
     
I must admit that I was surprised when I found out there was no listing
file generated. But they were right! Who needs it?
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1971
          for JMS@ARIZMIS; Thu,  8-MAY-1986 03:45 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011838; 6 May 86 16:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018675; 6 May 86 15:58 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <601@brl-smoke.ARPA>
Date: 6 May 86 19:57:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <560@brl-smoke.ARPA> Root Boy Jim <rbj@icst-cmr> writes:
>BSD has a program called `error' that will insert the errors ...
     
Coals to Newcastle.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3152
          for JMS@ARIZMIS; Thu,  8-MAY-1986 06:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 07:52:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012051; 6 May 86 16:26 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a019020; 6 May 86 16:11 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA29705; Tue, 6 May 86 16:11:03 edt
Date: Tue, 6 May 86 16:11:03 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605062011.AA29705@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, ulysses!ggs@seismo.ARPA
Subject: Re: Boolean Operators Slighted in C
     
> > In article <778@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
> > >Btw, you can't have *all* operators extended with "=".  How would you write
> > >"v = v < e;"?  (Not that it's useful.)
> > I think it's useful! ...
> ... [ deleted usual arguments for "op-assign" operators ]
> > James F. Carter            (213) 206-1306
> > UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024
> > UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc  ARPA:jimc@locus.UCLA.EDU
>
> I think the quality of suggestions is degenerating rapidly.  This is a
> blatant type clash.  The "op-assign" interpretation of " <= " is
> self-contradictory nonsense.  The expression "v < e" has the
> (nonexistent) type "boolean", which implies that the destination is
> also boolean.  But that implies that you are using a boolean variable
> in the " < " relation, which would be nonsense if "bool" were a real type.
     
It would be nonsense IF boolean was a real type. There is no need to
make any distinction between them. It just gets in the way of coding.
APL, the most mathematical language, treats booleans exactly like C.
THERE IS NO SUCH THING AS A BOOLEAN DATA TYPE (to which Doug Gwyn will
reply `there is no such thing as an integer either :-). There may be
boolean OPERATORS, but their range and domain is integers.
     
> Instead of proposing yet another obfuscation of the language, why don't
> we discuss ways that we can simplify and improve the clarity of our
> coding style within the confines of the current language.  Better yet;
> quit talking, and do something about it.
     
Like what? Make it like Pascal :-)
     
> Griff Smith    AT&T (Bell Laboratories), Murray Hill
> Phone:        (201) 582-7736
> Internet:    ggs@ulysses.uucp
> UUCP:        ulysses!ggs  ( {allegra|ihnp4}!ulysses!ggs )
     
A couple of wild suggestions myself. In the tradition of APL one liners,
     
1) Chain Lvalues. I would like to be able to write:
     
    ((n *= 10) += (c -= '0');        instead of
    c -= '0'; n *= 10; n += c;
     
2) More of the same. We all know about *++p. But what if I want to jump
    more than one element? I can't write *(p += 2); Or maybe I
    want to write `p = &(i += 5).
     
3) Exchange operator. This has probably been discussed before, so pardon
    me if I blunder into that pit. BUT, DMR has stated that one of
    the reasons that exponentiation was left out was because no
    (or few, if any) machine could do it inline, and therefore
    all the compiler would be doing is a function call anyway.
    By the same reasoning, exchange CAN be done efficiently by
    some machines, and the hack of a temporary variable and
    three assignments is a rather stale idiom. The three
    statement XOR trick avoids the temporary, at the expense
    of execution time and clarity.
     
4) Allow complex statements to be considered as expressions so that
    the comma operator can be used to avoid braces, as in
     
    if (e) x = y, return z;
     
5) Allow immediate constants. Currently, there is only one special
    case, that of a character array. One can say char *p = "string";
    and have the string squirreled away and the (magic) address
    stuffed into the pointer. Why not int *p = &5; where the
    integer five is whisked away and replaced by its address.
    Sure would eliminate a lot of housekeeping variables.
     
6) Eliminate arrays altogether! Well not exactly, but make all
    arrays vectored in all dimensions. This would show
    those quiche eaters what a real tough language C is :-).
    Array syntax would still be available of course, but would
    be translated into glorious pointer notation. And it wouldn't
    matter whether a variable was defined differently than it
    was declared (char x[] or char *x).
     
7) Negative Structure Offsets. After reading those last few, I don't
    expect anyone to take me seriously, but I am serious. These
    can be real useful for such things as communications, where
    each block is wrapped in another layer. We can even use the
    entry keyword for this (quick before ANSI takes it out :-).
    The advantage is real and twofold. First, all offsets are]
    known at compile time, and second, if the data is redone,
    only the code that uses it need be recompiled. This could
    be a win, especially if other programs used the same data.
     
8) Allow formal arguments to be declared AFTER the opening brace.
    This would allow prioritization of register variables.
     
Well that should be enuf to chew on. I'm not really seriously
suggesting munging the language. This is just a thought experiment
in the art of the possible. I'm not even going to mention such
radical changes as explicit end statements (gid rid of braces),
an #include MACRO from FILE, or using backquotes as explicit
substition characters (to allow concatenation of tokens, but it
would break strings with backquotes in them, be them ever so few)
as these would be major redefinitions. Now I will go on vacation
until all the flames die out :-).
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4199
          for JMS@ARIZMIS; Thu,  8-MAY-1986 07:56 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 09:47:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014808; 7 May 86 3:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024704; 7 May 86 3:42 EDT
From: Arthur David Olson <ado%elsie.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <6092@elsie.UUCP>
Date: 6 May 86 22:40:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> The. . .header file that I mentioned a few days ago. . .
> contains the following:
>
> typedef int    bool;            /* boolean data */
> #define     false    0
> #define     true    1
     
My recommendation to folks would be to use the defines that appear in
the 4.?bsd version of "curses.h"--
     
    # define    TRUE    (1)
    # define    FALSE    (0)
     
--on a conditional basis in any "nifty_header.h" file, a la:
     
    #ifndef TRUE
    #define TRUE    (1)
    #define FALSE    (0)
    #endif
     
Using the "unnecessary" parentheses that appear in "curses.h" will prevent
any "redefined to a different value" diagnostics if you both
    #include "curses.h"
and
    #include "nifty_header.h"
while conditionalizing the definitions as above will prevent
"redefined (though not to a different value)" diagnostics if
you include both files in the order shown above.
--
    UUCP: ..decvax!seismo!elsie!ado        ARPA: elsie!ado@seismo.ARPA
    DEC, VAX, Elsie & Ado are Digital, Borden & Shakespeare trademarks.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4291
          for JMS@ARIZMIS; Thu,  8-MAY-1986 08:01 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014865; 7 May 86 4:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024700; 7 May 86 3:42 EDT
From: Arthur David Olson <ado%elsie.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <6091@elsie.UUCP>
Date: 6 May 86 22:28:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> . . .All the PCC impementations I've checked don't test the ["1" in a
> "while (1)"] even when you don't turn the optimizer on.  Our old PDP-11
> Ritchie compiler does generate the test, but the standard -O optimizer
> removes it. . .
     
If I recall my ancient history aright, the Version 6 C compiler generated the
constant test, and the Version 6 optimizer failed to remove it.
--
PDP is a Digital Equipment Corporation trademark.
--
    UUCP: ..decvax!seismo!elsie!ado        ARPA: elsie!ado@seismo.ARPA
    DEC, VAX, Elsie & Ado are Digital, Borden & Shakespeare trademarks.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4360
          for JMS@ARIZMIS; Thu,  8-MAY-1986 08:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015233; 7 May 86 6:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026413; 7 May 86 5:58 EDT
From: G M Anderson <gma%ssc-vax.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: PC .COM files and memory resident code.
Message-ID: <733@ssc-vax.UUCP>
Date: 6 May 86 19:37:17 GMT
Xref: seismo net.micro.pc:8619 net.lang.c:9073
To:       info-c@BRL-SMOKE.ARPA
     
I am interested in creating a resident interrupt driven
process in C, and I don't really care if it is a .COM, .EXE, or
whatever.  I understand how to do it in assembly, but it appears
very difficult to do in C because of the jumping around code,
replacing addresses, getting addresses, and the sticky little stack
segment problem.  (By the way, if there is no defined stack segment,
where does the stuff stack up?)
     
If anyone knows how to:
  1) Create interrupt driven code with C.
  2) Make that code memory resident without assembly modification.
  3) The proposed memory resident addressing agreements between MS,
     and the popup utility people.
     
I would greatly appreciate your help.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4461
          for JMS@ARIZMIS; Thu,  8-MAY-1986 08:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015267; 7 May 86 6:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026203; 7 May 86 5:50 EDT
From: "Wayne A. Christopher" <faustus%cad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <277@cad.UUCP>
Date: 6 May 86 04:10:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Hmm, so now we see from which soapbox Root Boy is speaking... I don't like
to criticize people's personal preferences, but when you are writing code
that other people have to maintain, strange coding practices like this are
as bad as bugs...  I almost wish that lint would catch non-standard style
in addition to portability problems...
     
    Wayne

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4557
          for JMS@ARIZMIS; Thu,  8-MAY-1986 08:22 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015269; 7 May 86 6:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026285; 7 May 86 5:53 EDT
From: "Wayne A. Christopher" <faustus%cad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <276@cad.UUCP>
Date: 6 May 86 03:52:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The thing that RBJ seems to be annoyed about is the fact that lint
generates error messages whenever you ignore the return value of
close(), unlink(), etc, and it is quite ugly to put (void) in
everywhere.  However, in my experience if you use the right flags
these are the only sort of errors you should ignore (and malloc
pointer problems, of course).  I would say that the most useful
messages lint gives you is argument type/number mismatches...
     
    Wayne

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4717
          for JMS@ARIZMIS; Thu,  8-MAY-1986 08:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa17043; 7 May 86 8:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028136; 7 May 86 7:51 EDT
From: Toby Gottfried <toby%felix.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <1138@felix.UUCP>
Date: 5 May 86 20:09:25 GMT
Xref: seismo net.lang.c:9074 net.lang.c++:204
To:       info-c@BRL-SMOKE.ARPA
     
In article <763@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>Now, if only somebody would invent an architecture where all objects,
>including dynamicly allocated objects, are isolated in memory, then any
>subscript error would cause an immediate memory fault.
     
    Burroughs did exactly this in their Large Systems
    over 20 years ago.
     
>You'd still be vulnerable to completely wild pointers (but less likely
>in a huge address space),
     
    Not a problem - the address space isn't flat.
     
>and overflow of an array inside a structure might be untrappable,
>but otherwise it sounds like a great machine to do your debugging on.
     
    It is.
     
--
Toby Gottfried
 FileNet Corp     {ucbvax,ihnp4,decvax}!trwrb!felix!toby
Costa Mesa, CA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4873
          for JMS@ARIZMIS; Thu,  8-MAY-1986 08:59 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 10:30:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005911; 7 May 86 23:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003473; 7 May 86 23:43 EDT
From: "Sundar R. Iyengar" <sundar%cwruecmp.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++,net.arch
Subject: iAPX 432
Message-ID: <1474@cwruecmp.UUCP>
Date: 6 May 86 13:50:37 GMT
Xref: seismo net.lang.c:9075 net.lang.c++:205 net.arch:3295
To:       info-c@BRL-SMOKE.ARPA
     
>> >Now, if only somebody would invent an architecture where all objects,
>> >including dynamicly allocated objects, are isolated in memory, then any
>> >subscript error would cause an immediate memory fault.
>>
>>    If I'm not mistaken, this was done on the iAPX432, using a capability-
>> based addressing scheme.  Dimmed the lights.  You could probably construct
>> such an environment on the 80286, but no one does, probably for efficiency
>> reasons.
     
> One problem with the 432's approach was that it was very extreme; I don't
> think it's good to say "the 432 tried these approaches and it was too slow,
> therefore the checking can't be efficiently implemented."
     
If I remember correctly, iAPX 432 is a vertically microcoded machine.
On top of that, the microcode is generated in one chip and then used in
another.  These two are some more reasons why iAPX is slow.
     
-- sri

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4801
          for JMS@ARIZMIS; Thu,  8-MAY-1986 08:59 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 05/08/86 at 10:27:20 CDT
Received: from WISCVM.WISC.EDU by SRI-KL.ARPA with TCP; Tue 6 May 86
  11:53:40-PDT
Received: from (MANSFIEL)DHDEMBL5.BITNET by WISCVM.WISC.EDU on 05/06/86
  at 12:08:58 CDT
Date:           Tue, 06 May 86 16:14:20 n
To:  info-vax@sri-kl.arpa
From:             Niall Mansfield
  <MANSFIELD%DHDEMBL5.BITNET@WISCVM.WISC.EDU>
Organisation:   European Molecular Biology Laboratory
Postal-address: Meyerhofstrasse 1, 6900 Heidelberg, W. Germany
Phone:          (6221)387-0 [switchboard]  (6221)387-247 [direct]
Subject:        Problem with C and Link
     
     
If the file T.C contains
     
extern  char    *sto;
main()
        {
        f("bongo");
        printf("%s\n", sto);
        }
     
and T2.C contains
     
char    sto[100] = 0;
f(s)
        char    *s;
        {
        strcpy(sto, s);
        printf("in func, sto is %s\n", sto);
        }
     
and a program is made from the two by the commands
     
$ cc t
$ cc t2
$ link t,t2,sys$library:vaxcrtl/opt
     
then running t gives the output
     
in func, sto is bongo
%SYSTEM-F-ACCVIO, access violation, reason mask=01, virtual address=676E6F62, PC
=0000423B, PSL=0BC00005
%TRACE-F-TRACEBACK, symbolic stack dump follows
module name     routine name                     line       rel PC    abs PC
     
                                                           0000423B  0000423B
                                                           00002941  00002941
T               main                                5      0000002B  0000042B
     
As far as I can see, the linker is not correctly resolving
T's reference to "sto". (c.f. what is printed if you insert the line
        printf("%d\n", sto);
in both files).
     
Is there something wrong? How do I do what I want, portably?
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6510
          for JMS@ARIZMIS; Thu,  8-MAY-1986 11:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 13:11:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018549; 8 May 86 13:43 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a015628; 8 May 86 13:22 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA14418; Thu, 8 May 86 13:22:37 edt
Date: Thu, 8 May 86 13:22:37 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605081722.AA14418@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, sfsup!mjs@seismo.ARPA
Subject: Re: C Builtin Funxions
     
    In article <1700010@umn-cs.UUCP> herndon@umn-cs.UUCP writes:
    >
    >  I feel compelled to go on record as being VERY MUCH AGAINST
    >having reserved procedure names in C.  For those of us who have
    >ever written stand-alone code for PDP-11s, VAXen, ..., it is
    >a simple matter, as things stand, to compile our programs,
    >and then have them linked with our own versions of 'putc',
    >'read', etc. stashed in stand-alone libraries.
    > ...
    >In addition, porting the C compiler to a different OS on the
    >same machine only requires that the libraries be re-written
    >(almost always).  Building those functions into the language
    >implies that there will be much code for special casing those
    >functions.
     
    Nowhere is it required that the compiler have any special knowledge of
    the reserved names in the library.  Yes, *some* compilers will
    undoubtedly have *some* special knowledge of *some* of those names,
    but the ANSI spec does *NOT* *require* the compiler to know anything
    about any reserved library names.
     
    Please, do NOT flame about statements that are not made in the spec.
    There are enough statements that ARE made in the spec that may be worth
    flaming about (although I hope that rational discusssion, rather than
    flames, result).
     
He didn't say it would be *required*. Neither did I. We don't want it
even allowed, unless we can turn it off. I would even go one step
further and require that you explicitly turn it on for each function.
     
    If you don't have a copy of the current state of the
    proposed standard, GET ONE!
     
Yeah, fork over another $20 for an out-of-date copy. Possibly the one you
already have. They should be free, posted to net.sources, and distributed
by the NIC or some such. See quote at end of article.
     
        Marty Shannon
    UUCP:    ihnp4!attunix!mjs
    Phone:    +1 (201) 522 6063
     
    Disclaimer: I speak for no one.
     
    "If I never loved, I never would have cried." -- Simon & Garfunkel
     
"Well I've paid all the dues I want to pay" -- S & G
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6614
          for JMS@ARIZMIS; Thu,  8-MAY-1986 11:51 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 13:16:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018825; 8 May 86 13:56 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a015983; 8 May 86 13:39 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA14458; Thu, 8 May 86 13:39:39 edt
Date: Thu, 8 May 86 13:39:39 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605081739.AA14458@icst-cmr.ARPA>
To: gelfand%valid.uucp@BRL.ARPA, gwyn@BRL.ARPA
Subject: Re:  questions from using lint
Cc: info-c@BRL-SMOKE.ARPA
     
????-->    > C is the only language that I can remember that has a separate
????-->    > program (lint) to find and report compiler errors in source code.
     
GWYN-->    [most of reply deleted]
     
Because I agree with everything you said here.
     
GWYN-->    In short, I see nothing wrong with the present set-up.
     
First off, let us remember that `cc' is NOT the C compiler. It is
just the coordinator for all the phases that build programs.
Therefore, I see no inconsistency with allowing `cc' to call lint
if a given option is specified. This might encourage non-unix
vendors to include lint with their products.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6774
          for JMS@ARIZMIS; Thu,  8-MAY-1986 12:04 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/08/86 at 13:30:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018899; 8 May 86 13:57 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a016313; 8 May 86 13:44 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA14465; Thu, 8 May 86 13:43:46 edt
Date: Thu, 8 May 86 13:43:46 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605081743.AA14465@icst-cmr.ARPA>
To: bentley!kwh@seismo.ARPA, info-c@BRL-SMOKE.ARPA
Subject: String Compare
     
    A more general mechanism is
    #define strrel(a,R,b)    (strcmp(a, b) R 0)
    which allows you to write strrel(a,==,b).
     
I *like* it! In fact, I think this is sufficiently general enuf to
be called simply `string'.
     
    Some consider this to be abuse of the preprocessor.
     
Well, they're just a bunch of wimps!
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1108
          for JMS@ARIZMIS; Thu,  8-MAY-1986 21:00 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 05/08/86 at 22:43:01 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Thu 8 May 86
  02:08:46-PDT
Received: from umass-cs by csnet-relay.csnet id ar10380; 8 May 86 1:37 EDT
Date:     Tue, 6 May 86 12:02 EST
From:     Stride 440 User <HELLER%umass-cs.csnet@CSNET-RELAY.ARPA>
To:       info-vax@SRI-KL.ARPA
Subject:  VAX11-C & the IV entry-mask bit.
     
We have some 240 little access functions written in C which we want integer
overflow to be caught by the hardware.  Since these routines are called
frequently we don't want to add the overhead of a call to LIB$INT_OVER()
every time an one of these access functions is called.  Instead we would
like the IV bit set in the entry masks of these routines.  VAX11C does
not set this bit.  Is there some way to either make VAX11C set this bit?
Or some way of modifying the .OBJ or .EXE file later?  We are building
these functions into a shareable image file.
     
        Robert Heller (Heller@UMass-CS.CSNET)
or        James Burrill (Burrill@UMass-CS.CSNET)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1685
          for JMS@ARIZMIS; Thu,  8-MAY-1986 22:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 00:06:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027467; 8 May 86 22:42 EDT
Received: from brl-tgr.arpa by SMOKE.BRL.ARPA id a024045; 8 May 86 22:30 EDT
Received: from mitre-bedford.arpa by TGR.BRL.ARPA id a025504; 8 May 86 22:26 EDT
Full-Name: James R. Vanzandt
Message-Id: <8605090225.AA14975@mitre-bedford.ARPA>
Organization: The MITRE Corp., Bedford, MA
To: info-c@BRL-TGR.ARPA, info-ibmpc@USC-ISIB.ARPA, delftcc!sam@NYU.ARPA
Subject: lint
Date: Thu, 08 May 86 22:25:34 -0500
From: "James R. Van Zandt" <jrv@MITRE-BEDFORD.ARPA>
     
>> I'm aware of four lint-type programs for checking C code on an MS-DOS
 machine:
>>
>> PC-LINT   Tecware                              $ 99
>> PC-Lint   Gimpel Software                      $139
>> Pre-C     Phoenix Computer Products Corp.      $395
>> Lint      Wizard Systems Software, Inc.        $450  (bundled with compiler)
>>
>> Can anyone report experience with these or others, or point to
>> published reviews?
     
All the responses but one were requests for information.  Here's the one:
     
> We are using the Wizard C compiler and BSD 4.3 to develop a large
> (~150,000 lines) system that will run under UNIX and MS-DOS.  The Wizard
> compiler reports intra-module errors and warnings.  The lint option
> will create a lint library and do inter-module checking.  Overall the
> Wizard system catches the same errors that the BSD lint catches and
> often reports more warnings.  The whole package is well worth the price
> (especially since you get library sources and can get an update service
>
from Wizard).
>
> --
> Brad Davis      {ihnp4, decvax, seismo}!utah-cs!b-davis
>                 b-davis@utah-cs.ARPA
     
Now I'm trying to decide whether (1) nobody else has buggy C code, (2) nobody
else wants to ADMIT to having buggy C code, or (3) lint is hazardous, and
few users survive :-).
     
                              - Jim Van Zandt
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3222
          for JMS@ARIZMIS; Fri,  9-MAY-1986 01:02 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 02:41:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027941; 9 May 86 1:13 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a024845; 9 May 86 1:02 EDT
Received: from (MAILER)UREGINA1.BITNET by WISCVM.WISC.EDU on 05/09/86
  at 00:02:12 CDT
Received: by UREGINA1 (Mailer X1.23b) id 6967; Thu, 08 May 86 23:00:23
  CST
Date:         Thu, 8 May 1986 22:59 CST
From:           Craig Knelsen <CRAIG%UREGINA1.BITNET@wiscvm.ARPA>
Subject:      Aztec C compiler bug(?)
To:  INFO-C@BRL-SMOKE.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
#include        <quickdraw.h>
#include        <window.h>
#include        <control.h>
     
main()
{
    register ControlHandle        p;
     
    f((*p)->contrlTitle);
}
----
     
-? cc c.c
c.c: line 9: error 29: illegal use of structure:
     
Compiler:        Aztec C 1.06G for the Macintosh
     
        The problem seems to result from the fact that Aztec changed the
declaration of the member 'contrlTitle' in control.h:
     
        1.06D release:
                        char        contrlTitle[1];
        1.06G release:
                        Str255        contrlTitle;
     
where Str255 is a typedef for: char *
     
        I have tried this example under the Vax 4.2bsd and Sun 2.0 compilers
with no complaints from either. Changing the declaration back to what it
was in the 1.06D release makes the problem disappear. Removing the register
storage class declaration doesn't make a difference as far as the error is
concerned.
     
     
                                                Craig Knelsen
                                                Dept. of Computer Science
                                                University of Regina
                                                Regina, Sk.
     
UUCP: {ihnp4 | utcsri | alberta} !sask!regina!cknelsen

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3608
          for JMS@ARIZMIS; Fri,  9-MAY-1986 01:33 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 05/09/86 at 03:17:14 CDT
Received: from USC-ECLC.ARPA by SRI-KL.ARPA with TCP; Wed 7 May 86 18:33:19-PDT
Received: from ECLD by ECLC with DECnet; Wed 7 May 86 18:30:01-PDT
Date: Wed 7 May 86 18:29:55-PDT
From: Christopher Ho <Chris%ECLD@USC-ECLC.ARPA>
Subject: Re: Problem with C and Link
To: Mansfield%DHDEMBL5.Bitnet@WISCVM.WISC.EDU
cc: Info-Vax@SRI-KL.ARPA
Office: Ucc 178 (213)743-2957
Message-ID: <12204916720.60.CHRIS@USC-ECLD.Internet>
     
> If the file T.C contains
> extern char *sto;
> ...
     
How about using the correct declaration:
     
extern char sto[];
-------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5476
          for JMS@ARIZMIS; Fri,  9-MAY-1986 05:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 07:18:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000647; 9 May 86 8:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027890; 9 May 86 7:48 EDT
From: faustus%cad.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <287@cad.UUCP>
Date: 6 May 86 18:08:34 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <256@valid.UUCP>, gelfand@valid.UUCP writes:
     
> I have been programming for many years (over 20) in many different
> languages, and C is the only language that I can remember that
> has a separate program (lint) to find and report compiler errors in
> source code.
     
First, lint doesn't report ERRORS -- it reports possible problems.  Second,
there is no other way you can check things like argument types (except for
prototyping, which will make lint much less useful), since you generally
compile only one .c file at a time.
     
    Wayne

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5616
          for JMS@ARIZMIS; Fri,  9-MAY-1986 05:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 07:36:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001009; 9 May 86 8:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027766; 9 May 86 7:45 EDT
From: Rob McMahon <cudcv%daisy.warwick.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <147@daisy.warwick.UUCP>
Date: 7 May 86 10:22:04 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <412@brl-smoke.ARPA> gwyn@brl.ARPA writes:
>typedef int    bool;            /* boolean data */
>#define     false    0
>#define     true    1
     
What about
        typedef enum { false, true } bool;
?
--
UUCP:   ...!mcvax!ukc!warwick!cudcv
JANET:  cudcv@uk.ac.warwick.daisy
ARPA:   cudcv@daisy.warwick.ac.uk
PHONE:  +44 204 523037
Rob McMahon, Computer Unit, Warwick University, Coventry CV4 7AL, England

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5715
          for JMS@ARIZMIS; Fri,  9-MAY-1986 06:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 07:39:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001157; 9 May 86 8:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028062; 9 May 86 7:54 EDT
From: "John R. Levine" <johnl%ima.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: arguments in registers
Message-ID: <109@ima.UUCP>
Date: 6 May 86 15:36:51 GMT
Xref: seismo net.lang.c:9080 net.unix-wizards:18103
To:       info-c@BRL-SMOKE.ARPA
     
In article <1205@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>In article <155@cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>>[Passing arguments in registers] would be fine if C had nested
>>procedures or inlines or something, but a disaster otherwise.
>
>In fact, a compiler is free to optimise any function into inline code,
     
Actually, you can always pass arguments in registers if you're smart about it.
The compiler for the IBM RT/PC does.  (A clever idea added after I stopped
working on it.)  The first few arguments to a procedure are always passed in
registers, but space is left for them in the stack frame.  If they aren't
declared register in the routine, the routine's prolog saves them.  Note that
this saves code space, since you have one set of store instructions in the
routine's prolog rather than replicating the code at each call.  If the
arguments are declared register, well, they're already in registers.
     
As far as passing args to system calls in registers goes, the big win there
is that the kernel's job of validating the arguments is made easier.  If the
args are in memory, the kernel has to make sure the address is valid, go
through some address mapping calculations, possibly take page faults, and so
forth.  It's much easier if the user program puts the args in registers, since
then the validation is done for free by hardware.
--
John R. Levine, {ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl
Levine@YALE.EDU
     
The opinions expressed above are those of a 12-year-old hacker who has
broken into my account and not those of any person or organization.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5905
          for JMS@ARIZMIS; Fri,  9-MAY-1986 06:06 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 07:59:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001647; 9 May 86 8:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027851; 9 May 86 7:47 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Signed Characters
Message-ID: <724@steinmetz.UUCP>
Date: 6 May 86 19:07:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <570@tjalk.UUCP> dick@vu44.UUCP (Dick Grune) writes:
>I just dropped into this, and it may have been said before, but if there
>is char and unsigned char, I expect the char to be signed.
     
X3J11 (ANSI C committee) added "signed char". If you assume that your char is
signed your code is highly non-portable.
--
    -bill davidsen
     
    seismo!rochester!steinmetz!--\
       /                               \
ihnp4!              unirot ------------->---> crdos1!davidsen
       \                               /
        chinet! ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5830
          for JMS@ARIZMIS; Fri,  9-MAY-1986 06:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 07:51:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001191; 9 May 86 8:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028275; 9 May 86 7:58 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <857@ttrdc.UUCP>
Date: 6 May 86 09:55:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <12329@ucla-cs.ARPA>, jimc@ucla-cs.ARPA (Jim Carter) writes:
>I think it's useful!  As written, of course, it's semantically invalid,
>but what you really mean is "v <= e" (sic) or, to demonstrate where it's
>really useful,
>     array[horrendous] [subscript] [list] <= bigexpr;
>  rather than
>     if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
>Now "<=" already means something else so this syntax is not acceptable.
>How about "v < = e" with a mandatory blank?  This is atrocious human
>engineering but at least is parseable.  Anybody have any better ideas?
>--
>James F. Carter            (213) 206-1306
>UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024
>UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc  ARPA:jimc@locus.UCLA.EDU
     
First, one could use the preprocessor to help:
#define UPMAX(i,j)    if ((i) < (j)) (i) = (j)
...
UPMAX(array[h][s][l],bigexpr);
     
While the output of cpp would look real messy, comp would handle this just
fine.  Of course, you lose (as with any macro which uses an argument more
than once) if the arguments have side effects such as ++ (but that isn't
the case here, right?).  Or if you know that the optimizer is not smart
enough to catch this and will evaluate the entire array[h][s][l] including
subscripts twice (as well as bigexpr), you can force temp variables:
     
FOO array[I][J][K];
...
FOO *atmp;
FOO btmp;
...
     
atmp = &(array[h][s][l]);
btmp = bigexpr;
UPMAX(*atmp,btmp);
     
As for the lousy human engineering in requiring extra blanks in certain
expressions, don't we have that already in C, e.g.:
     
a = b/*c;    /* did this mean divide b by *c, or to start a comment? */ ;
a=*b;        /* compiler complains about "ambiguous assignment" here */
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6173
          for JMS@ARIZMIS; Fri,  9-MAY-1986 06:27 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 08:11:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001671; 9 May 86 8:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027856; 9 May 86 7:48 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Infinite loops
Message-ID: <725@steinmetz.UUCP>
Date: 6 May 86 19:22:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <116@cbmvax.cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>In article <117@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>>
>>do ... while(1);
>>while(1) ...
>>for(;;) ...
>>
>>are all widely-used idioms for unconditional looping in C.
>>I personally prefer the latter, but the choice is just a
>>matter of taste.  Any reasonable compiler will generate
>>efficient code for all three constructs.
>
>#define loop for(;;)
>
>This is a clean way to do it, but be aware that there is no obvious stopping
>point, and soon C purists will soon be declaring that your code has been
 tainted
>by exposure to noxious influences from Algol 68 or worse...
>
     
You could change the definition(s) to:
  #define loop for(;;){
  #define endloop }
     
Or, as I have seen in a few programs:
  #define ever (;;)
--
    -bill davidsen
     
    seismo!rochester!steinmetz!--\
       /                               \
ihnp4!              unirot ------------->---> crdos1!davidsen
       \                               /
        chinet! ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6672
          for JMS@ARIZMIS; Fri,  9-MAY-1986 07:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 09:18:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004540; 9 May 86 10:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001526; 9 May 86 9:50 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.apl
Subject: Re: C Builtin Functions
Message-ID: <1418@mmintl.UUCP>
Date: 6 May 86 19:03:38 GMT
Xref: seismo net.lang.c:9082 net.lang.apl:199
To:       info-c@BRL-SMOKE.ARPA
     
In article <788@bentley.UUCP> kwh@bentley.UUCP writes:
>I can feel the flames ("More operators?  It's getting as bad as APL!").
>
>Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
"More operators?  It's getting as good as APL!" -- except that it still
falls way short in this respect.  I'm serious; APL does *not* have too many
operators.  It does have too little structure.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6770
          for JMS@ARIZMIS; Fri,  9-MAY-1986 07:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 09:21:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004610; 9 May 86 10:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001539; 9 May 86 9:51 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <1419@mmintl.UUCP>
Date: 6 May 86 20:17:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <12329@ucla-cs.ARPA> jimc@ucla-cs.UUCP (Jim Carter) writes:
>I think it's useful!  As written, of course, it's semantically invalid,
>but what you really mean is "v <= e" (sic) or, to demonstrate where it's
>really useful,
>     array[horrendous] [subscript] [list] <= bigexpr;
>  rather than
>     if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
>Now "<=" already means something else so this syntax is not acceptable.
>How about "v < = e" with a mandatory blank?  This is atrocious human
>engineering but at least is parseable.  Anybody have any better ideas?
     
What you talking about isn't "<=".  It's "\/=" (to use a notation which
showed up here recently).  I.e., v = min(v,e), not v = v < e.  The latter
really is pretty useless.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6996
          for JMS@ARIZMIS; Fri,  9-MAY-1986 08:30 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 09:41:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004752; 9 May 86 10:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001634; 9 May 86 9:53 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.unix,net.unix-wizards,net.lang.c
Subject: Re: faster malloc anyone?
Message-ID: <2699@utcsri.UUCP>
Date: 4 May 86 18:19:43 GMT
Xref: seismo net.unix:8192 net.unix-wizards:18105 net.lang.c:9084
To:       info-c@BRL-SMOKE.ARPA
     
In article <433@geowhiz.UUCP> larry@geowhiz.UUCP (Larry McVoy) writes:
>each call to strsav().  So, I wrote the following little chunks of code and
>am requesting comments.  Can anyone point out why these are a *bad* idea
>(aside from the obvious upper bound problem)?  Another problem is that
>free() won't work on these blocks...
    stay tuned...
>
>new.h:
># define    BLKSIZ        8096
>char* new();
>
>utils.c:
>/* utils.c -- strsav(), new() */
># include    "new.h"
>
>    char*
>strsav(s)
>    register char* s;
>{
>    char* strcpy();
>    register char* t;
>
>    t = new(strlen(s) + 1);    /* strings smaller than BLKSIZ */
>    return strcpy(t, s);
>}
>
>
>/*------------------------------------------------------------------02/May/86-*
> * new(size) - fast(??) memory allocator
> *
> * Inputs    -> (int)
> *
> * Returns   -> (char*)
> *
> * Results  ->The memory is allocated in big contiguous blocks via calloc(3).
> *        If the requst can fit in what's left of a block, then a block
> *        of the size requested is returned.  Otherwise, the rest of the
> *        block is discarded & a new block is allocated.
> *
> * Warning   -> This would seem to work great for little stuff.  Don't use it
> *        for big blocks.  Absolute largest allocatable block is BLKSIZ.
> *        For speed NO CHECK IS PERFORMED TO SEE IF THE REQUEST IS LESS
> *        THAN BLKSIZ.  BLKSIZ is guaranteed to be 1k or bigger (usually
> *        much bigger).
> * Revisions:
> *-----------------------------------------------------------------larry-*/
>    char*
>new(size)
>    register unsigned size;
>{
>    register char* blk;
>    static char* block = NULL;
>    static unsigned bytes_left = 0;
>
>    if (bytes_left < size)
            /* bytes_left should be set to BLKSIZ here */
>    if (!(block = calloc(1, BLKSIZ)))
>        syserr("calloc in new");
>
>    blk = block;
>    block += size;
>    bytes -= size;
     return blk;        :-)
>}
>--
     
If the storage occupied by these strings can be released all at once,
the following 'new' can be used:
     
     
struct str_block{
    struct str_block *sb_link;
    char sb_chars[ BLKSIZ ];
} *allocated = NULL;
unsigned bytes_left = 0;
char* block;
     
char *new(size)
register unsigned size;
{   register char* blk;
    register struct str_block *new_blk;
     
    if (bytes_left < size){
    if ((new_blk =(struct str_block*) malloc(sizeof( struct str_block)))
        == NULL)
        syserr("malloc in new");
    bytes_left = BLKSIZ;
    new_blk->sb_link = allocated;
    allocated = new_blk;
    block = new_blk->sb_chars;
    }
    blk = block;
    block += size;
    bytes_left -= size;
    return blk;
}
     
/*
 * this subroutine frees up all allocated memory
 */
forget(){
    register struct str_block *p;
    while( (p = allocated) != NULL ){
        allocated = p->sb_link;
        free(p);
    }
    bytes_left = 0;
}
     
I used a similar approach on a program I wrote recently - many small structs
needed to be allocated and reused during a certain phase of execution, and
then they were all released at once. So I got them from malloc in blocks of
about 200, and handled them on linked lists. When I was done, I released all
the blocks, which were kept on another linked list.
     
An enhancement: maintain separate 'allocated, bytes_left, block'
triplets for independent storage categories - then each category can be
'forgotten' independently of the others.
     
--
"For every action there is an equal and opposite malfunction"
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9804
          for JMS@ARIZMIS; Fri,  9-MAY-1986 13:43 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 14:18:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005087; 9 May 86 10:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001673; 9 May 86 9:54 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: LINT
Message-ID: <2452@watmath.UUCP>
Date: 6 May 86 14:26:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
  > From rbj@icst-cmr (Root Boy Jim) Fri May  2 17:28:02 1986
  > Yes, but it all depends on what you're willing to put up with. I find it
  > terribly ugly having to cast printf's or close's to void.
Not only is it ugly, it's wrong.  Didn't you read in the man page where
it says that these functions return ERROR STATUSES?  Do you believe that
nothing will ever go wrong?  What if programs such as cat(1) didn't check
these error statuses, think what a mess the world would be in.  I mean
if one ran cat from a tape and an I/O error occured, it would probably
just treat it as end-of-file and not tell you that the rest of the
file couldn't be read, and if your file-quota was exhaused cat wouldn't
notice that it couldn't flush its buffers properly and there you would
be with an empty file and cat telling you that everything ran fine.
     
  > From: woody@juliet.caltech.edu (William E. Woody)
  > Here here!  Though (whenever possible) I try to run my code through lint,
  > I think I only use about a fifth of what lint complains (screams, shouts,
  > moans, groans) about.
I too used to think that most of what lint complained about was crap.
I also noticed an awful lot of things that it didn't complain about but
should have.  So I took the source and turned on all the options that
normally make it shut up about certain things, and then added even more
checks than lint ever had before.  Then I looked at all the crap in the
output and gradually taught lint which one's really were crap and
shouldn't be issued.  Now I have a version of lint with which I use
four fifths of what it complains about.
For instance,
    int i;
    long l;
    short s;
    char *a,*b;
    i=l; s=i;                 /* these both generate warnings */
    i=(int)l; s=(short)i;     /* NO warnings */
    l=i<<100;                 /* warning */
    open("file",0);           /* warning */
    (void)open("file",0);     /* (optional) warning */
    strcpy(a,b);              /* NO warning */
If you assign something that is larger to something that is
smaller lint warns you, but if you explicitly cast it to indicate
that you know it isn't a mistake you get no warning.
There is also an /*OPTRESULT*/ directive which is used like the
/*VARARGS*/ directive in the function definition.  strcpy() is
so defined, and so lint doesn't care whether you look at its
result or not.  But open() is not defined with this directive,
so lint does expect you to look at its return value.  With things
set up this way, it is almost always an error to cast any function
to (void), so lint warns about this too (only as an optional
summary, once per function, not per call).
     
Too many times I've seen people try to make code lint cleanly
by simply casting all the ignored function returns to (void)
and by using lots of options to tell lint not to complain about
certain things.  Lint really can be useful.  I don't know why
the people who support it don't try to improve it.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0855
          for JMS@ARIZMIS; Fri,  9-MAY-1986 14:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 15:54:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018079; 9 May 86 16:46 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id aa14367; 9 May 86 16:31 EDT
Date:     Fri, 9 May 86 16:26:01 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Rob McMahon <cudcv%daisy.warwick.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Boolean Operators Slighted in C
     
One can define "bool" to be a variety of things,
including an enumeration type, but as C was designed
the result of a relational expression (for example)
is an int; that's what Boolean data in C really "is".

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1185
          for JMS@ARIZMIS; Fri,  9-MAY-1986 14:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 16:30:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005113; 9 May 86 10:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001865; 9 May 86 10:00 EDT
From: Greg Noel <greg%ncr-sd.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Functions
Message-ID: <479@ncr-sd.UUCP>
Date: 8 May 86 03:46:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I'm surprised that with all this discussion on built-ins, nobody has pointed
out how the C standard specifies that it should work.  My copy of the standard
is pretty old and has been stolen, so perhaps it was removed in a later
specification?
     
In article <788@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>In article <1700010@umn-cs.UUCP> umn-cs!herndon writes:
>>I feel compelled to go on record as being VERY MUCH AGAINST having reserved
>>procedure names in C. ......
>>One of the (in my opinion) great strengths of the C language is that it
>>does not have 'built-in' functions.
>
>After rethinking this question, I've decided that it *does*.  However, the
>builtins are all punctuation ("%"), whereas the library functions are all
>alphanumeric ("abs").
>    .......
>Here's my opinion.  Using punctuation for builtins (and alphanumerics for
>library functions) is a nice way to keep them straight; let's keep it that
>way.  If certain functions are so trivial that it's worthwhile for them to
>be expanded inline (are there any besides abs(), min(), and max()?), then
>they should have non-alphanumeric spellings; i.e. they should be operators.
     
No, what the standard does (did?) is reserve all names that begin with one
or two underscores.  There is some difference in meaning between the two,
but it's not important here.  Pick one of these names, say, __OPEN, and
build it in to the compiler (i.e., it produces in-line code).  Then you
simply act as if there were an implicit "#define open __OPEN" at the head
of each program so that under normal circumstances the built-in version
is used.  If you want to provide your own "open" routine, all you have to
do is have an "#undef open" in your program and the external semantics we
all know and love are used instead.
     
This seems to solve both of your needs without turning C into APL.  If this
technique is still in the standard, this debate is moot.  If it's not, then
I, for one, would like to know why it was removed.
     
Aside:  I think that all of the machine-specific names should be in a file
somewhere and the preprocessor should implicitly read it, as if there were
a "#include <standard.h>" (or equivalent) as the first line of every
program.  This would have the #defines for the machine, architecture, OS,
and whatever else it takes to describe the environment.  The header for
the standalone environment simply wouldn't have the #defines for whichever
syscalls are built-in (like __OPEN above) but might have #defines for, say,
abs, l3tol/lto3l, or memcpy if it made sense.
--
-- Greg Noel, NCR Rancho Bernardo    Greg@ncr-sd.UUCP or Greg@nosc.ARPA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1283
          for JMS@ARIZMIS; Fri,  9-MAY-1986 15:04 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 16:42:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005947; 9 May 86 10:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002247; 9 May 86 10:10 EDT
From: Steve Schlaifer x3171 156/224 <steve%jplgodo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <778@jplgodo.UUCP>
Date: 6 May 86 17:01:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <256@valid.UUCP>, gelfand@valid.UUCP (Brooks Gelfand) writes:
>
> I have been programming for many years (over 20) in many different
> languages, and C is the only language that I can remember that
> has a separate program (lint) to find and report compiler errors in
> source code. All of the other languages I have used have this function
> built into the compiler. Perhaps because UNIX is a programmers
> system rather than a production system this was felt to be unnecessary.
> In most production systems the programs spend more time executing than
> compiling; while in a development system most of the time is spent editing
> and compiling. Thus running lint each time would add to the load
> on the system.
     
Actually, having lint be a seperate program fits nicely with the original
software tools philosophy of unix.  That is, a program should do one thing
and do it well.  A compiler within this philosophy should compile whatever
you give it so long as it can make sense of it.  A seperate tool (lint in this
case) should exist to point out things that you are doing which are
questionable.  The idea here is that the programs are then simpler to build,
maintain and debug since they each have a simpler function to perform.
     
For a better discussion of this than I can give see the AT&T Bell Laboratories
Technical Journal of October 1984 (Vol 63, No. 8, Part 2) article by R. Pike
and B. W. Kernighan (Program Design in the Unix Environment).
     
--
     
...smeagol\            Steve Schlaifer
......wlbr->!jplgodo!steve    Advance Projects Group, Jet Propulsion Labs
....group3/            4800 Oak Grove Drive, M/S 156/204
                Pasadena, California, 91109
                    +1 818 354 3171

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1551
          for JMS@ARIZMIS; Fri,  9-MAY-1986 15:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007073; 9 May 86 10:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002588; 9 May 86 10:19 EDT
From: Eric Black <eric%chronon.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: varargs
Message-ID: <250@chronon.chronon.UUCP>
Date: 8 May 86 17:31:00 GMT
Keywords: Taking address of register
Xref: seismo net.lang.c:9090 net.unix-wizards:18110
To:       info-c@BRL-SMOKE.ARPA
     
Yes, this is slightly to the side of the original question as
to whether it is POSSIBLE to write a varargs() handler (a la 4.2 manpage)
for any given machine architecture, but the discussion is legitimately
moving around that target...
     
In article <2694@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>In article <236@chronon.chronon.UUCP> eric@chronon.UUCP (Eric Black) writes:
>>In article <129@drilex.UUCP> dricej@drilex.UUCP writes:
>>>rb@ccird2 (Rex Ballard) wonders what kind of systems would not be able to
>>>handle varargs. ...
>>>... Therefore, a more proper question would be: is there any
>>>architecture which is suitable for a C compiler, but not for varargs?
     
[I guess I answered a slightly different question here:]
     
>>Yes!  I can think of an example close to home... An architecture with
>>a large (LARGE) number of registers, a sliding window to allow reference
>>    [... description of register stack machine ...]
>>I assert that this architecture, and the rest of what goes with this
>>particular feature, is particularly well-suited for efficient execution
>>of programs written in C.
>>
>I agree with your assertion. If this machine supports pointers to registers,
>you could write a varargs. va_arg() would have to bump a pointer to the last
>register arg to a pointer to memory, maybe by calling a 'va_bump' function.
>If it doesn't support pointers to register args, then it is in a bit of
>trouble with C because this is supposed to be legal:
>
>    f(a) int a;
>    {    wombat(&a);
>    }
>--
     
Yup.  This is legal, and is permitted.  This machine DOES allow you
to take the address of a register, but it's an expensive feature
to support, and we'd like to get rid of it.  Other systems take care
of this at the compiler level, and it crops up with register variables,
not just arguments -- if you take the address of a variable, it can't
reside in a register, but must be copied into memory.  Possible
aliasing with pointer arithmetic gets quite hairy, but that's a
dangerous [and generally non-portable] thing to do in an undisciplined
manner.
     
This brings me back to my point (sort of).  This is the same problem that
other machines have with register variables and getting at them in
two different ways (by name and at the other end of a pointer).  In
the case of varargs, the "by name" is as a formal parameter, the pointer
is the usual varargs method.  Accessing varargs directly is just as
sloppy as doing something like this:
    foo()
    {
        int a, b, *intp;
     
        intp = &a;
        *intp = 1;        /* set a to 1 */
        intp++;
        *intp = 2;        /* of course, this sets b to 2, doesn't it? */
    }
If you think this is good coding practice, I don't want you working
for me!  If you object to this technique, why is direct accessing of
varargs items OK?
     
Again, I realize this is not answering the precise question in the
original posting, but it's worth discussing.  Thanks for putting up
with me...
     
--
Eric Black   "Garbage In, Gospel Out"
UUCP:        {sun,pyramid,hplabs,amdcad}!chronon!eric

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1417
          for JMS@ARIZMIS; Fri,  9-MAY-1986 15:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 16:54:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006236; 9 May 86 10:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002454; 9 May 86 10:15 EDT
From: Steven Brian McKechnie Sargent <sbs%valid.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <268@valid.UUCP>
Date: 8 May 86 11:39:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
This group has lately been besieged with a variety of odd C features,
namely
     
*    boolean operators and data types
*    builtin functions
*    New operators like "< ="
*    Arguments passed in registers
     
All these have the same effect of reducing simplicity for doubtful gain.
     
**
A Boolean data type distinct from integers clutters the language with
another (moderately useless) type and removes handy idioms like
    foo[x == 0] = bar;
(Vide the "enum" type, which doesn't participate in address arithemtic
either.)
Arguments that boolean functions make for more efficient implementations
are pretty puny:
> o  A function returning a bool could be implemented on some machines by
>    setting the condition codes instead of storing a full integer value in
>    the return register.
If the caller wants to use the result of the function as a value, rather
than as input to a branching decision, then it must write branches anyway
to set the value appropriately.  Result: bigger slower code.
> >o  Multiple flag variables with local scope and no address operator (e.g.
> >   variables declared "register bool") could be packed into a single word.
Last I checked, (flags&BOOLEAN_VALUE_OF_MERIT) did what you want.  Packing
and unpacking don't come for free, in space or time.
     
     
**
Builtin functions confuse language implementation with programming
environment implementation; C lives in enough different environments
that this is just plain bad planning.  "Inline functions," a la those
of C++, are another matter entirely (although they have been mentioned
repeatedly in discussions of builtin functions).  The benefits that
inline functions offer over CPP macros are: simpler cleaner syntax,
more flexibility because they admit arbitrary control structure within,
and avoidance of horrible botches like putchar(*p++).  The disadvantage,
at least in my mind, is uncertainty as to what happens to the free
variables of an inline function.  Are they bound lexically where the
inline is declared, or are they bound at the point where the inline is
used, assuming the nearest enclosing scope?  Consider:
     
    int oddval;    // Not odd, as in = 1 (mod 2), but "odd"
     
    inline max(x, y) {
        ++oddval;
        return (x > y)? x: y;
    }
     
    foo(oddval) {
        int n = max(oddval, 0);
        oddval = max(4, oddval);
        return max(oddval, oddval);
    }
     
    bar(x) {
        ...
        return max(x, 4);
    }
     
The question that leaps to mind is "what the hell does this code hope
to achieve?"  You can of course write just as silly code using the C
preprocessor; but then the question becomes: Why provide redundant ways
to write this unsafely?
     
**
New operators like "< =", in addition to being hard to spell and understand,
facilitate usages that just aren't that common.  I hardly ever want to
say x = (x < y), and I don't mind typing the extra characters.  I'm not
interested in paying compiler vendors money for supporting this (or any
other dubious misfeature pounded into the language for "completeness'
sake.")
     
     
**
There's also been a discussion about arguments passed in registers,
with one fellow (sorry I forget the name) noting that "microcomputer
people pass arguments in registers."  Well, big computer people do
the same thing, and in both cases the disease is one of not thinking
through to the consequences of your actions.  Suppose you pass arguments
in registers.  Well, if you're like me, you have a lot of variables in
registers.  So in order to pass your arguments, you have to save those
registers somewhere.  Where do you do it?  Put them on the stack, of
course.  Well, suppose that you "know" that %3 and %4 are reserved for
parameter passing: then those registers are unavailable to the caller,
whose code gets correspondingly bigger and slower.  Well, suppose you're
keeping the arguments in %3 and %4, and the callee can use them "in
place" because caller and callee have agreed to do that (in order to
avoid the overhead of explicit parameter moving).  Now, you're writing
spaghetti code, full of "special" communication among routines, with
all the attendant side effects and untraceable bugs.  And why for?
The speed gain from non-standard calling sequences seems marginal at
best: one recent posting discussed at great length the most efficient
way to present arguments to the UNIX open(2) call -- which executes
hundreds or thousands of instructions inside namei, involving perhaps
multiple waits for the disk in order to fetch the inode for the file!
Put the arguments on a linked list of bit-wide elements and force the
kernel to chase them down, if you want: it won't make much of a
difference in how fast your programs run.
     
     
**
It's lots of fun to talk about wonderful "features" we'd like to see,
but somebody (ANSI?) might be listening and do something about it.  So,
for my $.02 worth:
     
*    Always strive to separate language from libraries, libraries
    from host environment, and host environment from development
    environment.  These are all separate entities; make their
    interactions as clean as possible.
     
*    Keep implementations simple.  This means: eschew oddball
    calling sequences that are hard for debuggers to follow.
    This means: minimize the number of compile-time options --
    the user needs to determine the meaning of his program from
    the source code; don't confuse the process by throwing in
    options that invisibly change this meaning.
     
*    Be EXTREMELY conservative about adding features.  I have yet
    to see a feature proposed that fixes a crippling problem
    of the language.  Quite the opposite: many proposed features,
    such as unary + to denote evaluation ordering, help a min-
    ority of users while making the language more baroque for
    everybody.
     
     
I do go on, don't I?  Oh, well; enjoy, flame back, or whatever.
     
Blessed be,
     
S.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1862
          for JMS@ARIZMIS; Fri,  9-MAY-1986 15:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 17:34:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007374; 9 May 86 11:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003296; 9 May 86 10:35 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <2713@utcsri.UUCP>
Date: 6 May 86 14:45:14 GMT
Keywords: :-)
To:       info-c@BRL-SMOKE.ARPA
     
In <183@cbmvax.cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>...  I'm not dumb, but trying to learn a debug a big program though
>a 24-line window and my memory just doesn't make it...
>
Get EMACS.
     
--
"Canabee be said2b or not2b anin tire b, if half thabee isnotabee, due2
somain chunt injury?" - Eric's Dilemma
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1747
          for JMS@ARIZMIS; Fri,  9-MAY-1986 15:50 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007200; 9 May 86 10:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002645; 9 May 86 10:20 EDT
From: Wendy Thrash <wendyt%pyramid.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C (Really arguments in registers)
Message-ID: <357@pyramid.UUCP>
Date: 8 May 86 18:30:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
WARNING:  This article discusses compiler issues, not specifically C
language issues.
     
In article <268@valid.UUCP> sbs@valid.UUCP (Steven Brian McKechnie Sargent)
 writes:
>*    Arguments passed in registers...
>... have the same effect of reducing simplicity for doubtful gain.
     
I don't want to quote too much of the original article -- it was rather long.
The thrust of it was that passing parameters in registers doesn't make things
run faster.  This does not fit with my experience.  When we implemented
parameter passing in registers at Zilog, it was a big win.
     
The argument that register variables must be pushed on the stack in order
to pass parameters in registers seems tenuous.  If you have only one set
of registers available for variables, you have to save them sometime,
unless the routine you are calling has no register variables itself.  More
commonly, registers used for parameter passing are not used for register
variables; they may be used for temporaries.  It is true that this may cut
down on the number of available registers, but our work showed that we had
enough registers remaining to allow good code generation for most programs.
     
We did, indeed, allow the callee to use its arguments in place. Mr. Sargent's
statements about "spaghetti code" make no sense at all to me -- this was
a COMPILER;  it was designed to produce efficient assembly language, not
readable assembly language.  When the compiler functioned correctly (as it
usually did) there were no "attendant side effects and untraceable bugs."
     
I will admit that this parameter passing caused difficulties.  In particular,
varargs code was messy, and debuggers more difficult to implement.  Was it
worth it?  I believe so.  Our emphasis was on speed, and that we had.
     
Of course, this is all moot on RISC machines with sliding register windows.
The concept of parameter passing in registers is then wired into the
architecture, and there are plenty of registers left for register variables.
     
---
Disclaimer:  My opinions have obviously been influenced by the parameter
passing in registers of my former employer (Zilog) and the sliding windows
of my current employer (Pyramid).
--
Wendy Thrash   {allegra,cmcl2,decwrl,hplabs,topaz,ut-sally}!pyramid!wendyt
Pyramid Technology Corp, Mountain View, CA  +1 415 965 7200 ext. 3001

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1953
          for JMS@ARIZMIS; Fri,  9-MAY-1986 16:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 17:42:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007424; 9 May 86 11:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003301; 9 May 86 10:36 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Infinite loops
Message-ID: <2717@utcsri.UUCP>
Date: 6 May 86 15:27:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <203@brl-sem.ARPA> ron@brl-sem.ARPA (Ron Natalie <ron>) writes:
>In article <390@hadron.UUCP>, jsdy@hadron.UUCP (Joseph S. D. Yao) writes:
>>
>> Unfortunately, as I'm sure many readers of this group will agree,
>> not all compilers are reasonable.  The only one that consistently
>> doesn't generate useless code is for (;;) {...}.
>Joe, it is exactly this second guessing of compilers that get people in
>trouble.  It is bad to make sweeping statements as to what is more efficient
>because some compilers just do entirely unexpected, yet no more inefficient
>things with code generation.
...
>Wait until the compiler comes out that does the following:
>
>    for(;;)  { included code )
>
>    L1:    NOP    /  init
>    L2:    NOP    /  test
>        INCLUDED CODE
>        NOP    /  increment
>        JUMP    L2
>
     
Well, it's even worse... Consider C/80, a subset C compiler for 8080's
[ no floats, longs, structs, unions, **s, :-( ]:
     
    for( e1;e2; e3 ){
becomes
        <e1>
    f0:    <e2>
        JZ    f3
        JMP    f2
    f1:    <e3>
        JMP    f0
    f2:    <loop code>
        JMP    f1
    f3:
     
So for(;;) just reduces to
     
    f0:    JMP    f2
    f1:    JMP    f0
    f2:    <loop code>
        JMP    f1
     
Really! The compiler apparently cannot save <e3> until later; it doesn't
build trees. It also pushes function args left-to-right ( another story ).
     
while(1), on the other hand, becomes
     
    w0:    LXI    H,1    ; evaluate 1 ( in 16-bit reg HL )
        MOV    A,H    ; test HL by ORing the upper
        ORA    L    ;    and lower bytes to the ACC
        JZ    w1    ;    ( standard 8080 idiom )
        <loop>
        JMP    w0
    w1:
     
>Frankly, if your compiler is so bad that it can't perform routine constant
>elimination, than I doubt that you will really notice the extra performance
>loss.  It's probably still multiplying out 60*60 for seconds in an hour
>and other definitions.
     
C/80 is ( using a 'mult' subroutine, of course. a<b uses a 'lt' subroutine ).
     
I have written a large amount of code with this beast - including an
`optimizing assembler' to cure many of the horridities emitted by the
compiler.
     
Sorry, I know, this should be in net.lang.brain.damaged. If you don't
flame me, I promise never to mention this compiler again :-).
     
P.S. There is an 8088 version of the compiler - I don't know if it is
any better ( or worse ).
     
--
"Canabee be said2b or not2b anin tire b, if half thabee isnotabee, due2
somain chunt injury?" - Eric's Dilemma
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2006
          for JMS@ARIZMIS; Fri,  9-MAY-1986 16:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007508; 9 May 86 11:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003319; 9 May 86 10:36 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  C Builtin Funxions
Message-ID: <6658@utzoo.UUCP>
Date: 6 May 86 19:04:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> One of the better things to come out of the COBOL standards efforts
> was the notion of specifying a minimum core language, then defining
> optional modules that were pretty close to the way the big boys (IBM)
> had actually implemented their extensions...
     
Whether this is a good idea or not is very much a matter of opinion.
As I recall, X3J11 representatives said at the very beginning that they
had explicitly renounced this approach, because there are something like
4096 distinct languages that meet the COBOL "standard", and this is a real
obstacle to portability.
     
In practice, of course, what happens is that implementations converge on
a few widely-agreed preferred points in this large space of possibilities.
So why not identify those points in advance?  Maybe one could even... pick
just one of them!  This is what X3J11 is trying to do, although it looks
like it's ending up as 1.5 rather than 1.0.
--
Join STRAW: the Society To    Henry Spencer @ U of Toronto Zoology
Revile Ada Wholeheartedly    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4438
          for JMS@ARIZMIS; Fri,  9-MAY-1986 21:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/09/86 at 22:50:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007552; 9 May 86 11:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003413; 9 May 86 10:38 EDT
From: Mark DeWitt <dewitt%cca.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <7706@cca.UUCP>
Date: 7 May 86 14:34:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <> garys@bunkerb.UUCP (Gary M. Samuelson) writes:
>In article <475@snow.warwick.UUCP> kay@warwick.UUCP (Kay Dekker) writes:
>>In article <7097@cca.UUCP> dewitt@cca.UUCP (Mark DeWitt) writes:
>>>After three years of C programming I'm just starting to use lint, so
>>>please no negative reinforcement by flaming about how stupid my questions
>>>are, lest I give up on it entirely :-).
>
>>Mark, I'm not flaming you, but I *am* worried!...
>
>And well you should be.
     
I would like to thank the above and other contributors who have kept this
discussion on a non-judgmental, rational plane.
     
I would also like to point out that there is more than one way to learn
portable coding style.  Using lint and avoiding the messages it produces
is one way.  Having to (gasp!) port other people's code yourself is
another way.  Of my first six months of C programming, a good four months
were spent porting "working" C code from the IBM PC to the Apple II+ / IIe,
including graphics and floating point applications.  Blech!  It was
painful, but I sure as hell learned a lot of what NOT to do if you want
to write portable code.  Most of my trouble with lint has not been with
having to change my coding style, only with getting it to shut up.
--
"We like your attitude, but what are you doing?"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4595
          for JMS@ARIZMIS; Fri,  9-MAY-1986 21:19 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019055; 9 May 86 20:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016118; 9 May 86 19:45 EDT
From: #Bill_Stewart <wcs%ho95e.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <674@ho95e.UUCP>
Date: 8 May 86 02:22:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <183@cbmvax.cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>One of the more traumatic things about being exposed to unix after working
>with numerous other systems was that the stupid c compiler refused to give me
>a nice clean listing with source, interspersed error messages, and optional
>object code.  I'm not dumb, but trying to learn a debug a big program though
>a 24-line window and my memory just doesn't make it...
     
One of the more traumatic things about programming an IBM System-34 in RPG2
was that you got the listing whether you liked it or not.  We had the slow
printer, so my 10-page program took 45 minutes to compile, including
cross-references, overlay maps, ....  If we'd had the fast printer it would
have taken about 20.  Then we got the box of cheap paper which jammed the
printer a lot, and I almost wanted my keypunch back.....   (The system 34 was
a desk-sized beast with 48K of core and a 13 Meg disk.  Can you say "wimp!"?)
     
If you get a fancy enough emacs package, you can have your C listing
on-screen; otherwise you'll have to use somebody's pretty-printer, and hack in
error message support.
     
--
# Bill Stewart, AT&T Bell Labs 2G-202, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4505
          for JMS@ARIZMIS; Fri,  9-MAY-1986 21:24 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018169; 9 May 86 17:08 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a014633; 9 May 86 16:52 EDT
Date:     Fri, 9 May 86 16:46:38 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Steven Brian McKechnie Sargent <sbs%valid.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Boolean Operators Slighted in C
     
Steven Brian McKechnie Sargent <valid!sbs> says ("> ..."):
> A Boolean data type distinct from integers clutters the language with
> another (moderately useless) type and removes handy idioms like
>     foo[x == 0] = bar;
     
Boolean quantities form an important abstract data type distinct from
counters, sets, real numbers, etc.  By not making the distinction,
the language encourages usage errors, the most notorious being
    if ( a = b )
        stuff;
Sure, one can make integers do double (or triple, or ...) duty,
but by now every programmer should realize the value of data
abstraction.
     
> New operators like "< =", in addition to being hard to spell and understand,
> facilitate usages that just aren't that common.  I hardly ever want to
> say x = (x < y), and I don't mind typing the extra characters.  I'm not
> interested in paying compiler vendors money for supporting this (or any
> other dubious misfeature pounded into the language for "completeness'
> sake.")
     
Here is an example where proper use of Boolean data would be violated.
A statement like
    x = x < y;
should NEVER be used, since it assigns a Boolean result to an
arithmetic variable.  This means that a "< =" operator is not
a good idea.
     
I find data abstraction to be a Good Thing, and have produced
much better code since defining a Boolean data type and using
it in a strictly type-correct manner.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9700
          for JMS@ARIZMIS; Sat, 10-MAY-1986 06:49 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 05/10/86 at 08:32:28 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Thu 8 May 86 09:15:24-PDT
Date:  8 MAY 1986 12:13:50 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: MANSFIELD%DHDEMBL5.BITNET@WISCVM.WISC.EDU
cc: info-vax@sri-kl.arpa
Subject:  Re: Problem with C and Link
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
     
    File T.C contains:        |        File T2.C contains:
                |
    extern  char    *sto;    |    char    sto[100] = 0;
    main()            |    f(s)
    {    f("bongo");        |    char    *s;
    printf("%s\n", sto);    |    {   strcpy(sto, s);
    }                |        printf("in func, sto = %s\n",sto);
                |    }
     
    [Compiling T and T2, linking with the shareable VAX C library, and
     running the result produces:]
     
    in func, sto is bongo
    %SYSTEM-F-ACCVIO, access violation, reason mask=01,
        virtual address=676E6F62, PC=0000423B, PSL=0BC00005
    ...[traceback information]
     
    [The author goes on to blame the linker for incorrectly resolving the
     references to sto.]
One of the first thing I always teach students is:  Before you start blaming
the compiler, the operating system, the hardware - and before you blast your
question at hundreds of people on INFO-VAX - do make sure that you've checked
your program, and your understanding of your programming language, for bugs.
     
The C compiler and linker are behaving exactly as they should; your program
is incorrect.
     
    extern char *sto;
     
declares that sto, storage for which is allocated elsewhere, contains a
(4-byte) address that POINTS TO some memory that contains a single character.
     
    char sto[100] = 0;
     
allocates a hundred bytes of memory filled with zero's - actually, the "=0"
is a no-op - and declares that sto IS the address of those hundred bytes of
memory.
     
    printf("%s\n", sto);
     
takes the first four of those hundred bytes - which now contain the byte codes
'b', 'o', 'n', 'g', or hex 62, 6F, 6E, 67; see the virtual address in the
error message, and keep in mind that the VAX orders bytes in a word from least
to most significant - and interprets them as the address of a character.  This
does nothing particularly useful.
     
char *x and char x[] are VERY DIFFERENT THINGS.  The ONLY context in which
they are the same is the declaration of formal parameters.  The "equivalence"
of these two forms is a widely-made misreading of some unfortunate comments in
K&R.  K&R is absolutely correct in what it says, but the emphasis misleads
many people.
                            -- Jerry
-------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0066
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 19:34:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000990; 11 May 86 20:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003515; 11 May 86 19:57 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C builtin functions?
Message-ID: <802@bentley.UUCP>
Date: 9 May 86 13:50:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <716@steinmetz.UUCP> steinmetz!davidsen (Davidsen) writes:
>At that point, given that we were talking about an "advisory" keyword,
>and that obviously you couldn't take the address of an intrinsic
>function, one of us suggested that the term "register" be used, since
>it may be ignored by the compiler, and prevents taking the address of a
>variable.
     
I thought of that too!  However, I think the meaning is sufficiently
different from a register variable that it's better to use a new keyword.
     
>register foo() { ... }
>register foo();
     
You seem to be using the former to mean "inline" and the latter to mean
"builtin".  These are not the same concept!  Also, why should the user
have to know which functions are (or might be) builtins?  They should be
automatically recognized by the compiler unless explicitly disabled.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8877
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 16:26:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029696; 11 May 86 17:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001245; 11 May 86 16:16 EDT
From: Jerry Schwarz <jss%ulysses.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Builtin Functions
Message-ID: <1253@ulysses.UUCP>
Date: 8 May 86 21:42:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I'm surprised that with all this discussion on built-ins, nobody has pointed
> out how the C standard specifies that it should work.  My copy of the standard
> is pretty old and has been stolen, so perhaps it was removed in a later
> specification?
>
     
It was about the 3rd item posted in the discussion.  But here it is
again (Februray 1986 draft)
     
        D.1.2 Headers
     
        ... All external identifiers declared in any of the headers
        [i.e. as specified in the standard] are reserved, whether or
        not the associated header is included. All external
        identifiers and macro names that begin with an underscore are
        also reserved.  If the program redefines a reserved external
        identifier, even with a semantically equivalent form the
        behavior is implementation defined. ...
     
        D.1.3 Use of library functions
     
        ... Any function declared in a header may be implemented as a
        macro defined in the header, so a library function should not
        be declared explicitly if its header is included. ... The use
        of #undef to remove any macro definition will also ensure
        that  an actual function is referenced.
     
To me this seems perfectly reasonable.  Note in particular that a
vendor is required to tell you what will happen if you try to redefine
one of the reserved identifiers.
     
Jerry Schwarz
Bell Labs, MH
ulysses!jss

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0027
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 19:31:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000988; 11 May 86 20:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003420; 11 May 86 19:54 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: oops, corrupted memory again!
Message-ID: <801@bentley.UUCP>
Date: 9 May 86 13:39:03 GMT
Xref: brl-sem net.lang.c:994 net.lang.c++:183
To:       info-c@BRL-SMOKE.ARPA
     
In article <5097@think.ARPA> rose@think.ARPA (John Rose) writes:
>If you do have source code, here's another suggestion which has worked
>very well for me.  Define an circular buffer which stores a record of
>the last few hundred records of malloc/free/morecore history.  Make
>sure your symbolic debugger can dump it for you.  This trick alone
>has saved me hours of debugging time on quite a few occasions.
     
I've found the following front-end* to be very useful:
    char *Dalloc(n) unsigned n; {
        register char *p = malloc(n);
        fprintf(stderr, "+%8x\n", p);
        return (p);
    }
    void Dfree(p) char *p; {
        fprintf(stderr, "-%8x\n", p);
        free(p);
    }
    char *Drealloc(p, n) char *p; unsigned n; {
        fprintf(stderr, "-%8x\n", p);
        p = realloc(p, n);
        fprintf(stderr, "+%8x\n", p);
        return (p);
    }
     
When the program terminates (normal exit or core dump), I run a consistency
check on the log file to cancel out "+xxx" and "-xxx".  Any unbalanced "-"
is a bug.  I consider an unbalanced "+" to be a bug, too, unless there are
a bounded number of them and I can account for them all.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
*It can also be built into malloc.c if you have source; this allows it to
log the calls within stdio.  For some applications, a special log file
should be used instead of stderr.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9825
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 19:15:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000974; 11 May 86 20:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003183; 11 May 86 19:46 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  A good use of a bad feature
Message-ID: <800@bentley.UUCP>
Date: 9 May 86 04:18:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <528@brl-smoke.ARPA> root@icst-cmr ((Root Boy) Jim Cottrell) writes:
[concerning the fall-through case feature]
>You will find much disagreement on that point, I'm afraid. Fall thru is
>more flexible. You can always break, but often cases are related so that
>a particular case requires a superset of another case. It is to DMR's
>credit that he realized this feature. I sure wouldn't have thought of it.
     
An alternate implementation would have been for cases to be distinct by
default, but "continue" at the bottom of a case would cause a fall-thru.
(In this model, "break" would be meaningless inside a switch and "continue"
would be meaningful, instead of the opposite.)  Given that most use of the
switch statement *does* have distinct cases, and the exceptions are often
explicitly labeled /* no break */, I think this would've been better.
(I would *almost* accept a model with automatic break and no keyword for
fall-thru, and suffer the occasional goto.)
     
One special instance is where the superset is actually an equivalence, i.e.
two or more labels on the same code:
    case ' ':
    case '\t':
    case '\n':
        white();
        break;
This would be ugly with the auto-break model, but the solution is to allow
    case ' ','\t','\n':
        white();
which I think looks neater anyway.
     
(Btw, I find
    case '0':
    ...
    case '9':
        digit();
annoyingly verbose in the current model, and often use "if" rather than
"switch" because of it.)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0187
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 19:54:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001020; 11 May 86 20:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003179; 11 May 86 19:45 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: More on BOOLEAN vs. boolean
Message-ID: <799@bentley.UUCP>
Date: 9 May 86 03:57:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <559@brl-smoke.ARPA> HARGED%ti-eg.csnet@CSNET-RELAY.ARPA writes:
>>o  Multiple flag variables with local scope and no address operator (e.g.
>>   variables declared "register bool") could be packed into a single word.
>
>*IF* packing bits is feasible on your host machine. (Whether you like it or
>not) there are many C implementations that can't afford the overhead of bit
>packing.
     
The bits don't need to be explicitly packed and unpacked except to convert
between bool and int.  Otherwise a bit-test, bit-set, and bit-clear will do,
I think; these are just "&", "|", and "&~", and are very common instructions.
(Anyway, an implementation is free to NOT pack the bits, just as it can put
a char in a 32-bit word if the alternative is too much trouble.)
     
>>o  "++x" and "--x" could be defined as "set" and "clear"; "x++" and "x--"
>>   would then be "test and (set|clear)".  This would obviate such things as
>>   "if (!flag) { flag=1; printmsg(); }".
>
>I think the same problems with doing that now (on integers of whatever size)
>would plague the boolean type. The code that would have to generated to avoid
>giving a boolean variable an undefined value would probably match the size
>of the code currently generated when the user explicitly controls a flag's
>value.
     
Actually, I was introducing "x++" for the user's benefit, not the machine's.
I wouldn't mind if it generated the same code as in the explicit case; after
all, it's only two instructions (test, followed by store-constant).  However,
I'd expect a machine with an efficient test-and-set instruction to use it.
     
>However, (~x) for "toggle" would be useful. The lack of an efficient
>toggle operation on integer BOOLEAN's is sometimes a pain.
     
I see no reason to change it from "!" to "~".  The only case where it's
inefficient now is with "x = !x", which could indeed be optimized if "x" is
known to be boolean rather than int.  (Of course you can write "x ^= 1".)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8815
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 16:20:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029686; 11 May 86 17:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000636; 11 May 86 12:26 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <797@bentley.UUCP>
Date: 9 May 86 02:54:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <501@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>I have ranted about C using a one statement model for its control
>statements instead of an explicit end statement.  Compound statements are
>bounded by braces instead.  Yuk!
     
Ah yes, there are two major types of language in the structured family;
f77 with "endif" (some members use "end" for all of "endif", "endwhile",
etc.) and pascal with "begin" "end" (which C abbreviates to "{" "}").  I
presume this is what you dislike.  (If it's the spelling that bothers you,
I'm sure you're aware that you can define "begin" and "end" as macros.)
     
Yet another convention, not endorsed by any language I know, is to dispense
with the braces and let the indentation alone tell the compiler how to
interpret the program.  (I came up with this idea after an argument on the
"correct" place to put the braces.)
     
>Fortunately, there is the comma operator. This allows the following:
>    Most People            Your's Truly
>    if (c) {            if (c)
>        w = y;                w = x,
>        y = z;                y = z;
>    }                /* look ma, no brace */
     
I can hardly flame you for this, since I've used it myself when in a hurry.
(But I write it on one line, "if (c) w=x, y=z").  I usually end up rewriting
it with braces, though.
     
>Other things you will see in my code are:
>        exit((printf("usage: foo bar\n"),1));
>or even:    exit(1,printf("usage: foo bar\n"));
     
What's wrong with
    printf("usage: foo bar\n"), exit(1);
as above?
     
>Sufficeth to say that I use a lot of commas in my code. Unfortunately,
>I cannot do this if either statement is a control struxure, *except* return.
>    Most People            Your's Truly
>    if (c) {            if (c)
>        w = y;                return w = x,
>        return;
>    }                /* look ma, no brace */
     
You're introducing a minor inefficiency, since the compiler will have to
copy the result of the last expression into the return register.  I presume
you don't bother to declare void functions "void", either, or this wouldn't
make it past the compiler.
     
>I cannot see *any* implementation doing either of the following:
>    1) barfing because I returned an *extra* value sometimes
>    2) barfing because I added an extra argument
     
You're probably correct in that all implementations that accept your code
will produce correct results; however, I can easily imagine a compiler that
would refuse to compile such an "obvious bug".
     
>Now you may claim that this is `bad programming practice', but I claim
>that it is just a convention, just like #defines are usually capitalized.
>You may not like either one, but I claim this is portable. And, it is
>meaningful to me.
     
But it *is* bad practice, in a measurable sense: you are using a style which
is indistinguishable from a bug.  As a result, you cannot easily use lint to
find *real* bugs, because you've introduced so much noise in the lint output.
You're throwing away a useful tool unnecessarily.
     
>I find it terribly ugly having to cast printf's or close's to void.
     
Me too.  But let's not lump all the cases together:
     
[0] strcpy() returns a value that can be safely ignored.  (Although I often
    find that I can use it in the next statement anyway.)
     
[1] printf() returns a number which is normally pretty useless.  It does also
    have an error return, but if you're writing to the terminal it's pretty
    safe to ignore that too.  (Especially fprintf(stderr).  What can you do
    if it fails, print an error message?)
     
[2] close(), as near as I can tell, can only fail by being handed a number
    that does not denote an open file.  I usually assume that this error
    would have been caught earlier.
     
[3] unlink() and most other system calls should be checked!  (It's too bad
    lint can't tell whether you've tested the return value of open(), etc.)
     
My "solution" for [0]-[2] is simply to check the bottom of the lint output
for "result ignored" messages, and decide which ones are serious.  ("lint
returns an error which is always ignored" :-)
     
>And as someone pointed out, assignments return a value too, so should we
>cast them to void as well?  Oh yeah, assignment is `different'.
     
Actually, this does bother me somewhat.  I think I prefer the idea that
values should be used or explicitly discarded, as in forth.  (Not that forth
has any error checking!)  No, I'm not suggesting that lint should complain
about assignments, or that C should have a different notation for assignments
that are being pipelined into another expression.  Just waiting for the next
generation of languages.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8732
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 16:07:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029531; 11 May 86 16:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000608; 11 May 86 12:18 EDT
From: Landon Noll <chongo%nsc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: 1984 winners
Message-ID: <3551@nsc.UUCP>
Date: 9 May 86 00:27:49 GMT
Keywords: obfuscate,1984,winners
To:       info-c@BRL-SMOKE.ARPA
     
A number of people have requested the winners from two years ago.  *sigh*
O.K. folks, here it is once again.  Grab it now because it would be sent
out for a while...
     
BTW, the 1986 contest ends 30-May.  Send in your programs now...
     
1984 awards:
     
<dis>honorable mention:
------------------------------------------------------------------------------
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
-----------------------------------------------------------------------------
anonymous entry   (too embarrassed that he/she could write such trash i guess)
     
     
     
Third place:
---------------------------------------------------------------------------
a[900];        b;c;d=1        ;e=1;f;        g;h;O;        main(k,
l)char*        *l;{g=        atoi(*        ++l);        for(k=
0;k*k<        g;b=k        ++>>1)        ;for(h=        0;h*h<=
g;++h);        --h;c=(        (h+=g>h        *(h+1))        -1)>>1;
while(d        <=g){        ++O;for        (f=0;f<        O&&d<=g
;++f)a[        b<<5|c]        =d++,b+        =e;for(        f=0;f<O
&&d<=g;        ++f)a[b        <<5|c]=        d++,c+=        e;e= -e
;}for(c        =0;c<h;        ++c){        for(b=0        ;b<k;++
b){if(b        <k/2)a[        b<<5|c]        ^=a[(k        -(b+1))
<<5|c]^        =a[b<<5        |c]^=a[        (k-(b+1        ))<<5|c]
;printf(    a[b<<5|c    ]?"%-4d"    :"    "        ,a[b<<5
|c]);}        putchar(    '\n');}}    /*Mike        Laman*/
----------------------------------------------------------------------------
            Mike Laman
            UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman
P.S.  I hope you have the C beautifier! The program accepts ONE positive
      argument.  Seeing is believing!  Try something like "cmd 37" for an
      example.  <ed: also try cmd 4; cmd 9; cmd 16; cmd 25; cmd 36; ...>
     
     
     
Second place award:
---------------------------------------------------------------------------
#define x =
#define double(a,b) int
#define char k['a']
#define union static struct
     
extern int floor;
double (x1, y1) b,
char x {sizeof(
    double(%s,%D)(*)())
,};
struct tag{int x0,*xO;}
     
*main(i, dup, signal) {
{
  for(signal=0;*k * x * __FILE__ *i;) do {
   (printf(&*"'\",x);    /*\n\\", (*((double(tag,u)(*)())&floor))(i)));
    goto _0;
     
_O: while (!(char <<x - dup)) {    /*/*\*/
    union tag u x{4};
  }
}
     
     
while(b x 3, i); {
char x b,i;
  _0:if(b&&k+
  sin(signal)        / *    ((main) (b)-> xO));/*}
  ;
}
     
*/}}}
-------------------------------------------------------------------------------
By: Dave Decot   hplabs!hpda!hpdsd!decot
     
     
     
First place award goes to:
------------------------------------------------------------------------
/* Portable between VAX11 && PDP11 */
     
short main[] = {
    277, 04735, -4129, 25, 0, 477, 1019, 0xbef, 0, 12800,
    -113, 21119, 0x52d7, -1006, -7151, 0, 0x4bc, 020004,
    14880, 10541, 2056, 04010, 4548, 3044, -6716, 0x9,
    4407, 6, 5568, 1, -30460, 0, 0x9, 5570, 512, -30419,
    0x7e82, 0760, 6, 0, 4, 02400, 15, 0, 4, 1280, 4, 0,
    4, 0, 0, 0, 0x8, 0, 4, 0, ',', 0, 12, 0, 4, 0, '#',
    0, 020, 0, 4, 0, 30, 0, 026, 0, 0x6176, 120, 25712,
    'p', 072163, 'r', 29303, 29801, 'e'
};
------------------------------------------------------------------------------
        Sjoerd Mullender
        Robbert van Renesse
Both @ Vrije Universiteit, Amsterdam, the Netherlands.
    ..!decvax!mcvax!vu44!{sjoerd,cogito}
<ed: try this on your local VAX or pdp-11>
     
chongo <> /\oo/\

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0440
          for JMS@ARIZMIS; Sun, 11-MAY-1986 18:31 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/11/86 at 20:07:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001037; 11 May 86 20:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003976; 11 May 86 20:17 EDT
From: Rex Ballard <rb%ccird1.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: LINT as documentation
Message-ID: <411@ccird1.UUCP>
Date: 9 May 86 19:16:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
This is just one more argument for lint.
     
True, lint often burps over "trivial" little problems like
passing a *int to a function that expects *char, among others,
but there are some real good reasons for using lint.
     
Frequently, after working on a project for several months and
coming up with a working system, it gets passed to someone else.
That someone else then has to make a small enhancement that affects
only one module out of 100.  This second person might not understand
that this *int is not really a pointer to integers, but is in fact
a pointer to some more complex type.  By putting the casts, VARARGS,
NOSTRICTS, et al, the new guy at least gets a warning that something
is not what it appears to be.  This is particularly important if
I do something like us an int as a pointer to char (yuckkk!!! :-).
     
Now, if either he or I induce a new bug, or something that might
need explanation, lint is there finding that "1/5" of the wierdness
that might have gone wrong.
     
Even more important is when we switch compilers, go to cross-tools,
or use some other change in the environment.  If the thing has
been linted, casted, and cleaned up, we can ASK it to tell us
about "dubious casts", or whatever and have a better idea of why
things don't work as well.
     
When someone comes up with the "lint cramps my style" arguments,
I tend to get worried.  When I get handed some code that has to
be "ported" or enhanced, I run lint on it before I do anything.
If lint goes crazy, I know I will have to read ALL of the code
before I can do anything.
     
There are a lot of cute "tricks" you can do with C, like setting
"pointers" that are really integers.  But if you want to do this,
you should be explicit in defining "(char *)0x2300ffff".  Believe
it or not, I have actually seen code that legitimately calls
address location 0 (useful on the 8085).  This is guarenteed to
drive a programmer crazy if he tries to port this to another machine.
     
I also expect a programmer to run code through lint before he
gets my help.  I have spent too many hours with people who insist
the compiler is broken because they have tried to, in effect,
build an array in the operating system vector space :-).
If he really WANTS to build an array in the operating system
vector space, he should SAY SO, not just to me, but to lint.
     
I find it amazing that an employer would pay a programmer for
three days worth of debugging using ODT (octal debugging toy)
to test and debug code when all but one hours worth could be
found in a 2 hour session of lint/vi.
     
Real Programmers CAN use the "front panal", but they won't if
there is a faster easier way!
     
If you are programming on your own time, and don't have any plans
for releasing your code to anyone, then don't use lint.  But if
you want to "publish" your little gem, the $95 for lint on a
"PC" will easily offset the $20/hr*20 or thirty hours someone
might spend getting it to run on their "not quite compatible".
This is especially true on 68K machines where Ints can be
short and pointers can be long and (*char)i can do some really
nasty things.  Sure it's possible to use the "long int switch",
but then the program runs 150% slower.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5483
          for JMS@ARIZMIS; Wed, 14-MAY-1986 02:31 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008766; 13 May 86 21:18 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a014489; 13 May 86 20:17 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA01366; Tue, 13 May 86 20:17:10 edt
Date: Tue, 13 May 86 20:17:10 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605140017.AA01366@icst-cmr.ARPA>
To: bentley!kwh@ICST-CMR.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: oops, corrupted memory again!
     
> ...I consider an unbalanced "+" to be a bug, too, unless there are
> a bounded number of them and I can account for them all.
     
There always is :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5380
          for JMS@ARIZMIS; Wed, 14-MAY-1986 02:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/14/86 at 04:14:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008723; 13 May 86 20:55 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a014464; 13 May 86 20:11 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA00837; Tue, 13 May 86 20:10:16 edt
Date: Tue, 13 May 86 20:10:16 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605140010.AA00837@icst-cmr.ARPA>
To: bentley!kwh@seismo.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re:  questions from using lint
     
> In article <501@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
> >I have ranted about C using a one statement model for its control
> >statements instead of an explicit end statement.  Compound statements are
> >bounded by braces instead.  Yuk!
>
> Ah yes, there are two major types of language in the structured family;
> f77 with "endif" (some members use "end" for all of "endif", "endwhile",
> etc.) and pascal with "begin" "end" (which C abbreviates to "{" "}").  I
> presume this is what you dislike.  (If it's the spelling that bothers you,
> I'm sure you're aware that you can define "begin" and "end" as macros.)
     
Well C certainly makes the spelling less verbose, but that is not my
complaint. The first structured language I came across (SIMPL-T at U of Md)
used the notation `IF <condition> THEN <list> { ELSE <list> } END'. This
has become my personal favorite paradigm for if statements. In fact, the
syntax of all control statements was almost entirely similar to that used
by the Bourne shell, except that END ended any kind of block.
     
This is superior to the `one statement' (braces, BEGIN-END, etc) style
because it explicitly delimits where the else statement goes. It is also
easier to parse.
     
> Yet another convention, not endorsed by any language I know, is to dispense
> with the braces and let the indentation alone tell the compiler how to
> interpret the program.  (I came up with this idea after an argument on the
> "correct" place to put the braces.)
     
This is too scary, even for a scofflaw like myself. I don't trust
white space, and you give up the ability to `cb' or `indent' it.
     
> >Fortunately, there is the comma operator. This allows the following:
> >    Most People            Your's Truly
> >    if (c) {            if (c)
> >        w = y;                w = x,
> >        y = z;                y = z;
> >    }                /* look ma, no brace */
>
> I can hardly flame you for this, since I've used it myself when in a hurry.
> (But I write it on one line, "if (c) w=x, y=z").  I usually end up rewriting
> it with braces, though.
     
I often do myself. EMACS C-mode adds them for you automatically, so I
guess it's not much of an issue for some people.
     
> >Other things you will see in my code are:
> >        exit((printf("usage: foo bar\n"),1));
> >or even:    exit(1,printf("usage: foo bar\n"));
>
> What's wrong with
>     printf("usage: foo bar\n"), exit(1);
> as above?
     
Oops, I goofed royally. BTW, I didn't notice that I needed the extra
parens in the first example until I posted it. Another example of why
not to use tricks. Silly rabbit :-)
     
> >Sufficeth to say that I use a lot of commas in my code. Unfortunately,
> >I cannot do this if either statement is a control struxure, *except* return.
> >    Most People            Your's Truly
> >    if (c) {            if (c)
> >        w = y;                return w = x,
> >        return;
> >    }                /* look ma, no brace */
>
> You're introducing a minor inefficiency, since the compiler will have to
> copy the result of the last expression into the return register.  I presume
> you don't bother to declare void functions "void", either, or this wouldn't
> make it past the compiler.
     
I hadn't even thought of that. In my defense I will have to mention
that 1) the expression may have already been computed in R0 anyway,
2) `tis a small matter, & 3) the attempt is to optimize cranial
time rather than execution time. The statements of the left side
are starting to get verbose, while the ones on the right side, especially
if written on one lline, are simple and to he point. It might take you
a bit to get used to the convention, but it's not that difficult.
     
As for void, it didn't exist on the compiler I first used. Even BSD
has problems with pointers to functions returning voids (did I get
it right?) so I avoid them. It is easier just to default it to
int, never return anything (or use my convention), and ignore the
value. That's right, easier, not better. I'm lazy. Generally, tho,
I find that I don't make *that* kind of mistake too often, so why
bother? It all comes down to what you gain versus what you put out,
and have to read for all eternity.
     
> >I cannot see *any* implementation doing either of the following:
> >    1) barfing because I returned an *extra* value sometimes
> >    2) barfing because I added an extra argument
>>
> You're probably correct in that all implementations that accept your code
> will produce correct results; however, I can easily imagine a compiler that
> would refuse to compile such an "obvious bug".
     
Not true. The first case is required to be supported so that I can ignore
a value (strcpy, eg) if I choose. The second is required to support printf.
     
> >Now you may claim that this is `bad programming practice', but I claim
> >that it is just a convention, just like #defines are usually capitalized.
> >You may not like either one, but I claim this is portable. And, it is
> >meaningful to me.
>
> But it *is* bad practice, in a measurable sense: you are using a style which
> is indistinguishable from a bug.  As a result, you cannot easily use lint to
> find *real* bugs, because you've introduced so much noise in the lint output.
> You're throwing away a useful tool unnecessarily.
     
I see your point. I first ran lint after I had a few thousand lines of
code written, and it barfed unmercifully. Before that, I had attempted
to run it but the permission bits were set wrong for some files. Only
root could run it. By the time I figured out why, I had a bad taste in
my mouth. Also, reading the documentation left me unexcited. Maybe I will
give it another try someday. I'll probably point it at net.sources.
     
I find I can get along okay without it.  That is my whole point. It's
not lint that bothers me, it's the people that think it's a panacea for
everything.  Actually, I am pleased by the mixed reaction I received.
About half of the articles I've seen make this point as well.
     
I do prefer the way it fits into the language tho. It's there when you
need it but not shoved down your throat by run-time or compile-time checks.
     
> >I find it terribly ugly having to cast printf's or close's to void.
>
> Me too.  But let's not lump all the cases together:
>
> [0] strcpy() returns a value that can be safely ignored.  (Although I often
>     find that I can use it in the next statement anyway.)
>
> [1] printf() returns a number which is normally pretty useless.  It does also
>     have an error return, but if you're writing to the terminal it's pretty
>     safe to ignore that too.  (Especially fprintf(stderr).  What can you do
>     if it fails, print an error message?)
>
> [2] close(), as near as I can tell, can only fail by being handed a number
>     that does not denote an open file.  I usually assume that this error
>     would have been caught earlier.
     
I meant to say `fclose', which can write data and thus barf too.
     
> [3] unlink() and most other system calls should be checked!  (It's too bad
>     lint can't tell whether you've tested the return value of open(), etc.)
     
Mostly. But sometimes you don't care if the file you are trying to unlink
or the descriptor you are trying to close doesn't exist.
     
> My "solution" for [0]-[2] is simply to check the bottom of the lint output
> for "result ignored" messages, and decide which ones are serious.  ("lint
> returns an error which is always ignored" :-)
     
Right. Grep -v helps here too.
     
> >And as someone pointed out, assignments return a value too, so should we
> >cast them to void as well?  Oh yeah, assignment is `different'.
>
> Actually, this does bother me somewhat.  I think I prefer the idea that
> values should be used or explicitly discarded, as in forth.  (Not that forth
> has any error checking!)  No, I'm not suggesting that lint should complain
> about assignments, or that C should have a different notation for assignments
> that are being pipelined into another expression.  Just waiting for the next
> generation of languages.
     
The explicitness comes in the source code. Why do you find it so hard
to believe that I meant what I said?
     
> Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    The Sitting Lint Maker

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5572
          for JMS@ARIZMIS; Wed, 14-MAY-1986 02:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008984; 13 May 86 22:02 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a014813; 13 May 86 21:08 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA04870; Tue, 13 May 86 21:08:03 edt
Date: Tue, 13 May 86 21:08:03 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605140108.AA04870@icst-cmr.ARPA>
To: gwyn@BRL.ARPA, sbs%valid.uucp@BRL.ARPA
Subject: Re:  Boolean Operators Slighted in C
Cc: info-c@BRL-SMOKE.ARPA
     
    Doug Gwyn responds:
    Steven Brian McKechnie Sargent <valid!sbs> says ("> ..."):
    > A Boolean data type distinct from integers clutters the language with
    > another (moderately useless) type and removes handy idioms like
    >     foo[x == 0] = bar;
     
    Boolean quantities form an important abstract data type distinct from
    counters, sets, real numbers, etc.  By not making the distinction,
    the language encourages usage errors, the most notorious being
        if ( a = b )
            stuff;
     
True. It is easily found tho.
     
    Sure, one can make integers do double (or triple, or ...) duty,
    but by now every programmer should realize the value of data
    abstraction.
     
Or lack of it. I find that the Boolean/Integer schism in Fortran caused
me lots of headaches long ago.
     
    > New operators like "< =", in addition to being hard to spell and
    > understand,
    > facilitate usages that just aren't that common.  I hardly ever want to
    > say x = (x < y), and I don't mind typing the extra characters. I'm not
    > interested in paying compiler vendors money for supporting this
    > (or any other dubious misfeature pounded into the language for
    > "completeness'sake.")
     
    Here is an example where proper use of Boolean data would be violated.
    A statement like
        x = x < y;
    should NEVER be used, since it assigns a Boolean result to an
    arithmetic variable.  This means that a "< =" operator is not
    a good idea.
     
Wrong you are, Doug. You have been thinking in this Boolean paradigm
for so long that you are missing another Good thing. Implication!
Given that P and Q are `Boolean' variables (0 or 1), the Logical
Implication is described by the operator `<='. Thus, the statement
`x = p <= q;' sets the `boolean' value x to a `boolean' expression.
Since there are no such things as booleans :-), x, p, & q are integers.
It's all a matter of interpretation. APL has no `boolean exclusive or'
operator because the operator `!=' does the same thing (when given
only zero's or one's). There are sixteen different boolean functions
with two inputs and one output. They all fit nicely into C operators:
     
    p 0 0 1 1
    q 0 1 0 1    Name        Symbol
    ---------    ----        ------
      0 0 0 0    False        0
      0 0 0 1    And        &
      0 0 1 0    Doesn't Imply    >
      0 0 1 1    Alpha        p
      0 1 0 0    Not Implied By    <
      0 1 0 1    Omega        q
      0 1 1 0    Diff        != or ^
      0 1 1 1    Or        |
      1 0 0 0    Nor        !(p | q)
      1 0 0 1    Same        ==
      1 0 1 0    Not Omega    !q
      1 0 1 1    Is Implied By    >=
      1 1 0 0    Not Alpha    !p
      1 1 0 1    Implies        <=
      1 1 1 0    Nand        !(p & q)
      1 1 1 1    True        1
     
Neat! I never thought I'd get to use my engineering switching theory again!
     
    I find data abstraction to be a Good Thing, and have produced
    much better code since defining a Boolean data type and using
    it in a strictly type-correct manner.
     
This fact doesn't bother people who write in APL, widely considered
to be the most mathematical language. Why does it bother you?
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6034
          for JMS@ARIZMIS; Wed, 14-MAY-1986 04:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/14/86 at 06:18:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009274; 13 May 86 23:07 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a015399; 13 May 86 22:15 EDT
Date:     Tue, 13 May 86 22:11:57 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Root Boy Jim <rbj@ICST-CMR.ARPA>
cc:        sbs%valid.uucp@BRL.ARPA, info-c@BRL-SMOKE.ARPA
Subject:  Re:  Boolean Operators Slighted in C
     
Index to participants:
    >>> Steven Brian McKechnie Sargent
    >> Doug Gwyn
    > Jim Cottrell
     
>>> New operators like "< =", in addition to being hard to spell and
>>> understand,
>>> facilitate usages that just aren't that common.  I hardly ever want to
>>> say x = (x < y), and I don't mind typing the extra characters. I'm not
>>> interested in paying compiler vendors money for supporting this
>>> (or any other dubious misfeature pounded into the language for
>>> "completeness'sake.")
>>
>> Here is an example where proper use of Boolean data would be violated.
>> A statement like
>>     x = x < y;
>> should NEVER be used, since it assigns a Boolean result to an
>> arithmetic variable.  This means that a "< =" operator is not
>> a good idea.
>
> Wrong you are, Doug. You have been thinking in this Boolean paradigm
> for so long that you are missing another Good thing. Implication!
> Given that P and Q are `Boolean' variables (0 or 1), the Logical
> Implication is described by the operator `<='. Thus, the statement
> `x = p <= q;' sets the `boolean' value x to a `boolean' expression.
> Since there are no such things as booleans :-), x, p, & q are integers.
> It's all a matter of interpretation. APL has no `boolean exclusive or'
> operator because the operator `!=' does the same thing (when given
> only zero's or one's). There are sixteen different boolean functions
> with two inputs and one output. They all fit nicely into C operators:
> [table omitted]
     
Even Boole knew that Boolean operations can be performed
by appropriate arithmetic on {0,1} operands; that is irrelevant.
     
The original example, x "< =" y;, interpreted as you suggest, would
mean `set x to "x is not implied by y"', if and only if x and y were
Boolean in the first place.  Not only is this of negligible practical
value, but that meaning of the operator differs from its meaning
when applied to non-Boolean values (the general case, and the one I
had in mind when I argued that it was a bad idea).
     
>> I find data abstraction to be a Good Thing, and have produced
>> much better code since defining a Boolean data type and using
>> it in a strictly type-correct manner.
>
> This fact doesn't bother people who write in APL, widely considered
> to be the most mathematical language.
     
APL doesn't offer real facilities for data abstraction.
     
> Why does it bother you?
     
Because as a conscientious software engineer I have to produce
reliable and maintainable systems for people to use.
This requires quality standards well beyond what hackers might
feel to be necessary.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2148
          for JMS@ARIZMIS; Fri, 16-MAY-1986 16:18 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/15/86 at 21:31:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016276; 15 May 86 21:43 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a006738; 15 May 86 21:00 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA20738; Thu, 15 May 86 21:00:59 edt
Date: Thu, 15 May 86 21:00:59 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605160100.AA20738@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Design Process
     
    > All too often, one sees programmers writing code before
    > a proper job of analysis and design has been done.  I
    > also believe that is partly because semi-running code
    > makes it appear as though progress has been made,
    > while a complete design doesn't convey the same impression.
     
    Sorry, Doug, I can't let that one go by.
     
Me neither. It has also been said that programs should be written twice:
once to find out what the specs are, then that program should be thrown
away and the job done right.
     
TPC seems to have followed that philosophy, as System V looks nothing
at all like UNIX :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8362
          for JMS@ARIZMIS; Fri, 16-MAY-1986 16:19 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/15/86 at 13:01:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021676; 14 May 86 13:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026379; 14 May 86 13:42 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: "formals" and "actuals"
Message-ID: <347@dg_rtp.UUCP>
Date: 9 May 86 00:46:04 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>>Well.  Sizeof is indeed peculiar.  For example,
>>sizeof(formal_array_name) yeilds your machine's pointer size.
>
> Ouch.  First off (see that nit?), it took me two (admittedly
> fraction-of-a-second) passes to understand that you were talking
> about what sizeof yields [sp!] on an array declared as a formal
> a r g u m e n t .
     
Hmpf.  I thought that the term "formal" used to mean "an argument to a
function" was quite wide-spread in talking about algol-derived
languages, and others besides.  The value passed to a formal is normally
called an "actual" or an "actual argument".  Sorry about the
confusion.  I suppose I could have said "formal_argument_array_name".
Using "formal_argument" rather than "argument" is, of course, intended
to get around the ambiguity of whether I'm talking about something I'm
passing to a function, or something that the function expects to
be passed.
     
Is there anybody (besides Joe) who thinks this abreviated usage
("formal" meaning "formal argument") is unclear?  I'm not sure but what
I'm tempted to continue using "formal" to refer to a formal argument,
since it is so convenient.  On the other hand, I don't want to confuse
folks.
     
> It's fairly clear that when you declare a formal
> argument to a function, the C compiler coerces it from array-of-X
> to pointer-to-X.  You are therefore taking the size of a pointer,
> and it returns the size of that pointer (which size may depend on
> the type of the thing to which you are pointing).
     
Yes, fine, wonderful, I agree, great.  *BUT*.  The formal was defined to
be an array, by gar.  It's sizeof should be array-like.  Take this
example, for example.
     
        void f(a,c,s,i) int a[10]; char c; short s; int i; {
            printf( "%d %d %d %d\n",
                sizeof a,
                sizeof c,
                sizeof s,
                sizeof i );
        }
     
        void main(){
            int a[10]; char c; short s; int i;
            f( a, c, s, i );
            printf( "%d %d %d %d\n",
                sizeof a,
                sizeof c,
                sizeof s,
                sizeof i );
        }
     
This program produces the output
     
        4 1 2 4
        40 1 2 4
     
Now, by your theory, since "char" and "short" are promoted to int in the
context of a call, it "ought to" have printed
     
        4 4 4 4
        40 1 2 4
     
Clearly, my way of having it print
     
        40 1 2 4
        40 1 2 4
     
is a smaller change to the language, and is thus preferable to yours.
:-)
     
More seriously, if one can say "f's formal is an array", the dratted
thing should *behave* like an array, just like a char formal behaves
like a char despite the actual being promoted to an int.  Compilers do
handstands now to see that char and short formals behave properly
despite being transformed by the calling conventions.  I think arrays
should do the same.  And before you say that "well, the coersion of
array to pointer happens before the call", let me reply that that is
irrelevant.  The point is that the formal declaration is a white lie,
and for some types this white lie is well hidden and for others it is
not.  I wish it to be equally well hidden for all types where this is
possible.
     
> As usual, this has been discussed to death in earlier articles.
> If someone has a copy of my long-ish tutorial on this subject,
> please send it to me.  I promise not to re-post it more often than
> every year or two, and flag it so you can junk it.
     
Sadly, I don't have it.  I remember it as being quite good, though.
So it goes.
     
> Joe Yao  hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9092
          for JMS@ARIZMIS; Sun, 18-MAY-1986 23:27 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 01:15:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000297; 19 May 86 1:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010141; 16 May 86 5:53 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <1469@umcp-cs.UUCP>
Date: 12 May 86 14:05:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <989@dataioDataio.UUCP>, bjorn@dataio.UUCP writes:
>... I notice this (odd) fact: the compiler on the PC is better than
>the one on the VAX!  It's faster, it produces better code, and it
>catches errors that the UNIX C does not.  So I'm curious:
>    The state-of-the-art in compilers has progressed on PCs,
>    so why hasn't anyone come up with a better compiler for
>    UNIX, or have I just not heard of it?
     
1.  Your company gets paid for improving your compiler.  Is not
    that so?
     
2.  The 4.3BSD C compiler has a number of improvements in both
    compilation speed and code generation.  (Nothing major, just
    little fixes, but then *we* are *not* paid to do this sort
    of thing....)
     
3.  I believe there are several optimising compilers for Vax Unix
    (which version(s), I do not know) on the market.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9187
          for JMS@ARIZMIS; Sun, 18-MAY-1986 23:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 01:30:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ab00297; 19 May 86 1:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008371; 16 May 86 0:28 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c,net.micro.pc,net.unix-wizards
Subject: Re: Varargs, portability
Message-ID: <916@brl-smoke.ARPA>
Date: 16 May 86 04:28:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> No, because you have exceeded the VAX's 255-byte argument limit.
     
Oops, the VAX allows 255 longwords, not 255 bytes.  Sorry!
However, this is a problem to watch out for, if you pass
structs by value.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9546
          for JMS@ARIZMIS; Mon, 19-MAY-1986 00:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 02:45:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023343; 14 May 86 14:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026361; 14 May 86 13:42 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <345@dg_rtp.UUCP>
Date: 8 May 86 20:36:34 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> jimc@ucla-cs.ARPA (Jim Carter)
>>  kwh@bentley.UUCP (KW Heuer)
>>Btw, you can't have *all* operators extended with "=".  How would you write
>>"v = v < e;"?  (Not that it's useful.)
> I think it's useful!  As written, of course, it's semantically invalid,
> but what you really mean is "v <= e" (sic) or, to demonstrate where it's
> really useful,
>      array[horrendous] [subscript] [list] <= bigexpr;
>   rather than
>      if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
     
The point is not that it isn't useful to collapse multiple array (or
other clumsy) references.  The point is that in "e1 = e1 < e2", the "<"
operator assumes arguments with numeric semantics and yeilds a value
with boolean semantics.  Since e1 is both an argument and a result, this
expression isn't very meaningful.  The fact that C overloads the numeric
types with boolean meaning doesn't make this a useful thing to do.
Interestingly, if e2 also has boolean semantics, the "e1 < e2" gives the
same result as "!e1 && e2" (ignoring side effects).  Doesn't seem like a
primitive to clammor for in the language, nor does "<" seem like a good
symbol for it if it were a primitive.
     
Now, I know what all you hackers are saying.  You're saying "But Wayne,
how did you become a LOVE GOD?" (What's that?  net.lang.c?  Not
net.panting.singles?  Sorry, I mean) "But Wayne, I just don't care
diddly about numeric vs boolean type safety debates.  I just want
something that'll WORK." Ok.  Fine.  But you'll probably be looking for
subtle and disgusting bugs in programs that contain oddities like
"e1 = e1 < e2" long after others are happily using working programs that
don't.  So there.
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9590
          for JMS@ARIZMIS; Mon, 19-MAY-1986 00:56 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 02:48:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026857; 14 May 86 19:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003691; 14 May 86 19:41 EDT
From: Svante Lindahl <zap%duvan.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: A good use of a bad feature
Message-ID: <812@duvan.UUCP>
Date: 10 May 86 04:37:24 GMT
Keywords: tacky programs, algol 68
To:       info-c@BRL-SMOKE.ARPA
     
In article <1298@umcp-cs.UUCP> jim@umcp-cs.UUCP writes:
>/*
> * xmas.c - a program to print The Twelve Days of Christmas
> * using the C fall thru case statement.
> * If this wasn't my idea, I appologize to whomever I
> * got the idea from, but I wrote the program 5 years
> * ago and I don't remember now.
[...]
Sorry this isnt' C, but I can't resist posting this... though
I realize this is probably not a very apropriate newsgroup.
It isn't my work, but I've lost track of who wrote it. Anyway
it is an amusing piece of Algol-68-code. Example of execution
under the TOPS-10 OS included after the code.
     
BEGIN
  PROC readint = INT: (INT i; read(i); i);
  INT  one=1, two=2, three=3, four=4, five=5, six=6,
       seven=7, eight=8, nine=9, ten=10, eleven=11, twelve=12;
  INT  a=one;
  PRIO ME=5, LOVE=7, MY=7, LORDS=7, LADIES=7,
       PIPERS=7, DRUMMERS=7, MAIDS=7, SWANS=7, GEESE=7,
       GOLD=7, COLLY=7, FRENCH=7, TURTLE=7, PARTRIDGE=6;
  BOOL sent to=TRUE;
  OP THE =    (BOOL a)BOOL:a,
     TWELFTH =    (INT a)BOOL: a=twelve,
     ELEVENTH =    (INT a)BOOL: a=eleven,
     TENTH =    (INT a)BOOL: a=ten,
     NINTH =    (INT a)BOOL: a=nine,
     EIGHTH =    (INT a)BOOL: a=eight,
     SEVENTH =    (INT a)BOOL: a=seven,
     SIXTH =    (INT a)BOOL: a=six,
     FIFTH =    (INT a)BOOL: a=five,
     FOURTH =    (INT a)BOOL: a=four,
     THIRD =    (INT a)BOOL: a=three,
     SECOND =    (INT a)BOOL: a=two,
     FIRST =    (INT a)BOOL: a=one;
  OP ME =    (BOOL a, INT b)VOID: (IF a THEN print(b) FI),
     LOVE =    (BOOL a, b)BOOL: (IF a THEN b ELSE FALSE FI),
     MY =    (BOOL a, b)BOOL: a LOVE b,
     AND =    (INT a)INT: a;
  MODE DATE =    STRUCT(INT day, month);
  DATE christmas := (25, 12);
  OP LORDS =    (INT a, b)INT: a*b,
     LADIES =    (INT a, b)INT: a*b,
     PIPERS =    (INT a, b)INT: a*b,
     DRUMMERS =    (INT a, b)INT: a*b,
     MAIDS =    (INT a, b)INT: a*b,
     SWANS =    (INT a, b)INT: a*b,
     GEESE =    (INT a, b)INT: a*b,
     GOLD =    (INT a, b)INT: a*b,
     COLLY =    (INT a, b)INT: a*b,
     FRENCH =    (INT a, b)INT: a*b,
     TURTLE =    (INT a, b)INT: a*b;
  OP LEAPING =    (INT a)INT: a,
     DANCING =    (INT a)INT: a,
     PIPING =    (INT a)INT: a,
     DRUMMING =    (INT a)INT: a,
     MILKING =    (INT a)INT: a,
     SWIMMING =    (INT a)INT: a,
     LAYING =    (INT a)INT: a,
     RINGS =    (INT a)INT: a,
     BIRDS =    (INT a)INT: a,
     HENS =    (INT a)INT: a,
     DOVES =    (INT a)INT: a;
  OP PARTRIDGE = (INT a, b)INT: a+b;
  INT in a pear tree = 0;
     
  print("Factorial of ");
  print(day OF christmas := readint);
  print(" is ");
  IF day OF christmas > 12 THEN
    print("too big for this program.");
    stop
  FI;
     
    # Now we are ready.. #
     
   THE FIRST day OF christmas MY TRUE LOVE sent to ME
  a PARTRIDGE in a pear tree;
     
    THE SECOND day OF christmas MY TRUE LOVE sent to ME
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE THIRD day OF christmas MY TRUE LOVE sent to ME
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE FOURTH day OF christmas MY TRUE LOVE sent to ME
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE FIFTH day OF christmas MY TRUE LOVE sent to ME
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE SIXTH day OF christmas MY TRUE LOVE sent to ME
  six GEESE LAYING
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE SEVENTH day OF christmas MY TRUE LOVE sent to ME
  seven SWANS SWIMMING
  six GEESE LAYING
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE EIGHTH day OF christmas MY TRUE LOVE sent to ME
  eight MAIDS MILKING
  seven SWANS SWIMMING
  six GEESE LAYING
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE NINTH day OF christmas MY TRUE LOVE sent to ME
  nine DRUMMERS DRUMMING
  eight MAIDS MILKING
  seven SWANS SWIMMING
  six GEESE LAYING
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE TENTH day OF christmas MY TRUE LOVE sent to ME
  ten PIPERS PIPING
  nine DRUMMERS DRUMMING
  eight MAIDS MILKING
  seven SWANS SWIMMING
  six GEESE LAYING
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE ELEVENTH day OF christmas MY TRUE LOVE sent to ME
  eleven LADIES DANCING
  ten PIPERS PIPING
  nine DRUMMERS DRUMMING
  eight MAIDS MILKING
  seven SWANS SWIMMING
  six GEESE LAYING
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree;
     
    THE TWELFTH day OF christmas MY TRUE LOVE sent to ME
  twelve LORDS LEAPING
  eleven LADIES DANCING
  ten PIPERS PIPING
  nine DRUMMERS DRUMMING
  eight MAIDS MILKING
  seven SWANS SWIMMING
  six GEESE LAYING
  five GOLD RINGS
  four COLLY BIRDS
  three FRENCH HENS
  two TURTLE DOVES AND
  a PARTRIDGE in a pear tree
     
END
     
     
.execut xmas
A68:    XMAS
ALGOL68C Release 1.271
Unused space 991
     
Code generated 8r2271
     
LINK:    Loading
[LNKXCT    A68 execution]
7
Factorial of            +7 is         +5040
     
Svante Lindahl, NADA, KTH            Numerical Analysis & Computer Science
UUCP: {seismo,mcvax}!enea!ttds!zap   Royal Institute of Technology, Sweden
ARPA: enea!ttds!zap@seismo.CSS.GOV   EAN: zap@cs.kth.sunet

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9701
          for JMS@ARIZMIS; Mon, 19-MAY-1986 01:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 02:52:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027992; 15 May 86 0:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006081; 14 May 86 23:54 EDT
From: Mark Patrick <markl%vecpyr.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc,net.unix-wizards
Subject: Varargs, portability
Message-ID: <279@vecpyr.UUCP>
Date: 9 May 86 22:55:04 GMT
Xref: brl-sem net.lang.c:1009 net.micro.pc:1084 net.unix-wizards:1176
To:       info-c@BRL-SMOKE.ARPA
     
Is the following program portable to any machine which provides a
(reasonable) implementation of C.
     
     
#include <varargs.h>
     
fred(ap)
va_list ap ;
{
    int i ;
     
    for ( i=0; i < 52 ; i++ ) {
        if ( (i%2) == 0 )
            printf("%d\n",va_arg(ap, int)) ;
        else    printf("%f\n", va_arg(ap, double)) ;
    }
}
     
joe(va_alist)
va_dcl
{
    va_list ap ;
    va_start(ap) ;
    fred(ap) ;
    va_end(ap) ;
}
     
main()
{
    joe( 1,2.5,3,4.5,5,6.5,7,8.5,9,10.5,11,12.5,13,14.5,15, 16.5, 17,
18.5, 19,20.5,21,22.5,23,24.5,25,26.5,27,28.5,29,30.5,31,32.5,33,34.5,35,36.5,
37,38.5,39,40.5,41,42.5,43,44.5,45,46.5,47,48.5,49,50.5,51,52.5) ;
}
     
--
     
            Mark Patrick
     
            ...{lll-crg, amd, dual}!vecpyr!markl
            Visual Engineering Corp, San Jose, CA

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0339
          for JMS@ARIZMIS; Mon, 19-MAY-1986 02:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id af00297; 19 May 86 2:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022831; 16 May 86 15:48 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: varargs
Message-ID: <5430@alice.uUCp>
Date: 10 May 86 16:37:11 GMT
Xref: brl-sem net.lang.c:1072 net.unix-wizards:1194
To:       info-c@BRL-SMOKE.ARPA
     
> Hypothetical but quite beleivable:  On a 68000, pass the first N
> 32-bit integer (int, long, etc.) arguements in data regisers and the
> first M (32-bit) pointer arguments in address registers.  There isn't
> a typeof operator, and the hack of determining the data type by doing
> string manipulations on the quoted type, besides preprocessor
> replacements in quoted strings being a pcc oddity, breaks when faced
> with typedefs.  (I think argument quoting via a different meathod is
> proposed in the current ansi C draft.)
>
> This is true of any architecture with different register types with
> identical size.  (Otherwise the type could be determined by sizeof,
> which I do in the varargs.h implementation I wrote.)  Any proposted
> solutions, other than not having such a compiler on such a machine?
     
If a pointer argument is passed in a different place from an
integer argument of the same size, then implementing varargs
requires some help from the compiler.
     
But such an implementation is going to have trouble in any event
because even today there are sometimes programs that forget to,
say, declare the type of an argument.  This is especially true
when that argument is merely passed to some other function.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0378
          for JMS@ARIZMIS; Mon, 19-MAY-1986 02:23 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ah00297; 19 May 86 2:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022909; 16 May 86 15:49 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <2496@watmath.UUCP>
Date: 9 May 86 13:16:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > lots of us say "typedef short bool" in our .h files.
> typedef char bool;    uses less space on some machines.
     
And on some machines it uses more space.  Some machines can
reference an int with a single instruction, but checking the
value of a byte might take several.  The one I am using now
does the "if(integer)" test in 4 bytes of machine instructions,
but "if(character)" takes 12 bytes.
     
So defining it as short or char instead of int might save you
1 or 3 bytes of storage, but it also might cost you several
times this amount EVERY time you reference the variable.
In general you should always use int (or long).  short (or char)
should only be used for structures read in from an external
source or for large arrays where the saving in space for the
data is significantly large.
     
Of course if you aren't worried about portable efficiencies
do whatever is best for your machine.  On the other hand, I'd
like to think that at least some of the software I write now
will still be running in 10 years, but I have my doubts about
whether or not some of the machines I am using now will still
be here then.  (I can think of some wonderful code I wrote for
an IBM1620 not much more than 10 years ago.)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0421
          for JMS@ARIZMIS; Mon, 19-MAY-1986 02:27 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aj00297; 19 May 86 2:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022941; 16 May 86 15:50 EDT
From: bright%dataio.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Greenleaf Function Library
Message-ID: <992@dataioDataio.UUCP>
Date: 9 May 86 15:18:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <479@brl-smoke.ARPA> C90562JM%WUVMD.BITNET@wiscvm.ARPA writes:
>I have been using the Greenleaf Functions general library for
>over 2 years and have in general been quite happy with it and have
>recommended it to others as a reasonable general purpose library
>for PC-DOS environments.  I now must modify that recommendation
>as it appears that the vendor is unwilling to support the code
>which they distribute.
> [description of bug]
>I sent a fix to them.  This was over two
>weeks ago and the greenleaf folks have neither acknowledged what
>I sent them nor fixed the routine.
>Since source is supplied with the Greenleaf Functions, I can fix
>it for myself, but other potential buyers should be aware of the
>apparent lack of support by Greenleaf for their library.
     
I think you should give the people at Greenleaf a break. Expecting them
to fall over dead when a minor bug is found in their code is unreasonable.
All significant software has bugs. Normal practice for a company is to
wait until a sufficient number of bugs have been found to warrant
issuing an update. If a company released revised versions of their software
every time a bug was reported, and worked overtime to release it as soon
as possible, they would go out of business.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0478
          for JMS@ARIZMIS; Mon, 19-MAY-1986 02:31 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ai00297; 19 May 86 2:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023014; 16 May 86 15:53 EDT
From: flaps%utcs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: builtins and automatic defines
Message-ID: <1232@utcs.uucp>
Date: 11 May 86 07:12:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Well I sure hope no one sticks in such a thing without telling me!
Any such #include or #define things should not only be optional, they
should have to be explicit.  So perhaps instead of merely beginning every
program with #include <stdio.h>, you can also have #include <builtins.h>.
     
*I* won't #include it, though...
     
Alan J Rosenthal
{linus|decvax}!utzoo!utcs!flaps, {ihnp4|allegra}!cbosgd!utcs!flaps

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0545
          for JMS@ARIZMIS; Mon, 19-MAY-1986 02:37 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ak00297; 19 May 86 2:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023335; 16 May 86 16:00 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <880@ttrdc.UUCP>
Date: 11 May 86 22:27:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <732@steinmetz.UUCP>, davidsen@steinmetz.UUCP (Davidsen) writes:
>XOR can be defined as an (ugly) macro, I believe.
>
>#define XOR(a,b) (((a) != 0) != ((b) != 0)
>/* or if you like small better than readable */
>#define XOR(a,b) (!!(a) != !!(b))
>--
>    -bill davidsen
     
or even
     
#define XOR(a,b)    (!(a) != !(b))
     
since XOR(not-a,not-b) == XOR(a,b)
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0664
          for JMS@ARIZMIS; Mon, 19-MAY-1986 02:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id al00297; 19 May 86 2:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023485; 16 May 86 16:03 EDT
From: Maurice Lampell <ml%sabre.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.68k,net.micro.cpm
Subject: Reposting: need Z80 cross-compiler for 68000-based 4.2 BSD UNIX
Message-ID: <111@sabre.UUCP>
Date: 12 May 86 15:33:27 GMT
Xref: brl-sem net.lang.c:1077 net.micro.68k:166 net.micro.cpm:296
To:       info-c@BRL-SMOKE.ARPA
     
I am in need of Z80 cross-compiler tools to run on my Integrated Solutions
Unix System. The I.S. system is a 68020 4.2 BSD with a Green Hills Compiler
(with 4-byte ints). I need a full set of tools: compiler, linker, assembler
and library functions; the target is a Z80-based SBC.
     
We are willing to buy this product if it is available.
     
                Maurice Lampell
                Bell Communications Research
                (201) 758-2592
     
Please send any replies to: ...!bellcore!nvuxd!ml
            or  ...inhp4!nvuxd!ml

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1030
          for JMS@ARIZMIS; Mon, 19-MAY-1986 03:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 05:03:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028006; 15 May 86 0:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005834; 14 May 86 23:46 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <754@nbires.UUCP>
Date: 9 May 86 05:31:54 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >Btw, you can't have *all* operators extended with "=".  How would you write
> >"v = v < e;"?  (Not that it's useful.)
     
A more precisely stated rule, for C, would be that you can extend any
dyadic operator whose result type is the same as the type of the first
operand, but...
     
> I think it's useful!  As written, of course, it's semantically invalid,
> but what you really mean is "v <= e" (sic) or, to demonstrate where it's
> really useful,
>      array[horrendous] [subscript] [list] <= bigexpr;
>   rather than
>      if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
     
Cf. Icon, in which the success/failure of a conditional is separate from
its value.  Icon's <= operator (as all of its relational operators) yields
the value of its right operand if it succeeds; otherwise it fails (meaning
no result is produced).  The semantics described above in ">" is just that
of Icon's <:= operator.
--
Dick Dunn    {hao,ucbvax,allegra}!nbires!rcd        (303)444-5710 x3086
   ...Cerebus for dictator!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1106
          for JMS@ARIZMIS; Mon, 19-MAY-1986 03:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 05:12:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028065; 15 May 86 0:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006355; 15 May 86 0:11 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c,net.micro.pc,net.unix-wizards
Subject: Re: Varargs, portability
Message-ID: <862@brl-smoke.ARPA>
Date: 15 May 86 04:11:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <279@vecpyr.UUCP> markl@vecpyr.UUCP (Mark Patrick) writes:
>Is the following program portable to any machine which provides a
>(reasonable) implementation of C.
> ...
>    joe( 1,2.5,3,4.5,5,6.5,7,8.5,9,10.5,11,12.5,13,14.5,15, 16.5, 17,
>18.5, 19,20.5,21,22.5,23,24.5,25,26.5,27,28.5,29,30.5,31,32.5,33,34.5,35,36.5,
>37,38.5,39,40.5,41,42.5,43,44.5,45,46.5,47,48.5,49,50.5,51,52.5) ;
     
No, because you have exceeded the VAX's 255-byte argument limit.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1284
          for JMS@ARIZMIS; Mon, 19-MAY-1986 03:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028735; 15 May 86 4:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007686; 15 May 86 3:50 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint (also, malloc())
Message-ID: <866@ttrdc.UUCP>
Date: 9 May 86 23:41:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <798@bentley.UUCP>, kwh@bentley.UUCP (KW Heuer) writes:
>In article <592@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>>> C is the only language that I can remember that has a separate
>>> program (lint) to find and report compiler errors in source code.
>>First, the errors detected are not COMPILER errors but CODING errors.
>>Second, [examples of other languages]
>>Third, "lint"ing is not necessary on every compilation.
>>Fourth, on small systems ... [it's better than] complicated multi-pass.
>>Fifth, "lint" is rather portable, [but cc] is inherently machine-dependent.
>Moreover, because lint is an optional pass which doesn't produce code, it's
>safe for it to be overly conservative and flag "errors" which might be okay.
>For example, the "possible pointer alignment problem" which results from any
>nontrivial cast of malloc().
>Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
While I also think that 'lint' is best standalone or at least not default
when compiling, I wish to note that cc as it stands now sometimes produces
warnings about things which are not fatal but which usually indicate sleazy
or nonportable code.
     
Y'know--while I'm thinking about it, why IS malloc() set up to return a
(char *) pointer at all, if that IS inviting a potential (or at least to
lint's little mind) pointer alignment problem?  Since malloc() is supposed
to return a maximally aligned pointer, seems to me that it should have
been set up to return a (double *).  Yes, yes, before flames of misunder-
standing start, I _KNOW_ that the convention for malloc() is to return
a (char *) and that it returns a maximally aligned pointer just the same
because of the way it has been written.  It just seems that the methodology
was back-a**wards, that at least returning a (double *) would indicate an
implicit promise to the user (and to lint-like checking) that the return
value WAS maximally aligned.  The only problem I could see with this kind
of scheme is that some systems might not support double.  But that could
be gotten around by #defining a malloc_t type that would represent the
maximally aligned data type of the machine at hand.
     
Of course malloc() is now cast in stone, so I doubt seriously whether it
would be worth the trouble to implement a new memory-allocating interface
in C now.
     
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2190
          for JMS@ARIZMIS; Mon, 19-MAY-1986 05:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 07:15:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002366; 19 May 86 4:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001893; 19 May 86 3:48 EDT
From: John Mashey <mash%mips.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: arguments in registers [a Good Thing]
Message-ID: <476@mips.UUCP>
Date: 12 May 86 05:07:14 GMT
Xref: brl-sem net.lang.c:1080 net.unix-wizards:1199
To:       info-c@BRL-SMOKE.ARPA
     
In article <109@ima.UUCP> johnl@ima.UUCP (John R. Levine) writes:
>In article <1205@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>>In article <155@cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>>>[Passing arguments in registers] would be fine if C had nested
>>>procedures or inlines or something, but a disaster otherwise.
>>
>>In fact, a compiler is free to optimise any function into inline code,
>
>Actually, you can always pass arguments in registers if you're smart about it.
>The compiler for the IBM RT/PC does.  (A clever idea added after I stopped
>working on it.)  The first few arguments to a procedure are always passed in
>registers, but space is left for them in the stack frame.  If they aren't
>declared register in the routine, the routine's prolog saves them.  Note that
^----------------------------------------------------------------^
>this saves code space, since you have one set of store instructions in the
>routine's prolog rather than replicating the code at each call.  If the
>arguments are declared register, well, they're already in registers.
     
1) Passing arguments in registers is indeed a big win. There is at least
some belief that 2 registers gets you 70-80% of the calls, 4 registers
gets you 90-95%.
     
2) I'm sure many systems do this these days, especially now that varargs
is more widely used.  I may recall incorrectly, but I thought the Zilog
ZEUS system's compiler did this.  At least the HP Spectrum and MIPS R2000
compilers do (4 regs).  This is especially attractive on 32-register RISC
machines.  Certainly the method is not a "disaster", since live
running Unices are supported by them.
     
3) (^---^ part above): They don't have to be saved unless the code takes
the address of them (the exact conditions vary, but reasonable assumptions
can be made).  A good global optimizer may well NEVER save them.
In particular, they almost NEVER need to be saved inside a leaf (i.e.,
calls no functions) routine, at least on machines that have 32 registers.
Even better, the arguments may well be computed into the argument registers
in the first place.
     
4) For good optimizers, "register x" doesn't mean much any more except
to clue the compiler quickly that no address can be taken of x.
--
-john mashey    DISCLAIMER: <generic disclaimer, I speak for me only, etc>
UUCP:     {decvax,ucbvax,ihnp4}!decwrl!mips!mash, DDD:      408-720-1700, x253
USPS:     MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2312
          for JMS@ARIZMIS; Mon, 19-MAY-1986 05:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 07:20:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002368; 19 May 86 4:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001986; 19 May 86 3:51 EDT
From: Steve Rumsby <steve%warwick.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <287@euclid.warwick.UUCP>
Date: 12 May 86 10:13:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <797@bentley.UUCP> kwh@bentley.UUCP writes:
>In article <501@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>>I have ranted about C using a one statement model for its control
>>statements instead of an explicit end statement.  Compound statements are
>>bounded by braces instead.  Yuk!
>
>Ah yes, there are two major types of language in the structured family;
>f77 with "endif" (some members use "end" for all of "endif", "endwhile",
>etc.) and pascal with "begin" "end" (which C abbreviates to "{" "}").  I
>presume this is what you dislike.  (If it's the spelling that bothers you,
>I'm sure you're aware that you can define "begin" and "end" as macros.)
>
>Yet another convention, not endorsed by any language I know, is to dispense
>with the braces and let the indentation alone tell the compiler how to
>interpret the program.  (I came up with this idea after an argument on the
>"correct" place to put the braces.)
>
Occam uses this model to delimit its blocks. It's a nice idea - no more
adding {/} around an if's "then" or "else" part simply because you've
changed it from one statement to two. Consistency like this can save a
lot of time looking for missing braces, etc. However, you do have to be
*very* careful with the space bar. One space in the wrong place can
also be a bit irritating to find, especially if you can't use vi/emacs
to match them for you like you can with {/}!
     
Couldn't you write a small(?) filter which would let you write C
without braces and fill them in for you from the indentation? It
doesn't seem too difficult. (No I'm not offering to do it).
     
                    Steve.
     
--
Steve Rumsby.
     
UUCP:    ...!ukc!warwick!steve
JANET:    steve%warwick.uucp@uk.ac.warwick.daisy
ARPA:    steve%warwick.uucp@ucl-cs.ARPA
BITNET:    steve%warwick.uucp%uk.ac.warwick.daisy@uk.ac

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2399
          for JMS@ARIZMIS; Mon, 19-MAY-1986 05:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002371; 19 May 86 4:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002034; 19 May 86 3:53 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#6
Message-ID: <1039@hou2d.UUCP>
Date: 11 May 86 11:28:56 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Sun, 11 May 86       Volume 16 : Issue   6
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 5
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 5
To: cbosgd!std-c%utcsri
     
# C.3.0.1 Lvalues {--> and function locators}
     
  *    An "lvalue" is an expression that designates an object {and  that
  *    may  be  used  to  change its value -->}.  {--> When an object is
       said to have a particular type, the  type  is  specified  by  the
       lvalue used to designate the object.}
     
N-->   If an lvalue appears in a context other than as an  operand  that
N-->   may  or  shall be an lvalue, if it has array type it is converted
N-->   to a pointer as described in #C.2.2.1, otherwise it  is  replaced
N-->   by  the  value  of  the  designated  object.  In either case, the
N-->   result is not an lvalue.
     
N-->   A "modifiable lvalue" is an lvalue that does not have array  type
N-->   and does not have a type declared with the const type specifier.
     
N-->   A "function locator" is an expression that has function type.  If
N-->   a  function locator appears in a context other than as an operand
N-->   that may or shall be a function locator, it  is  converted  to  a
N-->   pointer  as  described in #C.2.2.1.  The result is not a function
N-->   locator.
     
  *    {Some operators yield lvalues. -->} The discussion of each opera-
  *    tor  {states if it expects --> identifies those that may or shall
  *    have an lvalue {-->,  modifiable  lvalue,  or  function  locator}
  *    operand, and {if it --> those that} yield an lvalue {--> or func-
       tion locator} result.
     
  *    ...  The name "lvalue" comes {--> originally} from the assignment
       expression  E1 = E2,  in  which  the  left  operand E1 must be an
  *    lvalue.  {--> It is perhaps better considered as representing  an
       object  "locator value".  What is sometimes called "rvalue" is in
       this Standard described as the "value of an expression".}
     
  *    An obvious example of an lvalue is an  identifier  {used  on  the
       left  side  of  an  assignment  operator --> of an object}.  As a
       further example, if E is a  unary  expression  that  has  pointer
       type,  *E  is  an  lvalue  that  designates the object to which E
       points.
     
     
     
# C.3.1 Primary expression
     
<--O   An identifier is a primary expression, provided it has been suit-
<--O   ably  declared  as discussed later.  Its type is specified by its
<--O   declaration, except for the conversions of function and array ex-
<--O   pressions  discussed  previously.   Because of these conversions,
<--O   function and array identifiers are not lvalues.
     
N-->   An identifier is a primary expression, provided it has  been  de-
N-->   clared as an object (in which case it is an lvalue) or a function
N-->   (in which case it is a function locator).
     
       A constant is a primary expression.   Its  type  depends  on  its
  *    form, as detailed {previously --> in #C.1.1.3}.
     
<--O   A string literal is a primary expression.  Its type is originally
<--O   "array of const char"; following the conversion rule given previ-
<--O   ously for arrays, this is converted to "pointer  to  const  char"
<--O   and  the  result  is  a  pointer  to the initial character in the
<--O   string literal.
     
N-->   A string literal is a primary expression.  It  is  an  lvalue  of
N-->   type "array of char", as detailed in #C.1.1.4.
     
  *    A parenthesized expression is a primary  ...   {The  presence  of
       parentheses  does not affect whether the expression is an lvalue.
       --> It is an lvalue if the unadorned expression is an lvalue,  or
       a  function locator if the unadorned expression is a function lo-
       cator.}
     
     
     
# C.3.2.1 Array subscripting
     
<--O   Usually,  the  first  expression  has  type   "array   of   TYPE"
<--O   (equivalently,  "pointer  to  TYPE"),  the subscript has integral
<--O   type, and the type of the result is "TYPE".
     
N-->   One of the expressions shall have type  "pointer  to  TYPE",  the
N-->   other  expression  shall  have  integral type, and the result has
N-->   type "TYPE".
     
     
     
# C.3.2.1 Array subscripting
     
  *    If E is an n-dimensional array ...  then E, {appearing in an  ex-
       pression  -->  used  as  other than an lvalue}, is converted to a
       pointer to an (n-1)-dimensional array ...  If the unary *  opera-
       tor  is  applied  to  this pointer explicitly, or implicitly as a
       result of subscripting,  the  result  is  the  pointed-to  (n-1)-
  *    dimensional  array, which is itself {immediately converted into a
       pointer --> converted into a pointer if used  as  other  than  an
       lvalue}.
     
     
     
# C.3.2.2 Function calls
     
  *    The {first expression --> expression preceding  the  parentheses}
  *    shall  have  type  {"function returning TYPE" or -->} "pointer to
  *    function returning TYPE" {--> (which could be the result of  con-
       verting a function locator)}.
     
     
     
# C.3.2.2 Function calls
     
N-->   If a function prototype declarator is in scope, the number of ar-
N-->   guments  shall  agree  with the number of formal parameters.  The
N-->   types shall be such that each formal parameter  may  be  assigned
N-->   the value of the corresponding argument.
     
     
     
# C.3.2.2 Function calls
     
  *    An argument may be {a function identifier or an  expression  that
       has  the  type of any object --> any expression other than a void
       expression}.  In preparing for the call to a function, each argu-
  *    ment  is  {assigned  to the corresponding formal parameter; thus,
       all argument passing is strictly by value --> evaluated, and each
       formal parameter is assigned the value of the corresponding argu-
       ment}.
     
  *    ...  If no {"function prototype" (a declaration that declares the
       types of the parameters) --> function prototype declarator} is in
       scope, the integral promotions are performed, and arguments  that
  *    have  type  float  are promoted to double.  {--> These are called
       the "default argument conversions".  If the number  of  arguments
       or  their  types  after conversion do not agree with those of the
       formal parameters, the behavior is undefined.}
     
     
     
# C.3.2.3 Structure and union members
     
       A postfix expression followed by a dot and an  identifier  desig-
  *    nates  a member of a structure or union {object --> entity}.  The
  *    value ... is an lvalue {if the first expression is an lvalue  and
       the  type of the member is not array or a type with the const at-
       tribute --> unless the first expression is the value returned  by
       a function call}.
     
       A postfix expression followed by an arrow ...  and an  identifier
       designates  a  member  of a structure or union object.  The value
  *    ... is an lvalue {if the type of the member is  not  array  or  a
       type with the const attribute -->}.
     
<--O   ...  If f is a function returning a structure or union, and x  is
<--O   a member of that structure of union, f().x is a valid postfix ex-
<--O   pression but is not an lvalue.
     
     
     
# C.3.2.4 Postfix increment and decrement operators
     
  *    The operand ... shall be a {--> modifiable} lvalue.  ...
     
     
     
# C.3.3.1 Prefix increment and decrement operators
     
  *    The operand ... shall be a {--> modifiable} lvalue.  ...
     
     
     
# C.3.3.2 Address and indirection operators
     
N-->   The operand of the unary & operator shall be a  function  locator
N-->   or  an lvalue that designates an object other than a bit-field or
N-->   an object declared with the register storage-class specifier.
     
  *    The operand of the unary * operator shall have pointer type {-->,
       other than pointer to void.}
     
     
     
# C.3.3.2 Address and indirection operators
     
       The unary * operator denotes indirection.  If the operand  points
  *    to a function, the result is {an expression by which the function
       can be called --> a function locator}; ...
     
     
     
# C.3.3.2 Address and indirection operators
     
  *    It is always true that if E is an lvalue {--> or  function  loca-
  *    tor}, *&E is an lvalue {--> or function locator} equal to E.
     
  *    If *P is an lvalue and T is the name of an {-->  object}  pointer
       type,  the  cast  expression *(T)P is an lvalue that has the same
       type as that to which T points.
     
  *    Forward references: cast operators (#C.3.4)  {-->,  storage-class
       specifiers (#C.5.1), structure and union specifiers (#C.5.2.1)}.
     
------------------------------
     
End of mod.std.c Digest - Sun, 11 May 86 07:27:01 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2471
          for JMS@ARIZMIS; Mon, 19-MAY-1986 05:53 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002373; 19 May 86 4:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002038; 19 May 86 3:53 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#7
Message-ID: <1040@hou2d.UUCP>
Date: 11 May 86 11:34:37 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Sun, 11 May 86       Volume 16 : Issue   7
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 6
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 6
To: cbosgd!std-c%utcsri
     
# C.3.3.3 Unary arithmetic operators
     
  *    Except that it inhibits regrouping {--> of  subexpressions  of  E
       with   subexpressions   outside  of  E},  the  expression  +E  is
       equivalent to (0+E).
     
     
     
# C.3.3.4 The sizeof operator
     
<--O   The sizeof operator ... may be applied to  any  object  except  a
<--O   bit-field member of a structure, which is the only kind of object
<--O   whose size might not be an integral number of bytes.
     
N-->   The sizeof operator may not be applied to any expression that has
N-->   type  function,  bit-field, or void, or to the parenthesized name
N-->   of the type of such an expression.
     
     
     
# C.3.3.4 The sizeof operator
     
  *    The size is determined from the {declaration  -->  type}  of  the
  *    {object in the -->} operand {expression -->}, which is not itself
  *    evaluated.  The result is {an unsigned constant that has integral
       type  and may be used anywhere such a constant is required --> an
       integer constant}.  The size of  the  result  is  implementation-
  *    defined  {-->, and its type (an unsigned integral type) is size_t
       defined in the <stddef.h> header}.
     
     
     
# C.3.3.4 The sizeof operator
     
  *    When applied to a formal parameter that has array {-->  or  func-
  *    tion}  type, the sizeof operator yields the size of {a pointer to
       a member of such an array --> the pointer obtained by  converting
       as in #C.2.2.1}.
     
     
     
# C.3.3.4 The sizeof operator
     
<--O                       double *dp = alloc(sizeof (double));
<--O   ...
     
     
     
     
     
     
<--O                       sizeof(array)/sizeof(array[0])
     
N-->                       double *dp = alloc(sizeof *dp);
N-->   ...
N-->                       sizeof array / sizeof array[0]
     
     
     
# C.3.3.4 The sizeof operator
     
  *    Forward  references:  ...   {-->  terms  and  common  definitions
       (#D.1.1)}, ...
     
     
     
# C.3.4 Cast operators
     
  *    An {--> arbitrary} integer may be converted to  a  pointer.   {If
       the space provided was long enough, the mapping always carries an
       integer converted from a pointer back to the same pointer, but is
       otherwise --> The result is} implementation-defined.
     
     
     
# C.3.4 Cast operators
     
N-->   A cast does not yield an lvalue.
     
     
     
# C.3.6 Additive operators
     
       When two pointers to members of the same array  object  are  sub-
       tracted  ...   the  size  of the result is implementation-defined
  *    {-->, and its type (a signed integral type) is ptrdiff_t  defined
       in the <stddef.h> header}.
     
     
     
# C.3.9 Equality operators
     
       Both of the operands may have arithmetic type,  or  both  may  be
  *    pointers  to  the same type.  In addition, {--> one may be an ob-
       ject pointer and the other a pointer to void, or} one  may  be  a
  *    pointer  and  the other {an integral constant expression with the
       value 0 --> a null pointer constant}.
     
N-->   ...  If one of the operands is a pointer to void,  the  other  is
N-->   converted to that type.
     
     
     
# C.3.15 Conditional operator
     
       Both the second and third operands shall have arithmetic type, or
       shall  have  the same structure, union, or pointer type, or shall
  *    be void expressions.  In addition, {-->  one  may  be  an  object
       pointer and the other a pointer to void, or} one may be a pointer
  *    and the other {an integral constant expression with the  value  0
       --> a null pointer constant}.
     
N-->   ...  If one of the operands is  a  pointer  to  void,  the  other
N-->   operand is converted to that type and the result has that type.
     
N-->   A conditional expression does not yield an lvalue.
     
     
     
# C.3.16 Assignment operators
     
  *    An assignment operator shall have a {-->  modifiable}  lvalue  as
       its left operand.
     
  *    An assignment operator stores a value in the object {specified by
       the  lvalue  -->  designated by the left operand}.  An assignment
       expression has the type of the left operand and the value of  the
  *    left operand after the assignment {-->, but is not an lvalue}.
     
     
     
# C.3.16.1 Simple assignment
     
<--O   The operands may each have arithmetic type or may be structure or
<--O   union  objects  that  have  the same type.  In addition, the left
<--O   operand may be a pointer, in which case the right operand must be
<--O   a  pointer  that has the same type or has type "pointer to void",
<--O   or must be an integral constant expression with the value 0.
     
N-->   Both the operands shall have arithmetic type or  shall  have  the
N-->   same structure, union, or pointer type.  In addition, if the left
N-->   operand is a pointer, either of the operands may be a pointer  to
N-->   void, or the right operand may be a null pointer constant.
     
  *    ...  If the left operand is a pointer {and the right  operand  an
       integral  constant  expression  with the value 0, the constant is
       converted into a null pointer -->, if either of the operands is a
       pointer  to void or the right operand is a null pointer constant,
       the right operand is converted to the type of the left operand}.
     
     
     
# C.3.17 Comma operator
     
N-->   A comma operator does not yield an lvalue.
     
     
     
# C.4 CONSTANT EXPRESSIONS
     
       A function-call operator (), an increment or  decrement  operator
  *    ++ or --, {an indirection * unary operator, -->} or an assignment
       operator shall not appear in any constant expression.
     
       ...  The array-subscripting [] and member-access . and ->  opera-
  *    tors  and the "address-of" & {--> and indirection *} unary opera-
  *    tors shall not appear {,--> except in an expression that  is  the
       operand of a sizeof operator}.
     
<--O   For constant expressions in initializers, in addition to integral
<--O   constant  expressions  as  discussed previously, one can also use
<--O   floating constants and arbitrary casts and can apply the unary  &
<--O   operator  to objects that have static storage duration and to ar-
<--O   rays that have static storage duration subscripted  with  an  in-
<--O   tegral  constant  expression.   The unary & operation can also be
<--O   implied by appearance of a function identifier or an unsubscript-
<--O   ed array identifier.  In short, the expression must evaluate to a
<--O   constant, to the identifier or a previously declared function, or
<--O   to  the  address  of a previously declared object that has static
<--O   storage duration plus or minus an integral  constant  expression,
<--O   or  to the difference in addresses of two previously declared ob-
<--O   jects that are members of the same aggregate.
     
N-->   For constant expressions in initializers, in addition to integral
N-->   constant  expressions as discussed previously, floating constants
N-->   and arbitrary casts may be used.  Lvalues of  objects  that  have
N-->   static  storage duration or function identifiers may also be used
N-->   to specify addresses, explicitly with the unary & operator or im-
N-->   plicitly for unsubscripted array identifiers or function identif-
N-->   iers.  A constant difference in the addresses of two  members  of
N-->   the  same  aggregrate may be used.  As a special case, a suitably
N-->   cast null pointer may be used to derive an integral constant  ex-
N-->   pression, the value of which is the offset in bytes of an element
N-->   of a structure from its beginning, by means of an  expression  of
N-->   the form
     
N-->               (int)&((TYPE-SPECIFIER)0)->POSTFIX-EXPRESSION
     
N-->   where TYPE-SPECIFIER specifies the type of a pointer to a  struc-
N-->   ture  and POSTFIX-EXPRESSION designates any member of that struc-
N-->   ture or of a subaggregate (any array subscript shall  be  an  in-
N-->   tegral constant expression).
     
------------------------------
     
End of mod.std.c Digest - Sun, 11 May 86 07:34:03 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2654
          for JMS@ARIZMIS; Mon, 19-MAY-1986 06:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028764; 15 May 86 4:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008335; 15 May 86 4:05 EDT
From: Bob Larson <blarson%usc-oberon.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: varargs
Message-ID: <318@usc-oberon.UUCP>
Date: 9 May 86 01:39:57 GMT
Xref: brl-sem net.lang.c:1015 net.unix-wizards:1179
To:       info-c@BRL-SMOKE.ARPA
     
In article <5388@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes:
>    2. the practice of writing programs that accept varying
>    numbers of actual parameters and access them using ONLY the
>    facilities provided by <varargs.h> .  The particular
>    implementation of these facilities may differ from one
>    machine to another.
>
>I said I don't know offhand of a machine that can't implement #2.
     
Hypothetical but quite beleivable:  On a 68000, pass the first N
32-bit integer (int, long, etc.) arguements in data regisers and the
first M (32-bit) pointer arguments in address registers.  There isn't
a typeof operator, and the hack of determining the data type by doing
string manipulations on the quoted type, besides preprocessor
replacements in quoted strings being a pcc oddity, breaks when faced
with typedefs.  (I think argument quoting via a different meathod is
proposed in the current ansi C draft.)
     
This is true of any architecture with different register types with
identical size.  (Otherwise the type could be determined by sizeof,
which I do in the varargs.h implementation I wrote.)  Any proposted
solutions, other than not having such a compiler on such a machine?
     
     
     
     
--
Bob Larson
Arpa: Blarson@Usc-Ecl.Arpa
Uucp: ihnp4!sdcrdcf!usc-oberon!blarson

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2715
          for JMS@ARIZMIS; Mon, 19-MAY-1986 06:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028782; 15 May 86 4:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008591; 15 May 86 4:14 EDT
From: Steve Summit <stevesu%copper.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <342@copper.UUCP>
Date: 8 May 86 06:58:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <501@brl-smoke.ARPA>, rbj@icst-cmr (Root Boy Jim) writes:
>     Most People            Your's Truly
>
>     if (c) {            if (c)
>         w = y;                w = x,
>         y = z;                y = z;
>     }                /* look ma, no brace */
     
There is an excellent, excellent book, which everybody should
read, called The Elements of Style, by William Strunk and E. B.
White.  It is about writing in English, but almost everything in
it applies to writing in programming languages as well.  One of
my favorite quotes (from page 74 of the third edition) is
     
    "In ordinary composition, use orthodox spelling.  Do not
    write "nite" for "night," "thru" for "through," "pleez"
    for "please," unless you plan to introduce a complete
    system of simplified spelling and are prepared to take
    the consequences."
     
The consequences, of course, are that in virtually all cases you
will be laughed out of the room.  Convention has a place.  You
are not being a sheep or a lemming if you do things the way most
people do things; you are being responsible.  C can be hard
enough to read when it is formatted "correctly;" we certainly
don't need any more unorthodox methodologies floating around.
     
Proponents of things like "look ma, no braces" will claim that
theirs is not "ordinary composition," and that they are therefore
exempt from generally accepted programming practices.  This
statement is in fact perfectly true.  If you want to be a rugged
individualist and program in a vacuum; if nobody else ever reads
your code; if only you have to maintain it or port it to other
machines; then you are certainly welcome to make each program you
write an odds on favorite for the winner's circle in the
Obfuscated C Contest.  However, do the rest of us a favor and
perfect your isolated environment by sparing this newsgroup from
your rantings and ravings.
     
                                         Steve Summit
                                         tektronix!copper!stevesu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3437
          for JMS@ARIZMIS; Mon, 19-MAY-1986 07:54 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 09:46:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002508; 19 May 86 4:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001696; 19 May 86 3:41 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang
Subject: Multiple assignments
Message-ID: <1455@mmintl.UUCP>
Date: 12 May 86 05:23:17 GMT
Followup-To: net.lang
Xref: brl-sem net.lang.c:1078 net.lang:307
To:       info-c@BRL-SMOKE.ARPA
     
In article <797@bentley.UUCP> kwh@bentley.UUCP writes:
>In article <501@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>>And as someone pointed out, assignments return a value too, so should we
>>cast them to void as well?  Oh yeah, assignment is `different'.
>
>Actually, this does bother me somewhat.  I think I prefer the idea that
>values should be used or explicitly discarded, as in forth.  (Not that forth
>has any error checking!)  No, I'm not suggesting that lint should complain
>about assignments, or that C should have a different notation for assignments
>that are being pipelined into another expression.  Just waiting for the next
>generation of languages.
     
This bothers me somewhat too.  I do have a suggestion for how to deal with
it: have a "multi-assignment" operator.  Supposing that "$" is being used
for this operator, then to set both "a" and "b" to zero, one would write
"a $ b = 0", rather than "a = b = 0", as C does.  This has the disadvantage
that it cannot be used where the result of the assignment is used
immediately in a calculation (e.g., "a = 2 * b = sqrt(c)").  On the other
hand, if your language supports argument passing by address, it permits an
output argument to be multiply assigned; something which
assignment-with-value does not support.
     
I am not recommending that this be put into C.  It is an idea for new
languages.  Accordingly, I have directed follow-ups to net.lang instead of
net.lang.c.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3498
          for JMS@ARIZMIS; Mon, 19-MAY-1986 07:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002533; 19 May 86 4:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002074; 19 May 86 3:54 EDT
From: Andrew Hunt <gt4099a%gitpyr.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: SCREEN INPUT
Message-ID: <1772@gitpyr.UUCP>
Date: 13 May 86 02:07:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Hello, NetLand!  I wonder if anyone out there might be
able to give me a little direction:  I am looking for a
portable C program that will do screen input forms
generation, using curses and depositing the result
into a C struct or a Pascal record.  Portable source
would be nice, but mostly I just need it for a Convergant
Technologies MiniFrame II.
     
As they say, thanks in advance...
     
"The more forking you do the more children you get"
Andy Hunt
Box 34099
Atlanta Georgia, 30332
...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!gt4099a

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3571
          for JMS@ARIZMIS; Mon, 19-MAY-1986 08:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002537; 19 May 86 4:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002197; 19 May 86 4:00 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <2741@utcsri.UUCP>
Date: 9 May 86 16:57:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <602@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
     
>2) More of the same. We all know about *++p. But what if I want to jump
>    more than one element? I can't write *(p += 2); Or maybe I
>    want to write `p = &(i += 5).
     
You can write *(p += 2). For *p++, you can write *((p += 2 ) - 2 ) if you
really want to. If p is a register, there will be little penalty over
dereferencing *before* the p+=2.
    Why you wanna do p = &(i += 5 ) ?????? Like your immortal
`exit(1,fprintf(stderr,"Arrg!!\n"))' this is an artificial combination of
two unconnected statements. What's wrong with  `i+=5; p= &i'?
( You probably prefer i+=5,p= &i; )
>
>3) Exchange operator. This has probably been discussed before, so pardon
>    me if I blunder into that pit. BUT, DMR has stated that one of
>    the reasons that exponentiation was left out was because no
>    (or few, if any) machine could do it inline, and therefore
>    all the compiler would be doing is a function call anyway.
>    By the same reasoning, exchange CAN be done efficiently by
>    some machines, and the hack of a temporary variable and
>    three assignments is a rather stale idiom. The three
>    statement XOR trick avoids the temporary, at the expense
>    of execution time and clarity.
>
Good stuff. Even machines without an EXG can use a scratch register, which
is better than using a user-supplied temp.
What, by the way, is the XOR trick?
     
>4) Allow complex statements to be considered as expressions so that
>    the comma operator can be used to avoid braces, as in
>
>    if (e) x = y, return z;
>
Errr... well....
I'm not a compiler guru, but.... In the current ( conventional ) setup,
compilation of expressions is done separately from 'statement processing'
( i.e. returns, ifs, whiles, cases, etc ). Your suggestion would require
that the two be entwined together, which would make generation of really
good code a difficult thing. Currently, when an expression is found, a tree
is built, then the tree is crunched upon, and the code is generated. If
every statement was an expression, then expression trees would need to
have nodes for ifs and whiles, etc... ( starting to get LISPy). This
could of course get very messy, and a really good coder is already a
fairly messy thing to do. Besides, I don't think this would help very
much, except for Obfuscated C entries.
     
>5) Allow immediate constants. Currently, there is only one special
>    case, that of a character array. One can say char *p = "string";
>    and have the string squirreled away and the (magic) address
>    stuffed into the pointer. Why not int *p = &5; where the
>    integer five is whisked away and replaced by its address.
>    Sure would eliminate a lot of housekeeping variables.
>
Fine by me.
I would also like to suggest struct constants/rvalues. Suppose I have
    struct foo{
        int f1;
        char f2;
        char *bar;
    } foo_var;
I'd like to write something like this ( an executable statement ):
     
    foo_var = struct foo{        /* set structure value */
        .bar = "Ergo Sum";
        .f1 = 73;
        .f2 = '?';
        };
     
This allows the use of unnamed (structure constants).
     
#define cmplx(a,b) struct complex { .r=(a); .i=(b); }
#define J cmplx( 0.0,1.0 )
     
    cvar1 = cmul( cvar2, cmplx( 2.0, 1.02 ) );
     
I think it is important that the member names be used instead of the
order. Also, it would be nice if the compiler were smart in cases like
     
    xchar = struct foo{ .bar="??"; .f2 = ychar+1; .f1 = func(i); }.f2;
     
not to generate all the code to compute f1 and bar ( Holy side-effects,
Batman! ). The above line could arise by a macro expansion.
I have though out many of the implementation details, and I *still* think
it's a good idea :-). I am very open to suggestions about the syntax.
I will ramble on about/ argue about this later if you want ( and probably
if you don't want 8-) <- peril-sensitive sunglasses. ).
     
     
>6) Eliminate arrays altogether! Well not exactly, but make all
>    arrays vectored in all dimensions. This would show
>    those quiche eaters what a real tough language C is :-).
>    Array syntax would still be available of course, but would
>    be translated into glorious pointer notation. And it wouldn't
>    matter whether a variable was defined differently than it
>    was declared (char x[] or char *x).
>
Fully vectored arrays were used in B, and I like C's stuff better.
You can always set up vectored arrays if you want - and still say
array[i][j][k] into the bargain. Of course, you have to set up the
vectors yourself...
     
>
>8) Allow formal arguments to be declared AFTER the opening brace.
>    This would allow prioritization of register variables.
>
Well, register arguments need to copied from the stack anyway, so
you can declare your own with an explicit copy. But it wouldn't
hurt to let the compiler do it. Since it silly ( presently ) to
say `foo(p){ register char *p;...' this could be taken as an argument
declaration.
     
I have a related suggestion.
     
Suppose I have the following:
     
f(){
    ...
    { int x,y;    ...    }
    { double xy;    ...    }
}
I would expect x and y to share the same stack space with xy.
Now look at this ( assume 4 regs available ):
     
f(){    register i,j,k,l,m;        /* more vars than regs available */
    { register ii ..... };
}
I think the inner loop should push 'l' ( the lowest priority reg var ) on
the stack and keep 'ii' in that reg, since ii will probably get more use
in the inner block. The register priority would become ii/i/j/k, so if
a further nested block said 'register a,b', the next regs to be kicked out
would be j and k, leaving the priority as a/b/ii/i.
At the end of the block, the value of l would be popped. If the block were
the body of a loop, the pushing/popping would need to be done outside the
actual loop, for speed. Inside the loop, of course, 'l' would be addressed
as an auto.
     
This allows C programmers one more advantage previously available only to
assembler programmers: the re-use of registers for completely different
things. The problem is that it would make jumping into/out of blocks a
mess. I guess the compiler would have to detect this and generate 'fix'
code for the jumps.
     
--
"Canabee be said2b or not2b anin tire b, if half thabee isnotabee, due2
somain chunt injury?" - Eric's Dilemma
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3697
          for JMS@ARIZMIS; Mon, 19-MAY-1986 08:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002539; 19 May 86 4:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002660; 19 May 86 4:05 EDT
From: Jim Hutchison <hutch%sdcsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <1776@sdcsvax.UUCP>
Date: 12 May 86 17:42:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
()
     
well now for ||= you can use |= because C defines 0 as false and non-0
as true (Yes, I know that boolean expressions are defined to return 0/1
as defined in K&R if that is still used).
     
typedef char bool;
     
#define B_TRUE    ((bool)1)
#define B_FALSE    ((bool)0)
     
bool a, b;
     
        a = B_TRUE;
        b = (x == READY);
        ...
        b |= (x == READY);
        b ^= a;
     
Now this can get you into trouble, because 2 and 1 and 47 are also
"true".  This is o.k. for '|' but not '^'.
     
You could of course do
     
        b = (b == 0) ^ (a == 0)
     
but that looks a bit strained.
--
/*    Jim Hutchison    UUCP:    {dcdwest,ucbvax}!sdcsvax!hutch
            ARPA:    Hutch@sdcsvax.ucsd.edu
            [ Disclaimer eaten by a passing kiwi ]     */

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3777
          for JMS@ARIZMIS; Mon, 19-MAY-1986 08:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 10:13:25 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000941; 15 May 86 8:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011174; 15 May 86 7:51 EDT
From: Kilsup Lee <kslee%kaist.uucp@BRL.ARPA>
Newsgroups: net.wanted,net.lang,net.lang.c,net.lang.pascal
Subject: Looking for Pascal-to-C Converter Program
Message-ID: <25@kaist.UUCP>
Date: 11 May 86 09:46:02 GMT
Keywords: Pascal, C
Xref: brl-sem net.wanted:546 net.lang:304 net.lang.c:1024 net.lang.pascal:91
To:       info-c@BRL-SMOKE.ARPA
     
     
     
     
                I am looking for Pascal to C converter
            that runs on UNIX environment. If does anyone
            know this information, please inform to me.
            And I don't care the Public Domain or Commercial one.
            The sooner it is, the better it is.
     
     
                          Lee, Kilsup
     
          ----- <> ------------------ <> ------------------ <> -----
     
        UUCP: ......seismo!kaist!kslee
        CSNET:  kslee@kaist.csnet

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3839
          for JMS@ARIZMIS; Mon, 19-MAY-1986 08:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001003; 15 May 86 8:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011234; 15 May 86 7:52 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <732@steinmetz.UUCP>
Date: 9 May 86 19:59:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <210@sdchema.sdchem.UUCP> tps@sdchema.UUCP (Tom Stockfisch) writes:
>In article <778@bentley.UUCP> kwh@bentley.UUCP writes:
>>In article <838@ihwpt.UUCP> ihwpt!knudsen writes:
>>>(2) There isn't any ^^ (XOR) operator either, as in
>>
>>There is, but it's spelled "!=".  (Presumably more efficient than "^", though
>>I think either one should work with a smart compiler.)
>>
>
>Not quite the same.
>    3 ^^ 4
>would evaluate as 0,
>    3 != 4
>evaluates as 1.
>
>-- Tom Stockfisch, UCSD Chemistry
     
     
XOR can be defined as an (ugly) macro, I believe.
     
#define XOR(a,b) (((a) != 0) != ((b) != 0)
/* or if you like small better than readable */
#define XOR(a,b) (!!(a) != !!(b))
--
    -bill davidsen
     
    seismo!rochester!steinmetz!--\
       /                               \
ihnp4!              unirot ------------->---> crdos1!davidsen
       \                               /
        chinet! ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3912
          for JMS@ARIZMIS; Mon, 19-MAY-1986 08:32 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001056; 15 May 86 8:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011256; 15 May 86 7:53 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc,net.unix
Subject: Re: allocating arrays
Message-ID: <350@dg_rtp.UUCP>
Date: 10 May 86 18:43:47 GMT
Xref: brl-sem net.lang.c:1026 net.micro.pc:1100 net.unix:682
To:       info-c@BRL-SMOKE.ARPA
     
Ever alert to save the world from mistaken C code examples that could
have been caught by simple use of lint or other commonly available
tools, our eagle eyed hero finds a particularly silly example.  Let's
listen in....
     
> allbery@ncoast.UUCP (Brandon Allbery)
     
> | Consider an array of 15 pointers to arrays of doubles:
> |     double (*parray[15])[];
> | The following code to 'malloc' the actual double array barfs on Microsoft
 'C',
> | with a 'different levels of indirection' warning on the '='.
> | The code passes through LINT, and compiles OK on UN*X 5.2
> |     char    *malloc();
> |     parray[0] = (double*)malloc((unsigned)sizeof(double)*75);
     
> double (*parray[15])[]; means:
>       an indefinitely-sized array of (or a pointer to)
>               an array of 15
>                       (double *)
     
Wrong.  It means just what the original poster said it meant.  It is an
array of 15 pointers to arrays of double.  What the original poster is
mistaken about is that lint doesn't complain about the example.  In
particular, given this example
     
        void f(){
            double (*a[15])[];
            char *malloc();
            a[0] = (double *)malloc((unsigned)sizeof(double)*75);
        }
lint (on our system at least) says
        warning: illegal pointer combination
            (4)
     
I grant you, this isn't very informative, but lint *doesn't* like it,
that much is certain.  Let's run a more blabbermouth tool over it.
     
        #1052 4 inconsistent types discovered
              (=
                (:AREF
                  (:IDENTIFIER a :AUTO ... )
                  (:OCT_INT 0))
                (:CAST
                  (:POINTER_TO
                    (:DOUBLE))
                  (:FUNCALL
                    (:IDENTIFIER malloc :EXTERN ... )
                    (*
                      (:CAST
                        (:UNSIGNED)
                        (:SIZEOF
                           ... ))
                      (:DEC_INT 75)))))
            Types are:
              (:POINTER_TO
                (:ARRAY_OF
                  (:DOUBLE)
                  () ()))
            and:
              (:POINTER_TO
                (:DOUBLE))
     
As you can see, this is an attempt to assign a pointer-to-double to a
pointer-to-array-of-double.  In this case, it is easy to tell that this
is what is going on even without blabbermouth typecheckers.  The
declaration of a is of the form (*[])[], making the type of a[0] (*)[],
a pointer to an array.  The cast of the return value of malloc was
simply *, that is, a simple pointer.  If you want your compiler to shut
up, you should make the cast read (double (*)[]).  When the cast is
changed in this way, lint no longer complains.  Changing the cast to
(double **) naturally still causes complaint.
     
The problem as I see it is that the C compiler led the original poster
astray with a misleading error message.  The problem isn't with a wrong
level of indirection, but with an assignment of a value of type
pointer-to-scalar to an lvalue of type pointer-to-array.  The compiler
in question seems to have the common misconception that
pointers == arrays in C... they do not.
     
Now, with all that said, I suspect that what was really wanted was this:
     
        void f(){
            double *a[15];
            char *malloc();
            a[0] = (double *)malloc((unsigned)sizeof(double)*75);
        }
     
This is type-correct, and is probably what is wanted.  We have here an
array of 15 pointers to (implicitly, variable sized arrays of) double.
To reference the second double in the implicit array pointed to by the
third pointer in a, one would say a[2][1].  To say the same thing with
the original definitions would be (*a[2])[1].
     
> My compiler (pcc) won't even TAKE ``double (*parray[15])[];'' unless it's
> initialized or external; apparently sys5 converts it to the declaration
> ``double *(*parray[15]);'' -- ptr to array[15] of (double *) -- automatically.
     
Yes, the pcc seems to be another beastie with odd (and in some cases
incorrect) ideas about pointers and arrays.  Sigh.
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4000
          for JMS@ARIZMIS; Mon, 19-MAY-1986 08:37 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001126; 15 May 86 8:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011334; 15 May 86 7:55 EDT
From: eric@chronon
Newsgroups: net.lang.c
Subject: Re: varargs
Message-ID: <236@chronon>
Date: 2 May 86 03:48:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <129@drilex.UUCP> dricej@drilex.UUCP writes:
>
>rb@ccird2 (Rex Ballard) wonders what kind of systems would not be able to
>handle varargs. ...
>... Therefore, a more proper question would be: is there any
>architecture which is suitable for a C compiler, but not for varargs?
     
Yes!  I can think of an example close to home... An architecture with
a large (LARGE) number of registers, a sliding window to allow reference
to a smaller register set locally within a procedure, and OS support
for using the register set as a stack (handling overflow/underflow).
The first <n> arguments are passed in registers via the overlapped
sliding window, remaining have to be passed in memory.  The problem
is that no choice of <n> will be correct; you can only make arbitrarily
small the probability of it not being big enough...  and at the cost of
additional expense elsewhere...
I assert that this architecture, and the rest of what goes with this
particular feature, is particularly well-suited for efficient execution
of programs written in C.
     
>P.S. Microcomputers pass things in registers, rather than on the stack,
>because stack operations are slow relative to register operations.  This
>is also typical of assembly language programming, rather than C language
>programming.
>Not everybody is willing to pay the high-level language penalty.
>
>Craig Jackson
>UUCP: {harvard,linus}!axiom!drilex!dricej
     
Microcomputers aren't the only ones interested in the fact that using
registers is faster than using memory.  Does this argument sound RISC-y?
     
Note that nothing in the C language requires this particular high-level
language penalty (passing args in memory rather than in registers).
The varargs kludge is for convenience only (yes, I like it, too, and
would chafe at Pascal-like restrictiveness!).
--
Eric Black   "Garbage In, Gospel Out"
UUCP:        {sun,pyramid,hplabs,amdcad}!chronon!eric
WELL:        eblack
BIX:         eblack

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4148
          for JMS@ARIZMIS; Mon, 19-MAY-1986 08:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006793; 15 May 86 11:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018825; 15 May 86 11:40 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#2
Message-ID: <1031@hou2d.UUCP>
Date: 10 May 86 23:12:25 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Sat, 10 May 86       Volume 16 : Issue   2
     
Today's Topics:
Differences from April 1985 to February 1986 Draft Standard, Explanation
 Differences from April 1985 to February 1986 Draft Standard, Part 1
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard,
 Explanation
To: cbosgd!std-c%utcsri
     
The preliminary draft proposed ANSI C Standard of April 30, 1985,
has  been  generally available for some time.  However, the X3J11
committee has produced since produced further drafts,  dated  Au-
gust  11,  1985;  November  11, 1985; and February 14, 1986.  The
last I heard another draft was going to be printed shortly.
     
This posting is intended for readers who  have  some  familiarity
with  the  April 1985 draft, to bring them up to date on what has
happened since then up to the February 1986 version.   It  exists
because I sent mail to Larry Rosler suggesting that it would be a
good idea, and he replied that he didn't have time to do  it  and
offered to send me all the versions if I did.
     
That mail exchange, incidentally, happened about Christmas  time,
and  referred  to changes up to the November draft only.  Much of
the delay since then  is  attributable  to  some  combination  of
AT&T's  mailroom in Summit, NJ; the US Postal Service; and Canada
Post.  The rest is attributable to my shortage of spare  time  to
do  this  in; if I'd known how long it was going to take, I would
not have volunteered.
     
This posting covers parts A-C of the document; that is, there  is
nothing  about  the libraries.  I hope to do another one covering
the rest of the document shortly.
     
     
Now, what you see here does not include all  of  the  differences
between  the  versions.  I have generally suppressed changes that
appeared to provide only a clearer wording.  Some  of  these  are
fairly substantial in extent, with sentences and paragraphs being
rearranged.  On the other hand, I have included  all  changes  to
the language and to the terminology for talking about it ...  un-
less, of course, I missed some.
     
The changes are cited in the order of their appearance in the new
version, with a few slight exceptions to group related matter.  I
don't give a lot of context for each one, to keep the  length  of
this  document  manageable.   Never  assume that you are seeing a
complete paragraph.  However, where I have elided important  text
I have placed an ellipsis (...).
     
For changes that affect a small  part  of  a  paragraph,  I  have
adopted the notation {old text --> new text}, which is simply run
in line.  Each line containing the start of  at  least  one  such
change is starred in the left margin.  The old or new text may be
null: thus, the change to section A.1 consists of the deletion of
the  word  "preliminary".  In such a paragraph, the words not en-
closed in braces may be unchanged from  April  1985  to  February
1986, or they have have changed in a minor way in which case I am
showing the new version.
     
For larger changes, I give complete paragraphs or blocks of para-
graphs  in  old  and  new forms.  The notation "<--O" in the left
margin means that this paragraph has been  deleted  or  replaced;
"N-->" refers to its replacement or an added paragraph.
     
Since the typographical changes of the actual  document  are  not
available  here,  I have rendered some of them in punctuation and
omitted others.  (In particular, "quotation marks" in this  arti-
cle  more  often  than  not represent italics in the original and
thus a definition of a term.)
     
Paragraphs marked Remark are mine.
     
Mark Brader
     
------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 1
To: cbosgd!std-c%utcsri
     
# Title
     
N-->   Draft Proposed American National Standard for Information Systems
N-->   -- Programming Language C
     
     
     
# A.1 Foreword
     
  *    This {preliminary -->} draft proposed American National  Standard
       describes the C programming language.
     
     
     
# A.6 Definitions of terms
     
<--O   Object -- something that has a value.
     
N-->   Object --  a  region  of  storage,  the  contents  of  which  can
N-->   represent values.
     
     
     
# A.6 Definitions of terms
     
       It need not be possible to express the address of each individual
  *    bit {--> of an object}.
     
  *    ...  It {must --> shall} be possible to express  the  address  of
  *    each individual byte {--> of an object} uniquely.
     
Remark: The word "must" seems to have been banished from the  do-
cument.  Further instances of this substitution will not be indi-
cated, even if the sentence is being cited for another change.
     
     
     
# A.6 Definitions of terms
     
N-->   Terms explicitly defined in this Standard are not to be  presumed
N-->   to refer implicitly to similar terms defined elsewhere.
     
     
     
# A.7 Compliance
     
  *    A "comforming freestanding implementation" {must -->  shall}  ...
  *    provide  the  standard  headers  <limits.h>  {-->  and <float.h>}
       specified in Section D (library).
     
<--O   A conforming implementation may have extensions, which  must  not
<--O   alter  the  behavior  of  a  strictly  conforming program (except
<--O   perhaps by requiring the replacement of identifiers that conflict
<--O   with new keywords or library symbols).
     
N-->   A conforming implementation may have extensions (including  addi-
N-->   tional  library  functions),  provided  they  do  not  alter  the
N-->   behavior of a strictly conforming program.
     
     
     
# {--> A.8 Future directions}
     
N-->   With the introduction of new devices and extended character sets,
N-->   new  features  may  be  added  to  the Standard.  Sections in the
N-->   Language and Library parts warn implementors and  programmers  of
N-->   usages  which,  though valid in themselves, may conflict with fu-
N-->   ture additions.
     
N-->   Certain features are "deprecated", which means that their use  in
N-->   new  programming  is discouraged.  They are retained in the Stan-
N-->   dard because  of  their  widespread  use  in  existing  programs.
N-->   Deprecated  features  may be withdrawn in future revisions of the
N-->   Standard.
     
Remark: With a new section A.8, the old  A.8  (Difference  marks)
becomes A.9.
     
     
     
# B.1.1.2 Translation phases
     
Remark: I'm showing the entire section this time.
     
       The precedence among the syntax rules of translation is specified
       by  the  following  stages.  An implementation is not required to
  *    mimic this separation into phases.  {Each phase requires  a  com-
       plete  parse  at  its level, that is, it may not terminate with a
       partial non-terminal. -->}
     
       1. Physical source text file characters are mapped to the  source
       character  set  (introducing  new-line characters for end-of-line
       indicators) if necessary.  Trigraph  sequences  are  replaced  by
       corresponding single-character internal representations.
     
       2. Each instance of  a  new-line  character  and  an  immediately
       preceding  backslash  character  is  deleted,  splicing  physical
  *    source lines to form logical source lines.  {--> A file shall not
       end  in  a backslash character immediately followed by a new-line
       character.}
     
       3. Character constants, string literals,  and  the  arguments  to
       #include preprocessing directives are tokenized.  Each comment is
  *    replaced by one space character.  {--> A file may not  end  in  a
       partial token.}
     
       4. The source text is completely tokenized.  New-line  characters
  *    {become  new-line  tokens  -->  are retained}.  {Each sequence of
       other white-space characters becomes a single white-space  token;
       alternatively,  each other white-space character becomes a unique
       token.  --> Whether each sequence of other white-space characters
       is  retained or is replaced by one space character is implementa-
       tion defined.}
     
  *    5. {The source text is preprocessed. --> Preprocessing directives
       are  executed.}  A  #include  preprocessing  directive causes the
  *    named file to be processed from phase 1,  recursively.   {Prepro-
       cessing  interprets  new-line  tokens  as --> New-line characters
       are} syntactically significant; "left-parenthesis not preceded by
       white-space" is syntactically significant to the #define grammar.
     
<--O   6. The preprocessing concatenation operation is applied, and  the
<--O   full  source  is  retokenized.  Adjacent string literals are con-
<--O   catenated.  New-line characters are treated  the  same  as  other
<--O   white-space characters.
     
N-->   6. White-space characters separating tokens are no longer  signi-
N-->   ficant.   The preprocessing concatenation operator ## is applied.
N-->   Adjacent string literals are concatenated.
     
       7. The  remaining  tokens  are  syntactically  and   semantically
       analyzed and translated.
     
  *    8. All external {data --> object}  and  function  references  are
       resolved.   Library  components may be linked to satisfy external
       references to functions and objects not defined  in  the  current
       translation.  All such translator output is collected into a pro-
       gram image which contains information needed for execution in its
       execution environment.
     
Remark: "Data" is another word that seems to have  been  banished
throughout the document.
     
------------------------------
     
End of mod.std.c Digest - Sat, 10 May 86 18:09:59 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4329
          for JMS@ARIZMIS; Mon, 19-MAY-1986 09:07 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006844; 15 May 86 11:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018930; 15 May 86 11:43 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#4
Message-ID: <1037@hou2d.UUCP>
Date: 10 May 86 23:00:30 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Sat, 10 May 86       Volume 16 : Issue   4
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 3
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 3
To: cbosgd!std-c%utcsri
     
# C.1 Lexical elements The program fragment x+++++y is parsed  as
x  ++  ++ + y, which {is a syntax error --> violates a constraint
on increment operators}, even though the parse x ++ + ++ y  might
yield a correct expression.
     
  *    Forward references: expressions (#C.3)  {-->,  postfix  increment
       and decrement operators (#C.3.2.4)}.
     
Remark: A number of things have been reclassified from syntax  to
constraints in this fashion.
     
     
     
# C.1.2 Identifiers
     
  *    An identifier denotes ... one of the following ...  a  {type  -->
       typedef} name ...
     
     
     
# C.1.2.1 Scopes of identifiers
     
N-->   (A "function prototype" is a declaration of a function  that  de-
N-->   clares the types of its parameters.)
     
     
     
# C.1.2.2 Linkages of identifiers
     
In the set of source files  and
libraries that constitutes an entire program, every instance of a
particular identifier with "external linkage"  denotes  the  same
function or object.  If the declarations in two source files {-->
or in  disjoint  scopes  within  one  source  file}  differ,  the
behavior is undefined.
     
     
     
# C.1.2.2 Linkages of identifiers
     
       For an identifier of a function  or  object  declared  with  file
  *    scope,  if  its lexically first declaration {--> with file scope}
       in the source file contains the keyword  static,  the  identifier
       has internal linkage.
     
     
     
# C.1.2.4 Storage durations of objects [An] instance of an object
that  has "automatic storage duration" ... is discarded when exe-
cution of the block ends by  reaching  the  terminating  "}",  by
jumping  to  an enclosing block, or by executing a {--> break or}
return statement.
     
     
     
# C.1.2.5 Types An object declared as a character (char) is large
enough  to  store any member of the {execution character set that
can be specified as a single-character character constant without
using an octal or hexadecimal escape sequence --> required source
character set enumerated in #B.2.1}.
     
     
     
# C.1.2.5 Types
     
       There are four types of  signed  integers,  called  signed  char,
       short int, int, and long int.  A "plain" int has the natural size
  *    suggested by the architecture of the execution  environment  {-->
       (large  enough  to  contain  any  value  in  the range INT_MIN to
       INT_MAX as defined in the header <limits.h>)};  the  other  types
       are  provided  to  meet special needs.  The set of values of each
       signed integral type is a subset of the values of the  next  type
  *    in  the  list  above.   Even  if  the implementation defines {-->
       signed char,} short int, int, or long int to have the same set of
       values, they are nevertheless different types.
     
     
     
# C.1.2.5 Types
     
N-->   The set of non-negative values of a signed type is  a  subset  of
N-->   its corresponding unsigned type.
     
     
     
# C.1.3 Constants
     
<--O   If the value of a constant cannot be represented in  the  storage
<--O   appropriate  for  that  type  in  the  execution environment, the
<--O   behavior is undefined.
     
N-->   The value of a constant shall be representable in the storage ap-
N-->   propriate for its type in the execution environment.
     
     
     
# C.1.3.2 Integer constants
     
Remark: The notation [opt]  below  represents  a  subscript  opt,
which means optional.
     
<--O   integer-suffix:
<--O               integer-suffix-letter
<--O               integer-suffix-letter integer-suffix-letter
     
<--O   integer-suffix-letter: one of
<--O               u l U L
     
N-->   integer-suffix:
N-->               unsigned-suffix long-suffix[opt]
N-->               long-suffix unsigned-suffix[opt]
     
N-->   unsigned-suffix: one of
N-->               u U
     
N-->   long-suffix: one of
N-->               l L
     
     
     
# C.1.3.2 Integer constants The type of an  integer  constant  is
the  first  of  the  corresponding list in which its value can be
represented.  Unsuffixed decimal: int, long  int  {-->,  unsigned
long int}.  ...
     
     
     
# C.1.3.4 Character constants Even if eight bits are used for ob-
jects that have type char, the construction {'\xFF1' --> '\x123'}
specifies a character constant  containing  only  one  character.
(The   value   of   this   {-->   single-character}  constant  is
implementation-defined.) To specify a character constant contain-
ing  the  two  characters  {0xFF and 1 --> 0x12 and 3} , the con-
struction {'\x0FF1' --> '\x0123'} may be  used.   (The  value  of
this   {-->   two-character}  constant  is  also  implementation-
defined.)
     
     
     
# C.1.4 String literals A string literal has static storage dura-
tion and type "array of {const -->} char" ...
     
N-->   If the program attempts to modify a string literal, the  behavior
N-->   is undefined.
     
     
     
# C.1.5 Operators operator: one of
            ...
            , {--> # ##}
     
N-->   ...  The operators # and ## may occur in  macro-defining  prepro-
N-->   cessor directives only.
     
     
     
# C.1.6 Punctuators punctuator: one of
            [ ] ( ) { } * , : = ; ... # {## -->}
     
N-->   The punctuator # may occur in preprocessor directives only.
     
     
     
# C.2.1.1 Characters and integers
     
  *    A char, or a short int {-->,  or  an  int  bit-field},  or  their
       signed  or unsigned varieties, may be used in an expression wher-
       ever an int may be used.  In all cases the value is converted  to
       an  int  if an int can represent all values of the original type;
       otherwise it is converted to an unsigned int.  These  are  called
  *    the "integral {widening conversions --> promotions}".
     
Remark: The new term "promotion" is used throughout the document.
     
  *    When an integer is {converted --> demoted} to a shorter  unsigned
  *    integer  {-->  or  unsigned  int bit-field} or unsigned char, the
       result is the remainder modulo the largest unsigned  number  that
  *    can  be  represented plus one.  When an integer is {converted -->
  *    demoted} to a shorter signed integer {--> or  int  bit-field}  or
       signed  char,  if  the  value cannot be represented the result is
       implementation-defined.
     
------------------------------
     
End of mod.std.c Digest - Sat, 10 May 86 19:00:12 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4421
          for JMS@ARIZMIS; Mon, 19-MAY-1986 09:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006854; 15 May 86 11:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018934; 15 May 86 11:43 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#5
Message-ID: <1038@hou2d.UUCP>
Date: 10 May 86 23:00:43 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Sat, 10 May 86       Volume 16 : Issue   5
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 4
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 4
To: cbosgd!std-c%utcsri
     
# C.2.1.2 Signed and unsigned integers
     
  *    When a signed integer is {assigned to, or  used  as  one  of  the
       operands  of  a binary operator the other operand of which is -->
       converted to} an unsigned integer of  equal  or  greater  length,
  *    {-->  if  the  value  of  the signed integer is non-negative, its
       value is  unchanged.   Otherwise,  if  the  unsigned  integer  is
  *    longer,}  the signed integer is first {converted --> promoted} to
  *    a signed integer of the same length as the unsigned integer.  {If
       the  value  of the signed integer is negative, the conversion in-
       volves --> Then it is converted to unsigned by} adding to it  the
       largest  number  that  can be represented in the unsigned integer
       type plus one.
     
     
     
# C.2.1.3 Floating and integral
     
<--O   When a value of floating type is converted to integral  type,  if
<--O   the  result  does  not fit in the space provided, the behavior is
<--O   undefined.  When a positive value is converted to  integral,  the
<--O   fractional part is discarded.  When a negative value is converted
<--O   and the value cannot be represented exactly, the result is one of
<--O   the  two  nearest  integers,  chosen in an implementation-defined
<--O   manner.
     
N-->   When a value of floating type is converted to integral type,  the
N-->   fractional  part is discarded.  If the result does not fit in the
N-->   space provided, the behavior is undefined.
     
     
     
# C.2.1.5 Usual arithmetic conversions
     
  *    ...  The purpose is to yield a common type, which is  {-->  also}
       the type of the result.
     
  *    ...  Otherwise, if {only one --> either} operand has type  float,
  *    the  other operand is converted to float.  {(The presence of this
       conversion is implementation-defined.  In  its  absence,  if  one
       operand  has  type float, both operands are converted to double.)
       -->}
     
  *    ...  Otherwise, both operands {and the result -->} have type int.
     
N-->   Operands may be converted to other types, provided neither  range
N-->   nor  precision  is  lost  thereby;  the type of the result is not
N-->   changed thereby.  Conversion of  an  operand  to  the  same  type
N-->   causes no change.
     
     
     
     
     
     
     
     
     
# C.2.2.1 Arrays, functions and pointers
     
  *    Except when used as {the operand of the sizeof  operator  -->  an
       operand that may or shall be an lvalue,} or when a string literal
       is used to initialize an array of chars, an expression  that  has
       type  "array of TYPE" is converted to an expression that has type
       "pointer to TYPE" and that points to the initial  member  of  the
       array object.
     
  *    {--> Except when used as an operand that may or shall be a  func-
       tion  locator,}  an  identifier  declared  as "function returning
       TYPE" is converted to an expression that  has  type  "pointer  to
       function returning TYPE".
     
  *    Forward references: {function calls (#C.3.2.2)  -->  lvalues  and
  *    function  locators  (#C.3.0.1)},  initialization  (#C.5.6) {, the
       sizeof operator (#C.3.3.4) -->}.
     
     
     
# C.2.2.2 void
     
  *    The (nonexistent) value of a {void expression -->  "void  expres-
       sion" (an expression that has type void)} must not be used in any
       way, and explicit or implicit conversions must not be applied  to
  *    such {a value --> an expression}.
     
Remark: Another change that applies throughout the document.
     
     
     
# C.2.2.3 Pointers
     
<--O   An integral constant expression with the value 0 may be  assigned
<--O   to or compared for equality to a pointer.  The integer constant 0
<--O   is converted to  a  pointer  of  the  appropriate  type  that  is
<--O   guaranteed  not to point to any object.  Such a pointer, called a
<--O   "null pointer", must appear to be equal to the  integer  constant
<--O   0.
     
N-->   An integral constant expression with the value 0 or such  an  ex-
N-->   pression cast to type void * is called a "null pointer constant".
N-->   If a null pointer constant is assigned to or compared for equali-
N-->   ty  to  a pointer, the constant is converted to a pointer of that
N-->   type.  Such a pointer, called a "null pointer", is guaranteed not
N-->   to point to any object or function.
     
     
     
# C.2.2.4 const and volatile
     
N-->   The properties associated with the const type specifier are mean-
N-->   ingful only for expressions that are lvalues.
     
       An expression that has  a  type  declared  with  the  const  type
  *    specifier shall not be {an --> a modifiable} lvalue.
     
Remark: The above does not reflect a change in the  language  but
rather a change in the meaning of the term "lvalue".  See...
     
  *    ...  Forward references: ...  {--> lvalues and function  locators
       (#C.3.0.1)}.
     
     
     
# C.2.2.4 const and volatile
     
  *    {The address of a const object may -->  Except  via  an  explicit
       cast, an expression that has type "pointer to type with the const
       attribute" shall not} be assigned to a pointer to a type  without
  *    the  const attribute.  If an attempt is made to {change the value
       --> modify an object that has a type declared with the const type
       specifier by means of an lvalue that has a type not declared with
       the const type specifier}, the behavior is undefined.
     
Remark: And likewise for volatile, except the paragraph for vola-
tile does not use the word "attempt".
     
     
     
# C.3 EXPRESSIONS
     
       An "expression" is a sequence  of  operators  and  operands  that
  *    specifies  how  to compute a value {--> or (in the case of a void
       expression) how to generate side effects}.
     
     
     
# C.3 EXPRESSIONS
     
       Except as indicated by the syntax or  otherwise  specified  later
  *    (for  the  function-call  operator (), {--> the unary plus opera-
       tor,} &&, ||, ?:, and comma operators), the order  of  evaluation
       of an expression is unspecified.
     
     
     
# C.3 EXPRESSIONS
     
       To force  a  particular  grouping  of  operations  ...   grouping
  *    parentheses may be preceded by a unary plus {or minus -->} opera-
       tor.
     
     
     
# C.3 EXPRESSIONS
     
       The syntax specifies the precedence of operators in  the  evalua-
       tion  of an expression, which is the same as the order of the ma-
       jor subsections of this section, highest precedence  first.   ...
  *    {The only exceptions are unary operators (#C.3.3), which may have
       cast expressions (#C.3.4) as operands.  -->  The  exceptions  are
       cast   expressions   (#C.3.4)  as  operands  of  unary  operators
       (#C.3.3), and an operand contained between any of  the  following
       pairs  of operators: grouping parentheses () (#C.3.1), subscript-
       ing  brackets  []  (#C.3.2.1),   function-call   parentheses   ()
       (#C.3.2.2), and the conditional operator ?: (#C.3.15).}
     
------------------------------
     
End of mod.std.c Digest - Sat, 10 May 86 18:53:53 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4629
          for JMS@ARIZMIS; Mon, 19-MAY-1986 09:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007344; 15 May 86 12:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019387; 15 May 86 11:59 EDT
From: Alan J Rosenthal <flaps%utcs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  A simple non-portable expression tha
Message-ID: <1229@utcs.uucp>
Date: 9 May 86 08:25:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <972@dataioDataio.UUCP> bright@dataio.UUCP (Walter Bright) writes:
>Different code for (L+I1)+I2 and L+(I1+I2) will only be generated if
>ints are smaller than longs.
     
This is strictly true, but it is not true that different code for (L+I1)+I2
and L+(I1+I2) will necessarily be generated if ints are smaller than longs.
(Besides which, it is unwise to assume this; see K&R p34...)
     
Anyway, the official K&R quote here is from page 185 which says:
    ...[besides precedence rules] the order of evaluation of
    expressions is undefined.  ... Expressions involving a
    commutative and associative operator (*, +, &, |, ^) may
    be rearranged arbitrarily, even in the presence of parentheses;
    to force a particular order of evaluation an explicit
    temporary must be used.
     
So you see that the expressions (L+I1)+I2 and L+(I1+I2) are not necessarily
distinct (though not necessarily identical either).
     
Alan J Rosenthal
{linus|decvax}!utzoo!utcs!flaps, {ihnp4|allegra}!cbosgd!utcs!flaps

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4529
          for JMS@ARIZMIS; Mon, 19-MAY-1986 09:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007113; 15 May 86 12:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019246; 15 May 86 11:53 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <6667@utzoo.UUCP>
Date: 8 May 86 19:14:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> All too often, one sees programmers writing code before
> a proper job of analysis and design has been done.  I
> also believe that is partly because semi-running code
> makes it appear as though progress has been made,
> while a complete design doesn't convey the same impression.
     
Sorry, Doug, I can't let that one go by.
     
All too often, one sees programmers writing detailed design specifications
before writing any code.  This is probably because design specs make it
appear that the problem is fully understood, and give the impression to
management that the rest of the process of implementation will be entirely
mechanical and hence will be on budget and on schedule.  Ho ho.  Then one
gets to draw up a new budget and schedule for "maintenance", which is the
process of modifying the program so that it really meets the customer's
needs, instead of merely meeting the specification.
     
The alternative is to recognize that (a) the user probably does not have
a complete and coherent idea of what he needs, and hence cannot write a
spec or meaningfully assess one you write, and (b) in any case, the presence
of the software itself will change the user's tasks and therefore his needs.
Given recognition of this situation, it is not even theoretically possible
to avoid a trial-and-error process of software development.  Hence you
should aim to make your inevitable mistakes as early as possible.  Which
puts a heavy premium on getting initial prototype software into the hands
of the customers right away, so that you can learn what's wrong with it.
One progresses by iteratively enhancing (and perhaps sometimes re-doing)
the prototype, with regular user feedback.
     
This is not to say that the design-it-first method doesn't have its uses,
and its advantages, when the problem is understood well enough.  But a very
large class of problems -- almost anything to do with user interaction, for
example -- simply don't meet that criterion.
--
Join STRAW: the Society To    Henry Spencer @ U of Toronto Zoology
Revile Ada Wholeheartedly    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4674
          for JMS@ARIZMIS; Mon, 19-MAY-1986 09:30 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007350; 15 May 86 12:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019507; 15 May 86 12:01 EDT
From: George Robbins <grr%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C (Really arguments in registers)
Message-ID: <227@cbmvax.cbmvax.cbm.UUCP>
Date: 12 May 86 01:26:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <357@pyramid.UUCP> wendyt@pyramid.UUCP (Wendy Thrash) writes:
[...]
>I don't want to quote too much of the original article -- it was rather long.
>The thrust of it was that passing parameters in registers doesn't make things
>run faster.  This does not fit with my experience.  When we implemented
>parameter passing in registers at Zilog, it was a big win.
     
*WAS* a big win - meaning maybe it looked good on benchmarks...
     
[...]
>I will admit that this parameter passing caused difficulties.  In particular,
>varargs code was messy, and debuggers more difficult to implement.  Was it
>worth it?  I believe so.  Our emphasis was on speed, and that we had.
     
1) pdp-11 style varargs was broken - no way from C to get a those arguments
   that got crammed into registers.
     
2) Because of the register assignment scheme used, you couldn't even blindly
   pass a list of variable arguments to a routine like printf that did know
   how to deal with them.
     
3) setjmp/longjmp got broken with respect to restoring register variable
   parameters somewhere along the way.
     
In the long run, portability seems to have become the more important issue:
     
Just try porting some of the code in mod.sources and net.sources to the
machine and see how far you can get without having to go into the editor
and start whacking at source code.  Assume that software developers will
have the same problems porting their wares...
     
Also, note that Zilog has never delivered its ATT SVID blessed System V port,
and that their next series of machines will contain ATT chips running vanilla
3Bx software...
--
George Robbins - now working with,    uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing    arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department    fone: 215-431-9255 (only by moonlite)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4245
          for JMS@ARIZMIS; Mon, 19-MAY-1986 09:30 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006816; 15 May 86 11:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018926; 15 May 86 11:43 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#3
Message-ID: <1034@hou2d.UUCP>
Date: 10 May 86 22:51:50 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Sat, 10 May 86       Volume 16 : Issue   3
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 2
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 2
To: cbosgd!std-c%utcsri
     
# B.1.1.3 Diagnostics
     
  *    A conforming implementation shall produce {a -->  at  least  one}
  *    diagnostic  message  for  every {--> source file that contains a}
       violation of any syntax rule or constraint.
     
     
     
# B.1.2.2 Hosted environment
     
<--O   The function called at program startup is called main, and can be
<--O   declared as
     
<--O                       extern int main(int argc, char *argv[]);
     
N-->   The function called at program startup is called main.   The  im-
N-->   plementation  declares no prototype for this function.  It can be
N-->   defined with no parameters:
     
N-->                       int main(void) { /*...*/ }
     
N-->   or two parameters (referred to here as argc and argv, though  any
N-->   names  may  be  used,  as they are local to the function in which
N-->   they are declared):
     
N-->                       int main(int argc, char *argv[]) { /*...*/ }
     
  *    {--> If they are defined,} the parameters to main have  the  fol-
       lowing constraints:
     
     
     
# B.1.2.3 Program execution
     
<--O   All output directed to interactive devices must occur before  new
<--O   interactively generated input is accepted.
     
N-->   The input and output dynamics of interactive devices  shall  take
N-->   place as specified in #D.9.
     
N-->   ...  The intent of the requirements of #D.9 is that unbuffered or
N-->   line-buffered  output  appear as soon as possible, to ensure that
N-->   prompting messages actually appear prior to a program waiting for
N-->   input.
     
     
     
# B.1.2.3 Program execution
     
N-->   ...  Alternatively, an operation involving only  ints  or  floats
N-->   may  be  executed  using  double  precision operations if neither
N-->   range nor precision is lost thereby.
     
     
     
# B.1.2.3 Program execution
     
  *    Forward references: ..., sequence points (#C.3, {--> #C.6}), ...
     
     
     
# B.2.1 Character sets
     
       The following trigraph sequences ... shall  be  replaced  by  the
       specified characters ...
     
N-->   Any other trigraph sequence that begins with ?? is unchanged.
     
       The trigraph sequences enable the input of  characters  that  are
  *    not  defined  in  the  ISO {646 --> 646-1983} Invariant Code Set,
       which is a subset of the seven-bit ASCII code set.
     
     
     
# B.2.2 Character display semantics
     
  *    The "{printing -->  active}  position"  is  that  location  on  a
       display device where the next character output by the fputc func-
  *    tion would appear.  The {effect --> intent} of writing  a  print-
       able  character (as defined by the isprint function) to a display
       device is to display a graphic representation of  that  character
  *    at  the  {current  printing --> active} position and then advance
  *    the {printing --> active} position to the next  position  on  the
  *    current  line.  {--> If the active position is at the final posi-
       tion of a line (if there is one), the behavior is unspecified.}
     
       Alphabetic escape sequences representing  non-graphic  characters
  *    {--> in the execution character set are intended to} produce for-
       mat effecting actions on display devices as follows:
     
  *    \a ("alert") Produces an {implementation-defined -->} audible  or
  *    visible  representation  of  an alert character.  {Any consequent
       alteration to the printing  position  is  implementation-defined.
       --> The active position shall not be changed.}
     
  *    ... \v ("vertical tab") Moves the {printing --> active}  position
  *    to  the  initial  {printing  -->  active}  position  of  the next
  *    {implementation-defined -->} vertical tabulation position.   {-->
       If  the  active  position is at or past the last defined vertical
       tabulation position, the behavior is unspecified.}
     
     
     
# B.2.3 Signals and interrupts
     
       Functions shall be implemented such that they may be  interrupted
       at  any  time  by a signal, and may be called by a signal handler
  *    with no alteration {-->  to  control  flow,  to  function  return
       values,  or} to objects with automatic storage duration belonging
       to earlier invocations.
     
     
     
# B.2.3 Signals and interrupts
     
N-->   The functions in the standard library are not  guaranteed  to  be
N-->   reentrant and may modify objects with static storage duration.
     
     
     
# B.2.4.1 Translation limits
     
  *    The implementation shall be able to {compile  at  least  one  -->
  *    translate  and  execute a} program that {meets or exceeds all -->
  *    contains at least one instance}  of  the  following  {translation
       -->} limits:
     
  *    ...  {6 --> 12} pointer, array, and function declarators  modify-
       ing a basic type in a declaration
     
  *    ...  {1024 --> 127} identifiers with block scope in one block
     
  *    1024 macro identifiers {--> simultaneously defined} in one source
       file
     
  *    31 parameters in one function {--> definition and} call
     
  *    31 parameters in one macro {--> definition and invocation}
     
     
N-->   ...  509 characters in a string literal (after concatenation)
     
N-->   32767 bytes in an object (in a hosted environment only)
     
  *    {4 --> 8} nesting levels for #included files
     
<--O   maximum number of alphabetic cases in an external identifier (1)
     
     
     
# B.2.4.2 Numerical limits
     
       A conforming implementation shall document all these items, which
  *    are specified in the headers <limits.h> {--> and <float.h>}.
     
  *    Sizes of integral types {--> <limits.h>}
     
       The values given  below  shall  be  replaced  by  implementation-
  *    defined  {values --> constant expressions} that shall be equal or
       greater in magnitude (absolute value).
     
     
     
# B.2.4.2 Numerical limits
     
     
  *    Characteristics of floating types {--> <float.h>}
     
N-->   The  integer  values   given   below   shall   be   replaced   by
N-->   implementation-defined  constant  expressions that shall be equal
N-->   or greater in  magnitude  (absolute  value).   Values  that  have
N-->   floating type need not be constant expressions.
     
N-->   The following apply to all three floating-point types and require
N-->   only one name.
     
       radix of exponent representation
               FLT_RADIX                      2
  *            {DBL_RADIX                2 -->}
  *            {LDBL_RADIX               2 -->}
     
  *    addition rounds (1), chops (0),  {-->  or  indeterminable  during
       translation (-1)}
               FLT_ROUNDS                     0
  *            {DBL_ROUNDS               0 -->}
  *            {LDBL_ROUNDS              0 -->}
     
N-->   guard digits are used (1) or not used (0) for floating  multipli-
N-->   cation
N-->           FLT_GUARD                      0
     
N-->   floating values must be normalized (1) or need not be (0)
N-->           FLT_NORMALIZE                  0
     
<--O   maximum power of 10 that can be represented ...
<--O           FLT_MAX_EXP                  +38
<--O           DBL_MAX_EXP                  +38
<--O           LDBL_MAX_EXP                 +38
     
<--O   minimum power of 10 that can be represented ...
<--O           FLT_MIN_EXP                  -38
<--O           DBL_MIN_EXP                  -38
<--O           LDBL_MIN_EXP                 -38
     
N-->   maximum representable finite floating-point number
N-->           FLT_MAX                    1E+38
N-->           DBL_MAX                    1E+38
N-->           LDBL_MAX                   1E+38
     
N-->   minimum representable positive floating-point number
N-->           FLT_MIN                    1E-38
N-->           DBL_MIN                    1E-38
N-->           LDBL_MIN                   1E-38
     
N-->   maximum integer such that FLT_RADIX raised to that power yields a
N-->   representable finite floating-point number
N-->           FLT_MAX_EXP
N-->           DBL_MAX_EXP
N-->           LDBL_MAX_EXP
     
N-->   minimum negative integer such that FLT_RADIX raised to that power
N-->   yields a representable positive floating-point number
N-->           FLT_MIN_EXP
N-->           DBL_MIN_EXP
N-->           LDBL_MIN_EXP
     
N-->   maximum integer such that  10  raised  to  that  power  yields  a
N-->   representable finite floating-point number
N-->           FLT_MAX_10_EXP               +38
N-->           DBL_MAX_10_EXP               +38
N-->           LDBL_MAX_10_EXP              +38
     
N-->   minimum negative integer such that 10 raised to that power yields
N-->   a representable positive floating-point number
N-->           FLT_MIN_10_EXP               -38
N-->           DBL_MIN_10_EXP               -38
N-->           LDBL_MIN_10_EXP              -38
     
       number of decimal digits of precision
               FLT_DIG                        6
               DBL_DIG                        6
               LDBL_DIG                       6
     
N-->   number of base-FLT_RADIX digits in the floating-point mantissa
N-->           FLT_MANT_DIG
N-->           DBL_MANT_DIG
N-->           LDBL_MANT_DIG
     
N-->   number of base-FLT_RADIX digits in  the  floating-point  exponent
N-->   (including bias or sign)
N-->           FLT_EXP_DIG
N-->           DBL_EXP_DIG
N-->           LDBL_EXP_DIG
     
N-->   minimum positive floating point number x such that 1.0 + x != 1.0
N-->           FLT_POS_EPS                 1E-5
N-->           DBL_POS_EPS                 1E-5
N-->           LDBL_POS_EPS                1E-5
     
N-->   minimum positive floating point number x such that 1.0 - x != 1.0
N-->           FLT_NEG_EPS                 1E-5
N-->           DBL_NEG_EPS                 1E-5
N-->           LDBL_NEG_EPS                1E-5
     
N-->   minimum integer such that FLT_RADIX raised to that power yields a
N-->   floating-point number x such that 1.0 + x != 1.0
N-->           FLT_POS_EPS_EXP
N-->           DBL_POS_EPS_EXP
N-->           LDBL_POS_EPS_EXP
     
N-->   minimum integer such that FLT_RADIX raised to that power yields a
N-->   floating-point number x such that 1.0 - x != 1.0
N-->           FLT_NEG_EPS_EXP
N-->           DBL_NEG_EPS_EXP
N-->           LDBL_NEG_EPS_EXP
     
------------------------------
     
End of mod.std.c Digest - Sat, 10 May 86 18:51:13 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4721
          for JMS@ARIZMIS; Mon, 19-MAY-1986 09:32 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007360; 15 May 86 12:25 EDT
Received: from csnet-relay.arpa by SMOKE.BRL.ARPA id a019775;
          15 May 86 12:12 EDT
Received: from slb-doll by csnet-relay.csnet id a010512; 15 May 86 12:07 EDT
Posted-Date: Thu 15 May 1986 11:40:08 EST
Date: Thu 15 May 1986 11:40:08 EST
From: Paul Dietz <dietz%slb-doll.csnet@CSNET-RELAY.ARPA>
Subject: Re: blabbermouth tool
To: info-c@BRL-SMOKE.ARPA
In-Reply-To: Wayne Throop's message of 10 May 86 18:43:47 GMT
Cc:
     
>I grant you, this isn't very informative, but lint *doesn't* like it,
>that much is certain.  Let's run a more blabbermouth tool over it.
>
>        #1052 4 inconsistent types discovered
>              (=
>                (:AREF
>                  (:IDENTIFIER a :AUTO ... )
>                  (:OCT_INT 0))
>                (:CAST
     
Wayne: what is that blabbermouth tool you refered to?  Look's like
a Lisp-based package.  Is it in the public domain, or for sale?
     
        Paul Dietz
        dietz%slb-doll@csnet-relay.arpa
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5338
          for JMS@ARIZMIS; Mon, 19-MAY-1986 10:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 12:21:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002543; 19 May 86 4:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002664; 19 May 86 4:05 EDT
From: Jim Hutchison <hutch%sdcsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Public domain C compiler
Message-ID: <1777@sdcsvax.UUCP>
Date: 12 May 86 17:52:26 GMT
Keywords: Public-Domain,compiler
To:       info-c@BRL-SMOKE.ARPA
     
<>
Does anyone know where I can get a reasonably bug free C compiler
or small-(read as subset)-C compiler?  It will end up in a commercial
product (icky I know), so some expense is justified.
     
Noble venture: I am trying to transform a fortran house into a C house!
I have a faction convinced that C is wonderful, now I need to port a
compiler to there proprietary system.  Probably on my own time, but to
be allowed to work in a more reasonable language than fortran is worth it.
     
If no public domain C compiler is available, could anyone point me at
public domain yacc's/lex's ???
     
--
/*    Jim Hutchison    UUCP:    {dcdwest,ucbvax}!sdcsvax!hutch
            ARPA:    Hutch@sdcsvax.ucsd.edu
            [ Disclaimer eaten by a passing kiwi ]     */

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5434
          for JMS@ARIZMIS; Mon, 19-MAY-1986 10:42 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002595; 19 May 86 4:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002927; 19 May 86 4:14 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.apl
Subject: Proliferation of operators (was: C Builtin Functions)
Message-ID: <812@bentley.UUCP>
Date: 14 May 86 00:01:09 GMT
Xref: brl-sem net.lang.c:1086 net.lang.apl:18
To:       info-c@BRL-SMOKE.ARPA
     
In article <1418@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>In article <788@bentley.UUCP> kwh@bentley.UUCP writes:
>>I can feel the flames ("More operators?  It's getting as bad as APL!").
>
>"More operators?  It's getting as good as APL!" -- except that it still
>falls way short in this respect.  I'm serious; APL does *not* have too many
>operators.  It does have too little structure.
     
The primitive functions in APL correspond roughly to C operators *and* the
entire runtime library.  I agree that APL does not have a problem there.
     
APL has its own character set; C is restricted to a subset of ASCII.  The
size of the alphabet is not a serious problem since new operators in C may
be multi-character; however, this may make them less mnemonic.  (Of course,
some of the APL characters are not all that mnemonic either: "x" for signum
is a good example.)
     
The reason APL can deal with having so many primitives is that they all have
the same precedence.  Adding that many operators to C would be a disaster.
     
You say APL has "too little structure".  If you mean things like "while" and
"if", I think they may be unwelcome.  Put in a "while" loop, and people will
start using it to implement a matrix multiply.  (For those who don't get it,
APL has a builtin matrix multiply, "+.x".)  The language doesn't need much
program structure, because it has data structure in its place.
     
Now, I *would* like to see some improvement in the data structure.  It's now
practically impossible to write a function which expects, say, three string
(character vector) arguments.  I like the grounded tree model, myself, as a
fix for this.  Also, APL is *severely* in need of *variable declarations*!
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
*** Please restrict followups appropriately! {net.lang.c|net.lang.apl} ***

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6512
          for JMS@ARIZMIS; Mon, 19-MAY-1986 12:38 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 14:25:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014080; 15 May 86 16:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002803; 15 May 86 15:46 EDT
From: mwm%ucbopal.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Problems with lint as a seperate program
Message-ID: <687@jade.BERKELEY.EDU>
Date: 10 May 86 05:26:16 GMT
Sender: usenet@jade.ucb-vax.ARPA
To:       info-c@BRL-SMOKE.ARPA
     
     
Just so that people don't assume that having lint-like things as a seperate
program is right, with no problems, I'd like to point out one: on at least
one occasion, lint didn't accept quite the same language that cc did. Unless
lint it just cc with a magic flag, somebody has to make sure that the lint
tracks cc (even if it's only making sure that lint gets recompiled whenever
cc changes).
     
I've been using a C compiler that has much of the lint-like checking built
in (uninitialized and unused variables, constant references beyond the
ends of arrays, type clashes and the like). It's GREAT! It's not a complete
lint, in that it won't help you verify that your code will port to other
machines, but it catches most of the coding errors that lint does, and
issues warnings so that it doesn't mangle the 1% of the cases where they
are correctly used.
     
I think most C compilers would benifit from having these types of checks
built in. Those obsessed by portability will disagree, because people
would be less likely to run lint. But you can still lint code if you
wish, and it makes the job of writing running code easier.
     
    <mike

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6623
          for JMS@ARIZMIS; Mon, 19-MAY-1986 12:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014103; 15 May 86 16:19 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002832; 15 May 86 15:46 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA20256; Thu, 15 May 86 15:46:52 edt
Date: Thu, 15 May 86 15:46:52 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605151946.AA20256@icst-cmr.ARPA>
To: copper!stevesu@seismo.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: questions from using lint
     
> In article <501@brl-smoke.ARPA>, rbj@icst-cmr (Root Boy Jim) writes:
> >     Most People            Your's Truly
> >
> >     if (c) {            if (c)
> >         w = y;                w = x,
> >         y = z;                y = z;
> >     }                /* look ma, no brace */
>
> There is an excellent, excellent book, which everybody should
> read, called The Elements of Style, by William Strunk and E. B.
> White.  It is about writing in English, but almost everything in
> it applies to writing in programming languages as well.  One of
> my favorite quotes (from page 74 of the third edition) is
>
>     "In ordinary composition, use orthodox spelling.  Do not
>     write "nite" for "night," "thru" for "through," "pleez"
>     for "please," unless you plan to introduce a complete
>     system of simplified spelling and are prepared to take
>     the consequences."
     
Attacking me on both fronts, eh? Well GFY! These people are obviously
more conservative than I choose to be. After all, don't we hear
enuf people screaming about UUCP transmission isn't free? Well, I
am just helping out in my own little way :-).
     
What kind of a person would let the way someone spells bother them?
You must have awfully thin skin. Worry about something that makes a
difference for a change. After all, you *do* understand me don't you?
     
> The consequences, of course, are that in virtually all cases you
> will be laughed out of the room.  Convention has a place.
     
True. When you start following mine I'll start following yours. For
example, I happen to think that all code should be formatted such
that all funxions fit on a page. This is a good idea, but one I
seldom see adhered to.
     
You're laughing? So what? I'm laughing at you for getting stuck
on an insignificant detail. Since you don't have anything real
to say, you're attacking the style, not the substance.
     
> You are not being a sheep or a lemming if you do things the way most
> people do things; you are being responsible.  C can be hard
> enough to read when it is formatted "correctly;" we certainly
> don't need any more unorthodox methodologies floating around.
     
I didn't make this style up just to be ornery. My whole point is that
the delimiting style chosen by the authors of the language left
a little something to be desired. Bourne's macros fixed this.
And yet, some people complained about them.
     
> Proponents of things like "look ma, no braces" will claim that
> theirs is not "ordinary composition," and that they are therefore
> exempt from generally accepted programming practices.  This
> statement is in fact perfectly true.  If you want to be a rugged
> individualist and program in a vacuum; if nobody else ever reads
> your code; if only you have to maintain it or port it to other
> machines; then you are certainly welcome to make each program you
> write an odds on favorite for the winner's circle in the
> Obfuscated C Contest.  However, do the rest of us a favor and
> perfect your isolated environment by sparing this newsgroup from
> your rantings and ravings.
     
Hey, lighten up pal. Most of the `examples' I posted I have
given up long ago. Even with the comma trick, sooner or later you're
going to want to add a control statement that forces the braces.
     
I just get tired of all you sanctimonious zealots that insist upon
quoting the party line on everything. It makes me ornery.
     
You can't please everyone all of the time. And you can't expect
people to please you either. All you can do get off on the common
ground, while putting aside the (minor & insignificant) differences.
I quit trying to please everyone else long ago. That's your job.
     
As for sparing you, I just might do that. I'm getting pretty sick
of these discussions and I haven't seen anything new for awhile.
     
>                                          Steve Summit
>                                          tektronix!copper!stevesu
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "You used to laugh about
     Everybody that was hanging out"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6695
          for JMS@ARIZMIS; Mon, 19-MAY-1986 12:46 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015402; 15 May 86 20:07 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a005862; 15 May 86 19:29 EDT
Date:     Thu, 15 May 86 19:17:03 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  questions from using lint
     
You seem to have missed a key word in my posting.
I urged "a proper job of analysis and design"
before coding.  A proper job of systems analysis
addresses the issues you raised.  Structured
software development even encourages early hands-
on use of prototypes, to REFINE the design, not to
try to ARRIVE at a design by trial-and-error.
     
There IS a lot of knowledge about user interaction;
like structured software development, however, few
practitioners appear to have bothered to study it.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7165
          for JMS@ARIZMIS; Mon, 19-MAY-1986 13:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 15:35:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016332; 15 May 86 21:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007034; 15 May 86 21:43 EDT
From: Landon Noll <chongo%nsc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Obfuscated C
Message-ID: <3570@nsc.UUCP>
Date: 12 May 86 06:53:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article woody@juliet.caltech.edu (William E. Woody) writes:
 >  I Like C to be reasonably easy to learn _and_ extremely powerful, as well.
 >But if we tack on new commands and operators at will, then everyone's program
 >will be a winner in the Obfuscated C contest!
 >
 >         - William Woody
     
I agree.  Most suggestions of "new-and-improved" C features try to make
C into some other language.  I was glad to see Ansi-C standard drafts
did not go Hog-wild (as in J. Poornelly C) with features, though some
of them go too far.
     
When you want to add something to C, ask yourself:  Does the power I
gain justify the additional complexity of the compiler?  Does it break
existing C programs?  Does it add something that was not already there
in another form?
     
Last, consider what this "new" feature will do to the complexity of C
source.  Consider the potential abuse of the "feature".  If 1986's
entries any any judge, we nearly have enough of these problems already...
     
chongo  <CONTEST ENDS MAY 30!  HAVE YOU SENT IN YOUR ENTRY?>  /\cc/\

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7276
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:02 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 15:41:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016411; 15 May 86 22:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007113; 15 May 86 21:45 EDT
From: "G.M. Paris" <gmp%rayssd.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: questions from using lint
Message-ID: <2235@rayssd.UUCP>
Date: 11 May 86 18:22:19 GMT
Sender: "Gregory M. Paris @ Raytheon Co., Portsmouth RI"
  <gmp%rayssd.uucp@BRL.ARPA>
To:       info-c@BRL-SMOKE.ARPA
     
> You people fail to realize that some of us out here don't like lint.
> It complains too much about what I do. I refuse to go any further
> than generating no compiler warnings. I know what I'm doing. When I
> goof, I'll fix it myself. I refuse to add extra casts to keep lint happy.
>
> Before you start flaming my style, let me say I am quite good.
> I am also quite philosophical and attentive to coding style.
> My outlook is just different. I program for myself. If it is applicable
> to you, fine. I have my own criteria which I rarely see embraced by
> others waving standardization flags.
>
> Most of the code I have written was intrinsically non-portable. I *do*
> appreciate portability as a spectrum concept, but not as a binary one.
>
> This is just me. I'm not sure I would recommend my methods to anyone
> else, especially novices. My experience was obtained with more than a
> few battle scars. There are probably easier ways.
>
>     (Root Boy) Jim Cottrell        <rbj@cmr>
>     "I'm alright, Jack, keep your hands off of my stack"
     
Sorry I enclosed so much of the original article above, but I found it
so surprisingly bizzare, I just couldn't leave any of it out.  I have
two things to say about it: 1) I'm glad that Mr. Cottrell doesn't work
here; 2) I'd never recommend him being hired as a programmer, anywhere.
--
++--------------------------------------------------------------------------++
||  Greg Paris            {allegra,linus,raybed2,ccice5,brunix}!rayssd!gmp  ||
++--------------------------------------------------------------------------++

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7428
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 15:50:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016417; 15 May 86 22:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007129; 15 May 86 21:47 EDT
From: Bellcore CIM <cim%pyuxv.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc
Subject: Microsoft 'C' - Problem with Spawns & Open files
Message-ID: <202@pyuxv.UUCP>
Date: 12 May 86 00:49:24 GMT
Xref: brl-sem net.lang.c:1066 net.micro.pc:1111
To:       info-c@BRL-SMOKE.ARPA
     
I'm having a  problem using the Microsoft C 3.0 'spawnlp' function
with open files in the calling program. (PCDOS-3.1, IBM PC/XT)
     
After returning from the spawn, all file pointers (except stdin,stdout etc) are
randomised !
The spawned program does nothing except print 'hello world' & exit.
     
I've tried:
a)    Using 'system' instead of 'spawn' - no change
b)    'dup'ing the relevent file descriptors before the spawn, and trying
    to restore them afterwards - no change
c)     Using 'freopen' to reopen the file as the standard input,
    and then read 'stdin' - no change.
     
The only work-around I've found so far is to do 'ftell's on the files
before the function, then 'fseek's afterwards - which, to put it mildly,
is a really putrid kludge.
     
Does anyone have a better fix ?
     
Robert Fair.            ihnp4!pyuxv!cim2
Bell Communications Research.
Piscataway NJ
     
My signature line has given up in disgust & become a COBOL programmer.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7536
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 16:02:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002597; 19 May 86 4:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002931; 19 May 86 4:14 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Operators for max and min (was: Boolean Operators Slighted in C)
Message-ID: <813@bentley.UUCP>
Date: 14 May 86 00:05:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2692@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>... to support '/\' and '\/' ( max and min ) ...
>#define min(a,b) ((a)\/(b))
>#define max(a,b) ((a)/\(b))
     
Shouldn't that be the other way around?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7610
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:19 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002602; 19 May 86 4:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003004; 19 May 86 4:16 EDT
From: " G.R.Tomasevich" <grt%twitch.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Shady programming, ignoring return values
Message-ID: <371@twitch.UUCP>
Date: 12 May 86 13:18:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>         w = y;                return w = x,
>         return;
     
As usual, news arrived out of order.  Someone else already barfed on this.
     
> Yes, but it all depends on what you're willing to put up with. I find it
> terribly ugly having to cast printf's or close's to void. And as
     
What happens if your program is a filter and the printf() return values
are trying to tell you something, such as that the disk is full?  We have
had people do that to us with overnight program runs.  Even if your program
is not a filter WRT stdout, you might still redirect output, or even
stderr also for an overnight run.  A 'little output' could become a lot for
some pathological reason.
--
    George Tomasevich, ihnp4!twitch!grt
    AT&T Bell Laboratories, Holmdel, NJ

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7681
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002616; 19 May 86 4:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003512; 19 May 86 4:33 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <815@bentley.UUCP>
Date: 14 May 86 01:42:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <866@ttrdc.UUCP> ttrdc!levy (Dan Levy) writes:
>Y'know--while I'm thinking about it, why IS malloc() set up to return a
>(char *) pointer at all, if that IS inviting a potential (or at least to
>lint's little mind) pointer alignment problem?  Since malloc() is supposed
>to return a maximally aligned pointer, seems to me that it should have
>been set up to return a (double *).  Yes, yes, before flames of misunder-
>standing start, I _KNOW_ that the convention for malloc() is to return
>a (char *) and that it returns a maximally aligned pointer just the same
>because of the way it has been written.  It just seems that the methodology
>was back-a**wards, that at least returning a (double *) would indicate an
>implicit promise to the user (and to lint-like checking) that the return
>value WAS maximally aligned.  The only problem I could see with this kind
>of scheme is that some systems might not support double.  But that could
>be gotten around by #defining a malloc_t type that would represent the
>maximally aligned data type of the machine at hand.
     
This is what I started to mention once before, and picked up a lot of "no,
you don't understand how it works" messages (sigh).  I saw the need for a
"ALIGN *" datatype, and was hoping "void *" would be it.  (Nope, just a
useless synonym for "char *").  The idea would be that, just as it's always
legal to cast any pointer into a "char *", it would be legal to cast *from*
"ALIGN *" to any pointer.  Then lint would shut up about malloc()!
     
Also, having malloc() return a real "ALIGN *" would be convenient for word-
addressible machines where "char *" requires extra bits.
     
Btw, if I really want to reduce the signal/noise ratio in lint, I use
#if lint
extern char       *cmalloc();
extern int        *imalloc();
extern struct foo *fmalloc();
...
#else
extern char *malloc();
#define cmalloc(n) ((char       *)malloc((n)*sizeof(char))
#define imalloc(n) ((int        *)malloc((n)*sizeof(int))
#define fmalloc(n) ((struct foo *)malloc((n)*sizeof(struct foo))
...
#endif
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7791
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 16:23:25 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002620; 19 May 86 4:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003588; 19 May 86 4:36 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <1544@ecsvax.UUCP>
Date: 12 May 86 17:26:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <797@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>Yet another convention, not endorsed by any language I know, is to dispense
>with the braces and let the indentation alone tell the compiler how to
>interpret the program.  (I came up with this idea after an argument on the
>"correct" place to put the braces.)
     
As several people have pointed out, this convention is used in some
languages.  I just wanted to point out an instance no one has mentioned
yet:  IBM's ISPF, a mainframe 3270 screen management package that
allows you to define a "panel" with associated procedural information.
     
You find things in the oddest places...
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7722
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 16:15:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002614; 19 May 86 4:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003508; 19 May 86 4:33 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <814@bentley.UUCP>
Date: 14 May 86 01:16:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <268@valid.UUCP> valid!sbs (Steven Brian McKechnie Sargent) writes:
>A Boolean data type distinct from integers clutters the language
     
I disagree.  I think an explicit boolean datatype *simplifies* the language.
The way I see it, booleans already exist internally.
     
>and removes handy idioms like
>    foo[x == 0] = bar;
     
I'd guess that would still be legal, just like "float x = 0;".  The compiler
could know how to convert bool to int.  At worst, you could write "(int)" to
force it.  (I prefer to write "foo[x==0 ? 1 : 0] = bar;", which is no less
efficient since that's how the compiler converts the "internal bool" into an
int anyway.)
     
>(Vide the "enum" type, which doesn't participate in address arithemtic
>either.)
     
I'd like to see a syntax to declare an array which is subscripted by an enum
instead of an int.  Having to use a cast is a pain.  (In the example above,
you didn't mean to imply that foo[] would only be indexed by bool, did you?
If so, cancel my comment about "?:".)
     
>Arguments that boolean functions make for more efficient implementations
>are pretty puny:
>> o  A function returning a bool could be implemented on some machines by
>>    setting the condition codes instead of storing a full integer value in
>>    the return register.
>If the caller wants to use the result of the function as a value, rather
>than as input to a branching decision, then it must write branches anyway
>to set the value appropriately.  Result: bigger slower code.
     
No slower than putting the same branch in the called function!  Anyway, I
suspect that most boolean functions *are* used in a boolean context rather
than an integer context.
     
>> >o  Multiple flag variables with local scope and no address operator (e.g.
>> >   variables declared "register bool") could be packed into a single word.
>Last I checked, (flags&BOOLEAN_VALUE_OF_MERIT) did what you want.  Packing
>and unpacking don't come for free, in space or time.
     
"Packing and unpacking" don't need to be done except in an integer context.
The boolean operations are single instructions.  As for (f&CONST), I'd just
like to reduce the ugliness.  Cf. bitfields.
     
>**
>Builtin functions confuse language implementation with programming
>environment implementation; C lives in enough different environments
>that this is just plain bad planning.  "Inline functions," a la those
>of C++, are another matter entirely (although they have been mentioned
>repeatedly in discussions of builtin functions).  The benefits that
>inline functions offer over CPP macros are: simpler cleaner syntax,
>more flexibility because they admit arbitrary control structure within,
>and avoidance of horrible botches like putchar(*p++).  The disadvantage,
>at least in my mind, is uncertainty as to what happens to the free
>variables of an inline function.  Are they bound lexically where the
>inline is declared, or are they bound at the point where the inline is
>used, assuming the nearest enclosing scope?  Consider: [example deleted]
     
I think I agree about builtins.  There's no problem with "putchar(*p++)",
I believe you're thinking of "putc(c, *fp++)".  It's my understanding that
"inline" has the same semantics as "static", but is a hint to the compiler;
your example may force the compiler to forgo the inline expansion.
     
>**
>New operators like "< =" ...
     
I originally mentioned this just to point out that there exist operators
which cannot be extended with "op=".  The one person who thought it would be
useful was confusing it with "MAX=".  (Mark Brader has pointed out that B,
a sibling* language to C, actually has these operators (spelled "=<", etc.)
for completeness.  I still think they're useless.)
     
>**
>... I have yet to see a feature proposed that fixes a crippling problem of
>the language.
     
Do you know of any "crippling problems" that require new features?
     
Anyway, it's useful to keep in mind that much of what is said here (by me,
certainly) is not a "proposal", but just an idea to be tossed around in the
think tank.  As an example of such, here's an idea which I do *not* want to
see in the next ANSI draft.
     
In stepping through a linked list (recursive structure), one often writes
"p=p->next;".  The logic that creates "+=" would suggest that this could be
written "p->=next".  However, "->" is not really an operator since its right
"argument" is not an expression.  An alternate notation would be "p=>next",
where "=>" is a sort of overstrike between "->" and "=".  (I actually had a
case once where this would've been useful -- "p" was an expression with side
effects!)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
*The original B was a parent language of C; modern B is a sibling.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7851
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:40 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002642; 19 May 86 5:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003740; 19 May 86 4:40 EDT
From: Mike Banahan <mikeb%inset.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Indentation
Message-ID: <995@inset.UUCP>
Date: 13 May 86 17:53:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <797@bentley.UUCP> kwh@bentley.UUCP writes:
(I just pull out the bit that interests me)
     
>In article <501@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>>I have ranted about C using a one statement model for its control
>>statements instead of an explicit end statement.  Compound statements are
>>bounded by braces instead.  Yuk!
>
>Ah yes, there are two major types of language in the structured family;
>f77 with "endif" (some members use "end" for all of "endif", "endwhile",
>etc.) and pascal with "begin" "end" (which C abbreviates to "{" "}").  I
>presume this is what you dislike.  (If it's the spelling that bothers you,
>I'm sure you're aware that you can define "begin" and "end" as macros.)
>
>Yet another convention, not endorsed by any language I know, is to dispense
>with the braces and let the indentation alone tell the compiler how to
>interpret the program.  (I came up with this idea after an argument on the
>"correct" place to put the braces.)
     
Sorry, you're wrong. Occam uses indentation to show nesting. You *can't*
write an incorrectly indented program, because different indent is a different
program!
     
(Occam is the parallel language for the Inmos Transputer; it's good fun
but boy do you have to re-think those old ideas about sequential execution.)
--
Mike Banahan, Technical Director, The Instruction Set Ltd.
mcvax!ukc!inset!mikeb

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7914
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 16:36:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006654; 19 May 86 9:18 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a006448; 19 May 86 8:42 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA23432; Fri, 16 May 86 16:27:51 edt
Date: Fri, 16 May 86 16:27:51 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605162027.AA23432@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, rayssd!gmp@seismo.ARPA
Subject: Re: Re: questions from using lint
     
    From info-c-request@BRL.ARPA Fri May 16 00:24:39 1986
    Received: from BRL-SMOKE.ARPA (brl-smoke.arpa.ARPA) by icst-cmr.ARPA
(4.12/4.7)
        id AA20984; Fri, 16 May 86 00:24:35 edt
    Received: from USENET by SMOKE.BRL.ARPA id a007113; 15 May 86 21:45 EDT
    From: "G.M. Paris" <rayssd!gmp>
    Newsgroups: net.lang.c
    Subject: Re: Re: questions from using lint
    Message-Id: <2235@rayssd.UUCP>
    Date: 11 May 86 18:22:19 GMT
    Sender: "Gregory M. Paris @ Raytheon Co., Portsmouth RI" <rayssd!gmp>
    To: info-c@brl-smoke.arpa
     
    > You people fail to realize that some of us out here don't like lint.
    > It complains too much about what I do. I refuse to go any further
    > than generating no compiler warnings. I know what I'm doing. When I
    > goof, I'll fix it myself. I refuse to add extra casts to keep lint happy.
    >
    > Before you start flaming my style, let me say I am quite good.
    > I am also quite philosophical and attentive to coding style.
    > My outlook is just different. I program for myself. If it is applicable
    > to you, fine. I have my own criteria which I rarely see embraced by
    > others waving standardization flags.
    >
    > Most of the code I have written was intrinsically non-portable. I *do*
    > appreciate portability as a spectrum concept, but not as a binary one.
    >
    > This is just me. I'm not sure I would recommend my methods to anyone
    > else, especially novices. My experience was obtained with more than a
    > few battle scars. There are probably easier ways.
    >
    >     (Root Boy) Jim Cottrell        <rbj@cmr>
    >     "I'm alright, Jack, keep your hands off of my stack"
     
    Sorry I enclosed so much of the original article above, but I found it
    so surprisingly bizzare, I just couldn't leave any of it out.  I have
    two things to say about it: 1) I'm glad that Mr. Cottrell doesn't work
    here; 2) I'd never recommend him being hired as a programmer, anywhere.
    --
     
 ++--------------------------------------------------------------------------++
    ||  Greg Paris            {allegra,linus,raybed2,ccice5,brunix}!rayssd!gmp
 ||
     
 ++--------------------------------------------------------------------------++
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7998
          for JMS@ARIZMIS; Mon, 19-MAY-1986 14:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016183; 19 May 86 14:10 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a015801; 19 May 86 13:50 EDT
Received: from (3GTLJHW)CALSTATE.BITNET by WISCVM.WISC.EDU on 05/19/86
  at 12:48:18 CDT
Date: Mon May 19, 1986 at 10:47 AM  PDT
From:   Joerg Hallbauer <3GTLJHW%CALSTATE.BITNET@wiscvm.ARPA>
To: Info-C <info-c@BRL-SMOKE.ARPA>
Subject: Analysis and DEsign
     
>All too often, one sees programmers writing detailed design specifications
>before writing any code.  This is probably because design specs make it
>appear that the problem is fully understood, and give the impression to
>management that the rest of the process of implementation will be entirely
>mechanical and hence will be on budget and on schedule.  Ho ho.  Then one
>gets to draw up a new budget and schedule for "maintenance", which is the
>process of modifying the program so that it really meets the customer's
>needs, instead of merely meeting the specification.
     
  Sorry, but *I* can't let that one go by.  The whole point is doing a
careful job of program/system design is so that you WILL understand the
problem fully.
     
     
>The alternative is to recognize that (a) the user probably does not have
>a complete and coherent idea of what he needs, and hence cannot write a
>spec or meaningfully assess one you write, and (b) in any case, the presence
>of the software itself will change the user's tasks and therefore his needs.
     
   You are absolutely right, few users have a meaningful or coherent idea
of what it is they want.  Again this is an good arguement for why you SHOULD
do a good job of systems analysis. One of the main tasks that a good analyst
does is to help the user make decisions!  He guides the user and in that
process gets a clear view of exactly what it is the user is trying to do and
what the user will expect as a result.  This is important not only so that
the system will meet the users need when it is delivered, but is also needed
in order for the system to be tested properly.  The presence of the software
only changes the user task's if this has not been discussed with the user.
Again a good analyst will expain to the user how the software will impact
his working enviroment, and together than can plan with this in mind.
     
>Given recognition of this situation, it is not even theoretically possible
>to avoid a trial-and-error process of software development.  Hence you
>should aim to make your inevitable mistakes as early as possible.  Which
>uts a heavy premium on getting initial prototype software into the hands
>of the customers right away, so that you can learn what's wrong with it.
>One progresses by iteratively enhancing (and perhaps sometimes re-doing)
>the prototype, with regular user feedback.
     
   That's the whole point to systems analysis.  Place the interative process
at the front of the systems life cycle, NOT at the end!  Currently maintenence
is the single largest cost in DP today.  One of the major reasons that so
much time is currently being spent "enhancing" existing software is that
when that software was written the people writing it did not have a good
understanding of that the user wanted.  Discovering what the users needs are
is not done in front of a computer terminal writting code, it's done TALKING
to the user!  Sure in order to full expain some things to the user you may
want to do some prototyping, but you certainly don't want to run out and
write the entire system and THEN ask the user what he/she thinks.
     
     
>This is not to say that the design-it-first method doesn't have its uses,
>and its advantages, when the problem is understood well enough.  But a very
>large class of problems -- almost anything to do with user interaction, for
>example -- simply don't meet that criterion.
     
     
  You have it exactly backwards!  Structured Systems Analysis and design
are MOST efective when they are used on large projects that have a great
deal of user interaction involved with them.  Sudies have shown conclusively
that 40+% of the time bugeted for a project whould be spent in analysis and
design with the rest divided between coding and testing (with documentation
though really having been done as part of the analysis and design taking a
couple of percent here too).
     
     
     
                                        Joerg Hallbauer
                                        Systems Analyst
                                 Professional Services Division
                                    Control Data Corporation
     
                                     Technical Support Group
                                  California State Universities
     
                            BitNet: 3GTLJHW@CALSTATE
                           ArpaNet: 3GTLJHW%CALSTATE@WISCVM.EDU
     
                             Phone: (213) 852 - 5087
     
     
[ The usual disclaimers apply of course ]

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8181
          for JMS@ARIZMIS; Mon, 19-MAY-1986 15:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 16:59:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002618; 19 May 86 4:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003516; 19 May 86 4:33 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: builtins and automatic defines
Message-ID: <816@bentley.UUCP>
Date: 14 May 86 02:01:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1232@utcs.uucp> utcs!flaps (Alan J Rosenthal) writes:
>Well I sure hope no one sticks in such a thing without telling me!
>Any such #include or #define things should not only be optional, they
>should have to be explicit.  So perhaps instead of merely beginning every
>program with #include <stdio.h>, you can also have #include <builtins.h>.
>
>*I* won't #include it, though...
     
They should be semantically identical, so what do you care whether it's
optimized by default?
     
I wonder if perhaps <stdio.h> (and <builtins.h>) should be included by
default, with an explicit "#exclude" to disable.  (Cf. "#undef".)  Probably
tricky to implement -- don't do the automatic "#include" until checking for
"#exclude", which must be at the top of the file (after whitespace)?
     
I had much the same attitude when I learned of the (then) new features that
allowed structure copy/call-by-value/return-by-value.  I wasn't using them
(of course, since they were new), and I wanted to see an error if I used one
by mistake (forgotten "&").  I was hoping for a compatibility option of some
type, like EO in TECO-10.  (A nice feature that allowed TECO to simulate an
older version of itself, so as not to obsolete all old macros.)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8403
          for JMS@ARIZMIS; Mon, 19-MAY-1986 15:46 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 17:20:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003312; 19 May 86 17:51 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a022042; 19 May 86 17:42 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA03421; Mon, 19 May 86 16:52:48 edt
Date: Mon, 19 May 86 16:52:48 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605192052.AA03421@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, rayssd!gmp@seismo.ARPA
Subject: Re: Re: questions from using lint
     
    > You people fail to realize that some of us out here don't like lint.
    > It complains too much about what I do. I refuse to go any further
    > than generating no compiler warnings. I know what I'm doing. When I
    > goof, I'll fix it myself. I refuse to add extra casts to keep lint
    > happy.
    >
    > Before you start flaming my style, let me say I am quite good.
    > I am also quite philosophical and attentive to coding style.
    > My outlook is just different. I program for myself. If it is applicable
    > to you, fine. I have my own criteria which I rarely see embraced by
    > others waving standardization flags.
    >
    > Most of the code I have written was intrinsically non-portable. I *do*
    > appreciate portability as a spectrum concept, but not as a binary one.
    >
    > This is just me. I'm not sure I would recommend my methods to anyone
    > else, especially novices. My experience was obtained with more than a
    > few battle scars. There are probably easier ways.
    >
    >     (Root Boy) Jim Cottrell        <rbj@cmr>
    >     "I'm alright, Jack, keep your hands off of my stack"
     
    Sorry I enclosed so much of the original article above, but I found it
    so surprisingly bizzare, I just couldn't leave any of it out.  I have
    two things to say about it: 1) I'm glad that Mr. Cottrell doesn't work
    here; 2) I'd never recommend him being hired as a programmer, anywhere.
    --
    ++------------------------------------------------------------------++
    ||  Greg Paris    {allegra,linus,raybed2,ccice5,brunix}!rayssd!gmp  ||
    ++------------------------------------------------------------------++
     
Where's the rest of me? I sent out a flame with this, but it must have
disappeared. Oh well, here it is:
     
For all of you who have ROT13 software, you will know what to do with this:
     
            Tb Shpx Lbhefrys!
     
And for those of you who don't like my spelling, at least it's deliberate.
This cretin doesn't even know how to spell `bizarre'.
     
Buddy, I forgot more than you'll ever know.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8786
          for JMS@ARIZMIS; Mon, 19-MAY-1986 16:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/19/86 at 18:18:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003749; 19 May 86 19:07 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a022422; 19 May 86 18:28 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA03595; Mon, 19 May 86 18:27:32 edt
Date: Mon, 19 May 86 18:27:32 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605192227.AA03595@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Args in Regs
     
>I don't want to quote too much of the original article -- it was rather long.
>The thrust of it was that passing parameters in registers doesn't make things
>run faster.  This does not fit with my experience.  When we implemented
>parameter passing in registers at Zilog, it was a big win.
     
*WAS* a big win - meaning maybe it looked good on benchmarks...
     
[...]
>I will admit that this parameter passing caused difficulties.  In particular,
>varargs code was messy, and debuggers more difficult to implement.  Was it
>worth it?  I believe so.  Our emphasis was on speed, and that we had.
     
1) pdp-11 style varargs was broken - no way from C to get a those arguments
   that got crammed into registers.
     
    The key phrase here is `pdp-11 style'. No way from C? Just use
    the variable names! The compiler knows about them.
     
2) Because of the register assignment scheme used, you couldn't even blindly
   pass a list of variable arguments to a routine like printf that did know
   how to deal with them.
     
    Why not? And who says varargs has to be written in C? It just may
       have to be written in assembly some day.
     
3) setjmp/longjmp got broken with respect to restoring register variable
   parameters somewhere along the way.
     
    Probably difficult, but not impossible. Pyramids seem to work.
     
In the long run, portability seems to have become the more important issue:
     
Just try porting some of the code in mod.sources and net.sources to the
machine and see how far you can get without having to go into the editor
and start whacking at source code.  Assume that software developers will
have the same problems porting their wares...
     
    Agreed. No one said it would be easy. But then, if it wasn't
    just a little bit hard, they'd hire your kid sister instead of you.
     
Also, note that Zilog has never delivered its ATT SVID blessed System V port,
and that their next series of machines will contain ATT chips running vanilla
3Bx software...
     
    Zilog of course has other problems as well.
     
George Robbins - now working with,    uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing    arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department    fone: 215-431-9255 (only by moonlite)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3461
          for JMS@ARIZMIS; Tue, 20-MAY-1986 07:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/20/86 at 09:11:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010966; 20 May 86 10:00 EDT
Received: from csnet-relay.arpa by SMOKE.BRL.ARPA id a002064; 20 May 86 9:24 EDT
Received: from ti-eg by csnet-relay.csnet id a009141; 20 May 86 9:23 EDT
Date:     Tue, 20 May 86 06:26 ???
From:     HARGED%ti-eg.csnet@CSNET-RELAY.ARPA
To:       info-c%brl-smoke.arpa@CSNET-RELAY.ARPA
Subject:  abuse from the net
     
Root Boy Jim
     
     
        Non carborundum illegitami !
     
      (Don't let the bastards wear you down !)
     
     
Joe Richard Hargrove
harged%ti-eg@csnet-relay.arpa

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4591
          for JMS@ARIZMIS; Tue, 20-MAY-1986 09:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/20/86 at 11:19:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014536; 20 May 86 12:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000350; 20 May 86 11:44 EDT
From: "Wayne A. Christopher" <faustus%cad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: LINT
Message-ID: <323@cad.UUCP>
Date: 13 May 86 20:05:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2452@watmath.UUCP>, rbutterworth@watmath.UUCP (Ray Butterworth)
 writes:
> I too used to think that most of what lint complained about was crap.
> I also noticed an awful lot of things that it didn't complain about but
> should have.  So I took the source and turned on all the options that
> normally make it shut up about certain things, and then added even more
> checks than lint ever had before.  Then I looked at all the crap in the
> output and gradually taught lint which one's really were crap and
> shouldn't be issued.  Now I have a version of lint with which I use
> four fifths of what it complains about.
     
Sounds great.  Can we have it?  (Post diffs to net.sources, maybe?)
     
    Wayne

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4547
          for JMS@ARIZMIS; Tue, 20-MAY-1986 09:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/20/86 at 11:19:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014554; 20 May 86 12:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000410; 20 May 86 11:46 EDT
From: "Jonathan P. Leech" <jon@cit-vax.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <479@cit-vax.Caltech.Edu>
Date: 14 May 86 09:00:45 GMT
Expires:
Sender:
Followup-To:
To:       info-c@BRL-SMOKE.ARPA
     
Organization : California Institute of Technology
Keywords:
     
In article <815@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>
>This is what I started to mention once before, and picked up a lot of "no,
>you don't understand how it works" messages (sigh).  I saw the need for a
>"ALIGN *" datatype, and was hoping "void *" would be it.  (Nope, just a
>useless synonym for "char *").  The idea would be that, just as it's always
>legal to cast any pointer into a "char *", it would be legal to cast *from*
>"ALIGN *" to any pointer.  Then lint would shut up about malloc()!
>
     
    I don't think 'void *' is useless. What do you  do    on  a  machine
where it's NOT 'always legal to cast any pointer into a "char *"'?   I
find 'void *' most wonderful and useful in C++.
--
    Jon Leech (jon@csvax.caltech.edu || ...seismo!cit-vax!jon)
    Caltech Computer Science Graphics Group
    __@/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5084
          for JMS@ARIZMIS; Tue, 20-MAY-1986 10:23 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/20/86 at 12:07:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015518; 20 May 86 12:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001529; 20 May 86 12:14 EDT
From: "Gary M. Samuelson" <garys%bunkerb.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <640@bunkerb.UUCP>
Date: 13 May 86 17:35:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <797@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
     
>[2] close(), as near as I can tell, can only fail by being handed a number
>    that does not denote an open file.  I usually assume that this error
>    would have been caught earlier.
     
Assuming a buffered device, the last block of data will not be physically
written until close(), in which case nearly all of the errors possible with
write() could occur with close().
     
>[3] unlink() and most other system calls should be checked!  (It's too bad
>    lint can't tell whether you've tested the return value of open(), etc.)
     
??? Lint certainly can check for that (at least the lint I use); it says
something like "open returns value which is sometimes ignored" (or
"always", as the case may be).  It does this by checking the definition
of open() in /usr/lib/lint
     
>"lint returns an error which is always ignored" :-)
     
This is going to my collection of classic quotes.
     
From Jim Cotrl (yes, I know the spelling is wrong, but after all,
think of all the keystrokes I saved):
>>And as someone pointed out, assignments return a value too, so should we
>>cast them to void as well?  Oh yeah, assignment is `different'.
     
If I say "a = b", I have clearly used the value of the expression.
     
Gary Samuelson

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5038
          for JMS@ARIZMIS; Tue, 20-MAY-1986 10:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/20/86 at 12:01:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015462; 20 May 86 12:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001440; 20 May 86 12:11 EDT
From: Kenneth Almquist <ka%hropus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <456@hropus.UUCP>
Date: 13 May 86 19:44:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Yet another convention, not endorsed by any language I know, is to dispense
> with the braces and let the indentation alone tell the compiler how to
> interpret the program.  (I came up with this idea after an argument on the
> "correct" place to put the braces.)
     
I first encountered this idea about 8 years ago, when Dave Korn used it
in a specialized language for data checking, and it is a good one.
     
Using braces to indicated the structure of a program results in code that
is quite difficult to read.  (Try removing all indentation from any C
program you choose and see how readable the result is.)  Of course
sensible programmers use indentation to indicate the structure of the
program to the reader.  So from the reader's point of view braces are
just useless clutter.  Thus the C language forces the programmer to use
two separate methods of indicating the structure of the program, one for
the benefit of the reader and the other for the benefit of the compiler.
Given that the compilers can fairly easily be written to understand
about indentation, there is no justification for requiring programmers
to translate the indentation information into brace form by hand, with
the attendent risk of errors.
     
Furthermore, Jim has correctly pointed out that the braces actually
obscure the code for the human reader, since they add clutter without
providing any new information about the program.  In fairness, C is
better than most languages in this respect since it reduces begin and
end to single characters.  This is good enough that I do not agree with
the extremes to which Jim goes to avoid braces.  But C doesn't take the
idea to its logical conclusion, which is to eliminate the delimiters
entirely.
     
Fortunately, grouping by indentation has finally been adopted by at least
on language.  See the article on "Modcap" in the March issue of Sigplan
Notices.
                Kenneth Almquist
                ihnp4!houxm!hropus!ka    (official name)
                ihnp4!opus!ka        (shorter path)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1049
          for JMS@ARIZMIS; Wed, 21-MAY-1986 00:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015856; 20 May 86 12:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002120; 20 May 86 12:29 EDT
From: Jim Reid <jim%cs.strath.ac.uk@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <131@stracs.cs.strath.ac.uk>
Date: 14 May 86 11:48:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <989@dataioDataio.UUCP> bjorn@dataio.UUCP writes:
>    The state-of-the-art in compilers has progressed on PCs,
>    so why hasn't anyone come up with a better compiler for
>    UNIX, or have I just not heard of it?
>
>For your information I'm running UNIX 4.2bsd with the standard C
>compiler on a VAX 11/750, and Datalight C 2.04 on an IBM PC/AT under
>MSDOS 3.0.  The PC takes 5 minutes 26 seconds to compile 7605 lines of
>code in 29 files (plus 735 lines of header in 13 files), whereas the unloaded
>VAX (load average 1.13) takes 8 minutes 30 seconds.  All the outside
>influences were indentical: debugging, optimization, etc.
     
Whoopee! I'm glad someone has proved that an AT - floppy disks and all? -
is faster than a VAX. Maybe now I can convince folk it's a good idea to
scrap our VAX for an AT!!! :-) :-) :-) :-) :-)
     
Comparisons like that are *totally meaningless* - What about the quality of
the generated code? What "optimisations" do the compilers perform? Do both
produce much the same symbolic information for debugging? What's involved in
linking object modules in the two progams? How many passes over the source
code/expanded code/"parse trees" does each compiler do? The 4BSD compiler has
at least 5 - 6 if you count linking. First there's the preprocessor, then
the compiler proper has probably two passes, the assembler has another two
for good measure (depending on how you look at the assembler). Then there's
your configuration - how much memory does each system have? How much core
does each compiler use/need? How much paging or swapping goes on during
compilation? How much disk traffic - intermediate files etc - is done?
     
Granted, your AT compiler might have faster algorithms for symbol table lookup
and the like, but the only conclusion that can be drawn from the numbers you
gave is that for the conditions you describe, your AT C compiler is faster.
It doesn't follow that both compilers or CPUs are doing the same amount of
work, so making comparisons or drawing conclusions are pointless.
     
        Jim

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0941
          for JMS@ARIZMIS; Wed, 21-MAY-1986 00:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/21/86 at 01:20:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015604; 20 May 86 12:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001541; 20 May 86 12:15 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#8
Message-ID: <1041@hou2d.UUCP>
Date: 13 May 86 13:06:56 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Tue, 13 May 86       Volume 16 : Issue   8
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 7
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 7
To: cbosgd!std-c%utcsri
     
# C.4 CONSTANT EXPRESSIONS
     
       An expression that evaluates to a constant is required in several
  *    contexts ...  More latitude is permitted for initializers {of ob-
       jects that have static storage duration -->}.
     
     
     
# C.5 DECLARATIONS
     
<--O   As discussed later, a declaration without  a  declarator  may  be
<--O   used to declare a structure, union, or enumeration tag.  Any oth-
<--O   er kind of declaration without a declarator  is  also  permitted,
<--O   though without effect.
     
N-->   A declaration shall declare at least a declarator, a tag, or  the
N-->   members of an enumeration.
     
     
     
# C.5.1 Storage-class specifiers
     
       A declaration with storage-class specifier extern indicates  that
  *    {-->,  if  the  identifier declared is in fact referred to, then}
       somewhere in the set of source files that constitutes the  entire
  *    program  there  exists an "external {data --> object} definition"
  *    for the given identifier (a definition with file scope).  {--> If
       the  declaration  with storage-class specifier extern occurs out-
       side a function, the identifier is declared with file  scope  and
       external  linkage,  and  may itself serve as the required defini-
       tion, as discussed later.}
     
     
     
# C.5.1 Storage-class specifiers
     
<--O   Invalid or excess register declarations are treated as  auto  de-
<--O   clarations.
     
N-->   The implementation may treat any register declaration  simply  as
N-->   an auto declaration.
     
     
     
# C.5.2.1 Structure and union specifiers
     
N-->   The presence of a struct-declaration-list in  a  struct-or-union-
N-->   specifier declares a new type.
     
     
     
# C.5.2.1 Structure and union specifiers
     
       In addition, a member may be declared to consist of  a  specified
  *    number  of  bits  {-->  (including  a sign bit, if any)}.  Such a
       member is called a "bit-field" ...
     
  *    ...  {--> An implementation may allocate any addressable  storage
       unit  large enough to hold a bit-field.} If enough space remains,
  *    a bit-field that follows another  bit-field  {is  -->  shall  be}
  *    packed into adjacent bits of the same {int --> unit}.  {An imple-
       mentation may refuse to permit a bit-field  to  straddle  an  int
       boundary,  in  which  case a bit-field that does not fit into the
       space remaining in an int is put into the next int. --> If insuf-
       ficient  space  remains, whether a bit-field that does not fit is
       put into the next unit is implementation-defined.} The  order  of
  *    allocation  of  bit-fields within {an int --> a unit} (high-order
       to low-order  or  low-order  to  high-order)  is  implementation-
       defined.
     
     
     
# C.5.2.1 Structure and union specifiers
     
N-->   A pointer to a structure object, suitably cast, points to its in-
N-->   itial  member  or,  if it is a bit-field, to the unit in which it
N-->   resides.
     
N-->   ...  A pointer to a union object, suitably cast, points  to  each
N-->   of  its  members  or,  if a member is a bit-field, to the unit in
N-->   which it resides.
     
     
     
# C.5.2.1 Structure and union specifiers
     
N-->   There may therefore be unnamed holes within a structure, but  not
N-->   at its beginning {-->, nor more than necessary to achieve the ap-
N-->   propriate alignment}.
     
     
     
# C.5.2.3 Enumeration specifiers
     
  *    The scope of an enumeration constant {is the same as that of  -->
       begins  after  its  declaration  and  ends with the scope of} the
       enumeration of which it is a member.
     
     
     
# C.5.2.3 Enumeration specifiers
     
  *    {--> An object that has an enumeration type behaves like  an  int
       in  an  expression.} The implementation may use the set of values
       in the enumeration to determine whether  to  make  the  effective
  *    type  of an enum object a shorter {signed -->} integral type that
       will promote to int ...
     
     
     
# C.5.3 Declarators
     
Remark: Again, the notation [opt] below  represents  a  subscript
opt,  which  means optional.  The [] characters not part of [opt]
are real [] characters.  The {} characters are the usual  differ-
ence notation of this article.
     
       declarator:
                   pointer[opt] declarator2
     
       declarator2:
                   identifier
                   ( declarator )
                   declarator2 [ constant-expression[opt] ]
  *                declarator2 ( parameter-type-list {[opt] -->} )
  *                declarator2 ( {parameter-identifier-list[opt]
                               --> identifier-list[opt]} )
     
<--O   ... parameter-identifier-list:
<--O               identifier-list
<--O               identifier-list , ...
     
     
     
# C.5.3 Declarators
     
  *    The implementation shall allow at least {six --> 12} pointer, ar-
       ray,  and  function declarators (in any combinations) modifying a
       basic type, either directly or via typedefs.
     
     
     
# C.5.3.3 Function declarators {--> (including prototypes)}
     
<--O   A parameter identifier list declares only the identifiers of  the
<--O   formal  parameters of the function, and may be present in the de-
<--O   clarator only in a function declaration (#C.7.1).  If the list is
<--O   empty, the function has no parameters.
     
N-->   An identifier list declares only the identifiers  of  the  formal
N-->   parameters  of  the function.  If the list is empty in a function
N-->   declaration that is not part of a function definition, no  infor-
N-->   mation  about  the number or types of the parameters is supplied.
N-->   If the list is empty in a function declaration that is part of  a
N-->   function definition, the function has no parameters.
     
     
     
# C.5.4 Type names
     
N-->   Empty parentheses in a type name  are  interpreted  as  "function
N-->   with  no  parameter  type  information",  rather  than  redundant
N-->   parentheses around the omitted identifier.
     
     
     
# C.5.5 Type definitions and type equivalence
     
<--O   In the program fragment
     
<--O               typedef float length;
<--O               /*...*/
<--O               {
<--O                       static int length;
<--O                       /*...*/
     
<--O   if the int type specifier were omitted from the  second  declara-
<--O   tion,  it  would be taken to be a (semantically vacuous) declara-
<--O   tion with type length and no declarators.
     
------------------------------
     
End of mod.std.c Digest - Tue, 13 May 86 09:05:58 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1180
          for JMS@ARIZMIS; Wed, 21-MAY-1986 00:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016007; 20 May 86 13:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002186; 20 May 86 12:31 EDT
From: mnl <mnl%cernvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C (really swap with XOR)
Message-ID: <314@cernvax.UUCP>
Date: 16 May 86 02:11:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2741@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>In article <602@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>
>>3) Exchange operator. This has probably been discussed before, so pardon
>>    me if I blunder into that pit. BUT, DMR has stated that one of
>>    the reasons that exponentiation was left out was because no
>>    (or few, if any) machine could do it inline, and therefore
>>    all the compiler would be doing is a function call anyway.
>>    By the same reasoning, exchange CAN be done efficiently by
>>    some machines, and the hack of a temporary variable and
>>    three assignments is a rather stale idiom. The three
>>    statement XOR trick avoids the temporary, at the expense
>>    of execution time and clarity.
>>
>Good stuff. Even machines without an EXG can use a scratch register, which
>is better than using a user-supplied temp.
>What, by the way, is the XOR trick?
>
To swap the contents of A and B (no particular language):
     
A = A XOR B
B = A XOR B
A = A XOR B
     
On some machines, assuming A and B are in registers, this won't take
any more time than the normal three assignments using a temporary.
--
Mark Nelson
     
mnl@cernvax.bitnet or ...!seismo!mcvax!cernvax!mnl
If the ACM had a sub-group for naturalists, would it be ACM
SIGnature?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1457
          for JMS@ARIZMIS; Wed, 21-MAY-1986 00:42 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017256; 20 May 86 13:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003749; 20 May 86 13:04 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#10
Message-ID: <1043@hou2d.UUCP>
Date: 13 May 86 13:10:39 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Tue, 13 May 86       Volume 16 : Issue  10
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 9
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 9
To: cbosgd!std-c%utcsri
     
# {C.8.3 --> C.8.1} Conditional inclusion
     
       Preprocessing directives of the forms
     
                   # if       constant-expression new-line group[opt]
  *           {--> # elif     constant-expression new-line group[opt]}
     
       check whether the controlling constant  expression  evaluates  to
       non-zero.
     
     
     
# {C.8.3 --> C.8.1} Conditional inclusion
     
       Each directive's condition is checked in order.  If it  evaluates
  *    to false (0), the {program text that follows it --> group that it
  *    controls} is skipped ...  The first {section of program text  -->
       group}  whose  control  condition evaluates to true (non-zero) is
       processed.  If none of the  conditions  evaluates  to  true,  and
  *    there  is  a #else directive, the {program text between the #else
       and the #endif --> group controlled by the #else}  is  processed;
  *    lacking  a  #else  directive,  all  the {program text through -->
       groups until} the #endif are skipped.
     
     
     
# {C.8.1 --> C.8.2} Source file inclusion
     
N-->   The character sequence in the form of preprocessing directive
     
N-->               # include    <x-char-sequence> new-line
     
N-->   shall not include a > character.  The character sequence  in  the
N-->   form of preprocessing directive
     
N-->               # include    "x-char-sequence" new-line
     
N-->   shall not include a " character.
     
     
     
# {C.8.1 --> C.8.2} Source file inclusion
     
       The named source file is searched for  in  association  with  the
  *    {-->  original}  source  file  {containing the #include directive
  *    -->}.  {This implementation-defined capability presumes that oth-
       er  named  source  files  may  be associated in some way with the
       source file containing the text being read, typically by means of
       a file system with named files organized into "directories". -->}
  *    If this {--> implementation-defined} capability is not  supported
       ...
     
     
     
# {C.8.1 --> C.8.2} Source file inclusion
     
  *    Failure in processing a  #include  directive  is  {an  error  -->
       equivalent to a violation of a syntax rule}.
     
     
     
# {C.8.2 --> C.8.3} Macro replacement
     
  *    The arguments in the invocation are {-->  (possibly  empty)}  se-
       quences of tokens separated by comma tokens ...
     
     
     
# {C.8.2 --> C.8.3} Macro replacement
     
       Each occurrence in the definition of a formal  parameter  is  re-
  *    placed  by  the  corresponding argument from the invocation {-->,
       with all macros replaced in each argument}.
     
     
     
# {C.8.2 --> C.8.3} Macro replacement
     
       If a formal parameter in the definition follows a #  token,  both
       are  replaced  by the corresponding argument from the invocation,
       preceded and followed by a double-quote  character  to  create  a
  *    string  literal.  {--> Whether} white space between tokens in the
  *    argument {may be --> is retained in the string or} replaced by  a
  *    single  space  character  {--> is implementation-defined}.  White
       space preceding the first token or following the  last  token  is
  *    deleted.   {-->  A  backslash  character  is inserted before each
       double-quote character in the argument.}
     
     
     
# {C.8.2 --> C.8.3} Macro replacement
     
  *    A macro definition lasts ...  {--> until a  corresponding  #undef
       directive  is  encountered or (if none is encountered)} until the
       end of the source file ...
     
     
     
# {C.8.2 --> C.8.3} Macro replacement
     
       The replacement token sequence is reexamined for more macro names
  *    {-->, which are themselves replaced and rescanned}.
     
     
     
# {C.8.2 --> C.8.3} Macro replacement
     
       After all replacements have taken place, each instance in the de-
  *    finition  of a ## {token --> operator} is deleted, and the tokens
  *    preceding and following it are concatenated.  {--> If the  result
       is not a valid token, the behavior is undefined.}
     
     
     
# C.8.4 Line control
     
<--O   The predefined macro name __LINE__ has  the  value  of  the  line
<--O   number  of  the  current  source  line (a decimal constant).  The
<--O   predefined macro name __FILE__ has the value of the presumed name
<--O   of the source file (a string literal).
     
     
     
# {--> C.8.7 Predefined macro names}
     
N-->   The following macro names shall be defined by the  implementation
N-->   prior to the beginning of translation:
     
N-->   __LINE__    The line number of the current source line (a decimal
N-->               constant).
     
N-->   __FILE__    The presumed  name  of  the  source  file  (a  string
N-->               literal).
     
N-->   __DATE__    The date of translation  of  the  source  file  as  a
N-->               string  literal  of the form "Mmm dd yyyy", where the
N-->               names of the months are the same as  those  generated
N-->               by the asctime function.
     
N-->   __TIME__    The time of translation  of  the  source  file  as  a
N-->               string literal of the form "hh:mm:ss".
     
N-->   No other macro names shall be predefined.
     
N-->   Forward references: the asctime function (#D.12.3.1).
     
     
     
# {--> C.9 FUTURE DIRECTIONS}
     
     
     
# {--> C.9.1 Character escape sequences}
     
N-->   Lower-case letters as escape sequences are  reserved  for  future
N-->   standardization.  Other characters may be used in extensions.
     
     
     
# {--> C.9.2 Function declarations}
     
N-->   The use of function  declarations  with  empty  parentheses  (not
N-->   prototype-format parameter-type declarations) is deprecated.
     
     
     
# {--> C.9.3 Function definitions}
     
N-->   The use of function definitions with separate parameter  identif-
N-->   ier  and  declaration  lists (not prototype-format parameter type
N-->   and identifier declarations) is deprecated.
     
------------------------------
     
End of mod.std.c Digest - Tue, 13 May 86 09:09:55 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1573
          for JMS@ARIZMIS; Wed, 21-MAY-1986 00:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017748; 20 May 86 13:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004161; 20 May 86 13:11 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <3674@sun.uucp>
Date: 14 May 86 19:36:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I saw the need for a "ALIGN *" datatype, and was hoping "void *" would
> be it.  (Nope, just a useless synonym for "char *").  The idea would
> be that, just as it's always legal to cast any pointer into a "char *",
> it would be legal to cast *from* "ALIGN *" to any pointer.  Then lint
> would shut up about malloc()!
     
No, you just don't understand how it works.  From the August 11, 1985 C
standard draft:
     
    C.2.2.3 Pointers
     
       A pointer to "void" may be converted to a pointer to an
    object of any type.  A pointer to an object of any type may be
    converted to a pointer to "void" or to a pointer to an object
    of less strict alignment and back again without change.
     
Nowhere is it implied that "void *" is a synonym for "char *".  "lint"
should not give any complaints about conversions between pointers of other
types and pointers to "void" (this isn't stated in the C draft, but then
again it's not a description of "lint", it's a language standard).  As such,
it is not a synonym for "char *", since "lint" should (and does) complain
about conversions between "char *" and other pointers.  As the C draft
clearly states, it is legal to cast *from* "void *" to any pointer; as such,
if "malloc" is declared to return "void *", "lint" will shut up about it.
     
No, the language does not *guarantee* that a "void *" is properly aligned,
but there's no way for it to do so anyway.  Big deal.  The language couldn't
*guarantee* that an "ALIGN *" is properly aligned either - if you wrote
"malloc" in C (as all UNIX implementations I know of are written), you would
just have to trust that the implementation delivers a maximally-aligned
pointer.  As such, "ALIGN *" is just a useless synonym for "void *".
     
> Also, having malloc() return a real "ALIGN *" would be convenient for word-
> addressible machines where "char *" requires extra bits.
     
Maybe, but I'm not sure the added convenience of having "malloc" be able to
return a value of a type requiring fewer bits is sufficient to justify
adding another type to the language.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.arpa

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1355
          for JMS@ARIZMIS; Wed, 21-MAY-1986 00:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/21/86 at 01:58:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa16648; 20 May 86 13:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003743; 20 May 86 13:04 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#9
Message-ID: <1042@hou2d.UUCP>
Date: 13 May 86 13:09:47 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Tue, 13 May 86       Volume 16 : Issue   9
     
Today's Topics:
 Differences from April 1985 to February 1986 Draft Standard, Part 8
----------------------------------------------------------------------
     
Date: Sun, 27 Apr 86 01:17:06 est
From: <ihnp4!utcsri!lsuc!msb%utcsri>
Subject: Differences from April 1985 to February 1986 Draft Standard, Part 8
To: cbosgd!std-c%utcsri
     
# C.5.6 Initialization
     
<--O   A declarator may include an initializer that specifies an initial
<--O   value for the object whose identifier is being declared.
     
<--O   ...  Any object may be initialized.
     
N-->   Any declaration that defines an object may include an initializer
N-->   that specifies its initial value.
     
     
     
# C.5.6 Initialization
     
N-->   Initializers that are neither flat  (no  interior  brackets)  nor
N-->   fully  bracketed are ambiguous.  ***> The draft shall specify the
N-->   correct category for this situation. <***
     
Remark: In other words, they haven't decided.
     
     
     
# C.6 STATEMENTS
     
<--O   Completion of the execution of a statement is a sequence point.
     
<--O   Forward references: compound statement, or block (#C.6.2),  func-
<--O   tion definitions (#C.7.1).
     
N-->   A "full expression" is an expression that is not part of  another
N-->   expression.   Each of the following is a full expression: an ini-
N-->   tializer of an object that has automatic  storage  duration;  the
N-->   expression in an expression statement; the controlling expression
N-->   of a selection statement (if or switch); the controlling  expres-
N-->   sion  of  an iteration statement (while, do, or for).  Completion
N-->   of the evaluation of a full expression is a sequence point.
     
N-->   Forward references:  expression  and  null  statements  (#C.6.3),
N-->   selection statements (#C.6.4), iteration statements (#C.6.5).
     
     
     
# C.6.2 Compound statement, or block
     
  *    An object declared extern {--> inside a block} shall not be  ini-
  *    tialized  in the declaration, as storage for it is {allocated -->
       defined} elsewhere.
     
     
     
# C.6.4.1 The if statement
     
  *    If the first substatement is reached via a {named -->} label, the
       second substatement is not executed.
     
     
     
# C.6.4.2 The switch statement
     
<--O   The implementation must allow at  least  255  case  values  in  a
<--O   switch statement.
     
N-->   As discussed previously (#B.2.4), the  implementation  may  limit
N-->   the number of case values in a switch statement.
     
     
     
# C.6.6.3 The break statement
     
N-->   A break statement may appear only in a switch body or loop body.
     
     
     
# C.6.6.4 The return statement
     
N-->   A return statement with an expression may not appear in  a  func-
N-->   tion declared as returning type void.
     
     
     
# C.6.6.4 The return statement
     
       Reaching the } that terminates a function is equivalent  to  exe-
  *    cuting  a return {with no returned value --> statement without an
       expression}.
     
     
     
# C.7.1 Function definitions
     
<--O   The following constraints apply only to  a  parameter  identifier
<--O   list.  Only the identifiers in the parameter list may be declared
<--O   in the declaration list.  An identifier  declared  as  a  typedef
<--O   name must not be redeclared as a formal parameter.
     
N-->   Even if the type specifier is a typedef name  that  declares  the
N-->   function  as having no parameters, the parentheses that bound the
N-->   (empty) parameter identifier list may not be omitted from the de-
N-->   clarator.
     
N-->   The only storage-class specifier allowed in the declaration of  a
N-->   formal parameter is register.
     
N-->   If the declarator is a function prototype declarator, no declara-
N-->   tion  list  may follow.  If the declarator is an identifier list,
N-->   only the identifiers it names may be declared in the  declaration
N-->   list; an identifier declared as a typedef name shall not be rede-
N-->   clared as a formal parameter.
     
     
     
# C.7.1 Function definitions
     
       If a function prototype is in scope when the function is  defined
  *    {,  -->  but} a semantically equivalent prototype {must be --> is
  *    not} in  scope  everywhere  the  function  is  called  {-->,  the
  *    behavior  is undefined}.  {--> If a function that accepts a vari-
       able number of arguments is defined without the ellipsis notation
       in its prototype, the behavior is undefined.}
     
       If no function prototype is in scope when  the  function  is  de-
  *    fined, the {following -->} default {--> argument} conversions are
  *    {--> assumed to have been} applied {--> to each call}.  ...
     
     
     
# C.8 PREPROCESSING DIRECTIVES
     
Remark: The subsections C.8.1 through C.8.3 have been  reordered,
and  all the syntax rules have been collected at the beginning of
section C.8.
     
     
     
# C.8 PREPROCESSING DIRECTIVES
     
Remark: Again, the notation [opt] below  represents  a  subscript
opt, which means optional.
     
N-->   preprocessing-file:
N-->               group
N-->               preprocessing-file group
     
N-->   group:
N-->               group-part
N-->               group group-part
     
N-->   group-part:
N-->               tokens[opt] new-line
N-->               if-section
N-->               control-line
     
  *    {token-sequence --> tokens}:
                   token
  *                {token-sequence --> tokens} token
     
N-->   if-section:
N-->               if-group elif-groups[opt] else-group[opt] endif-line
     
N-->   if-group:
N-->               # if         constant-expression new-line group[opt]
N-->               # ifdef      identifier new-line group[opt]
N-->               # ifndef     identifier new-line group[opt]
     
N-->   elif-groups:
N-->               elif-group
N-->               elif-groups elif-group
     
N-->   elif-group:
N-->               # elif       constant-expression new-line group[opt]
     
N-->   else-group:
N-->               # else       new-line group[opt]
     
N-->   endif-line:
N-->               # endif      new-line
     
  *    {--> control-line:}
  *                # include    {<s-char-sequence> -->
                                     <x-char-sequence>} new-line
  *                # include    {"s-char-sequence" -->
                                     "x-char-sequence"} new-line
                   # include    identifier new-line
  *                # define     identifier {token-sequence -->
                                     tokens}[opt] new-line
                   # define     identifier lparen identifier-list[opt]
  *                                  {token-sequence --> tokens}[opt]
                                     ) new-line
                   # undef      identifier new-line
                   # line       digit-sequence string-literal[opt]
                                     new-line
                   # pragma     x-char-sequence new-line
                   #            new-line
     
Remark: In the above syntax for "control-line", each entry begin-
ning  with # is supposed to be written on one line.  The multiple
lines in this document represent continuations rather than alter-
natives.
     
       x-char-sequence:
                   x-char
                   x-char-sequence x-char
     
       x-char:
                   any character in the source character set except
                                     the new-line character
     
Remark: An "s-char-sequence", which was used in the old  version,
is  defined  in #C.1.4; it is whatever can be between the double-
quotes of a string literal.
     
N-->   lparen:
N-->               the left-parenthesis character without preceding
N-->                                 white-space
     
       new-line:
                   the new-line character
     
<--O   A preprocessing directive may appear anywhere.  It is  terminated
<--O   by  the  next  new-line  character, which is not considered to be
<--O   part of the directive.
     
<--O   There may be any number of space  and  horizontal-tab  characters
<--O   between  the # token and the identifier that constitutes the next
<--O   token, and before the  new-line  character  that  terminates  the
<--O   directive.
     
N-->   In this phase of processing,  tokens  may  be  separated  by  any
N-->   number of space and horizontal-tab characters.
     
------------------------------
     
End of mod.std.c Digest - Tue, 13 May 86 09:09:25 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1679
          for JMS@ARIZMIS; Wed, 21-MAY-1986 01:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018547; 20 May 86 14:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006021; 20 May 86 13:55 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: More extensions to C (was: Boolean Operators Slighted in C)
Message-ID: <826@bentley.UUCP>
Date: 16 May 86 03:15:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2741@utcsri.UUCP> greg@utcsri.UUCP writes:
>In article <602@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>>3) Exchange operator. ...
>
>Good stuff. Even machines without an EXG can use a scratch register, which
>is better than using a user-supplied temp.
     
This could be considered a special case of my ",," operator: to exchange x
and y, write "x = (y ,, (y = x))".
     
>What, by the way, is the XOR trick?
     
"x ^= y; y ^= x; x ^= y;".  Not useful for floats or structs.
     
>>5) Allow immediate constants. [Generalization of quoted strings.]
>>... Why not int *p = &5 ...
     
Does "&5" point to a character, short, int, unsigned, or long constant?
(No fair using the left side of the assignment to disambiguate!)
     
>I would also like to suggest struct constants/rvalues. Suppose I have
>    struct foo{ int f1; char f2; char *bar; } foo_var;
>I'd like to write something like this ( an executable statement ):
>    foo_var = struct foo{ .bar = "Ergo Sum"; .f1 = 73; .f2 = '?'; };
>
>This allows the use of unnamed (structure constants).  ...  I think it is
>important that the member names be used instead of the order.
     
Yes, because then you could use unions too.  In fact, a similar notation
would allow the compile-time initialization of a union, something I've
wanted for some time.  (I hear ANSI wants to use the first member of the
union for initializations.  Sorry folks, I want to initialize an array[2] of
union {int;char*} to { {12}, {"foo"} }.)
     
>Also, it would be nice if the compiler were smart in cases like
>    xchar = struct foo{ .bar="??"; .f2 = ychar+1; .f1 = func(i); }.f2;
>not to generate all the code to compute f1 and bar ( Holy side-effects,
>Batman! ). The above line could arise by a macro expansion.
     
Umm... I think it's better if the compiler does include the call to func().
The constant assignment to ".bar" can be optimized out, of course, and the
structure itself need not exist.  (xchar = (void)func(i),ychar+1)
     
>>6) Eliminate arrays altogether!
     
You want to take them *out* of the language?  I say let's put them *in*!
As it stands, arrays are half-implemented.
     
>>And it wouldn't matter whether a variable was defined differently than it
>>was declared (char x[] or char *x).
     
I don't get it.  If "char *x" is valid for all array/pointer variables,
where does the memory come from, malloc()?
     
>>8) Allow formal arguments to be declared AFTER the opening brace.
>>    This would allow prioritization of register variables.
>>
>Well, register arguments need to copied from the stack anyway, so
>you can declare your own with an explicit copy. But it wouldn't
>hurt to let the compiler do it. Since it silly ( presently ) to
>say `foo(p){ register char *p;...' this could be taken as an argument
>declaration.
>
>I have a related suggestion.
>
>Suppose I have the following:
>
>f(){
>    ...
>    { int x,y;    ...    }
>    { double xy;    ...    }
>}
>I would expect x and y to share the same stack space with xy.
>Now look at this ( assume 4 regs available ):
>
>f(){    register i,j,k,l,m;        /* more vars than regs available */
>    { register ii ..... };
>}
>I think the inner loop should push 'l' ( the lowest priority reg var ) on
>the stack and keep 'ii' in that reg, since ii will probably get more use
>in the inner block. The register priority would become ii/i/j/k, so if
>a further nested block said 'register a,b', the next regs to be kicked out
>would be j and k, leaving the priority as a/b/ii/i.
>At the end of the block, the value of l would be popped. If the block were
>the body of a loop, the pushing/popping would need to be done outside the
>actual loop, for speed. Inside the loop, of course, 'l' would be addressed
>as an auto.
>
>This allows C programmers one more advantage previously available only to
>assembler programmers: the re-use of registers for completely different
>things. The problem is that it would make jumping into/out of blocks a
>mess. I guess the compiler would have to detect this and generate 'fix'
>code for the jumps.
     
(Sorry I had to quote so much here.)  This has *nothing* to do with the C
language; we are now in the realm of compiler implementation.  Here's a
counter-proposal: compilers should allocate registers based on the last
declaration instead of the first.  (This is quite legal; "register" has no
guaranteed semantics.)  In the above example, i and j would be auto, while
k, l, m, and ii would be register.  No need to save registers in the middle
of a function.
     
Better yet, Let's make the compilers smart enough to allocate registers on
their own, and make the "register" keyword obsolete!  (DEC did this.)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2212
          for JMS@ARIZMIS; Wed, 21-MAY-1986 01:51 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018588; 20 May 86 14:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006028; 20 May 86 13:55 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <827@bentley.UUCP>
Date: 16 May 86 03:18:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1776@sdcsvax.UUCP> hutch@sdcsvax.UUCP writes:
>well now for ||= you can use |= ...
     
I think the intent was that "v ||= e" would not evaluate e if v were already
true.  (Same as "v = v || e".)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2144
          for JMS@ARIZMIS; Wed, 21-MAY-1986 01:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/21/86 at 03:35:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018547; 20 May 86 14:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006021; 20 May 86 13:55 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: More extensions to C (was: Boolean Operators Slighted in C)
Message-ID: <826@bentley.UUCP>
Date: 16 May 86 03:15:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2741@utcsri.UUCP> greg@utcsri.UUCP writes:
>In article <602@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>>3) Exchange operator. ...
>
>Good stuff. Even machines without an EXG can use a scratch register, which
>is better than using a user-supplied temp.
     
This could be considered a special case of my ",," operator: to exchange x
and y, write "x = (y ,, (y = x))".
     
>What, by the way, is the XOR trick?
     
"x ^= y; y ^= x; x ^= y;".  Not useful for floats or structs.
     
>>5) Allow immediate constants. [Generalization of quoted strings.]
>>... Why not int *p = &5 ...
     
Does "&5" point to a character, short, int, unsigned, or long constant?
(No fair using the left side of the assignment to disambiguate!)
     
>I would also like to suggest struct constants/rvalues. Suppose I have
>    struct foo{ int f1; char f2; char *bar; } foo_var;
>I'd like to write something like this ( an executable statement ):
>    foo_var = struct foo{ .bar = "Ergo Sum"; .f1 = 73; .f2 = '?'; };
>
>This allows the use of unnamed (structure constants).  ...  I think it is
>important that the member names be used instead of the order.
     
Yes, because then you could use unions too.  In fact, a similar notation
would allow the compile-time initialization of a union, something I've
wanted for some time.  (I hear ANSI wants to use the first member of the
union for initializations.  Sorry folks, I want to initialize an array[2] of
union {int;char*} to { {12}, {"foo"} }.)
     
>Also, it would be nice if the compiler were smart in cases like
>    xchar = struct foo{ .bar="??"; .f2 = ychar+1; .f1 = func(i); }.f2;
>not to generate all the code to compute f1 and bar ( Holy side-effects,
>Batman! ). The above line could arise by a macro expansion.
     
Umm... I think it's better if the compiler does include the call to func().
The constant assignment to ".bar" can be optimized out, of course, and the
structure itself need not exist.  (xchar = (void)func(i),ychar+1)
     
>>6) Eliminate arrays altogether!
     
You want to take them *out* of the language?  I say let's put them *in*!
As it stands, arrays are half-implemented.
     
>>And it wouldn't matter whether a variable was defined differently than it
>>was declared (char x[] or char *x).
     
I don't get it.  If "char *x" is valid for all array/pointer variables,
where does the memory come from, malloc()?
     
>>8) Allow formal arguments to be declared AFTER the opening brace.
>>    This would allow prioritization of register variables.
>>
>Well, register arguments need to copied from the stack anyway, so
>you can declare your own with an explicit copy. But it wouldn't
>hurt to let the compiler do it. Since it silly ( presently ) to
>say `foo(p){ register char *p;...' this could be taken as an argument
>declaration.
>
>I have a related suggestion.
>
>Suppose I have the following:
>
>f(){
>    ...
>    { int x,y;    ...    }
>    { double xy;    ...    }
>}
>I would expect x and y to share the same stack space with xy.
>Now look at this ( assume 4 regs available ):
>
>f(){    register i,j,k,l,m;        /* more vars than regs available */
>    { register ii ..... };
>}
>I think the inner loop should push 'l' ( the lowest priority reg var ) on
>the stack and keep 'ii' in that reg, since ii will probably get more use
>in the inner block. The register priority would become ii/i/j/k, so if
>a further nested block said 'register a,b', the next regs to be kicked out
>would be j and k, leaving the priority as a/b/ii/i.
>At the end of the block, the value of l would be popped. If the block were
>the body of a loop, the pushing/popping would need to be done outside the
>actual loop, for speed. Inside the loop, of course, 'l' would be addressed
>as an auto.
>
>This allows C programmers one more advantage previously available only to
>assembler programmers: the re-use of registers for completely different
>things. The problem is that it would make jumping into/out of blocks a
>mess. I guess the compiler would have to detect this and generate 'fix'
>code for the jumps.
     
(Sorry I had to quote so much here.)  This has *nothing* to do with the C
language; we are now in the realm of compiler implementation.  Here's a
counter-proposal: compilers should allocate registers based on the last
declaration instead of the first.  (This is quite legal; "register" has no
guaranteed semantics.)  In the above example, i and j would be auto, while
k, l, m, and ii would be register.  No need to save registers in the middle
of a function.
     
Better yet, Let's make the compilers smart enough to allocate registers on
their own, and make the "register" keyword obsolete!  (DEC did this.)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2305
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018629; 20 May 86 14:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006036; 20 May 86 13:55 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <828@bentley.UUCP>
Date: 16 May 86 03:26:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <287@euclid.warwick.UUCP> warwick!steve writes:
>Couldn't you write a small(?) filter which would let you write C
>without braces and fill them in for you from the indentation? It
>doesn't seem too difficult. (No I'm not offering to do it).
     
I almost wrote such a filter when I first got this idea, but there wasn't
enough interest.  No, it isn't difficult -- a short awk script could do it,
I think.  I guess for continuation lines you'd have to either start flush
with the previous line, or use a continuation character (backslash).
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2346
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018684; 20 May 86 14:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006041; 20 May 86 13:55 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Indentation
Message-ID: <829@bentley.UUCP>
Date: 16 May 86 03:31:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <995@inset.UUCP> inset!mikeb (Mike Banahan) writes:
>In article <797@bentley.UUCP> kwh@bentley.UUCP writes:
>>Yet another convention, not endorsed by any language I know, is to dispense
>>with the braces...
>
>Sorry, you're wrong. Occam uses indentation to show nesting. ...
     
No, I was right.  Occam is not "a language I know".
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
(Okay, maybe I should've added a "that".)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2386
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018756; 20 May 86 14:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006054; 20 May 86 13:55 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <830@bentley.UUCP>
Date: 16 May 86 03:43:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <640@bunkerb.UUCP> bunkerb!garys (Gary Samuelson) writes:
>In article <797@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>>(It's too bad lint can't tell whether you've tested the return value of
>>open(), etc.)
>
>??? Lint certainly can check for that (at least the lint I use); it says
>something like "open returns value which is sometimes ignored"
     
By "open(), etc." I meant the class a functions which return a useful value
even when they succeed.  For example, lint does *not* catch the following:
    fp = fopen(fname, "r");
    c = getc(fp);
which is a potential error because fopen() could return NULL.  Trouble is,
even if lint knew that fopen had such an error return, it would have to
know whether getc() is prepared to handle it (it isn't).
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2433
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018802; 20 May 86 14:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006096; 20 May 86 13:56 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <831@bentley.UUCP>
Date: 16 May 86 03:49:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <479@cit-vax.Caltech.Edu> cit-vax!jon writes:
>    I don't think 'void *' is useless. What do you  do    on  a  machine
>where it's NOT 'always legal to cast any pointer into a "char *"'?
     
You get a compiler that works.  The proposed property of "void *" is
already guaranteed for "char *".  (Sorry, no K&R handy, can't quote it.)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2486
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:19 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018816; 20 May 86 14:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006105; 20 May 86 13:57 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: questions from using lint
Message-ID: <473@cubsvax.UUCP>
Date: 15 May 86 17:09:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <baylor.643> peter@baylor.UUCP writes:
>> One of the more traumatic things about being exposed to unix after working
>> with numerous other systems was that the stupid c compiler refused to give me
>> a nice clean listing with source, interspersed error messages, and optional
>> object code.  I'm not dumb, but trying to learn a debug a big program though
>> a 24-line window and my memory just doesn't make it...
>
>On the other hand, I found VAX/VMS 'C' a real pain after UNIX because it
>put all the error messages in this huge ugly listing instead of a brief
>list so I could find them. Of course the stupid bloody editor that didn't
>have a shell escape or any sort of facility for editing multiple files
>didn't help.
     
What I'm waiting for is an interactive interpretive debugger that runs from
vi.  The program would run interpretively until an error was encountered,
then place you at the appropriate line in the source file with the error
message displayed.  Then you could go into insert mode, make the necessary
change, and resume execution.  Normally interpreted languages, like APL,
often have such facilities.  Are there insuperable difficulties with doing
this with a normally compiled language like C?  (I'm sure it could be done
with FORTRAN, since FORTRAN interpreters are well-known... but why have we
seen no C interpreters?)
     
Seems to me a few years ago some people on the net from Harvard were trying
to implement this concept or one similar to it.  Whatever happened?
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2543
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa21414; 20 May 86 16:00 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a008836; 20 May 86 15:49 EDT
Received: from [128.39.1.2] by VGR.BRL.ARPA id aa01658; 20 May 86 15:32 EDT
Date: Wed, 14 May 86 14:22:49 -0200
From: Stein-Erik Engbr}ten <see@NTA-VAX.ARPA>
Posted-Date: Wed, 14 May 86 14:22:49 -0200
Message-Id: <8605141222.AA04921@nta-vax.ARPA>
Received: by nta-vax.ARPA (5.31/3.21)
    id AA04921; Wed, 14 May 86 14:22:49 -0200
To: info-c@BRL.ARPA
Subject: No booleans?
     
     
>THERE IS NO SUCH THING AS A BOOLEAN DATA TYPE (to which Doug Gwyn will
>reply `there is no such thing as an integer either :-). There may be
>boolean OPERATORS, but their range and domain is integers.
     
I hope this '...NO SUCH THING...' is a statement regarding C only!
     
Stein-Erik Engbr}ten
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2620
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/21/86 at 04:20:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023795; 20 May 86 18:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013595; 20 May 86 18:26 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <1918@ihlpg.UUCP>
Date: 15 May 86 15:04:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>>>And as someone pointed out, assignments return a value too, so should we
>>>cast them to void as well?  Oh yeah, assignment is `different'.
>If I say "a = b", I have clearly used the value of the expression.
> Gary Samuelson
     
No.  You have only used the value of the expression "b", not the expression
"a = b" (which happens, by definition, to return the value of the expression
"b").  The argument stands.  The principle behind ignoring, even meaningful,
return codes is:
    I don't have any particular response to this error so I will fall
    back on whatever default error handling the system provides.
     
Admittedly, this is not the desired response when what is being written is
a general tool.  ROBUSTNESS provides GENERALITY but costs DEVELOPMENT TIME.
     
--j.a.tainter

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2684
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023973; 20 May 86 19:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013910; 20 May 86 18:37 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <835@bentley.UUCP>
Date: 19 May 86 15:29:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3674@sun.uucp> sun!guy writes:
[bentley!kwh writes:]
>> I saw the need for a "ALIGN *" datatype, and was hoping "void *" would
>> be it.  (Nope, just a useless synonym for "char *").  The idea would
>> be that, just as it's always legal to cast any pointer into a "char *",
>> it would be legal to cast *from* "ALIGN *" to any pointer.  Then lint
>> would shut up about malloc()!
>
>No, you just don't understand how it works.  From the August 11, 1985 C
>standard draft:
>
>    C.2.2.3 Pointers
>
>       A pointer to "void" may be converted to a pointer to an
>    object of any type.  A pointer to an object of any type may be
>    converted to a pointer to "void" or to a pointer to an object
>    of less strict alignment and back again without change.
>
>Nowhere is it implied that "void *" is a synonym for "char *".
     
Since sizeof(char) == 1 (I believe that's now a guaranteed rule rather than
merely "true in all known implementations", right?), it has the least strict
alignment.  Thus your last quoted sentence implies that "char *" can also
hold a pointer of any type, and restore it unchanged.  And to even attempt
to restore it means that "char *" must meet the first property as well.  So,
although not necessarily synonyms, they do have the same properties, except
that "char *" conversions usually require a cast to be acceptable.
     
>No, the language does not *guarantee* that a "void *" is properly aligned,
>but there's no way for it to do so anyway.  Big deal.  The language couldn't
>*guarantee* that an "ALIGN *" is properly aligned either...
     
What I had in mind was that "ALIGN *" would be a synonym for "int *" or
whatever happens to be the most restrictive pointer type.  The "guarantee"
would be as good as the "guarantee" on an "int *".
     
>> Also, having malloc() return a real "ALIGN *" would be convenient for word-
>> addressible machines where "char *" requires extra bits.
>
>Maybe, but I'm not sure the added convenience of having "malloc" be able to
>return a value of a type requiring fewer bits is sufficient to justify
>adding another type to the language.
     
Well, what *is* the justification for adding "void *" to the language?  To
allow people to shove pointers around without casts?  (Shudder!)  To make
lint shut up about malloc()?  Or just to distinguish "generic pointers" from
pointers that can be dereferenced?  (Could be done with a typedef.  So could
"void", but they put it in anyway.)
     
I do not strongly object to the addition of "void *", but I am worried about
it "hiding" errors.  (I'm one of those purists who thinks that programmers
*should* use casts to change types.)  Also, it's a misnomer; it has nothing
to do with "void".
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2745
          for JMS@ARIZMIS; Wed, 21-MAY-1986 02:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023983; 20 May 86 19:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013916; 20 May 86 18:38 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Comma and semicolon
Message-ID: <836@bentley.UUCP>
Date: 19 May 86 15:46:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <118@danews.UUCP> danews!lvc writes:
>    printf("usage: foo bar\n") , return 1 ;
>seems reasonably "within C's style".  Comments ?
     
It would've been nice if the "," operator and the ";" separator had been
the same token, but they aren't.  They happen to be interchangeable in one
instance (both sides statement-expressions, and not the body of an if/else/
while/do/switch without braces), that's all.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4922
          for JMS@ARIZMIS; Wed, 21-MAY-1986 07:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/21/86 at 09:09:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023994; 20 May 86 19:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013924; 20 May 86 18:38 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: using indentation rather than braces
Message-ID: <838@bentley.UUCP>
Date: 19 May 86 16:09:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <968@umd5.UUCP> umd5!zben (Ben Cranston) writes:
>Forgive me if this is too obvious to mention, but it seems to me that using
>the indentation information makes life much harder for programs like YACC
>and LEX that act by creating C source code.  Now they have to keep track of
>what column they are outputting to...
     
Slightly harder, but still not all that difficult.  Instead of outputting a
left brace, the program increments a variable; instead of a right brace, it
decrements.  Then each output line is preceded by that many blanks.
     
Of course, I'm assuming some support would be built into yacc and lex.  They
would automatically add the indentation level of your code blocks to that of
the automatically-generated blocks.
     
Btw, how would such a language interpret a one-liner like "if (c) a; b;"?
Would that be "if (c) {a;} b;" or "if (c) {a; b;}" or just illegal?
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5204
          for JMS@ARIZMIS; Wed, 21-MAY-1986 07:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024053; 20 May 86 19:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014193; 20 May 86 18:48 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <5462@alice.uUCp>
Date: 15 May 86 13:29:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>    I don't think 'void *' is useless. What do you  do    on  a  machine
> where it's NOT 'always legal to cast any pointer into a "char *"'?
     
You don't implement C on it.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5261
          for JMS@ARIZMIS; Wed, 21-MAY-1986 09:34 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024253; 20 May 86 19:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014368; 20 May 86 18:55 EDT
From: bright%dataio.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <996@dataioDataio.UUCP>
Date: 14 May 86 16:35:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1469@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes:
>In article <989@dataioDataio.UUCP>, bjorn@dataio.UUCP writes:
>>... I notice this (odd) fact: the compiler on the PC is better than
>>the one on the VAX!  It's faster, it produces better code, and it
>>catches errors that the UNIX C does not.  So I'm curious:
>1.  Your company gets paid for improving your compiler.  Is not
>    that so?
     
No, it isn't so. Datalight, Data I/O, Data Exchange, Data Translation Inc.,
Data Zone Inc., Datacom Northwest Inc., Datatech Enterprises Co. and
Data General are all independent companies. The
similarity in the names is coincidence.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6477
          for JMS@ARIZMIS; Wed, 21-MAY-1986 10:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024369; 20 May 86 19:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014523; 20 May 86 19:01 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#18
Message-ID: <1056@hou2d.UUCP>
Date: 15 May 86 17:32:52 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  18
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 8 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 8 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.12.2.1 The clock function
     
  *    The clock function returns ...  the processor time used  {-->  by
       the program} since the beginning of an implementation-defined era
  *    {--> related only to the program invocation}.
     
     
     
# D.12.2.2 The time function
     
N-->   The encoding of the value is unspecified.
     
     
     
# D.12.2.2 The time function
     
  *    The time function returns ...  the current calendar  time  {since
       the beginning of an implementation-defined era -->}.
     
     
     
# D.12.3.1 The asctime function
     
       The asctime function converts the broken-down time in the  struc-
  *    ture  pointed  to  by timeptr into a {26-character -->} string in
  *    the {following -->} form {.  All the fields have constant  width.
       -->}
     
                   Sun Sep 16 01:03:52 1973\n\0
     
N-->   using the equivalent of the following algorithm:
     
N-->   char *asctime(const struct tm *timeptr)
N-->   {
N-->               static const char wday_name[7][3] = {
N-->                     "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
N-->               };
N-->               static const char mon_name[12][3] = {
N-->                     "Jan", "Feb", "Mar", "Apr", "May", "Jun",
N-->                     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
N-->               };
N-->               static char result[26];
     
N-->               (void) sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
N-->                     wday_name[timeptr->tm_wday],
N-->                     mon_name[timeptr->tm_mon],
N-->                     timeptr->tm_mday, timeptr->tm_hour,
N-->                     timeptr->tm_min, timeptr->tm_sec,
N-->                     1900 + timeptr->tm_year);
N-->               return result;
N-->   }
     
     
     
# C.12.3.2 The ctime function
     
N-->   It is equivalent to
     
N-->               asctime(localtime(timer))
     
N-->   ...  Forward references: the localtime function (#D.12.3.5).
     
     
     
# {--> D.13 FUTURE DIRECTIONS}
     
     
     
# {--> D.13.1 Character handling <ctype.h>}
     
N-->   Function names that begin with "is" and  "to"  and  a  lower-case
N-->   letter may be added to the declarations in the <ctype.h> header.
     
     
     
# {--> D.13.2 Mathematics <math.h>}
     
N-->   The names of all existing  functions  declared  in  the  <math.h>
N-->   header,  suffixed  with  f  or  l, are reserved for corresponding
N-->   functions with float and long double arguments and return values,
N-->   respectively.
     
     
     
# {--> D.13.3 Signal handling <signal.h>}
     
N-->   Macros that begin with SIG and an upper-case letter may be  added
N-->   to the definitions in the <signal.h> header.
     
     
     
# {--> D.13.4 Input/output <stdio.h>}
     
N-->   The use of leading 0 in fprintf format to  request  padding  with
N-->   leading  zeros  is deprecated.  Use the "precision" specifier in-
N-->   stead.
     
N-->   Lower-case letters may be added to the conversion  specifiers  in
N-->   fprintf and fscanf.  Other characters may be used in extensions.
     
     
     
# {--> D.13.5 String handling <string.h>
     
N-->   Function names that begin with "str" and "mem" and  a  lower-case
N-->   letter may be added to the declarations in the <string.h> header.
     
     
     
# E. APPENDICES
     
Remark: Since the appendices are not part of the Standard, I have
included  only  certain  ones here.  The ones I included were the
new section #E.2 Sequence Points, section #{E.3 -->  E.5}  Common
Warnings, and section #{E.5 --> E.6} Portability Issues.
     
     
     
# {--> E.2 SEQUENCE POINTS}
     
N-->   The following are the sequence points described in #B.1.2.3.
     
N-->   * The call to a function, after the arguments have been evaluated
N-->     (#C.3.2.2).
     
N-->   * The logical AND operator && (#C.3.2.13).
     
N-->   * The logical OR operator || (#C.3.2.14).
     
N-->   * The conditional operator ? (#C.3.2.15).
     
N-->   * The comma operator , (#C.3.2.17).
     
N-->   * Completion of the evaluation of a full expression: an  initial-
N-->     izer of an object that has automatic storage duration (#C.5.6);
N-->     the expression in an expression statement  (#C.6.3);  the  con-
N-->     trolling  expression  of  a  selection statement (if or switch)
N-->     (#C.6.4); the controlling expression of an iteration  statement
N-->     (while, do, or for) (#C.6.5).
     
     
     
  # {E.3 --> E.5} COMMON WARNINGS
     
       * An implicit narrowing conversion is encountered,  such  as  the
  *      assignment  of  a  long  int  or  a double to an int {-->, or a
         pointer to void to a pointer to any type of object  other  than
         char (#C.2)}.
     
       ...
     
<--O   * A declaration with no effect is encountered (#C.5).
     
N-->   * An object is defined but not used (#C.5).
     
     
     
# {E.5.1 --> E.6.1} Unspecified behavior
     
N-->   * The behavior if a printable character is written when  the  ac-
N-->     tive position is at the final position of a line (#B.2.2).
     
N-->   * The behavior if a backspace character is written when  the  ac-
N-->     tive position is at the initial position of a line (#B.2.2).
     
N-->   * The behavior if a horizontal tab character is written when  the
N-->     active position is at or past the last defined horizontal tabu-
N-->     lation position (#B.2.2).
     
N-->   * The behavior if a vertical tab character is  written  when  the
N-->     active position is at or past the last defined vectical tabula-
N-->     tion position (#B.2.2).
     
     
     
# {E.5.1 --> E.6.1} Unspecified behavior
     
N-->   * The order in an array sorted  by  the  qsort  function  of  two
N-->     members that compare as equal (#D.10.5.2).
     
     
     
# {E.5.1 --> E.6.1} Unspecified behavior
     
N-->   * The encoding of the calendar time returned by the time function
N-->     (#D.12.2.2).
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:32:29 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6203
          for JMS@ARIZMIS; Wed, 21-MAY-1986 10:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/21/86 at 10:39:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024327; 20 May 86 19:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014511; 20 May 86 19:00 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#15
Message-ID: <1053@hou2d.UUCP>
Date: 15 May 86 17:31:28 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  15
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 5 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 5 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.10.1.1 The atof function
     
<--O   If the value cannot be represented, the  behavior  is  undefined.
<--O   It  the string starts with an unrecognized character, zero is re-
<--O   turned.
     
Remark: And likewise for atoi (#D.10.1.2) and atol (#D.10.1.3).
     
     
     
# D.10.1.2 The atoi function
     
<--O   The function recognizes an optional sequence of white-space char-
<--O   acters,  then  an optional plus or minus sign, then a sequence of
<--O   digits.  The first unrecognized character  ends  the  conversion.
<--O   The  sequence of digits is interpreted by the same rules as for a
<--O   decimal integer constant.
     
N-->   Except for the behavior on error, it is equivalent to
     
N-->               (int)strtol(nptr, (char **)NULL, 10)
     
N-->   ...  Forward references: the strtol function (#D.10.1.5).
     
Remark: Likewise for atol (#D.10.1.3), except with no (int) cast.
     
     
     
# D.10.1.4 The strtod function
     
       The function recognizes an optional leading  sequence  of  white-
  *    space  characters  {-->  (as specified by the isspace function)},
       ...
     
N-->   If an unrecognized character occurs before the first  digit  fol-
N-->   lowing the e or E, the exponent is taken to be zero.  ...
     
  *    If {the string starts with -->} an  unrecognized  character  {-->
  *    occurs before any digit}, zero is returned {-->, and errno is set
       to EDOM}.
     
     
     
# D.10.1.4 The strtod function
     
<--O   The string is interpreted by the same rules as  a  floating  con-
<--O   stant.
     
N-->   The sequence of characters from the first digit  or  the  decimal
N-->   point  (whichever occurs first) to the character before the first
N-->   unrecognized character is interpreted as a floating constant  ac-
N-->   cording  to  the rules of #C.1.3.1, except that if neither an ex-
N-->   ponent part nor a decimal point appears, a decimal point  is  as-
N-->   sumed  to  follow  the last digit in the string.  If a minus sign
N-->   appears immediately before the first digit, the  value  resulting
N-->   from the conversion is negated.
     
     
     
# D.10.1.5 The strtol function
     
       The function recognizes an optional leading  sequence  of  white-
  *    space  characters  {-->  (as specified by the isspace function)},
       ...
     
  *    If {the string starts with -->} an  unrecognized  character  {-->
       occurs  before the first recognized digit or letter}, zero is re-
  *    turned {-->, and errno is set to EDOM}.
     
     
     
# D.10.1.5 The strtol function
     
  *    If the value of base is 0, the sequence of {digits --> characters
       from  the  first digit to the character before the first unrecog-
  *    nized character} is interpreted {by the same rules -->}  as  {for
  *    -->}   an  integer  constant  {-->  according  to  the  rules  of
  *    #C.1.3.2}.  {After the optional sign, a  leading  zero  indicates
       octal  conversion, and a leading 0x or 0X hexadecimal conversion.
       Otherwise, decimal conversion is used.  --> If a minus  sign  ap-
       pears  immediately  before  the  first digit, the value resulting
       from the conversion is negated.}
     
       If the value of base is between 2 and 36, it is used as the  base
  *    for  conversion.  {--> Letters from a (or A) through z (or Z) are
       ascribed the values 10 to 35; a letter  whose  value  is  greater
       than  or equal to the value of base ends the conversion.} Leading
  *    zeros after the optional sign are ignored, and {-->  leading}  0x
  *    or  0X  is  ignored  if the value of base is 16.  {--> If a minus
       sign appears immediately before the first digit  or  letter,  the
       value resulting from the conversion is negated.}
     
     
     
# D.10.2.1 The rand function
     
       The rand function computes a sequence of  pseudo-random  integers
  *    in  the  range  0  to  {32767  --> RAND_MAX} {using the specified
       linear multiplicative algorithm, which has a period of  2  raised
       to the power 32 -->}.
     
     
     
# D.10.2.1 The rand function
     
  *    The following functions define  {the  required  semantics  -->  a
       portable implementation} of rand and srand.  ...
     
  *                int rand({--> void})
     
       ...
     
<--O               void srand(seed)
<--O                    unsigned int seed;
     
N-->               void srand(unsigned int seed)
     
     
     
# D.10.3 Memory management functions
     
N-->   The pointer returned  if  the  allocation  succeeds  is  suitably
N-->   aligned  so  that  it may be assigned to a pointer to any type of
N-->   object and then used to access such an object in the space  allo-
N-->   cated (until the space is explicitly freed or reallocated).
     
     
     
# D.10.3.1 The calloc function
     
  *                void *calloc({unsigned int --> size_t} nelem,
                         size_t size);
     
     
     
# D.10.3.1 The calloc function
     
<--O   The pointer returned may safely be case to point to an object  of
<--O   any type.
     
Remark: Likewise for malloc (#D.10.3.3) and realloc (#D.10.3.4).
     
     
     
# D.10.3.1 The calloc function
     
  *    If the space cannot be allocated, {--> or if  nelem  or  size  is
       zero,} the calloc function returns a null pointer.
     
     
     
# D.10.3.2 The free function
     
N-->   If ptr is a null pointer, no action occurs.
     
     
     
# D.10.3.4 The realloc function
     
N-->   If ptr is a null pointer, the realloc function behaves  like  the
N-->   malloc function for the specified size.  ...
     
       If size is zero, the realloc function returns a null pointer  and
       the object pointed to by ptr is freed.
     
     
     
# D.10.4.1 The abort function
     
  *    Unless the signal SIGABRT is being {--> cuaght or}  ignored,  the
       abort function causes abnormal program termination to occur.
     
     
     
# D.10.4.1 The abort function
     
       If the signal SIGABRT is being ignored, the  abort  function  re-
  *    turns no value.  {--> Otherwise, the abort function cannot return
       to its caller.}
     
Remark: I assume "caught or ignored" is meant.
     
     
     
# D.10.4.2 The exit function
     
<--O   If a registered function fails to return as its value  the  value
<--O   returned  by the call to the onexit function by means of which it
<--O   was registered, the behavior is undefined.
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:31:09 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5459
          for JMS@ARIZMIS; Wed, 21-MAY-1986 10:17 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024263; 20 May 86 19:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014473; 20 May 86 18:59 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#11
Message-ID: <1049@hou2d.UUCP>
Date: 15 May 86 17:28:40 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  11
     
Today's Topics:
             Cover Letter for MORE C standard differences
         MORE C standard differences Apr85-Feb86, part 1 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: Cover Letter for MORE C standard differences
To: utzoo!ihnp4!hou2d!osd
     
This is the continuation of my earlier posting enumerating signi-
ficant  differences  between the April 30, 1985, and February 14,
1986, drafts of the proposed ANSI C Standard.  This posting  cov-
ers  Part D and part of Part E.  It did not seem worthwhile doing
the rest of Part E.
     
     
     
As before, what you see here does not include ALL of the  differ-
ences  between the versions.  I have generally suppressed changes
that appeared to provide only a clearer wording, or to move  some
text  to  a  more appropriate heading.  Some of these changes are
actually fairly substantial in extent.  On the other hand, I have
included all changes that affect either C itself or the terminol-
ogy for talking about it ...   except,  of  course,  any  that  I
missed.
     
The changes are cited in the order of their appearance in the new
version,  with  a few slight exceptions to group related text.  I
don't give a lot of context for each one, to keep the  length  of
this  document  manageable.   Never  assume that you are seeing a
complete paragraph.  However, where I have elided important  text
I have placed an ellipsis (...).
     
For changes that affect a small  part  of  a  paragraph,  I  have
adopted the notation {old text --> new text}, which is simply run
in line.  Each line containing the start of  at  least  one  such
change is starred in the left margin.  The old or new text may be
null: thus, the change to the description of ptrdiff_t in section
D.1.1  consists of the insertion of the word "signed".  In such a
paragraph, the words not enclosed in braces may be unchanged from
April  1985 to February 1986, or they may have changed in a minor
way, as described above, in which case I am showing the new  ver-
sion.
     
For larger changes, I give what are generally complete paragraphs
or  blocks  of  paragraphs, showing old and new forms separately.
The notation "<--O" in the left margin means that this  paragraph
has been deleted or replaced; "N-->" refers to its replacement or
an added paragraph.
     
Since the typographical changes of the actual  document  are  not
available  here,  I have rendered some of them in punctuation and
omitted others.  (In particular, "quotation marks" in this  arti-
cle  more  often  than  not represent italics in the original and
thus a definition of a term.)
     
Paragraphs marked Remark are mine.
     
Mark Brader - ihnp4!utzoo!lsuc!msb
     
------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 1 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.1 INTRODUCTION {<stdefs.h> --> <stddef.h>}
     
# D.1.1 Terms and common definitions
     
N-->   A  "letter"  is  a  character  in  the  execution  character  set
N-->   corresponding to any of the 52 required lower-case and upper-case
N-->   letters in the source character set, listed in #B.2.1.
     
     
     
# D.1.1 Terms and common definitions
     
<--O   A "null pointer" is a pointer of  appropriate  type  whose  value
<--O   compares  equal  to  that of an integral constant expression with
<--O   the value 0.
     
     
     
# D.1.1 Terms and common definitions
     
       The following types and macros ...  are also defined in a  common
  *    standard header, {<stdefs.h> --> <stddef.h>}.
     
       The types are
     
                   ptrdiff_t
     
  *    which is the {--> signed} integral type of  the  result  of  sub-
       tracting two pointers; and
     
                   size_t
     
  *    which is the {--> unsigned} integral type of the  result  of  the
       sizeof operator.
     
       The macros are
     
                   NULL
     
  *    which expands to {a  constant  expression  whose  value  compares
       equal  to  that of an integral constant expression with the value
       0, which can be assigned to a pointer or used as an  argument  to
       represent  the  null  pointer  --> an implementation-defined null
       pointer constant}; and
     
                   errno
     
  *    which expands to {an lvalue expression --> a  modifiable  lvalue}
  *    that designates {an int --> a volatile integer} which is set to a
       positive error code by several library functions.  ...
     
N-->   The macro errno need not be the  identifier  of  an  object.   It
N-->   might  be a modifiable lvalue resulting from a function call (for
N-->   example, *_errno()).
     
     
     
# D.1.2 Headers
     
  *    Each library function {or object -->} is {associated with --> de-
       clared  in}  a  "header"  ... made available via ... #include ...
  *    The header declares a set of related functions {and objects -->},
  *    plus  any  necessary  types  and  additional {#define -->} macros
       needed to facilitate their use.
     
Remark: The draft no longer refers to headers declaring  any  ob-
jects; this is a general change and will not be mentioned again.
     
     
     
# D.1.2 Headers
     
<--O   An implementation may define macros whose names begin with two or
<--O   more underscores, even if no headers are explicitly included.
     
     
     
# D.1.2 Headers
     
       The standard headers are ...
     
N-->   <float.h>
     
       ...
     
  *    {<stdefs.h> --> <stddef.h>}
     
     
     
# D.1.2 Headers
     
  *    Headers ... may be included  more  than  once  {-->  in  a  given
       scope}, with no effect different from being included only once.
     
     
     
# D.1.3 Use of library functions
     
       Any function declared in a header may be implemented as  a  macro
       defined in the header,
     
<--O   so it is generally not safe to declare or take the address  of  a
<--O   library function or object.
     
N-->   so a library function should not be declared  explicitly  if  its
N-->   header  is  included.   Any macro definition of a function can be
N-->   suppressed locally by enclosing  the  name  of  the  function  in
N-->   parentheses,  because  the  name is then not followed by the left
N-->   parenthesis that indicates expansion of a  macro  function  name.
N-->   For  the  same  syntactic reason, it is permitted to take the ad-
N-->   dress of a library function even if it is also defined as a  mac-
N-->   ro.
     
  *    The use of #undef to remove any macro definition will {-->  also}
       ensure that an actual function is referenced.
     
# D.1.3 Use of library functions
     
N-->   If a function that accepts a variable number of arguments is  not
N-->   declared  (explicitly or by including its associated header), the
N-->   behavior is undefined.
     
     
     
# D.1.3 Use of library functions
     
       ...  assuredly generating a true function reference ...
     
                   #include <stdlib.h>
                   #undef atoi
                   /*...*/
                   i = atoi(str);
     
N-->   or
     
N-->               #include <stdlib.h>
N-->               /*...*/
N-->               i = (atoi)(str);
     
     
     
# D.1.3 Use of library functions
     
       ...  the appropriate header could specify
     
                   #define abs(x) _builtin_abs(x)
     
       for a compiler whose code generator will accept it.
     
       In this manner, a user desiring to guarantee that a given library
       function such as abs will be a genuine function may write
     
                   #undef abs
     
       whether the implementation's header provides a macro  implementa-
  *    tion  of abs or a builtin implementation.  {--> The prototype for
       the function, which precedes and is hidden by any  macro  defini-
       tion, is thereby revealed also.}
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:28:03 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6335
          for JMS@ARIZMIS; Wed, 21-MAY-1986 10:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024340; 20 May 86 19:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014515; 20 May 86 19:00 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#16
Message-ID: <1054@hou2d.UUCP>
Date: 15 May 86 17:31:54 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  16
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 6 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 6 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.10.4.3 The getenv function
     
N-->   The array pointed to is not modifiable by the program, but may be
N-->   overwritten by a subsequent call to the getenv function.
     
     
     
# D.10.4.4 The onexit function
     
       If the registration succeeds, the onexit function returns a value
  *    that compares unequal to {--> the integer constant} 0.
     
     
     
# {--> D.10.5 Searching and sorting utilities}
     
     
     
# {--> D.10.5.1 The bsearch function}
     
N-->   Synopsis
     
N-->               #include <stdlib.h>
N-->               void *bsearch(const void *key, const void *base,
N-->                     size_t nel, size_t keysize,
N-->                     int (*compar)(const void *, const void *));
     
N-->   Description
     
N-->   The bsearch function searches an array of nel objects,  the  ini-
N-->   tial  member  of  which  is pointed to by base, for a member that
N-->   matches the object pointed to by key.  The size of each object is
N-->   specified by keysize.
     
N-->   The array shall be previously sorted in ascending order according
N-->   to  a  comparison  function pointed to by compar, which is called
N-->   with two arguments that point to the objects being compared.  The
N-->   function  shall return an integer less than, equal to, or greater
N-->   than zero if the first argument is considered to be  respectively
N-->   less than, equal to, or greater than the second.
     
N-->   Returns
     
N-->   The bsearch function returns a pointer to the matching member  of
N-->   the array, or a null pointer if no match is found.
     
     
     
# {--> D.10.5.2 The qsort function}
     
N-->   Synopsis
     
N-->               #include <stdlib.h>
N-->               void qsort(void *base, size_t nel, size_t keysize,
N-->                     int (*compar)(const void *, const void *));
     
N-->   Description
     
N-->   The qsort function sorts an array of  nel  objects,  the  initial
N-->   member  of  which is pointed to by base.  The size of each object
N-->   is specified by keysize.
     
N-->   The array is sorted in ascending order according to a  comparison
N-->   function pointed to by compar, which is called with two arguments
N-->   that point to the objects being compared.  The function shall re-
N-->   turn  an integer less than, equal to, or greater than zero if the
N-->   first argument is considered to be respectively less than,  equal
N-->   to, or greater than the second.
     
N-->   If two members compare as equal, their order in the sorted  array
N-->   is unspecified.
     
N-->   Returns
     
N-->   The qsort function returns no value.
     
     
     
# {--> D.10.6 Integer arithmetic functions}
     
     
     
# {D.5.6.1 --> D.10.6.1} The abs function
     
       ...
  *                #include {<math.h> --> <stdlib.h>}
       ...
     
     
     
# {--> D.10.6.2 The idiv function}
     
N-->   Synopsis
     
N-->               #include <stdlib.h>
N-->               idiv_t idiv(int numer, int denom);
     
N-->   Description
     
N-->   The idiv function computes the  quotient  and  remainder  of  the
N-->   division of the numerator numer by the denominator denom.  If the
N-->   division is inexact, the sign of the  quotient  is  that  of  the
N-->   mathematical  quotient,  and the magnitude of the quotient is the
N-->   largest integer less than the magnitude of the mathematical  quo-
N-->   tient.   If the result cannot be represented, the behavior is un-
N-->   defined.
     
N-->   Returns
     
N-->   The idiv function returns a structure with two elements: the quo-
N-->   tient and the remainder.  The type returned is defined by
     
N-->               typedef struct { int quot, rem; } idiv_t;
     
     
     
# {--> D.10.6.3 The ldiv function}
     
N-->   Synopsis
     
N-->               #include <stdlib.h>
N-->               ldiv_t ldiv(long numer, long denom);
     
N-->   Description
     
N-->   The ldiv function is similar to the idiv  function,  except  that
N-->   the  arguments  and  the members of the returned structure (which
N-->   has type ldiv_t) all have type long int.
     
     
     
# D.11 STRING HANDLING <string.h>
     
Remark: The memset and strlen functions are moved from  #D.11.2.2
and  #D.11.4.3,  respectively,  into #D.11.6, and the other func-
tions' sections in #D.11.2 and #D.11.4 are renumbered  according-
ly.
     
     
     
# D.11.1 String function conventions
     
       The header <string.h> declares several functions useful for mani-
  *    pulating character arrays {--> and other objects treated as char-
       acter arrays}.
     
     
     
# D.11.1 String function conventions
     
<--O   If copying takes place between objects that overlap, the behavior
<--O   is undefined.
     
     
     
# D.11.2.1 The memcpy function
     
  *    The memcpy function copies n characters from the {array  -->  ob-
  *    ject}  pointed to by s2 into the {array --> object} pointed to by
       s1.
     
Remark: This change is general through this section.
     
     
     
# D.11.2.1 The memcpy function
     
N-->   Copying between objects that overlap shall take place correctly.
     
     
     
# {D.11.2.3 --> D.11.2.2} The strcpy function
     
N-->   If copying takes place between objects that overlap, the behavior
N-->   is undefined.
     
     
     
# {D.11.2.4 --> D.11.2.3} The strncpy function
     
N-->   If copying takes place between objects that overlap, the behavior
N-->   is undefined.
     
     
     
# {D.11.2.4 --> D.11.2.3} The strncpy function
     
       If the string pointed to by s2 is longer than n  characters,  the
  *    result {may --> will} not be null-terminated.
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:31:29 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6032
          for JMS@ARIZMIS; Wed, 21-MAY-1986 10:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024310; 20 May 86 19:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014507; 20 May 86 19:00 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#14
Message-ID: <1052@hou2d.UUCP>
Date: 15 May 86 17:31:01 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  14
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 4 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 4 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.9.6.2 The fscanf function
     
<--O   e,f,g   A floating point number is expected; the subsequent argu-
<--O           ment must be a pointer to floating.  The input format for
<--O           floating point numbers is an optionally  signed  sequence
<--O           of  digits, possibly containing a decimal point, followed
<--O           by an optional exponent field consisting of an E or an e,
<--O           followed by an optionally signed integer.
     
N-->   e,f,g   A floating point number is  expected;  the  corresponding
N-->           argument  shall be a pointer to floating.  The input for-
N-->           mat is as described for the strtod function.
     
     
     
# D.9.6.2 The fscanf function
     
       n       No input is consumed; the corresponding argument shall be
               a  pointer to integer into which is written the number of
               characters read from the input stream so far by this call
  *            to  fscanf.   {-->  This  is not counted as a match input
               item.}
     
     
     
# D.9.6.2 The fscanf function
     
<--O   If an invalid conversion specifier follows the %, the  result  is
<--O   undefined.
     
N-->   If the conversion specifier is a lower-case letter  that  is  not
N-->   described  above,  the  behavior is undefined.  If the conversion
N-->   specifier is any other character that is not described above, the
N-->   behavior is implementation-defined.
     
     
     
# D.9.6.2 The fscanf function
     
N-->   If end-of-file is encountered during a conversion, the conversion
N-->   terminates.
     
     
     
# D.9.6.2 The fscanf function
     
  *    The fscanf function  returns  the  number  of  input  items  {-->
       matched and} assigned ...
     
     
     
# D.9.6.6 The sscanf function
     
  *                int sscanf ({--> const} char *s,
                         const char *format, ...);
     
     
     
# D.9.6.7 The vfprintf function
     
N-->   The vfprintf function does not invoke the va_end function.
     
Remark:  And  likewise  for  vprintf  (#D.9.6.8)   and   vsprintf
(#D.9.6.9).
     
     
     
# D.9.7.1 The fgetc function
     
  *    If the stream is at end-of-file, {or --> the end-of-file  indica-
  *    tor  is  set and fgetc returns EOF.} If a read error occurs, {-->
       the error indicator is set and} fgetc returns EOF.
     
Remark: And likewise for getc (#D.9.7.5) and getchar (#D.9.7.6).
     
     
     
# D.9.7.3 The fputc function
     
  *    The fputc function returns the  character  written.   If  a  {-->
  *    write}  error  occurs, {--> the error indicator is set and} fputc
       returns EOF.
     
Remark: And likewise for putc (#D.9.7.8) and putchar (#D.9.7.9).
     
     
     
# D.9.7.11 The ungetc function
     
  *    The ungetc function pushes the  character  specified  by  c  {-->
       (converted  to  an  unsigned  char)}  back  onto the input stream
  *    pointed to by stream.  ...  An intervening {-->  fflush,}  fseek,
  *    {-->  or  rewind}  erases  any memory of a pushed-back character.
       ...
     
N-->   If the ungetc function is called twice on the same stream without
N-->   an  intervening  read, fflush, fseek, or rewind operation on that
N-->   stream, the behavior is undefined.
     
  *    ...  The ungetc function returns  {c  -->  the  character  pushed
  *    back}, or EOF {--> if the value of c equals that of the macro EOF
       or} if it cannot push the character back.
     
     
     
# D.9.8.1 The fread function
     
       The file position indicator  (if  defined)  is  advanced  by  the
  *    number of {bytes --> characters} successfully read.
     
Remark: A similar change  occurs  for  fwrite  (#D.9.8.3),  fseek
(#D.9.9.1), and ftell (#D.9.9.2).
     
     
     
# D.9.9.1 The fseek function
     
  *    The fseek function {--> clears the end-of-file indicator and} un-
       does any effects of ungetc.
     
     
     
# D.9.9.3 The rewind function
     
  *    ...  the {end-of-file and -->} error indicator is cleared ...
     
     
     
# D.9.10.4 The perror function
     
  *                {const char * --> void} perror (const char *s);
     
     
     
# D.9.10.4 The perror function
     
  *    {If s is not null, perror --> It} writes a line to  the  standard
  *    error  {file  -->  stream}  thus:  first {--> (if s is not a null
       pointer and the character pointed to by s is not the null charac-
       ter)},  the  string  pointed  to  by  s followed by a colon and a
  *    space; then an {--> appropriate} error message string followed by
       a new-line character.
     
     
     
# D.9.10.4 The perror function
     
  *    The contents of the error message strings are {-->  the  same  as
       those  returned  by  the  strerror  function with argument errno,
       which are} implementation-defined.
     
     
     
# D.9.10.4 The perror function
     
<--O   If the argument is a null pointer, the perror function returns  a
<--O   pointer to the message string and performs no output.
     
N-->   The perror function returns no value.
     
N-->   Forward references: the strerror function (#D.11.6.2).
     
     
     
# D.10 GENERAL UTILITIES <stdlib.h>
     
  *    The header <stdlib.h> declares {a --> three}  types  and  several
  *    functions of general utility {-->, and defines four macros}.
     
       The types declared are
     
       ...
     
N-->               idiv_t
     
N-->   which is a structure type that is the type of the value  returned
N-->   by the idiv function, and
     
N-->               ldiv_t
     
N-->   which is a structure type that is the type of the value  returned
N-->   by the ldiv function.
     
N-->   The macros defined are
     
N-->               EDOM ,
N-->               ERANGE ,
     
N-->   and
     
N-->               HUGE_VAL
     
N-->   which are described in #D.5.1; and
     
N-->               RAND_MAX
     
N-->   which expands to an integral constant expression,  the  value  of
N-->   which is the maximum value returned by the rand function.
     
     
     
# D.10.1 String conversion functions
     
<--O   Each of the functions described in this section  accepts  an  op-
<--O   tional  leading  sequence of white-space characters (as specified
<--O   by the isspace function) in the input string.
     
     
     
# D.10.1 String conversion functions
     
N-->   The function ans atof, atoi, and atol do not set errno on  error.
N-->   If the value of the result cannot be represented, the behavior is
N-->   undefined.
     
     
     
# D.10.1.1 The atof function
     
<--O   The function recognizes an optional sequence of white-space char-
<--O   acters,  then  an optional plus or minus sign, then a sequence of
<--O   digits optionally containing a decimal point,  then  an  optional
<--O   letter  e  or  E  followed  by an optionally signed integer.  The
<--O   first unrecognized character ends the conversion.  The string  is
<--O   interpreted by the same rules as for a floating constant.
     
N-->   Except for the behavior on error, it is equivalent to
     
N-->               strtod(nptr, (char **)NULL)
     
N-->   ...  Forward references: the strtod function (#D.10.1.4).
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:30:27 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6423
          for JMS@ARIZMIS; Wed, 21-MAY-1986 10:41 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024357; 20 May 86 19:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014519; 20 May 86 19:00 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#17
Message-ID: <1055@hou2d.UUCP>
Date: 15 May 86 17:32:24 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  17
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 7 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 7 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.11.3.1 The strcat function
     
       The strcat function appends a copy of the string pointed to by s2
  *    {-->  (including  the  terminating null character)} to the end of
       the string pointed to by s1.
     
     
     
# D.11.3.2 The strncat function
     
       The strncat function appends not more than n  characters  of  the
  *    string  pointed to by s2 {--> (not including the terminating null
       character)} to the end of the string pointed to by s1.
     
     
     
# D.11.3.2 The strncat function
     
N-->   The number of characters that may end up in the array pointed  to
N-->   by s1 is strlen(s1)+n+1.
     
N-->   Forward references: the strlen function (#D.11.6.3).
     
     
     
# D.11.4 {Length and -->} Comparison functions
     
     
     
# D.11.4.1 The memcmp function
     
N-->   The contents of "holes" used as padding for purposes of alignment
N-->   within  structure  objects are indeterminate, unless the contents
N-->   of the entire object have been set explicitly by  the  calloc  or
N-->   memset function.  Unions and strings shorter than their allocated
N-->   space may also cause problems in comparison.
     
     
     
# D.11.5.1 The memchr function
     
  *    The memchr function locates the first occurrence of c {-->  (con-
       verted  to  an unsigned char)} in the initial n characters of the
       object pointed to by s.
     
     
     
# D.11.5.2 The strchr function
     
  *    The strchr function locates the first occurrence of c {-->  (con-
       verted to a char)} in the string pointed to by s.
     
Remark: And the same change for strrchr (#D.11.5.5).
     
     
     
# {--> D.11.5.7 The strstr function}
     
N-->   Synopsis
     
N-->               #include <string.h>
N-->               char *strstr(const char *s1, const char *s2);
     
N-->   Description
     
N-->   The strstr function locates the first occurrence  of  the  string
N-->   pointed to by s2 in the string pointed to by s1.
     
N-->   Returns
     
N-->   The strstr function returns a pointer to the located string, or a
N-->   null pointer if the string is not found.
     
     
     
# {D.11.5.7 --> D.11.5.8} The strtok function
     
<--O   The strtok function considers the string pointed to by s1 to con-
<--O   sist of a sequence of zero or more text tokens separated by spans
<--O   of one or more characters from the string pointed to by s2.
     
N-->   A sequence of calls to the  strtok  function  breaks  the  string
N-->   pointed to by s1 into a sequence of tokens, each of which is del-
N-->   imited by a character from the string  pointed  to  by  s2.   The
N-->   first  call  in the sequence has s1 as its first argument, and is
N-->   followed by calls with a null pointer as their first argument.
     
       The separator string pointed to by s2 may be different from  call
       to call.
     
N-->   The first call in the sequence searches s1 for the first  charac-
N-->   ter that is NOT contained in the current separator string s2.  If
N-->   no such character is found, there are no tokens in  s1,  and  the
N-->   strtok  function  returns a null pointer.  If such a character is
N-->   found, it is the start of the first token.
     
N-->   The strtok function then searches from there for a character that
N-->   IS contained in the current separator string.  If no such charac-
N-->   ter is found, the current token extends to the end of the  string
N-->   pointed  to by s1, and subsequent searches for a token will fail.
N-->   If such a character is found, it is overwritten by a null charac-
N-->   ter,  which  terminates  the  current token.  The strtok function
N-->   saves a pointer to the following character, from which  the  next
N-->   search for a token will start.
     
N-->   Each subsequent call, with a null pointer as  the  value  of  the
N-->   first  argument,  starts  searching  from  the  saved pointer and
N-->   behaves as described above.
     
<--O   The first call to the strtok function returns a  pointer  to  the
<--O   initial character of the first token, and will have written a NUL
<--O   character into s1 immediately following the returned token.  Each
<--O   subsequent  call  (with the value of the first argument null) re-
<--O   turns a pointer to a subsequent token.  When no token remains  in
<--O   s1, the strtok function returns a null pointer.
     
N-->   The strtok function returns a pointer to the first character of a
N-->   token, or a null pointer if there is no token.
     
     
     
# {D.11.5.7 --> D.11.5.8} The strtok function
     
N-->   Example
     
N-->         #include <string.h>
N-->         static char str[] = "?a???b,,,#c";
N-->         char *t;
     
N-->         t = strtok(str, "?");   /* t points to the token "a" */
N-->         t = strtok(NULL, ",");  /* t points to the token "??b" */
N-->         t = strtok(NULL, "#,"); /* t points to the token "c" */
N-->         t = strtok(NULL, "?");  /* t is a null pointer */
     
     
     
# {--> D.11.6 Miscellaneous functions}
     
     
     
# {D.11.2.2 --> D.11.6.1} The memset function
     
  *    The memset function copies the value of c ({cast  -->  converted}
  *    to  an unsigned char) into each of the first n {bytes --> charac-
       ters} of the object pointed to by s.
     
     
     
# {--> D.11.6.2 The strerror function}
     
N-->   Synopsis
     
N-->               #include <string.h>
N-->               char *strerror(int errnum);
     
N-->   Description
     
N-->   The strerror function maps the error number in errnum to an error
N-->   message string.
     
N-->   Returns
     
N-->   The strerror function returns a pointer to the string,  the  con-
N-->   tents  of which are implementation-defined.  The array pointed to
N-->   is not modifiable by the program, but may  be  overwritten  by  a
N-->   subsequent call to the strerror function.
     
     
     
# {D.11.4.3 --> D.11.6.3} the strlen function
     
       The strlen function computes the length of the string pointed  to
  *    by s {, not counting the terminating NUL character -->}.  ...
     
  *    The strlen function returns the number of {initial  -->}  charac-
  *    ters {--> that precede the terminating null character}.
     
     
     
# D.12.1 Components of time
     
       Many functions deal with a "calendar time"  that  represents  the
  *    current  date  {-->  (according  to  the Gregorian calendar)} and
       time.
     
     
     
# D.12.1 Components of time
     
  *                int tm_mon;    /* {month of the year -->
                         months since January} - [0, 11] */
     
       ...
  *                int tm_yday;   /* {day of the year -->
                         days since January 1} - [0, 365] */
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:32:04 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6575
          for JMS@ARIZMIS; Wed, 21-MAY-1986 11:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024378; 20 May 86 19:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014528; 20 May 86 19:01 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#19
Message-ID: <1057@hou2d.UUCP>
Date: 15 May 86 17:33:20 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  19
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 9 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 9 of 9
To: utzoo!ihnp4!hou2d!osd
     
# {E.5.2 --> E.6.2} Undefined behavior
     
N-->   * An attempt is made to modify a string literal (#C.1.1.4).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
<--O   * The value of a constant is not representable (#C.1.3).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
N-->   * For a function call with no function  prototype  declarator  in
N-->     scope, the number of arguments or their types after the default
N-->     argument conversions do not match those of the  formal  parame-
N-->     ters (#C.3.2.2).
     
N-->   * A function that accepts  a  variable  number  of  arguments  is
N-->     called,  but  no prototype declarator wth the ellipsis notation
N-->     is in scope (#C.3.2.2).  ...
     
N-->   * A function that accepts a variable number of arguments  is  de-
N-->     fined without the ellipsis notation (#C.7.1).
     
N-->   * A function prototype is in scope when a  function  is  defined,
N-->     but  a semantically equivalent prototype is not in scope every-
N-->     where the function is called (#C.7.1).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
N-->   * The result of the preprocessing concatenation  operator  ##  is
N-->     not a valid token (#C.8.3).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
  *    * A {--> library} function argument has an invalid value,  unless
  *      the behavior is specified explicitly (#{D.1.1 --> D.1.3}).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
  *    * The value of {a register variable --> an  object  of  automatic
         storage  class  that  does  not  have  volatile  type} has been
         changed bwteen a setjmp and longjmp call (#D.6.2.1).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
N-->   * The type of the actual next argument  in  a  variable  argument
N-->     list  disagrees  with  the  type  specified by the va_arg macro
N-->     (#D.8.1.2).
     
N-->   * A return occurs from a function with a variable  argument  list
N-->     initialized by the va_start macro before the va_end function is
N-->     invoked (#D.8.1.3).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
N-->   * A single conversion by the fprintf function produces more  than
N-->     509 characters of output (#D.9.6.1).  ...
     
N-->   * A single conversion by the fscanf function consumes  more  than
N-->     509 characters of input (#D.9.6.2).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
N-->   * The ungetc function is called twice on the same stream  without
N-->     an intervening read, fflush, fseek, or rewind operation on that
N-->     stream (#D.9.7.11).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
<--O   * When called by the exit function, a function registered by  the
<--O     onexit function fails to return the value returned by the onex-
<--O     it function at the time of registration (#D.10.4.2).
     
     
     
# {E.5.2 --> E.6.2} Undefined behavior
     
  *    * The result of {the abs --> an integer arithmetic} function {-->
  *      (abs,  idiv,  or  ldiv)}  cannot  be represented (#{D.5.6.1 -->
         D.10.6}).
     
     
     
# {E.5.3.3 --> E.6.3.3} Characters
     
N-->   * The {correspondence --> mapping} of characters  in  the  source
N-->     character set {--> in character constants} to characters in the
N-->     execution character set {--> (#C.1.3.4)}.
     
     
     
# {E.5.3.5 --> E.6.3.5} Floating point.
     
<--O   * The direction of  truncation  when  a  negative  floating-point
<--O     number is converted to an integer (#C.2.1.3).
     
     
     
# {E.5.3.5 --> E.6.3.5} Floating point.
     
<--O   * Whether the presence in an expression of a float operand but no
<--O     double operand requires the operands to be converted to double.
     
     
     
# {E.5.3.11 --> E.6.3.11} Preprocessing {control lines --> direc-
tives}
     
N-->   * Whether white space between tokens in a macro argument used  to
N-->     create  a  string literal is retained in the string or replaced
N-->     by a single space character (#C.8.3).
     
     
     
# {E.5.3.12 --> E.6.3.12} Library functions
     
N-->   * The null pointer constant  to  which  the  macro  NULL  expands
N-->     (#D.1.1).
     
     
     
# {E.5.3.12 --> E.6.3.12} Library functions
     
N-->   * The effect if the program redefines a reserved  external  iden-
N-->     tifier (#D.1.2).
     
     
     
# {E.5.3.12 --> E.6.3.12} Library functions
     
  *    * The sets of characters tested for by the  {-->  isalnum,  isal-
  *      pha,}  iscntrl, {--> islower}, isprint, {--> and isupper} func-
         tion (#D.3.1).
     
     
     
# {E.5.3.12 --> E.6.3.12} Library functions
     
N-->   * The values returned by the mathematics functions on domain  er-
N-->     rors (#D.5).
     
     
     
# {E.5.3.12 --> E.6.3.12} Library functions
     
N-->   * Whether a text line containing only a  single  space  character
N-->     plus  a terminating new-line character is converted on input to
N-->     a line consisting only of the  terminating  new-line  character
N-->     (#D.9.2).
     
N-->   * The characteristics of file buffering (#D.9.3).
     
N-->   * Whether a zero-length file actually exists (#D.9.3).
     
     
     
# {E.5.3.12 --> E.6.3.12} Library functions
     
N-->   * The contents of the  error  message  strings  returned  by  the
N-->     strerror function (#D.11.6.2).
     
     
     
# {E.5.3.12 --> E.6.3.12} Library functions
     
<--O   * The era for the time function (#D.12.3).
     
     
     
# {E.5.4 --> E.6.4} Common extensions
     
N-->   The inclusion of any extension that may cause a strictly conform-
N-->   ing  program  to become invalid renders an implementation noncon-
N-->   forming.  Examples of such extensions are  new  keywords,  prede-
N-->   fined  macro  names,  or library functions with names that do not
N-->   begin with an underscore.
     
     
     
# {--> E.6.4.1 Environment arguments}
     
N-->   In a hosted environment, the main function receives a third argu-
N-->   ment,  char  *envp[],  that  points to a null-terminated array of
N-->   pointers to char, each of which points to a string that  provides
N-->   information  about the environment for this execution of the pro-
N-->   cess (#B.1.2.2).
     
Remark: With this inserted subsection, the other  subsections  of
this section are renumbered.
     
     
     
# {E.5.4.4 --> E.6.4.5} Writable string literals
     
<--O   String literals are arrays of char,  not  arrays  of  const  char
<--O   (#C.1.4).
     
N-->   String literals are modifiable.  Identical string literals  shall
N-->   be distinct (#C.1.4).
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:32:54 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5907
          for JMS@ARIZMIS; Wed, 21-MAY-1986 11:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024298; 20 May 86 19:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014489; 20 May 86 19:00 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#13
Message-ID: <1051@hou2d.UUCP>
Date: 15 May 86 17:29:50 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  13
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 3 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 3 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.9.4.4 The tmpnam function
     
  *    If the argument is not {null --> a null pointer}, it  is  assumed
  *    to  point to an array of at least L_tmpnam {bytes --> characters}
       ...
     
     
     
# D.9.5.2 The fflush function
     
       The fflush function causes any  unwritten  data  for  the  output
  *    stream  pointed to by stream to be {--> delivered to the host en-
       vironment to be} written to the file.
     
     
     
# D.9.5.3 The fopen function
     
  *    "w": create text file for  writing,  or  truncate  {-->  to  zero
       length}.
     
Remark: The same change for "wb", "w+", and "w+b".
     
     
     
# D.9.5.3 The fopen function
     
       However, output may not be directly followed by input without  an
  *    intervening  {--> fflush,} fseek, or rewind, and input may not be
  *    directly followed by output without an intervening {-->  fflush,}
       fseek,  or  rewind, unless the input operation encounters end-of-
       file.
     
     
     
# D.9.5.3 The fopen function
     
<--O   After the write operation, the file pointer  is  repositioned  at
<--O   the end of the output file and the buffer is flushed.
     
     
     
# D.9.5.3 The fopen function
     
N-->   When opened, a stream is fully buffered if and only  if  it  does
N-->   not refer to an interactive device.
     
     
     
# D.9.5.4 The freopen function
     
       The primary use of freopen is ...  with ...   stderr,  stdin,  or
  *    stdout  ..., as those identifiers need not be {lvalue expressions
       --> modifiable lvalues} (that may be assigned  to  by  the  fopen
       function).
     
     
     
# D.9.5.5 The setbuf function
     
<--O   The setbuf function is used after the stream pointed to be stream
<--O   has  been  associated  with an open file but before it is read or
<--O   written.  It causes the array pointed to by buf to  be  used  in-
<--O   stead  of  an  automatically  allocated buffer.  If buf is a null
<--O   pointer, input/output on that stream will  be  completely  unbuf-
<--O   fered.  The macro BUFSIZ specifies the size in bytes of the array
<--O   that is needed.
     
<--O   The standard stream stdout is normally buffered if  and  only  if
<--O   the  output  does  not  refer  to a terminal; this default may be
<--O   changed by setbuf.  The standard stream stderr is by default  un-
<--O   buffered  unconditionally;  setbuf will set the state to whatever
<--O   is desired.  When an output stream is unbuffered, information ap-
<--O   pears  on  the  destination  file or terminal as soon as written;
<--O   when it is buffered, characters are saved up  and  written  as  a
<--O   block.
     
<--O   ...  The buffer must have a lifetime at least  as  great  as  the
<--O   open  stream, so a stream must be closed before a buffer that has
<--O   automatic storage duration is deallocated upon block exit.
     
N-->   Except  that  it  returns  no  value,  the  setbuf  function   is
N-->   equivalent to the setvbuf function invoked with the values _IOFBF
N-->   for type and BUFSIZ for size, or (if buf is a null pointer), with
N-->   the value _IONBF for type.
     
     
     
# D.9.5.6 The setvbuf function
     
                   int setvbuf(FILE *stream, char *buf, int type,
  *                        {int --> size_t} size);
     
     
     
# D.9.5.6 The setvbuf function
     
  *    The setvbuf function {is --> may be} used after the stream point-
       ed  to by stream has been associated with an open file but before
       it is read or written.
     
     
     
# D.9.5.6 The setvbuf function
     
  *    ...  _IOFBF causes input/output to be fully buffered {, if possi-
  *    ble  -->};  _IOLBF  causes input/output to be line buffered {, if
       possible -->} ...; _IONBF causes input/output  to  be  completely
  *    unbuffered {, if possible -->}.
     
     
     
# D.9.5.6 The setvbuf function
     
  *    If buf is not a null pointer, the array it points  to  {will  -->
       may}  be  used instead of an automatically allocated buffer.  ...
  *    {--> The contents of the array at any time are indeterminate.}
     
       ...  The buffer must have a lifetime at least  as  great  as  the
  *    open  stream,  so the stream {must --> should} be closed before a
       buffer that has automatic storage duration  is  deallocated  upon
       block exit.
     
     
     
# D.9.5.6 The setvbuf function
     
       The setvbuf function returns non-zero  if  an  invalid  value  is
  *    given  for  type  or  size  {-->,  or  if  the  request cannot be
       honored}.
     
     
     
# D.9.6.1 The fprintf function
     
  *    An optional decimal  {digit  string  -->  integer}  specifying  a
       minimum  "field  width".   ...  The padding is with spaces unless
  *    the field width {digit string --> integer} starts with a zero, in
       which case the padding is with zeros.
     
  *    An {--> optional} "precision" ...  The precision takes  the  form
  *    of  a  period  (.)  followed  by an {--> optional} decimal {digit
  *    string  --> integer}; {a null digit string --> if the integer  is
       omitted, it} is treated as zero.
     
     
     
# D.9.6.1 The fprintf function
     
       An optional h specifying that a following ...  conversion specif-
       ier  applies  to  a short int or unsigned short int argument (the
       argument will have been promoted ...   and  its  value  shall  be
  *    {cast  --> converted} to a short int or unsigned short int before
       printing) ...
     
     
     
# D.9.6.1 The fprintf function
     
  *    c       The {least significant byte of the -->} int  argument  is
  *            converted to a {character --> char}, and {--> the result-
               ing character is} printed.
     
     
     
# D.9.6.1 The fprintf function
     
<--O   If the character after the % is not a valid conversion specifier,
<--O   the behavior is undefined.
     
N-->   If the conversion specifier is a lower-case letter  that  is  not
N-->   described  above,  the  behavior is undefined.  If the conversion
N-->   specifier is any other character that is not described above, the
N-->   behavior is implementation-defined.
     
     
     
# D.9.6.1 The fprintf function
     
  *           {--> #include <stdio.h>}
                   fprintf(stdout, "%s, %s %d, %.2d:%.2d\n",
                         weekday, month, day, hour, min);
     
       ...
     
                   #include <math.h>
  *           {--> #include <stdio.h>}
                   fprintf(stdout, "pi = %.5f\n", 4 * atan(1.0));
     
     
     
# D.9.6.2 The fscanf function
     
  *    Conversion specifications, consisting {--> in  sequence}  of  the
       character  %,  an optional assignment-suppressing character *, an
  *    optional {numerical --> decimal integer that specifies the}  max-
       imum field width, ...
     
     
     
# D.9.6.2 The fscanf function
     
       ...  The following conversion specifiers are valid:
     
  *    d       An {--> optionally signed} decimal integer  is  expected;
               ...
     
     
     
# D.9.6.2 The fscanf function
     
  *            ...  the {subsequent --> corresponding} argument shall be
               a pointer to integer.
     
Remark: This change is made throughout the section.
     
     
     
# D.9.6.2 The fscanf function
     
<--O   i       An integer is expected; the subsequent argument must be a
<--O           pointer  to  integer.  The input is interpreted as an in-
<--O           teger constant, with an optional sign prefix and  an  op-
<--O           tional  integer  suffix.   If the input field begins with
<--O           the characters 0x or 0X, the field is taken as a  hexade-
<--O           cimal integer.  Otherwise, if the input field begins with
<--O           the character 0, the field is taken as an octal  integer.
<--O           Otherwise, the input field is taken as a decimal integer.
     
N-->   i       An integer is expected; the corresponding argument  shall
N-->           be  a  pointer  to  integer.   The  input  format  is  as
N-->           described for the strtol function, with the value  0  for
N-->           the base argument.
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:29:24 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5643
          for JMS@ARIZMIS; Wed, 21-MAY-1986 12:01 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024277; 20 May 86 19:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014477; 20 May 86 18:59 EDT
From: Orlando Sotomayor-Diaz <osd%hou2d.uucp@BRL.ARPA>
Newsgroups: mod.std.c
Subject: mod.std.c Digest V16#12
Message-ID: <1050@hou2d.UUCP>
Date: 15 May 86 17:29:13 GMT
Approved: osd@hou2d.UUCP
To:       info-c@BRL-SMOKE.ARPA
     
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
     
     
mod.std.c Digest            Thu, 15 May 86       Volume 16 : Issue  12
     
Today's Topics:
         MORE C standard differences Apr85-Feb86, part 2 of 9
----------------------------------------------------------------------
     
Date:
From: ihnp4!utzoo!lsuc!msb
Subject: MORE C standard differences Apr85-Feb86, part 2 of 9
To: utzoo!ihnp4!hou2d!osd
     
# D.3.1 Character testing functions
     
  *    In an implementation that uses the {--> seven-bit} ASCII  charac-
       ter  set,  the  printing  characters  are  those whose values lie
  *    between 0x20 (space) and {0xFE -->  0x7E}  (tilde);  the  control
  *    characters  are  those whose values lie between 0 (NUL) and {0x17
  *    --> 0x1F} (US), and the character {0xFF --> 0x7F} (DEL).
     
     
     
# D.3.1.1 The isalnum function
     
  *    The isalnum function tests for any {letter or digit --> character
       for which isalpha or isdigit is true}.
     
     
     
# D.3.1.2 The isalpha function
     
  *    The isalpha function tests for  any  {letter  -->  character  for
       which  isupper  or  islower is true, or any of an implementation-
       defined set of characters for which  none  of  iscntrl,  isdigit,
       ispunct, or isspace is true}.
     
     
     
# D.3.1.6 The islower function
     
  *    The islower function tests for any lower-case letter {--> as  de-
       fined in #B.2.1, or any of an implementation-defined set of char-
       acters for which none of iscntrl, isdigit, ispunct, or isspace is
       true}.
     
Remark: Likewise for isupper (#D.3.1.10).
     
     
     
# D.3.1.8 The ispunct function
     
       The ispunct function tests  for  any  printing  character  except
  *    space  (' ') {, a digit, or a letter --> or a character for which
       isalnum is true}.
     
     
     
# D.3.2.1 The tolower function
     
       If the argument is an upper-case letter, the tolower function re-
  *    turns the corresponding lower-case letter {-->, if any}; ...
     
Remark: Likewise for toupper (#D.3.2.2).
     
     
     
# D.4 LIMITS {--> <float.h> and} <limits.h>
     
  *    The headers {--> <float.h> and} <limits.h> define several  macros
  *    that ...  were listed in {#B.2.4.1 --> #B.2.4.2}.
     
     
     
# D.5 MATHEMATICS <math.h>
     
       ...
     
                   HUGE_VAL
     
  *    which expands to a positive double expression  {-->,  not  neces-
       sarily representable as a float}.
     
     
     
# D.5.1 Treatment of error conditions
     
  *    On a domain error, the {int --> integer expression} errno {is set
       to  -->  acquires  the value of} the macro EDOM, and the function
  *    returns  {the  value  indicated  -->  an   implementation-defined
       value}.
     
Remark: The sentences that formerly  gave  the  value  that  each
function  returned  on a domain error are deleted, but I will not
list them individually.
     
     
     
# D.5.2.3 The atan function
     
  *    The atan function returns the arc tangent in the  range  {[-pi/2,
       pi/2] --> (-pi/2, pi/2)}.
     
Remark: In other words, the endpoints of the range are now impos-
sible.
     
     
     
# D.5.4.4 The log function
     
  *    A domain error occurs if the argument is {zero or -->}  negative.
  *    {--> A range error occurs if the argument is zero.}
     
Remark: Likewise for log10 (#D.5.4.5).
     
     
     
# D.5.6 {--> Nearest integer,} absolute value, {nearest  integer,
-->} and {modulo --> remainder} functions
     
Remark: The abs function is moved  from  #D.5.6.1  to  #D.10.6.1.
See  below.  The other functions' sections are renumbered accord-
ingly.
     
     
     
# D.6.1.1 The setjmp function
     
  *    {--> If the return is from a direct invocation,} the setjmp func-
  *    tion  returns  the value zero.  {--> If the return is from a call
       to the longjmp function, the setjmp function returns  a  non-zero
       value.}
     
     
     
# D.6.2.1 The longjmp function
     
       All accessible objects have values as of  the  time  longjmp  was
  *    called,  except  that the values of objects of {storage class re-
       gister --> automatic storage class  that  do  not  have  volatile
       type}  and have been changed between the setjmp and longjmp calls
       are indeterminate.
     
     
     
# D.7 SIGNAL HANDLING <signal.h>
     
  *    Additional signals, {--> with macro  definitions  beginning  with
       the letters SIG followed by an upper-case letter and} with signal
       numbers distinct from those listed, may also be specified  by  an
       implementation.
     
     
     
# D.7 SIGNAL HANDLING <signal.h>
     
N-->   The names of the  signal  numbers  reflect  the  following  terms
N-->   (respectively): abort, floating-point exception, illegal instruc-
N-->   tion, interrupt, segment violation, and termination.
     
Remark: Respectively, that's  SIGABRT,  SIGFPE,  SIGILL,  SIGINT,
SIGSEGV, and SIGTERM.
     
     
     
# D.7.1.1 The signal function
     
N-->   As the functions in the standard library are not guaranteed to be
N-->   reentrant  and  may  modify objects with static storage duration,
N-->   they may not be used reliably in a signal handler that returns.
     
     
     
# D.8 VARIABLE ARGUMENTS <stdarg.h>
     
  *    The header <stdarg.h> declares a type {--> and  a  function}  and
  *    {-->  defines}  {several  --> two} macros for advancing through a
       list of arguments ...
     
     
     
# D.8 VARIABLE ARGUMENTS <stdarg.h>
     
       A function may be called with a variable number of  arguments  of
  *    varying types.  As described in {#C.7.1.1 --> #C.7.1}, its param-
       eter list contains one or more parameters.
     
     
     
# D.8.1 Variable argument list access macros {--> and function}
     
  *    The {capabilities --> va_start and va_arg  macros}  described  in
       this  section  shall  be implemented as macros, not as real func-
       tions.
     
Remark: Va_end is now allowed to be a function, and  this  change
applies throughout this section.
     
     
     
# D.8.1.2 The va_arg macro
     
  *    {--> If} the specified type {must agree --> disagrees}  with  the
       type  of the actual next argument (as promoted ...  into int, un-
  *    signed int, or double) {-->, the behavior is undefined}.
     
     
     
# D.8.1.2 The va_arg macro
     
N-->   The first invocation of  the  va_arg  macro  after  that  of  the
N-->   va_start  macro  returns  the  value  of  the argument after that
N-->   specified by parmN.  Successive invocations return the values  of
N-->   the remaining arrguments in succession.
     
     
     
# D.8.1.3 The va_end {macro --> function}
     
  *    The va_end function {performs any processing so that -->  facili-
  *    titates} a normal return {may safely occur -->} from the function
       whose variable argument list was referenced by the  expansion  of
  *    va_start  that  initialized  the  va_list  ap.  ...  {--> If} the
  *    va_end function {must be --> is not} invoked {after all arguments
       have  been  accessed --> before the return, the behavior is unde-
       fined}.
     
     
     
# D.9.1 Introduction
     
       ...
     
                   _IOFBF
     
       which expands to an integral constant  expression,  suitable  for
  *    use  as the third argument to the setvbuf function {, to indicate
       that full buffering is desired -->}.
     
Remark: The analogous phrases are deleted from  the  descriptions
of _IOLBF, _IONBF, SEEK_CUR, SEEK_END, and SEEK_SET.
     
     
     
# D.9.1 Introduction
     
     
       ...
     
                   SYS_OPEN
     
       which expands to an integral  constant  expression  that  is  the
  *    minimum  number of files that {may --> the implementation guaran-
       tees can} be open simultaneously.
     
     
     
# D.9.2 Streams
     
  *    A text stream is an ordered sequence of  {bytes  -->  characters}
       composed into "lines" ...
     
  *    A binary stream is an ordered sequence of {bytes -->  characters}
       that can transparently record internal data.
     
     
     
# D.9.2 Streams
     
N-->   Whether a text line containing only a single space character plus
N-->   a  terminating new-line character is converted on input to a line
N-->   consisting  only  of  the  terminating  new-line   character   is
N-->   implementation-defined.
     
     
     
# D.9.3 Files
     
       If a file can support positioning  requests  ...   then  a  "file
  *    {pointer  -->  position indicator}" associated with the stream is
       ...
     
Remark: This change of terminology applies  throughout  the  sec-
tion.
     
     
     
# D.9.3 Files
     
N-->   When a stream is unbuffered, characters are  intended  to  appear
N-->   from the source or at the destination as soon as written.  When a
N-->   stream is fully  buffered,  characters  may  be  accumulated  and
N-->   transmitted  to  or  from  the host environment as a block when a
N-->   buffer is filled.  When a stream is line buffered, characters may
N-->   be accumulated and transmitted to or from the host environment as
N-->   a block when a new-line character is encountered or when a buffer
N-->   is  filled.  Support for these characteristics is implementation-
N-->   defined, and may be controlled via the setbuf and  setvbuf  func-
N-->   tions.
     
     
     
# D.9.3 Files
     
N-->   Whether a file of zero length (on which no characters  have  been
N-->   written  by  an output stream) actually exists is implementation-
N-->   defined.
     
     
     
# D.9.3 Files
     
  *    At program startup, three text {files --> streams} are {open  -->
       predefined and need not be opened explicitly} -- "standard input"
  *    ...  "standard output" ...  and "standard error" ...   {-->  When
       opened,  the  standard  streams are fully buffered if and only if
       the stream does not refer to an interactive device.} ...
     
     
     
# D.9.4.1 The remove function
     
  *    The remove function returns {--> zero if the operation succeeds,}
  *    non-zero if {the operation --> it} fails.
     
     
     
# D.9.4.2 The rename function
     
  *    The rename function returns {--> zero if the operation succeeds,}
  *    non-zero  if  {the operation --> it} fails {-->, in which case if
       the file existed previously it is still  known  by  its  original
       name}.
     
N-->   Among the reasons the implementation may cause the  rename  func-
N-->   tion  to  fail  are  if the file is open or if it is necessary to
N-->   copy its contents to effectuate its renaming.
     
     
     
# D.9.4.4 The tmpnam function
     
  *    The tmpnam function generates a string that {can safely  be  used
       as  the name of a temporary --> is not the same as the name of an
       existing} file.
     
  *    ...  a different {file name --> string} each time  it  is  called
  *    {-->  up  to  TMP_MAX  times.   If it is called more than TMP_MAX
       times, the behavior is implementation-defined}.
     
  *    ...  The value of the macro TMP_MAX {specifies the minimum number
       of unique names that must be generated by the tmpnam function be-
       fore any names repeat, which -->} shall be at least 25.
     
------------------------------
     
End of mod.std.c Digest - Thu, 15 May 86 13:28:42 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8848
          for JMS@ARIZMIS; Wed, 21-MAY-1986 14:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/21/86 at 15:57:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024038; 20 May 86 19:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014100; 20 May 86 18:44 EDT
From: david%ukma.uucp@BRL.ARPA
Newsgroups: net.lang.c,net.micro.pc,net.unix
Subject: Re: allocating arrays
Message-ID: <3423@ukma.UUCP>
Date: 14 May 86 14:29:15 GMT
Xref: brl-sem net.lang.c:1120 net.micro.pc:1202 net.unix:735
To:       info-c@BRL-SMOKE.ARPA
     
     
[My mailer doesn't know anything about dg_rtp.UUCP, could you please
let uucpmap@cbosgd know of your existance????]
     
In article <350@dg_rtp.UUCP> you write:
>> allbery@ncoast.UUCP (Brandon Allbery)
>
>> | Consider an array of 15 pointers to arrays of doubles:
>> |     double (*parray[15])[];
>> | The following code to 'malloc' the actual double array barfs on Microsoft
 'C',
>> | with a 'different levels of indirection' warning on the '='.
>> | The code passes through LINT, and compiles OK on UN*X 5.2
>> |     char    *malloc();
>> |     parray[0] = (double*)malloc((unsigned)sizeof(double)*75);
>
>> double (*parray[15])[]; means:
>>       an indefinitely-sized array of (or a pointer to)
>>               an array of 15
>>                       (double *)
>
>Wrong.  It means just what the original poster said it meant.  It is an
>array of 15 pointers to arrays of double.  What the original poster is
>mistaken about is that lint doesn't complain about the example.  In
>particular, given this example
     
I respectively submit that you're full of it and that Brandon is correct.
     
Using []'s in a declaration is SIMILAR to declaring a pointer, 'cept
that the pointer is an internal constant in the compiler, and if you
fill in a value inside the []'s it allocates some space.  A stumbling
point is when a [] declaration is an arg to a function, THAT gets
translated to a * declaration...
     
Some examples:
     
        char a[] = "this is a character string\n";
        char b[];
     
(oh, they're both external decl's)  Tell me tho, what USE is a
the declaration of b[]????  Translating the decl to *b isn't
doing what I SAY, and (on Unix anyway) what I SAY is what I MEAN.
Anyway, compiling I get:
     
        Undefined:
        _main
        _b
     
_main is undefined because I don't have a main() obviously.
_b is undefined because it knew that somewhere there's a b[]
and made a reference to it.
     
Modifying it to read:
     
char a[] = "this is a character string\n";
main()
{
        char b[], *c;
        char *malloc();
     
        printf("b = 0x%x\n", b);
        /* b = */ c = malloc(5);
        printf("b = 0x%x, c = 0x%x\n", b, c);
}
     
produces:
     
        b = 0x7fffe880
        b = 0x7fffe880, c = 0x2800
     
(BTW, this is a Vax running 4.2BSD, and we have the "hated" pcc,
a value like the one for b is a stack location)
     
Originally I had the b[] decl by itself and the compiler swallowed it.
(I have no idea what the compiler thought I wanted to do with a b[]...)
But it didn't like it when I had the b = uncommented...  (which is
what I'd expect).  Looking at the assembler output, b[] is a pointer
to the top of the stack but there's no space allocated to it.  There's
only space allocated for the *c.
     
>
>        void f(){
>            double (*a[15])[];
>            char *malloc();
>            a[0] = (double *)malloc((unsigned)sizeof(double)*75);
>        }
>lint (on our system at least) says
>        warning: illegal pointer combination
>            (4)
     
Right.  the pcc says "illegal lhs" or something to that effect.  Which
is correct... there's no space allocated to your a.
     
>
>I grant you, this isn't very informative, but lint *doesn't* like it,
>that much is certain.  Let's run a more blabbermouth tool over it.
>
        ... [deleted, for the sake of brevity, some very interesting output]
>
>As you can see, this is an attempt to assign a pointer-to-double to a
>pointer-to-array-of-double.  In this case, it is easy to tell that this
>is what is going on even without blabbermouth typecheckers.  The
>declaration of a is of the form (*[])[], making the type of a[0] (*)[],
>a pointer to an array.  The cast of the return value of malloc was
>simply *, that is, a simple pointer.  If you want your compiler to shut
>up, you should make the cast read (double (*)[]).  When the cast is
>changed in this way, lint no longer complains.  Changing the cast to
>(double **) naturally still causes complaint.
     
er... where did you get that program?  I agree with it somewhat EXCEPT
it's not making a distinction about CONSTANT pointers a la arrays. It's
an interesting program nonetheless...
     
I agree with you that the compilers need to produce better error messages.
     
     
--
David Herron,  cbosgd!ukma!david, david@UKMA.BITNET, david@uky.csnet

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2903
          for JMS@ARIZMIS; Wed, 21-MAY-1986 23:21 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/22/86 at 01:04:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024453; 20 May 86 19:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014845; 20 May 86 19:12 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.unix-wizards
Subject: Re: arguments in registers
Message-ID: <743@steinmetz.UUCP>
Date: 14 May 86 17:11:37 GMT
Xref: brl-sem net.lang.c:1125 net.unix-wizards:1249
To:       info-c@BRL-SMOKE.ARPA
     
In article <109@ima.UUCP> johnl@ima.UUCP (John R. Levine) writes:
>In article <1205@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>>In article <155@cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>>>[Passing arguments in registers] would be fine if C had nested
>>>procedures or inlines or something, but a disaster otherwise.
>>
     
The original "B" compiler for the GECOS operating system passed the first
two arguments in registers and it worked fine. There are no inherent
limitations, and it makes the code run much faster.
     
Someone doing software metrics told me that 90% of the procedure calls in
UNIX source code use <3 arguments, and running over about 50k lines of
code by people at our site it looks as if that's true, even more so if you
eliminate printf, which hopefully isn't called as often as the internal
routines.
     
There are three cases of action if the first N arguments are passed in
registers:
 a) the values are never stored in memory and the procedure runs faster.
 b) the values are stored in memory when needed to preserve them during a
procedure call, or when the registers are required for inline code.
 c) the compiler just stores the value in memory (stack of course) and
goes on as if the calling program had done it.
     
Note that in the worst case, the code to save the values has been moved
from the calling routines to the called routine, making the code smaller,
if not faster.
     
In 1972 I produced a language called IMP from the original B, and it ran
on the GE 600 series and the INtel 8080 (and could cross compile in either
direction). If it can be done on an 8080, it can be done anywhere. The
code was smaller and faster than that produced by any C compiler I've ever
seen for the 8080, due in part to the frequent occurence of case (a)
above, where the values were never stored.
--
    -bill davidsen
     
    seismo!rochester!steinmetz!--\
       /                               \
ihnp4!              unirot ------------->---> crdos1!davidsen
       \                               /
        chinet! ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3033
          for JMS@ARIZMIS; Wed, 21-MAY-1986 23:32 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024518; 20 May 86 20:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014864; 20 May 86 19:13 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.apl
Subject: Nial, an extended apl
Message-ID: <1571@ecsvax.UUCP>
Date: 16 May 86 15:27:43 GMT
Xref: brl-sem net.lang.c:1126 net.lang.apl:20
To:       info-c@BRL-SMOKE.ARPA
     
I've been playing lately with the Nested Interactive Array Language NIAL
(pronounced "kneel").  It allows arrays to contain other arrays of
arbitrary type and dimensionality.  It uses the normal ASCII character
set and has about a billion reserved words.  It also has the structural
features missing from APL.  (Anyone who thinks APL primitives in clever
combinations are all-powerful is invited to write a program to compute
a determinant in apl.  And don't try to weasel out by insisting
determinants are a Bad Thing.)
     
The version I'm using (Q'Nial on an IBM PC) cleverly displays the
structure of arrays by means of boxes drawn with the IBM extended
character set.  Using conventional ASCII, this means that if I type in
the statement
    ("Tom 17)("Dick 9)("Harry 44)
I see something like this:
    +-------------------+-----------------+--------------------+
    | +---------+-----+ | +---------+---+ | +----------+-----+ |
    | |  Tom    | 17  | | |  Dick   | 9 | | | Harry    | 44  | |
    | +---------+-----+ | +---------+---+ | +----------+-----+ |
    +-------------------|-----------------+--------------------+
     
Here's a Nial program:
     
    fibonacci IS OPERATION N {
        Fiblist get 0 1 ;
        WHILE last Fiblist < N DO
            (last Fiblist +
            last front Fiblist);
        ENDWHILE ;
    front Fiblist }
     
Yes, it does look like an unholy union of APL, Lisp, and C.  And that's
not a bad description.  I like the structured programming constructs and
the ability to apply operators to even user-defined functions
("transformers" to user-defined "operators" in Nial terminology).  I
don't like the long list of reserved words (worse than Cobol), the
confusing rules about how deeply into a structure an operator reaches,
the equally confusing rules on precedence of monadic and dyadic
operators (and the fact that ALL operators can be used in monadic or
dyadic form; that is, + 1 2 is the same as 1 + 2!).
     
Nial exists mainly as an expression of the nested rectangular array
theory of Trenchard More.  I don't know that it's of much value as a
practical language right now, but there is some promise for the
future.  If you'd like more information try writing Nial Systems
Limited, 20 Hatter St, Kingston, Ontario K7M 2L5.  I'm not connected
with them.
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3142
          for JMS@ARIZMIS; Wed, 21-MAY-1986 23:37 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024530; 20 May 86 20:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015249; 20 May 86 19:27 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: What's wrong with printf() , exit() ?
Message-ID: <117@danews.UUCP>
Date: 11 May 86 12:31:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> What's wrong with
>     printf("usage: foo bar\n"), exit(1);
> as above?
>
     
Aside from style, exit is a statement syntatically but , requires
expressions.  The compilers I've used will accept this and do
what you'd expect.  Why is that ?  Is this a special exeption ?
     
Compilers may exist that won't accept it.  However, this:
     
    printf("uage: foo bar\n"), return 1 ;
     
generates a syntactic error message.  If a compiler accepts , exit()
why not , return ?  Maybe it's too complicated to do, and not worth the
trouble.
     
Some uses of , are transparent and useful.  Such as multiple initial-
izations in a for loop, e.g. for(i = 0 , j = 1; ...).  Doing all the
relevant initializations in one place is important.  Or in a while loop:
     
    while(readresp(CMD), command)
     
where readresp is a void function (and has to be) and command is side
affected several routines down.  Coding this without the , obscures the
code (at least to me).
     
--
     
Larry Cipriani        Nothing is worse than having
danews!lvc        an itch you can never scratch

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3219
          for JMS@ARIZMIS; Wed, 21-MAY-1986 23:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024532; 20 May 86 20:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015253; 20 May 86 19:28 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What's wrong with printf() , exit() ? (oops)
Message-ID: <118@danews.UUCP>
Date: 11 May 86 17:49:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I wrote:
>> What's wrong with
>>     printf("usage: foo bar\n"), exit(1);
>> as above?
>>
     
>Aside from style, exit is a statement syntatically but , requires
>expressions.  The compilers I've used will accept this and do
>what you'd expect.  Why is that ?  Is this a special exeption ?
     
Oops.  I mistakenly believed exit and return were both reserved words
in C but only return is.  There may be compilers that won't accept it
but they would be wrong.
     
    printf("usage: foo bar\n") , return 1 ;
     
seems reasonably "within C's style".  Comments ?
--
     
Larry Cipriani        Nothing is worse than having
danews!lvc        an itch you can never scratch

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3283
          for JMS@ARIZMIS; Wed, 21-MAY-1986 23:50 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024534; 20 May 86 20:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015261; 20 May 86 19:28 EDT
From: Lee Dickey <ljdickey%water.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Proliferation of operators (was: C Builtin Functions)
Message-ID: <372@water.UUCP>
Date: 16 May 86 12:33:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
There are several APL's that admit data with tree structure.
     
An older example of one of these is Honeywell's GCOS APL, which since
the early 70's ran on its 66 series machines, and now runs on its
DPS 8 line.
     
GCOS APL allows things of the sort
     
    a  <-  'now is the time'
    b  <-  'next one'
    c  <-  'the third'
    list  <-  (a;b;c)
     
and more.  A list may contain, as an element, any other list.
You can construct a tree.  Honeywell is not agressive in
marketing this product.
     
Today, there are two newer APL's that use strand notation,
APL2 and STSC's production APL.
Perhaps the best known of these is IBM's product:  APL2.
There, one uses "strand notation" and one types something like
     
    list2  <-  'now is the time'  'next one'  'the third'
     
or
     
    list2  <-  a b c
     
Of course, allowing this sort of statement introduces a lot
of power in the data, but introduces new complications in the
syntactic analyzer.
     
On the other hand, another new implementation is the one done
by I.P.Sharp Associates.  There one builds arrays in which
each element of the array is a scalar (same as in APL).  But
there are new primitives
called enclose and disclose.  The result of enclose is
always a scalar.  Disclose is a left inverse of enclose.
Then, for any data object, BLAT,
     
    BLAT <---> disclose enclose BLAT
     
A fourth implementation is NIAL (Nested Interactive Array Language)
developed by Mike Jenkins at Queens' University in Kingston.
His language runs on UN*X machines and on IBM PC's.
It appear to be a super set of APL, and uses keywords.
It has rooted trees, and it has Pascal like structured statements.
     
Perhaps the Sharp version is the most esthetically beautiful and has
the simplest theory.  The strand notation supported by APL2 may be
easier to use if the for trees are simple, but I am told that some
trees can not be modelled in this APL.  NIAL has the advantage
that it does not have to have a special keyboard, it has all
the power of APL, and it has structured control statements.
     
----------------
Yo pays yer money an' yo takes yer choice.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3341
          for JMS@ARIZMIS; Wed, 21-MAY-1986 23:54 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024623; 20 May 86 20:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015966; 20 May 86 19:56 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What's wrong with printf() , exit() ? (oops)
Message-ID: <5470@alice.uUCp>
Date: 17 May 86 04:22:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Oops.  I mistakenly believed exit and return were both reserved words
> in C but only return is.  There may be compilers that won't accept it
> but they would be wrong.
>
>    printf("usage: foo bar\n") , return 1 ;
>
> seems reasonably "within C's style".  Comments ?
     
return isn't an expression.  You can't write
     
    printf("usage: foo bar\n") , if (!fflag) exit(1);
     
either.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3420
          for JMS@ARIZMIS; Thu, 22-MAY-1986 00:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024625; 20 May 86 20:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015973; 20 May 86 19:56 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.unix,net.micro.att,net.lang.c
Subject: Re: query: argument passing on UNIX PC, VAX, et al
Message-ID: <5471@alice.uUCp>
Date: 17 May 86 04:25:45 GMT
Xref: brl-sem net.unix:749 net.micro.att:271 net.lang.c:1136
To:       info-c@BRL-SMOKE.ARPA
     
> I am interested in the precision used by various C compilers when
> passing arguments on the stack to a called routine.  For example:
>
>    some_routine_or_main()
>    {
>    char    a,b;
>
>    foo(a,b)
>    }
>
>    foo (a,b)
>    long a,b;
>
>    {
>    printf("%#lx\t%#lx\n", a, b);
>    }
>
> I tried a program similar to the above on a vax and a UNIX PC
> and in both cases the values of 'a' and 'b' were correctly
> passed.  Given that a long on both machines is 32 bits and a char
> is 8 bits, from this I assumed that both compilers are expanding
> 'a' and 'b' to 32 bits before putting them on the stack.  I might
> have expected this for the vax, but not for the UNIX PC (68000
> based).
     
The definition of C is that char or short arguments are expanded
to ints.  Both the VAX and UNIX PC (and the 3B machines, for that
matter) support 32-bit ints.  Since subscripts are ints rather than
longs, a machine that implements only 16-bit ints has a rather hard
time dealing with arrays with more than 32767 elements.  This
is, of course, often the case on little machines like PDP-11 or 8086.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3287
          for JMS@ARIZMIS; Tue, 27-MAY-1986 06:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 08:01:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010124; 27 May 86 8:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015938; 23 May 86 5:51 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: More extensions to C (was: Boolean Operators Slighted in C)
Message-ID: <1483@mmintl.UUCP>
Date: 20 May 86 22:54:02 GMT
Posted: Tue May 20 18:54:02 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <826@bentley.UUCP> kwh@bentley.UUCP writes:
>In article <2741@utcsri.UUCP> greg@utcsri.UUCP writes:
>>In article <602@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>>>3) Exchange operator. ...
>>
>>Good stuff. Even machines without an EXG can use a scratch register, which
>>is better than using a user-supplied temp.
>
>This could be considered a special case of my ",," operator: to exchange x
>and y, write "x = (y ,, (y = x))".
     
I would prefer a syntax like "{x, y} = {y, x};"  It's more readable.
     
(BTW, a really good optimizing compiler can optimize out the temporary.  I'm
not fully up on what optimizers are doing these days, but I doubt that there
are many compilers which do this.  Optimizing it out is easier if it is
declared locally ("{int temp = x; x = y; y = temp;}") instead of being
declared at the top of the routine.)
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3341
          for JMS@ARIZMIS; Tue, 27-MAY-1986 06:21 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 08:02:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009978; 27 May 86 8:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015918; 23 May 86 5:51 EDT
From: "Frank A. Adrian" <franka%mentor.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: YANO (Yet Another New Operator)
Message-ID: <304@apollo.mentor.UUCP>
Date: 16 May 86 22:13:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Yes, I know the purists don't want their langauge munged around,
but having been working on a program that uses several arrays of
linked lists, I was wondering about:
     
    (A very long computataion which gets you to a pointer) ->= next;
     
which of course is equivalent to
     
    (A...) = (A...)->next;
     
Of course, this would be checked by lint (or some of the newer cc's)
to make sure you are assiging a pointer field to the same type of
pointer.  With this construct, a nice list search could be written
as:
        for(x = foo; x && (x->key != key); x ->= next);
        /*           ^^^^^^^^^^^^^^^^^^^^ I know, non-portable, but it
                                          works for me                 */
        return x;
     
I know this is probably unnecessary for efficiency, as most optimizing
compilers will put the left hand side in a register, but it does increase
clarity in some cases, such as:
     
    a[x++] = a[x]->next; or a[x] = a[x++]->next;
     
I have trouble remembering in what order the increment takes
place. Is it before or after the assignment (No fair peeking in K&R!)?
The semantics of
     
    a[x++] ->= next;
     
is clear -- the increment takes place after the asignment.
     
In any case, I don't think that this would mung up the language
too bad, and comments about how tough it is to add "features" to
compilers don't bother me at all (I don't have to write them, I
just have to use them).
     
                Frank Adrian
                The opinions expressed here are
                in no way reflect those of ANY
                sane person or organization.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3551
          for JMS@ARIZMIS; Tue, 27-MAY-1986 06:48 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 08:21:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010335; 27 May 86 8:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016202; 23 May 86 5:59 EDT
From: ron@BRL-SEM.ARPA
Newsgroups: net.lang.c
Subject: Re: Infinite Loops
Message-ID: <185@brl-sem>
Date: 30 Apr 86 05:10:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Unless you have a very unique optimizer, it is usually better to use the
> for(;;) form rather than the while(1) form.  Reason is:  while(1) is
> ALWAYS evaluated (ie. : is 1 TRUE? if so, continue) before each iteration,
> whereas for(;;) compiles as a simple branch or jump instruction with no
> test and no conditional branch.
>
Crapola.  All the PCC impementations I've checked don't test the constant
even when you don't turn the optimizer on.  Our old PDP-11 Ritchie compiler
does generate the test, but the standard -O optimizer removes it.  Nothing
unique here.
     
-Ron

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3645
          for JMS@ARIZMIS; Tue, 27-MAY-1986 06:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 08:22:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010253; 27 May 86 8:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015942; 23 May 86 5:52 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: using indentation rather than braces
Message-ID: <1484@mmintl.UUCP>
Date: 20 May 86 23:05:03 GMT
Posted: Tue May 20 19:05:03 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <968@umd5.UUCP> zben@umd5.UUCP (Ben Cranston) writes:
>
>Forgive me if this is too obvious to mention, but it seems to me that using
>the indentation information makes life much harder for programs like YACC
>and LEX that act by creating C source code.  Now they have to keep track of
>what column they are outputting to...
     
This isn't all that hard.  Such programs must implicitly keep track of depth,
frequently by recursion.  Adding the additional machinery to make this
explicit is not bad.  One global variable, and update it every time you
enter or exit a block in the generated code.
     
>I just remember doing some assembly macros that tried to make their
>expansion obvious by "display"ing the code they were generating to the
>listing before actually generating it.  There was real gore in getting the
>columns lined up right, and in getting meaningful comments...
     
Dealing with such issues in the macro processing portion of an assembler is
another matter entirely.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3838
          for JMS@ARIZMIS; Tue, 27-MAY-1986 07:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 08:49:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010381; 27 May 86 8:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016918; 23 May 86 7:41 EDT
From: Roy Smith <roy%phri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <2355@phri.UUCP>
Date: 21 May 86 00:45:12 GMT
Posted: Tue May 20 20:45:12 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <1463@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
> Something which got forgotten in my original article: I would favor an
> exchange operator.  This one is quite frequently useful, and the
> alternatives are ugly.
     
    Why don't we just invent a new language?   We could call it PL/2.
--
Roy Smith, {allegra,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3953
          for JMS@ARIZMIS; Tue, 27-MAY-1986 07:27 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 08:57:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010478; 27 May 86 8:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016931; 23 May 86 7:42 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: void * (was Re: malloc())
Message-ID: <3717@sun.uucp>
Date: 20 May 86 18:36:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> So, although not necessarily synonyms, they ("char *" and "void *" - gh)
> do have the same properties, except that "char *" conversions usually
> require a cast to be acceptable.
     
Well,
     
    1) they don't have the same properties - if you dereference a
       "char *", you get a "char", while if you dereference a "void *",
       you get a "void", which means you can't dereference a "void *"
       without casting it to a pointer to some meaningful type (this,
       in answer to your question below, is presumably why "void *"
       was chosen)
     
    2) the fact that "char *" conversions require a cast is NOT a
       characteristic of the language, but a characteristic of the
       compiler/"lint".  A C compiler which never generated any
       warnings about pointer conversions would not be in violation
       of the language specification.
     
       As such, a C compiler could, if its author wanted it to,
       generate warning messages about "illegal pointer combination"
       and about "possible pointer alignment problem" for implicit
       conversions (i.e., conversions not involving casts) between
       "char *" and other pointers, and not generate them for
       implicit conversions between "void *" and other pointers.
       It could generate both warning messages for all implicit pointer
       conversions, and generate them for all explicit pointer
       conversions except those involving "void *".
     
       A compiler which did so would not assign "char *" and "void *"
       the same properties, since replacing objects of type "void *"
       with objects of type "char *" in some expressions would cause
       warnings to be issued.
     
> What I had in mind was that "ALIGN *" would be a synonym for "int *" or
> whatever happens to be the most restrictive pointer type.  The "guarantee"
> would be as good as the "guarantee" on an "int *".
     
I.e., not very good.  Again, you would have to trust "malloc" to know what
it was doing, just as you would have to do if it returned "void *".
Somewhere inside the guts of "malloc" there would probably be an conversion
of a "char *" to a "void *" or an "ALIGN *", and you'd have to hope that the
algorithm used by "malloc" guaranteed that the pointer being converted were
aligned properly.
     
> Well, what *is* the justification for adding "void *" to the language?  To
> allow people to shove pointers around without casts?
     
No.  One could allow people to shove pointers around with casts simply by
removing some warning messages from some current C compilers.
     
> To make lint shut up about malloc()?
     
In a sense, yes.  It also makes it possible to use "opaque pointers" without
getting complaints from the compiler.  We currently run our kernel through
"lint" before it goes out the door; the "lint" rules in the 4.2BSD kernel
"makefile" run the "lint" output through "egrep" to eliminate "possible
pointer alignment problem" messages, since there are a number of cases where
there are no such problems but we have no way to tell "lint" that.  If
"caddr_t" were "void *" instead of "char *", we wouldn't have to strip out
all "possible pointer alignment problem" messages; any that appeared would
indicate that there was a real problem in the code.
     
> Or just to distinguish "generic pointers" from pointers that can be
> dereferenced?  (Could be done with a typedef.  So could "void", but
> they put it in anyway.)
     
You can do "void" and "caddr_t" (or whatever you want to call a "generic
pointer") with "typedefs", but you can't make the compiler recognize their
unique properties that way.  If you do "typedef int void;", the compiler
will not recognize that casting something to "void" throws its argument
away, and certainly won't recognize that "void foo();" declares a function
which doesn't return a value.  If you declared "caddr_t foop;", the compiler
would let you dereference "foop" in an expression.
     
As such, I presume by "distinguish" you mean "distinguish *for the reader of
code*", not "distinguish for the compiler".  That is one thing you can use
"void *" to do, but it's not the only reason it was proposed.
     
> I do not strongly object to the addition of "void *", but I am worried about
> it "hiding" errors.  (I'm one of those purists who thinks that programmers
> *should* use casts to change types.)
     
Yes, if some compiler implementer misses the obvious, it could be used to
hide errors.  (Unfortunately, I've seen a lot of cases where implementers
miss the obvious.)  If one assumes that the current PCC/"lint" rules for
complaining about pointer conversions are correct, the correct extension of
those rules to "void *" is:
     
    implicit conversions to and from "void *" should generate
    "illegal pointer combination" warnings (although they need not
    give "possible pointer alignment problem" warnings)
     
    explicit conversions (i.e., conversions with casts) should not
    give any "possible pointer alignment problem" warnings; if you
    specify the "-c" flag to older "lint"s, or the "-p" flag to
    newer ones (both of which turn on the "complain about all pointer
    casts" flag - older versions give "illegal pointer combination"
    warnings, and newer ones give "pointer casts may be troublesome"),
    it should probably continue to give warnings.
     
This means that if you're going to toss pointers around casually, the
compiler is at least going to warn you about it; you have to say "I know
what I'm doing, shut up" by adding casts if you don't want errors.  In fact,
I would suggest that all conversions between pointers other than "void *"
should get "illegal pointer combination" (or, perhaps, "questionable pointer
combination", at least in some cases, since the C standard does permit
certain combinations) warnings, even if casts are used.
     
> Also, it's a misnomer; it has nothing to do with "void".
     
I presume the reason why "void *" was chosen is, as stated above, that a
pointer of type "void *" would, when dereferenced, yield an object of type
"void", and as such dereferencing a "void *" would be illegal, just as using
a function of type "void" as if it returned a value would be.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.arpa

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7690
          for JMS@ARIZMIS; Tue, 27-MAY-1986 14:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 15:54:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010532; 27 May 86 8:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017096; 23 May 86 7:46 EDT
From: Noemi Berry <noemi%moscom.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Structure initialization rules question
Message-ID: <696@moscom.UUCP>
Date: 21 May 86 12:21:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
    Why is it that you can only initialize structures when they are global
    (outside of main() )?  If you initialize a structure within a function
    you get an "No auto. aggregate initialization" error.  I don't see
    anywhere in K&R where the structure initialization rules are explained.
     
    e.g.:
     
*--------------------- Compiles
struct XX {
    int i;
} xx = { 0 };
     
main()
{
}
------------------------------*
     
*--------------------- Doesn't compile
main()
{
    struct XX {
        int i;
    } xx = { 0 };
     
}
-------------------------------------*
     
    Is there some good reason for this?  (Is it a language inconsistency?)
    Is there something obvious I'm missing here?!
     
                            noemi
-----------
noemi berry
{allegra|decvax|seismo}!rochester!moscom!noemi
"On a souvent besoin de plus petit que soi"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7789
          for JMS@ARIZMIS; Tue, 27-MAY-1986 14:41 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011201; 27 May 86 9:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017275; 23 May 86 7:51 EDT
From: "Donald L. Nash" <dlnash%ut-ngp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <3414@ut-ngp.UUCP>
Date: 20 May 86 17:44:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1462@mmintl.UUCP>, franka@mmintl.UUCP (Frank Adams) writes:
>
> o := as a synonym for =.  Compilers could have an option to permit := only.
>
     
Why?  "Since assignment is about twice as frequent as equality testing
in typical C programs, it's appropriate that the operator be half as long."
K&R, p. 17.  Allowing := as a synonym is OK, if you prefer that operator,
but why would you want to make it manditory?
     
>
> o Any sort of multi-level break statement.  There is no syntacticly clean
> way of adding this to C.
>
     
How about using goto?  Some people may think that goto sucks wind, but it
is a perfectly legitimate statement which can get you out of trouble, if
properly used.
     
> I do not support the following:
>
> o ^^ for logical exclusive or.  Unlike the other "short-circuit" forms (&&
> and ||), this doesn't save any execution -- both operands must be evaluated.
     
So what if they both have to be evaluated?  If you need to use some
kludge to get ^^ (like !a != !b), you will still wind up evaluating both
operands.  That's just the way XOR works.  Just because it requires more
work is no reason to exclude it from the language.
     
>
> Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
> Multimate International    52 Oakland Ave North    E. Hartford, CT 06108
     
I don't want to come off sounding like a fluff picker, so just for the
benefit of those of you who care, I did agree with the rest of the
article.  If net traffic weren't such a big issue, I'd have included the
rest of the article as well, with more agreeable comments added.
     
                    Don Nash
     
UUCP:    ...!{ihnp4,allegra,seismo!ut-sally}!ut-ngp!dlnash
APRA:    dlnash@ngp.CC.UTEXAS.EDU
BITNET:  cceu001@utadnx
     
     
        "If you can't say something nice, then don't" -- Thumper the rabbit

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7623
          for JMS@ARIZMIS; Tue, 27-MAY-1986 14:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 15:49:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025382; 27 May 86 16:32 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a013193; 27 May 86 16:18 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA24168; Tue, 27 May 86 16:18:16 edt
Date: Tue, 27 May 86 16:18:16 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605272018.AA24168@icst-cmr.ARPA>
To: hropus!ka@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Braces
     
    Furthermore, Jim has correctly pointed out that the braces actually
    obscure the code for the human reader, since they add clutter without
    providing any new information about the program.
     
This is *not* what I pointed out. I am against braces not because they
delimit control flow statements, but because they group single statements
into `blocks', which are equivalent to a single statement. I am also against
control flow statements implicitly eating exactly one statement.
     
The disadvantage to the one statement model is mismatched else's, as in:
     
    if (c1)
        if (c2)
            p();
    else            /* really matches c2 */
        q();
     
In COBOL it is impossible to even write this statement because a period
terminates the `if' statement, and would terminate the outer one as well.
     
My model of structured programming parallels the Bourne shell constructs.
Here, the `fi' statement (or endif, or end) is actually `part' of the `if'.
It serves to delimit the range of the conditional. In fact, I still read
`{' as `then', or `do' and `}' as `fi' or `end'.
     
    In fairness, C is better than most languages in this respect
    since it reduces begin and end to single characters.
     
Agreed. I would like to see all control statements reduced to a symbolic
token. If control statements could return values, we'd be 1/2 way there
with `?:' for if-then-else.
     
    This is good enough that I do not agree with
    the extremes to which Jim goes to avoid braces.  But C doesn't take the
    idea to its logical conclusion, which is to eliminate the delimiters
    entirely.
     
No. The delimiters should stay. I don't trust editors to preserve formatting.
This would be a disaster for portability. And white space would no longer
be that.  A certain amount of redundancy is necessary for cross checking.
     
    Fortunately, grouping by indentation has finally been adopted by at
    least one language.  See the article on "Modcap" in the March issue
    of Sigplan Notices.
                    Kenneth Almquist
                    ihnp4!houxm!hropus!ka    (official name)
                    ihnp4!opus!ka        (shorter path)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"
     
Q: What do you call a group of UNIX bigots?
A: White space.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7951
          for JMS@ARIZMIS; Tue, 27-MAY-1986 14:51 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011238; 27 May 86 9:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017876; 23 May 86 8:07 EDT
From: Topher Eliot <topher%cyb-eng.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc
Subject: Re: double (*parray[15])[];
Message-ID: <863@cyb-eng.UUCP>
Date: 22 May 86 16:18:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
(I have dropped net.unix from the newsgroups list).
There has been some debate on what the declaration
    double (*parray[15])[];
means.  David Herron seems to be arguing that it declares a zero-length
array of some sort, which some people and/or compilers might interpret as
being a pointer of the same sort.  I admit I found his note a little hard
to follow, so maybe I misunderstood him.  But I thought I would add my bit
of net volume in the form of an explanation of HOW I would go about parsing
such a statement.  My basic rule, which I have trusted for many years, is
to parse it as if it were an expression, starting inside the parentheses,
and obeying operator precedence rules:
     
    double (*parray[15])[];
               ^^^^
1.  It's an array with 15 elements
     
    double (*parray[15])[];
        ^^^^^^^^^^^
2.  It's an array of 15 pointers.
     
    double (*parray[15])[];
           ^^^^^^^^^^^^^^^
3.  It's an array of 15 pointers to arrays (the sizes of these arrays being
pointed at is not specified).
     
    double (*parray[15])[];
    ^^^^^^^^^^^^^^^^^^^^^^
4.  It's an array of 15 pointers to arrays of doubles.
     
There's another way to parse it, sort of from the outside in:
     
    double (*parray[15])[];
               ^^^^^^^^^^^^^^^
1.  The expression (*parray[15])[] has type double.
     
    double (*parray[15])[];
               ^^^^^^^^^^^^^
2.  The expression (*parray[15]) has type "array of double", with the size
of the array unspecified.
     
    double (*parray[15])[];
                 ^^^^^^^^^^
3.  The expression parray[15] has type "pointer to array of double".
     
    double (*parray[15])[];
                 ^^^^^^
4.  parray has type "array of pointers to arrays of doubles", parray has 15
elements.
     
Notice that both these methods are nice and methodical, and they both come
up with the same result.
     
I get the impression that at least one of the participants of this
discussion parsed the declaration something along the lines of:
     
    double (*parray[15])[];
                        ^^
1.  It's a zero-length array of somethings.
     
    double (*parray[15])[];
        ^           ^^
2.  It's a zero-length array of pointers to something.
     
    double (*parray[15])[];
        ^^^^^^^^^^^^^^
3.  It's a zero-length array of pointers to 15-element arrays of
something.
     
    double (*parray[15])[];
    ^^^^^^^^^^^^^^^^^^^^^^
4.  It's a zero-length array of pointers to 15-element arrays of doubles.
     
It is my contention that parsing a declaration this way is just plain
wrong, but I admit it's an easy mistake to make, one that I myself made
back before I had given this subject as much thought as I have.
     
The original discussion involved lint and malloc; I have nothing to add to
that aspect of it, so I am not repeating it here.
     
Cheers,
Topher Eliot           Cyb Systems, Austin, TX          (512) 835-2266
 {gatech,harvard,ihnp4,nbires,seismo,ucb-vax}!ut-sally!cyb-eng!topher

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1048
          for JMS@ARIZMIS; Tue, 27-MAY-1986 21:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 23:00:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011219; 27 May 86 9:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017853; 23 May 86 8:06 EDT
From: Lloyd Zusman <ljz%well.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1136@well.UUCP>
Date: 22 May 86 18:10:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2355@phri.UUCP> roy@phri.UUCP (Roy Smith) writes:
     
...
     
>> Something which got forgotten in my original article: I would favor an
>> exchange operator.  This one is quite frequently useful, and the
>> alternatives are ugly.
>
>    Why don't we just invent a new language?   We could call it PL/2.
     
... or ADA++

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1107
          for JMS@ARIZMIS; Tue, 27-MAY-1986 21:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/27/86 at 23:06:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011274; 27 May 86 9:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025042; 23 May 86 11:48 EDT
From: Carl Micarelli <6063366%pucc.bitnet@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <602@pucc.BITNET>
Date: 20 May 86 22:11:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1462@mmintl.UUCP>, Frank Adams (franka@mmintl.UUCP) suggests
adding the following to C:
     
>o Any sort of multi-level break statement.  There is no syntacticly clean
>way of adding this to C.
     
Good idea, but I don't think there's any syntactically clean way of
implementing a multi-level break statement in C -- at least no way that's
preferable to a goto.
     
>There are several things which are not part of the language definition, but
>which would be useful in compilers.  These consist mostly of flagging
>certain statements with (at least) warning messages.
     
Requiring compilers to flag constructions that look like bugs is a good idea,
but only if you establish a standard way of forcing the compiler to
(selectively) shut up.
     
>(Actually, I wouldn't be averse to a coding standard which forbade such
>things [as if (v = e) ... ], in favor of if (v = e, v) ...)
     
No!  = is an operator, v=e has a value, and its value should be usable
anywhere.  Making up special rules -- even for the noble purpose of protecting
programmers from carelessness or typos -- just complicates things.
     
Carl Micarelli -  BITNET: 6063366@pucc
                  UUCP:   ...allegra!psuvax1!pucc.bitnet!6063366

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3121
          for JMS@ARIZMIS; Wed, 28-MAY-1986 02:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011393; 27 May 86 9:20 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a029062; 23 May 86 14:19 EDT
Received: from nwc-143b.arpa by AOS.BRL.ARPA id a018135; 23 May 86 14:10 EDT
Date: 23 May 86 10:57:00 PST
From: sefunix@NWC-143B.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject: Fwd to Usenet:  FORTRAN-TO-C
To: info-c <info-c@BRL.ARPA>
Reply-To: sefunix@NWC-143B.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
    Some time ago, someone asked about a Fortan to C translation
package. Since I don't know whether that was ever answered, here is
the information.
     
    PRODUCT:  FORTRIX-C
     
    COMPANY:  Rapitech Systems, Inc.
          Montebello Corporate Park
          Suffern, NY 10901
          (914) 368-3000
          1-800-FORTRIX
          TELEX 509210
     
    I hope this info helps.
                Gene Guglielmo
                SEFUNIX@NWC-143B.ARPA
------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3247
          for JMS@ARIZMIS; Wed, 28-MAY-1986 02:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011428; 27 May 86 9:24 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a001134; 23 May 86 16:44 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA16533; Fri, 23 May 86 14:43:38 edt
Date: Fri, 23 May 86 14:43:38 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605231843.AA16533@icst-cmr.ARPA>
To: alice!ark@ICST-CMR.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: malloc()
     
    >    I don't think 'void *' is useless. What do you  do    on  a  machine
    > where it's NOT 'always legal to cast any pointer into a "char *"'?
     
    You don't implement C on it.
     
When would this be illegal? If the machine was not byte addressable?
I think not, because the 36 bit machine mentioned in K&R (Honeywell)
obviously isn't. A decision would have to be made whether such a
machine is big or little endian, but I don't see any other problem.
     
Besides, there is nothing in the C spec that says that `character'
data has to occupy only one byte. In fact, all types could occupy
exactly the same amount of space on a given machine. Not the best
strategy, but not illegal either. And better than no C at all.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3343
          for JMS@ARIZMIS; Wed, 28-MAY-1986 02:31 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011460; 27 May 86 9:25 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a009167; 26 May 86 4:49 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a002025; 26 May 86 4:39 EDT
Received: from (XBR2D995)DDATHD21.BITNET by WISCVM.WISC.EDU on 05/26/86
  at 02:55:47 CDT
Date:      Mon, 26 may 1986, 09:45 B
From:         XBR2D995%DDATHD21.BITNET@wiscvm.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
To:  INFO-AMIGA@rutgers.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Cc:  unix-sources@BRL-SMOKE.ARPA, info-c@BRL.ARPA,
     XBR2D995%DDATHD21.BITNET@wiscvm.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject:   Problem with MANX/Aztec C (3.20a 26-Feb-86) and arrays on
  AMIGA.
     
----------------------------------------------------------------------------
This is a repost of my message from 21-May-1986. I repost it, because there
are some problems on the net. By the way: whats wrong with INFO-AMIGA ???
PLEASE: Answer direct to <XBR2D995@DDATHD21.BITNET>. I'm not a member of all
lists.
----------------------------------------------------------------------------
Hello,
     
we have a serious problem with Aztec-C 3.20a and float arrays. The
program at the end of my message compiles an links correctly, but gives
a guru meditation (00000003.000097B0) wenn started. The program is
compiled and linked with the following command:
     
  CC T3
  LN T3.O -lm -lc
     
The same program gives an assembler error when compiled with
     
  CC T3 +l
     
We think the problem is related to the expression:
     
  z[k][m] = z[k][m] - z[k][i] * z[i][k]
     
in the program. Reducing the "complexity" of the statement resolves
both problems.
     
Any people from Manx listening? Anybody got the same problem?
     
Regards
Martin
     
My address: Martin Knoblauch
            Technische Hochschule Darmstadt
            Dept. for Physical Chemistry (PC 1)
            Petersenstrasse 20
            D-6100 Darmstadt (West Germany)
BITNET:     <XBR2D995@DDATHD21.BITNET>
----------------------------T3.C-------------------------------------
#include <exec/types.h>
#include <libraries/mathffp.h>
#undef NULL
#include <stdio.h>
     
main()
#define BOR 5
{
  int i,k,m;
  float  a1,a2,a3;
  static float z[BOR][BOR];
     
  printf(" programmstart now\n");
     
  for(i=0;i<BOR;i=i+1)
     {
      z[i][i] = 3.33333;
     }
     
  for(i=0;i<BOR;i=i+1)
     {
      for(k=0;k<BOR;k=k+1)
         {
          for(m=0;m<BOR;m=m+1)
             {
               printf(" i k m = %d %d %d \n",i,k,m);
               /* The following statement causes the program
                  to crash (GURU: 00000007:000097b0) when
                  compiled with CC T3.
                  Trying to compile the program with
                                CC T3 -L
                  gives an assembler error */
     
               z[k][m] = z[k][m] - z[k][i] * z[i][m];
     
              /* The following statements work ok, and there
                 are no assembler errors. This is no real solotion,
                 because it slows down the program and makes the
                 program less understandable.
     
               a1 = z[k][m];
               a2 = z[k][i];
               a3 = z[i][m];
               z[k][m] = a1 - a2 * a3;
     
             */
             }
         }
     }
}
-----------------------------------------------------------------------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3427
          for JMS@ARIZMIS; Wed, 28-MAY-1986 02:38 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/28/86 at 04:23:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013222; 27 May 86 10:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003610; 27 May 86 10:03 EDT
From: William Roberts <liam%cs.qmc.ac.uk@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <146@cs.qmc.ac.uk>
Date: 20 May 86 10:49:26 GMT
Posted: Tue May 20 10:49:26 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <169@comp.lancs.ac.uk> craig@comp.lancs.ac.uk (Craig Wylie) quotes:
>>Using braces to indicated the structure of a program results in code that
>>is quite difficult to read.  (Try removing all indentation from any C
>>program you choose and see how readable the result is.)  Of course
>>sensible programmers use indentation to indicate the structure of the
>>program to the reader.
     
I use programs like "cb" and "indent" to get my C programs
indented according to what they *REALLY* mean, as opposed to
what I intended them to mean (indicated by MY indenting).  This
can be quite illuminating....
--
     
William Roberts                 ARPA: liam@UK.AC.qmc.cs
Queen Mary College              UUCP: liam@qmc-cs.UUCP
LONDON, UK

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3524
          for JMS@ARIZMIS; Wed, 28-MAY-1986 02:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013714; 27 May 86 10:44 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003999; 27 May 86 10:12 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Followup to Very Tough C Riddle
Message-ID: <396@hadron.UUCP>
Date: 8 May 86 13:29:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
AARRGGHHHHHHHHHHH!!!!!
     
In article <140@delftcc.UUCP> sam@delftcc.UUCP (Sam Kendall) writes:
>     Even though it's not necessary for the riddle's solution, let's
>take a look at the other possibility, which is for there to be a formal
>parameter declaration of the form
>        type formal[][];
>Tony Li and Joe Yao mentioned this possibility, but they didn't think
>it was legal.  The passage mentioned in K&R that many people think
>prohibits any adjacent pairs of empty brackets is this:
>        multi-dimensional array ...        may be missing only for
>        the first member of the sequence.  (section 8.4)
>The passage that may allow `[ ] [ ]' for formal parameters is this
>(first elipsis mine):  [other ellipses mine -jsdy-]
>        ...  [D]eclarations of formal parameters declared "array of ..."
>        are adjusted to read "pointer to ...".  (section 10.1)
>    ... type formal[][]; "is adjusted to read" type (*formal)[];
>This second type is "pointer to array of unknown length".
     
Sam, this is not legal, has never been legal, and (pray God) will
never be legal.  One may have the first member of the [] sequence
empty because, from the rest, one can determine the size of each
member of the array.  One may not have pointers to or arrays of
items of which one does not know the size.  To see why this is so,
tell me: what do arrname[1] or *++ptr reference????
     
By the way -- section 10.1 cited above refers, of course only to the
outermost (first) []'s.  Do you remember the long essay on this a
year or two ago?  [I don't ... if you have a copy, please send it
to me ... ]
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3631
          for JMS@ARIZMIS; Wed, 28-MAY-1986 02:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013770; 27 May 86 10:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004147; 27 May 86 10:16 EDT
From: Walter Bright <bright%dataiodataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: questions from using lint
Message-ID: <1000@dataioDataio.UUCP>
Date: 19 May 86 20:50:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <473@cubsvax.UUCP> peters@cubsvax.UUCP (Peter S. Shenkin) writes:
>What I'm waiting for is an interactive interpretive debugger that runs from
>vi.  The program would run interpretively until an error was encountered,
>then place you at the appropriate line in the source file with the error
>message displayed.  Then you could go into insert mode, make the necessary
>change, and resume execution.  Normally interpreted languages, like APL,
>often have such facilities.  Are there insuperable difficulties with doing
>this with a normally compiled language like C?  (I'm sure it could be done
>with FORTRAN, since FORTRAN interpreters are well-known... but why have we
>seen no C interpreters?)
     
Major difficulties are:
     
1) The preprocessor. At any line,
a macro could be changed, which could change the meaning of the entire
remainder of the source text. This means that 'incremental compiles' becomes
'compile from here to the end of the source text'. Of course, that means
the parser must have the state of the parse saved at every line..., which
obviously is impractical.
     
2) C isn't line oriented. This means that any line could be any part of
a statement or expression. Thus, the parser must be able to back up from
any point to find a 'synchronization point'. But C isn't backwardly
parseable...
     
Why BASIC and FORTRAN can be handled this way:
     
1) They don't have a preprocessor.
     
2) They are line oriented. All the parser has to do is back up to the
beginning of the line (or in FORTRAN to the first line that isn't a
line continuation).
     
3) Each line is more or less independently parseable from the rest of
the program.
     
Conclusion:
     
The only fully functional, practical way is to do a reparse of the complete
source file upon any changes (even on whitespace changes). Turbo Pascal
works this way, instead of attempting to incrementally compile, Borland
spent their efforts making the compile step really fast.
     
An incremental compiler could be made if numerous assumptions and
restrictions were made about what could be changed. I think the bugs
and kludges that would result would make it impractical, however.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3798
          for JMS@ARIZMIS; Wed, 28-MAY-1986 05:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022792; 27 May 86 15:03 EDT
Received: from louie.udel.edu by SMOKE.BRL.ARPA id a011219; 27 May 86 14:55 EDT
Received: from ccvax1 by Louie.UDEL.EDU id a029514; 27 May 86 12:50 EDT
Received: by vax1.acs.udel.edu (4.12/4.7)
    id AA05982; Tue, 27 May 86 12:47:37 edt
Date: Tue, 27 May 86 12:47:37 edt
From: UFFNER <tom%vax1.acs.udel.edu@udel-louie.ARPA>
Message-Id: <8605271647.AA05982@vax1.acs.udel.edu>
To: info-c%brl-smoke.arpa@udel-louie.ARPA, phri!roy@vax1.acs.udel.edu.edu
Subject: Re: What should be added to C
     
> Why don't we just invent a new language?   We could call it PL/2.
     
We already have such a language. It's called "ADA"
---
Tom Uffner
tom%udel-cc-vax1@louie.ARPA
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3982
          for JMS@ARIZMIS; Wed, 28-MAY-1986 05:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026267; 27 May 86 17:55 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa14385; 27 May 86 17:39 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a026124; 27 May 86 17:27 EDT
Received: from (FULIGIN)UMASS.BITNET by WISCVM.WISC.EDU on 05/27/86 at
  16:25:29 CDT
Message-ID:  <860526172949.00000634.AZZT.AA@UMass>
Date:     Mon, 26 May 86  17:29:49 EDT
From:  "Peter E. Lee" <FULIGIN%UMass.BITNET@WISCVM.ARPA>
Subject:  request for software pointers
To:  info-c@BRL.ARPA
cc:  info-cpm@AMSAA.ARPA
     
Howdy,
     I work as a programmer in the psychology department at the University
 of Massachusetts (Amherst).  My co-workers and I work on Gifford CompuPros
 running CP/M-80, CP/M-86, and MP/M-8/16, doing program development primarily
 in C (Aztec CII, and Optimizing C86).  Unfortunately, we have been unable to
 to find any lint programs or pretty-printers that can run in a CP/M
 environment, which makes de-bugging even more of a hassle than usual.
     If anyone out there knows of such programs, either commercially
 available or in the public domain, or can find C source code to one or both,
 pointers would be greatly appreciated.
                                  Sincerely,
                                       -Peter E. Lee
     
---
   Please reply directly to :
     Fuligin%UMass.bitnet@WISCVM.ARPA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3879
          for JMS@ARIZMIS; Wed, 28-MAY-1986 06:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025975; 27 May 86 17:07 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id aa13891; 27 May 86 16:47 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA24320; Tue, 27 May 86 16:48:53 edt
Date: Tue, 27 May 86 16:48:53 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605272048.AA24320@icst-cmr.ARPA>
To: bentley!kwh@ICST-CMR.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re:  More extensions to C (was: Boolean Operators Slighted in C)
     
>>5) Allow immediate constants. [Generalization of quoted strings.]
>>... Why not int *p = &5 ...
     
Does "&5" point to a character, short, int, unsigned, or long constant?
(No fair using the left side of the assignment to disambiguate!)
     
    Good point. No proposal can claim to be perfect, and you just
    made an excellent case for feedback. We already have `L' as
    a suffix (for long). Why not go whole hog and add them all.
    Or maybe we need `*p = & (short) 5;'. BTW, it probably
    points to an int. Also a char & short on a little endian.
     
>>6) Eliminate arrays altogether!
     
You want to take them *out* of the language?  I say let's put them *in*!
As it stands, arrays are half-implemented.
     
    Well, I *would* like to see automatic dimensioning within
    functions. That's all I can think of that's missing. Don't
    even think about assignment or passing them as arguments.
    This never should have happened with structures either.
     
>>And it wouldn't matter whether a variable was defined differently than it
>>was declared (char x[] or char *x).
     
I don't get it.  If "char *x" is valid for all array/pointer variables,
where does the memory come from, malloc()?
     
    No, it comes from the declaration `char x[10]', which is the
    same as `char $[10]; char *x = $;' where `$' is an invisible name.
    This loses space/time just to fix bad declarations. Forget it.
     
>>8) Allow formal arguments to be declared AFTER the opening brace.
>>    This would allow prioritization of register variables.
     
    [register nesting suggestion deleted]
     
(Sorry I had to quote so much here.)  This has *nothing* to do with the C
language; we are now in the realm of compiler implementation.  Here's a
     
    Really!
     
counter-proposal: compilers should allocate registers based on the last
declaration instead of the first.  (This is quite legal; "register" has no
guaranteed semantics.)
     
    No way! Somebody goofed! There is no reason to go backwards
    when forwards is intuitive and came first. Lots of code has
    been written on the assumption that first is best. Have some respect.
     
Better yet, Let's make the compilers smart enough to allocate registers on
their own, and make the "register" keyword obsolete!  (DEC did this.)
     
    No, let's make optimisers obsolete and make the programmer
    say what he means. I am willing for the compiler to optimise
    away it's own control structure jumps and such, but it should
    not waste time looking at my own code. If I put loop invariant
    code in a loop, I deserve to pay the price. Perhaps a separate
    program like lint that would tell you these things...
     
    "Warning: loop coded by bozoid pinhead at line 54"
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    "One man gathers what another man spills"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7474
          for JMS@ARIZMIS; Wed, 28-MAY-1986 11:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/28/86 at 13:05:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002729; 28 May 86 9:29 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a025860; 28 May 86 9:10 EDT
Received: from bbn-labs-b.arpa by AOS.BRL.ARPA id a001881; 28 May 86 9:01 EDT
To: slezak@LLL-CRG.ARPA
cc: info-c@BRL.ARPA
Subject: Re: what printf returns
Date: 28 May 86 08:57:44 EDT (Wed)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     If you examine the manual page for printf/fprintf/sprintf supplied with
4.2BSD, you'll note that it does not say that *printf returns anything.  I
believe that returning the character count is a holdover from Version 7 days.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/506
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    ...!{decvax,linus}!bbnccv!rgenter
(UUCP)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1331
          for JMS@ARIZMIS; Wed, 28-MAY-1986 16:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/28/86 at 17:47:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011376; 28 May 86 14:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003650; 28 May 86 14:04 EDT
From: Brew Master <jadallah%cwruecmp.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.f77,net.wanted,net.sources
Subject: FORTRAN -> C (or Pascal)
Message-ID: <1488@cwruecmp.UUCP>
Date: 23 May 86 19:02:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
***** This was previously posted without my Signature, sorry. *****
     
I know it has been discussed before, but are there any public domain
or commercial FORTRAN to C or FORTRAN to Pascal translators?
     
I know about FORTRIX, but I understand it costs $6000. (That is a little
much since I only have convert one program!!)
     
Any replies would be greatly appreciated!
     
     
     
                          Sam Jadallah
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CSNet: Jadallah@Case          ARPA: Jadallah%Case@CSnet-relay
Usenet: ...!dexvax!cwruecmp!Jadallah
Snail Mail: EB65, School of Medicine
            Case Western Reserve University
            Cleveland, OH 44106
     
"Curiosity didn't kill the cat, it was a poisoning."  - E. Costello
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1457
          for JMS@ARIZMIS; Wed, 28-MAY-1986 16:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/28/86 at 17:58:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012008; 28 May 86 14:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004626; 28 May 86 14:25 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <3754@sun.uucp>
Date: 24 May 86 08:22:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I also thought that casting anything into a (void*) would be a big
> no-no.  Lint, and maybe even the compiler, would issue loud warnings
> every time one tried to do this.
     
The key word here is "warnings".  The X3J11 standard doesn't say what
constructs may not give warnings; it merely states what is and isn't legal
C.  As long as the compiler produces code for it, X3J11 doesn't care how
many complaints it puts out.
     
Maybe C should be stricter about types (I think so), but it's too late for
that.
     
> This wouldn't matter since normal programs would never need to do it...
     
Well, err, umm, "void *" is also useful for declaring objects used by
several different modules, where each client of the object's implementation
wants to store some private data in the object, and you can't get away with
statically restricting the class of modules using this object.  Dennis
Ritchie's "streams" article in the BSTJ gives an example of this.  A "queue"
has pointers to "put" and "service" procedures, and a "void *" which
provides private storage for those procedures.  Replacing that "void *" with
a "struct tty *", or a union of similar structures, would be ridiculous.
Yes, you can't rely on the type system to check correctness.  (Maybe
something like Goedel's Incompleteness Theorem applies, where any type
system strong enough that all programs written using it are "correct" is
incomplete, in that there exist interesting and meaningful programs which
cannot be written within this type system?)
     
> For some perverse reason that I have never been able to understand,
> X3J11 decided that any pointer could be converted to (void*) without
> complaint.
     
No, they just decided that it could be so converted in a legal C program.
Appendix E.3 gives a list of warnings which many implementations might give;
the situations listed are all legal C, but may not be desirable C.
     
> (Lint complains too much about your code?  Don't worry, just change
> all the pointers to void* and it will shut up.  (I assume you already
> "#define CALL (void*)" and put CALL in front of all your function
> calls so that you don't have to check any error statuses.)  Perhaps
> lint should have an option which redirects all output to /dev/null?)
     
If you're worried about programmers trying to spoof "lint" you'd better find
some way of preventing them from hiding all dubious code inside "#ifdef
lint".  C is not guaranteed to work in an environment where you have to ride
herd on programmers.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.arpa

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1570
          for JMS@ARIZMIS; Wed, 28-MAY-1986 16:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/28/86 at 18:11:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012086; 28 May 86 14:44 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004660; 28 May 86 14:26 EDT
From: John Chambers <jc%cdx39.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: questions from using lint
Message-ID: <209@cdx39.UUCP>
Date: 23 May 86 20:01:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>      ... I happen to think that all code should be formatted such
> that all funxions fit on a page. This is a good idea, but one I
> seldom see adhered to.
     
Not only do I agree, but I even think that all funxions (and even
prosejurz) should fit into one screen-full.  I mean, I can really
only understand what I can have sitting before my eyeballs at one
time.
     
Do I follow my own advice?  Are you kidding?  Of course, it is
easier with a 100-by-100 screen than with a 16-by-32 screen.
     
[OK, so a screen-full IS just another kind of a page.  I admit it.]
--
    John M Chambers (617-364-2000x7304)
     
          / cthulhu     \         /usenet
         /  inmet      \        / news
    ...!{   harvax       }!cdx39!{  jc
         \  mit-eddie /        \ uucp
          \ mot[bos] /         \root

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3017
          for JMS@ARIZMIS; Thu, 29-MAY-1986 15:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/29/86 at 16:50:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012876; 28 May 86 15:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004719; 28 May 86 14:28 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expression, expression;
Message-ID: <892@ttrdc.UUCP>
Date: 22 May 86 05:12:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I think there may be at least one good reason NOT to do this, or at
least to have expressions on different lines of the source code
even if <expression, expression;> is legal--and that is for debugging.
If you have code which is giving mysterious core dump problems,
Murphy's law says sdb or adb will show the problem occurring on a
line with multiple statements on it, and you'll just have to go back
and edit the code into several lines each containing a single statement
to pin down the problem.
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3164
          for JMS@ARIZMIS; Thu, 29-MAY-1986 16:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012956; 28 May 86 15:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005157; 28 May 86 14:36 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Indentation instead of braces
Message-ID: <845@bentley.UUCP>
Date: 22 May 86 20:26:21 GMT
Followup-To: net.lang
To:       info-c@BRL-SMOKE.ARPA
     
In article <2783@utcsri.UUCP> utcsri!greg writes:
>What about the following sort of thing, though ? ( this is
>how I would write it in normal C ):
>    ...    if( vogsphere == fuddle && !blasted ){
>            while( sixteenvalvedualoverheadcam( bleen ) == '?')
>                infriddle( batman.utility_belt );
>            if( total_confusion_estimated > MAX_CONFUSION )
>                printf(
>"Well I think you ought to know that I am getting really confused by %s\n",
>                    reason_for_confusion[WOMBAT]
>                );
>            return SAY_WHAT;
>        }else post_to_net_lang_c( silly_stuff_like_this );
     
No problem.  Remove the braces, leave the indentation alone, and tack a
backslash onto the first three lines of the printf statement.
     
Earlier I wondered aloud about the proper interpretation of "if (c) x; y;"
(without newlines).  It seems to me that both x and y would be within the
scope of the conditional (ditto for "\tif(c) x;\n\t\ty;\n").  Is this how
it's done in existing languages with significant indentation (OCCAM)?  Or
is that syntax illegal, requiring a newline (my guess)?
     
This feature is not likely to be incorporated into C in the foreseeable
future, So I am directing followups to net.lang only.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4828
          for JMS@ARIZMIS; Thu, 29-MAY-1986 20:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/29/86 at 21:43:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008683; 29 May 86 22:34 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a004682; 29 May 86 21:29 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA00678; Thu, 29 May 86 17:31:01 edt
Date: Thu, 29 May 86 17:31:01 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605292131.AA00678@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Re: LINT as documentation
     
    In article <411@ccird1.UUCP> rb@ccird1.UUCP (Rex Ballard) writes:
    >This is just one more argument for lint.
    >
    >True, lint often burps over "trivial" little problems like
    >passing a *int to a function that expects *char, among others,
    >but there are some real good reasons for using lint.
     
A related issue is forgetting to declare malloc as returning a (char *)
thus defaulting it to an (int), assuming that you will be casting
the returned value anyway. Surprise! On 680[012]0's pointers are
returned in `a0' while integers are returned in `d0'. Some attention
must be paid to this as 68k's are reasonable machines.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    What PROGRAM are they watching?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5049
          for JMS@ARIZMIS; Thu, 29-MAY-1986 20:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/29/86 at 22:17:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012989; 28 May 86 15:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005181; 28 May 86 14:36 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: builtins and automatic defines
Message-ID: <846@bentley.UUCP>
Date: 22 May 86 22:31:13 GMT
Keywords: #exclude
To:       info-c@BRL-SMOKE.ARPA
     
In article <1243@utcs.uucp> utcs!flaps (Alan J Rosenthal) writes:
>In article <816@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>>I wonder if perhaps <stdio.h> (and <builtins.h>) should be included by
>>default, with an explicit "#exclude" to disable.  (Cf. "#undef".)  Probably
>>tricky to implement -- don't do the automatic "#include" until checking for
>>"#exclude", which must be at the top of the file (after whitespace)?
>
>Why bother?  This would be very complicated and lead to many mistakes due
>to an unclear definition of whitespace or whatever.
     
It doesn't seem all that complicated to me, and probably seems simpler to
the neophyte who doesn't understand why he gets "stderr undefined" when his
program was working fine earlier.  The mistakes could be easily caught by
cpp: "#exclude must be at top of file".  I meant for "whitespace" to include
comments, otherwise I think it's quite clear (when restricted to the set of
characters that can legally appear in a C program).
     
>I have a file called "beginc", it's a shellscript, and it creates a file
[which contains several #include's and #define's and the start of main()]
>and then puts you in $EDITOR on the file.  This approach is much better
>than any #exclude op.  It's more easily disabled or modified because you
>don't have the reverse situation of deleting things by adding in lines.
     
Perhaps.  We already have the "delete by adding" situation with #undef,
though the analogy isn't perfect (you can't completely cancel an #include,
which is why #exclude would have to be first).
     
On a related note, I've always despised the automatic cpp builtins (such as
"#define unix 1" on UNIX(R) systems), because it effectively creates a new
reserved word for each possible operating system, machine, etc. that your
program might be compiled on.  Older versions got around this by making the
builtin definition be "#define unix unix", with a special kludge to prevent
infinite recursion.  I think the "who am i" testing should not use the same
namespace as the macros.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5138
          for JMS@ARIZMIS; Thu, 29-MAY-1986 21:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013044; 28 May 86 15:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005194; 28 May 86 14:37 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What's wrong with printf( ) , return ?
Message-ID: <847@bentley.UUCP>
Date: 22 May 86 22:41:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <123@danews.UUCP> danews!lvc writes:
>I knew that return wasn't an expression.  The fact that you can
>do `control flow' with , seperating expressions makes me wonder
>why this wasn't extended to include 'some' statements such as return.
     
It makes about as much sense as "printf() + return".  Comma in this context
is an *operator*.  A more serious argument would be to allow the statement
"return ((void)printf())", which would make sense if "void" were a real
datatype.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7068
          for JMS@ARIZMIS; Fri, 30-MAY-1986 01:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/30/86 at 03:13:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013179; 28 May 86 15:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005367; 28 May 86 14:39 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: A good use of a bad feature
Message-ID: <2600050@ccvaxa>
Date: 10 May 86 20:19:00 GMT
Nf-ID: #R:mit-eddie.MIT.EDU:1853:ccvaxa:2600050:000:1093
Nf-From: ccvaxa.UUCP!aglew    May 10 15:19:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
>/* Written 10:49 am  May  4, 1986 by root@icst-cmr in net.lang.c */
>You will find much disagreement on that point, I'm afraid. Fall thru is
>more flexible. You can always break, but often cases are related so that
>a particular case requires a superset of another case. It is to DMR's
>credit that he realized this feature. I sure wouldn't have thought of it.
>/* End of text from net.lang.c */
     
And what do you do if you have more than one case which is a superset of
another? Eg.
     
    case A      case B
          \    /
           \  /
             case C
                |
                |
                break
     
Dup code or use gotos. The worst is when people use combinations of gotos
and fall-through:
     
    case A:
        ...
        goto case_C;
    case B:
        ...
        /* fall through */
    case C:
    case_C:
        ...
        break;
     
There should be one way to do things. Special case constructs should only be
used if they crop up frequently. I don't think fall through qualifies.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7182
          for JMS@ARIZMIS; Fri, 30-MAY-1986 01:42 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013356; 28 May 86 15:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005382; 28 May 86 14:40 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <2600051@ccvaxa>
Date: 15 May 86 06:06:00 GMT
Nf-ID: #R:dataioDataio.UUCP:989:ccvaxa:2600051:000:592
Nf-From: ccvaxa.UUCP!aglew    May 15 01:06:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
I also noticed that C compilers on PCs are frequently better than UNIX issue.
Little things like printing a bit of context with your errors, like:
     
       cahr stuff;
Line EEE:    ^    ^    Illegal declaration or obsolete initialization
     
instead of telling you `invalid initialization on line 563'.
     
Coming back to minicomputers is like going back to the Stone Age - big, fast,
powerful monsters, but not quite as intelligent as their smaller successors.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7244
          for JMS@ARIZMIS; Fri, 30-MAY-1986 01:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013404; 28 May 86 15:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005400; 28 May 86 14:40 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Boolean Operators Slighted in C
Message-ID: <2600052@ccvaxa>
Date: 22 May 86 14:27:00 GMT
Nf-ID: #R:cernvax.UUCP:314:ccvaxa:2600052:000:674
Nf-From: ccvaxa.UUCP!aglew    May 22 09:27:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
~> Boolean data type in C
     
I say `typedef unsigned char bool'...
     
Instead of using macros like lxor, I do
#define boolval(bv) ((bv)!=0)
so I can get away with saying boolval(XXX) ^ boolval(YYY) and the like.
Doesn't help with waning to be able to do BBBBB &&= CCCCC;
     
"Equal rights for Booleans!" has been my cry for a while - but I meant it
with respect to computer architectures, not C. After all, C can't be expected
to be better than present day architectures - C is just structured assembly
language. :-). On second though, :-(.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7346
          for JMS@ARIZMIS; Fri, 30-MAY-1986 01:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013434; 28 May 86 15:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005408; 28 May 86 14:40 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <2600053@ccvaxa>
Date: 22 May 86 14:39:00 GMT
Nf-ID: #R:mmintl.UUCP:1463:ccvaxa:2600053:000:1161
Nf-From: ccvaxa.UUCP!aglew    May 22 09:39:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
>/* Written  8:04 pm  May 16, 1986 by franka@mmintl.UUCP in ccvaxa:net.lang.c */
>/* ---------- "Re: What should be added to C" ---------- */
>Something which got forgotten in my original article: I would favor an
>exchange operator.  This one is quite frequently useful, and the
>alternatives are ugly.
>
>Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
>Multimate International    52 Oakland Ave North    E. Hartford, CT 06108
>/* End of text from ccvaxa:net.lang.c */
     
Why not go all the way and implement Dijkstra's concurrent assignment?
     
    i,j := j,i
     
for a swap. Course, couldn't use commas, but you get the idea.
Compilers can generate good code for this, and it makes programs with
complicated pointer manipulations much clearer; I used to teach it, and the
associated code generation algorithm, to U1s in classes I TAed, and it
greatly reduced the noise level of assignments in the wrong order.
     
#define swap(a,b)  a,b := b,a
     
does the exchange without having to type the name twice.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7423
          for JMS@ARIZMIS; Fri, 30-MAY-1986 02:07 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014203; 28 May 86 15:44 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006817; 28 May 86 15:08 EDT
From: augart <augart%h-sc2.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: No!!! (was: Re: YANO (Yet Another New Operator))
Message-ID: <962@h-sc2.UUCP>
Date: 25 May 86 05:15:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <304@apollo.mentor.UUCP> franka@.UUCP (Frank A. Adrian) writes:
     
>    a[x++] = a[x]->next; or a[x] = a[x++]->next;
>
>I have trouble remembering in what order the increment takes
>place. Is it before or after the assignment (No fair peeking in K&R!)?
     
This is merely a slightly more complicated version of
the disgusting:
     
    x = 5;
    x = x++;
     
In my example, different compilers will leave you with  x == 5 or x == 6.
In your example, "what order the increment takes place" depends
upon what compiler you have.
     
Steven Augart
swa@xx.lcs.mit.edu (swa@xx.ARPA)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8698
          for JMS@ARIZMIS; Fri, 30-MAY-1986 04:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/30/86 at 06:24:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014284; 28 May 86 15:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006887; 28 May 86 15:09 EDT
From: Kilsup Lee <kslee%kaist.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c,net.lang.pascal,net.wanted
Subject: Summary of Pascal-to-C translator
Message-ID: <50@kaist.UUCP>
Date: 22 May 86 09:37:14 GMT
Keywords: pascal, C
To:       info-c@BRL-SMOKE.ARPA
     
     
    I received several response from very kind persons.
I will summary them and I hope to be helpful to those who want them.
     
     
 -----------------------------------------------------------------------
   Whitesmiths, Ltd      97 Lowell Road, Concord,      pascal and c
             MA 01742 (617) 369-8499       compilers($700)
             Telex: 951708 SODTWARE CNCM   Cross support
                               (Additional $700)
     
Note) Information provider
-- Peter Ludemann
    ludemann@ubc-cs.uucp (ubc-vision!ubc-cs!ludemann)
    ludemann@cs.ubc.cdn  (ludemann@cs.ubc.cdn@ubc.mailnet)
    ludemann@ubc.csnet   (ludemann%ubc.csnet@CSNET-RELAY.ARPA)
 -----------------------------------------------------------------------
     
I have a friend, a student at Cornell, who worked last summer at Northwest
Instrument Systems in Portland, Oregon (U.S.A.), and they used a program
written by a professor at Oregon State in Corvallis, Oregon (I think, it may
have been University of Oregon instead, in Eugene Oregon).  Sorry I can't be
of more help than this.  I'm leaving school for the summer in a week so
don't bother trying to reach me with mail at this address.
    Good luck.
     
        Stuart Williams
        1234 S.W. 57th Ave.
        Portland, OR 97221
     
        UUCP Sept. to May 20: ...ihnp4!wheaton!stuart
 -----------------------------------------------------------------------
     
From lewis@OREGON-STATE Sun May 18 00:06:57 1986
     
TGL inc at 503-745-7476 sells C source code to a Pascal-to0C translator
for $7,500. It currently converts MT+, MS, UCSD, and Apollo Domain Pascal
dialects to standard K&R C.
     
 -----------------------------------------------------------------------
     
From: Gregory Smith <greg@csri.toronto.csnet>
     
A pascal-to-C converter, which runs under UNIX, is made by
     Human Computing Resources Corporation
     10 St. Mary Street
     Toronto, Ontario,  M4Y 1P9
     Canada
     416-922-1937
     
     
It is HCR/PASCAL v4.1, and we are using it here now.
     
-----------------------------------------------------------------------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3767
          for JMS@ARIZMIS; Fri, 30-MAY-1986 13:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/30/86 at 14:50:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017383; 30 May 86 15:30 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a022661; 30 May 86 15:11 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02681; Fri, 30 May 86 15:10:22 edt
Date: Fri, 30 May 86 15:10:22 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605301910.AA02681@icst-cmr.ARPA>
To: bentley!kwh@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re:  C vs. FORTRAN
     
In article <1594@ecsvax.UUCP> ecsvax!dgary (D Gary Grady) writes:
>Right now Fortran has four things over C:
     
Of which I'd like to address the first two.
     
>o A richer set of floating point operators, including exponentiation and
>  the so-called "in-line" functions (many of which ARE in C).
     
I think you mean "builtin" rather than "inline".  I don't even consider that
a significant difference, much less an advantage of FORTRAN.  Exponentiation
in general is syntactically neater in FORTRAN but semantically identical on
most machines.  Exponentiation with integer exponents is a problem in C; it
isn't even available as a library function!  When the exponent is constant
(usually 2 or 3 in practice) it could easily be coded inline, but it's not
clear whether that's sufficient justification for making it an operator.
     
    DMR has said that he didn't add exponentiation to the language
    for the simple reason that computers don't do them as a primitive.
    The only recourse is for the code generator to call a function.
    Thus, we have two ways of generating the same code.
     
    Integer exponentiation is a trivial loop:
     
    int    ipower(j,k) { int m = 1; while (k--) m *= j; return m;}
     
    You also need a floating version. I always disliked
    exponentiation because a**b**c does b**c first.
     
>o A way of passing different-sized multidimensional arrays to the same
>  subroutine.  (For instance, right now it is not possible to write a
>  function in C that will invert a matrix of arbitrary size without use
>  of some "trick," like making the incoming matrix one-dimensional and
>  hard-coding the subscript computation or using arrays of pointers to
>  pointers.)
     
Again, this is merely a syntactic quibble -- what FORTRAN does is equivalent
to the one-dimensional "trick", but it's hidden from the user.  FORTRAN lets
you use a variable as a bound in an array declaration, in this special case.
That probably wouldn't be too hard to add to C; in fact it might be possible
to generalize it to allow *any* nonstatic array declaration to have variable
size (within reason).
     
    Not a variable *size*, but a variable *shape*. Users don't want
    to have to do this themselves.
     
Another advantage of FORTRAN is implicit DO loops in I/O statements, and the
related ability to use (constant, at least) repeat counts in FORMATs.  I had
a program that made this painfully clear when it was translated from FORTRAN
to C.
     
    Well, you could put the printf in a do loop. Of course, we
    used to have contests about what certain I/O statements
    would do with certain format statements. Printf is crystal
    clear by comparison.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    Quick, sing me the BUDAPEST NATIONAL ANTHEM!!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1926
          for JMS@ARIZMIS; Sat, 31-MAY-1986 05:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/31/86 at 07:07:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022789; 31 May 86 7:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010199; 31 May 86 7:41 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <113@watmath.UUCP>
Date: 29 May 86 13:05:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Ah, but if you have a function prototype such as:
>     extern void free(void *);
> and then try to free a pointer to a struct, you are implicitly casting
> the struct pointer to a void *. Generating an error on this would
> make void * fairly useless.
     
But if I were king, free() wouldn't take a (void*).
Almost the only place (void*) would be used is by malloc().
     
There is a need for two special types of generic pointers:  one which
is guaranteed to be aligned and can be cast into any other pointer, and
one which has no such guarantee and can have any other pointer cast
into it.  (void*) clearly fits the former.  (char*) almost fits the
latter (perhaps a new (pointer) type should have been introduced).
X3J11 defeated the niceness of all this by extending their definition
of (void*) to fit both requirements.  I really don't understand why
they would do such a thing.  It gains nothing and loses a lot.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4289
          for JMS@ARIZMIS; Sat, 31-MAY-1986 10:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/31/86 at 11:38:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017983; 29 May 86 0:46 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a012745; 29 May 86 0:33 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA28277; Thu, 29 May 86 00:34:54 edt
Date: Thu, 29 May 86 00:34:54 edt
From: "UNIX 4.2 BSD" <root@ICST-CMR.ARPA>
Message-Id: <8605290434.AA28277@icst-cmr.ARPA>
To: guy@sun.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Warnings
     
    > I also thought that casting anything into a (void*) would be a big
    > no-no.  Lint, and maybe even the compiler, would issue loud warnings
    > every time one tried to do this.
     
    The key word here is "warnings".  The X3J11 standard doesn't say what
    constructs may not give warnings; it merely states what is and isn't
    legal C.  As long as the compiler produces code for it, X3J11 doesn't
    care how many complaints it puts out.
     
There are those of us who consider it bad practice for the compiler to utter
ary a peep. Even when we indulge in other bad practices. I bet you are one.
     
        Guy Harris
        {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
        guy@sun.arpa
     
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    What UNIVERSE is this, please??

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4398
          for JMS@ARIZMIS; Sat, 31-MAY-1986 10:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020723; 29 May 86 8:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018557; 29 May 86 7:51 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <1677@umcp-cs.UUCP>
Date: 24 May 86 04:11:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The real reason for `void *', which everyone seems to be missing,
is that it provides a generic pointer type.
     
Of course, if you need such a thing, you can usually get away with
     
    union all_possible_ptrs {
        char        *ifchar;
        unsigned char    *ifuchar;
        short        *ifshort;
        unsigned short    *ifushort;
        int        *ifint;
        unsigned int    *ifunit;
        long        *iflong;
        unsigned long    *ifulong;
        float        *iffloat;
        double        *ifdouble;
    };
     
but it is conceivable that this might be insufficent on a
machine with special structure pointers.  On such a machine,
this union might be (say) 30 bits wide, whereas a generic
pointer might be 34 bits.  Thus `void *'.
     
Besides, do you really *want* to use such a union?
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5649
          for JMS@ARIZMIS; Sat, 31-MAY-1986 12:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/31/86 at 14:29:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020793; 29 May 86 8:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018797; 29 May 86 7:58 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: LINT as documentation
Message-ID: <762@steinmetz.UUCP>
Date: 22 May 86 20:24:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <411@ccird1.UUCP> rb@ccird1.UUCP (Rex Ballard) writes:
>This is just one more argument for lint.
>
>True, lint often burps over "trivial" little problems like
>passing a *int to a function that expects *char, among others,
>but there are some real good reasons for using lint.
>
     
These are *NOT* trivial problems! This is the type of things which destroys
portability. On a number of machines, the format of a data pointers is not
at all the same, and passing a wrong type pointer may break the program
completely. These machines include Honeywell (I bet you care), DG, and
Cray. I was part of X3J11 for two years and had it beaten into me why we
needed the "void *" pointer and forced casts. If you think these are
trivial problems you perhaps lack experience with a wide enough variety
of machines. Portability is the *best* reason for lint. There are better
debugging tools available these days.
--
    -bill davidsen
     
  ihnp4!seismo!rochester!steinmetz!--\
                                       \
                    unirot ------------->---> crdos1!davidsen
                                       /
         sixhub ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5811
          for JMS@ARIZMIS; Sat, 31-MAY-1986 13:02 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021545; 29 May 86 8:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018920; 29 May 86 8:01 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <6716@utzoo.UUCP>
Date: 22 May 86 16:39:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
One (relatively minor) defect of grouping by indentation is that it is
sometimes useful to use indenting violations to flag unusual situations.
The obvious example is a classic one:  temporary debugging code not
indented at all, to make it easy to find and remove later.
     
More seriously, any grouping-by-indenting scheme should be studied carefully
for ways in which minor typos could seriously alter the meaning of the
program in non-obvious ways.
--
Join STRAW: the Society To    Henry Spencer @ U of Toronto Zoology
Revile Ada Wholeheartedly    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8012
          for JMS@ARIZMIS; Sat, 31-MAY-1986 17:55 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 05/31/86 at 19:29:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021605; 29 May 86 8:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018934; 29 May 86 8:01 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: void * (was Re: malloc())
Message-ID: <6725@utzoo.UUCP>
Date: 23 May 86 17:42:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > Also, it's a misnomer; it has nothing to do with "void".
>
> I presume the reason why "void *" was chosen is, as stated above, that a
> pointer of type "void *" would, when dereferenced, yield an object of type
> "void", and as such dereferencing a "void *" would be illegal...
     
I believe a contributing reason was the desire to avoid introducing new
keywords.  (Yes, I know, X3J11 has managed to introduce a few; it remains
true that there is a preference for avoiding it.)  Every new keyword is
bound to break some existing programs.
--
Join STRAW: the Society To    Henry Spencer @ U of Toronto Zoology
Revile Ada Wholeheartedly    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1648
          for JMS@ARIZMIS; Mon,  2-JUN-1986 06:04 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 07:54:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014421; 28 May 86 15:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007282; 28 May 86 15:17 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <8@watmath.UUCP>
Date: 22 May 86 13:43:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Well, what *is* the justification for adding "void *" to the language?  To
> allow people to shove pointers around without casts?  (Shudder!)  To make
> lint shut up about malloc()?  Or just to distinguish "generic pointers" from
> pointers that can be dereferenced?  (Could be done with a typedef.  So could
> "void", but they put it in anyway.)
>
> I do not strongly object to the addition of "void *", but I am worried about
> its "hiding" errors.  (I'm one of those purists who thinks that programmers
> *should* use casts to change types.)  Also, it's a misnomer; it has nothing
> to do with "void".
     
When I first heard of (void*), I thought it was a wonderful idea.
malloc() and realloc() would return this type and it would be
guaranteed to be properly aligned and assignable to any other
type of pointer without complaint.  This much turned out to be true.
     
I also thought that casting anything into a (void*) would be a big
no-no.  Lint, and maybe even the compiler, would issue loud warnings
every time one tried to do this.  This wouldn't matter since normal
programs would never need to do it, and the warnings would only be
generated when malloc() and realloc() were compiled.  Unfortunately
this turned out to be false.
     
For some perverse reason that I have never been able to understand,
X3J11 decided that any pointer could be converted to (void*) without
complaint.  There was no need for this additional usage since the
standard also guarantees that any pointer may be correctly cast to
(char*).  It adds nothing useful and makes it much easier to code
undetectible errors.
     
(Lint complains too much about your code?  Don't worry, just change
all the pointers to void* and it will shut up.  (I assume you already
"#define CALL (void*)" and put CALL in front of all your function
calls so that you don't have to check any error statuses.)  Perhaps
lint should have an option which redirects all output to /dev/null?)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1927
          for JMS@ARIZMIS; Mon,  2-JUN-1986 06:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 08:24:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ab00570; 2 Jun 86 9:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000226; 31 May 86 5:48 EDT
From: Doug Gwyn <gwyn@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Why (void *)
Message-ID: <256@brl-sem.ARPA>
Date: 1 Jun 86 02:53:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
"The use of void * ("pointer to void") as a generic object pointer type has
been adopted from C++, a dialect of C developed at AT&T Bell Laboratories.
Adoption of this type was stimulated by the desire to specify function
prototype arguments that either quietly convert arbitrary pointers (as in
fread) or complain if the argument type does not exactly match (as in
strcmp)."
    - from the Draft Rationale for Draft ANSI C

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2144
          for JMS@ARIZMIS; Mon,  2-JUN-1986 07:12 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 08:45:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa00834; 2 Jun 86 9:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002069; 1 Jun 86 5:40 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C, call it PL/2
Message-ID: <264@brl-sem.ARPA>
Date: 1 Jun 86 06:52:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
You don't want to call it PL/2 anyway because it's not PL/1 it is PL/I.
You should call it PL/II.
     
-Ron

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2037
          for JMS@ARIZMIS; Mon,  2-JUN-1986 07:12 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 08:32:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000834; 2 Jun 86 9:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002065; 1 Jun 86 5:40 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: More extensions to C
Message-ID: <263@brl-sem.ARPA>
Date: 1 Jun 86 06:50:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <856@bentley.UUCP>, kwh@bentley.UUCP (KW Heuer) writes:
>
> >(BTW, a really good optimizing compiler can optimize out the temporary.  I'm
> >not fully up on what optimizers are doing these days, but I doubt that there
> >are many compilers which do this.  Optimizing it out is easier if it is
> >declared locally ("{int temp = x; x = y; y = temp;}") instead of being
> >declared at the top of the routine.)
>
> Unfortunately, I think the "clue" gets lost before the optimizing phase.
>
Eh?  Unless you have a machine that has an exchange operator, the compiler
is going to have to allocate a temporary anyhow.  I can't see yow a compiler
could generate better code for  x,,y than what most compilers (even before
optimization do for {register temp =x; x=y; y=temp}.
     
-Ron
     
INEWS SUCKS
INEWS SUCKS
INEWS SUCKS
INEWS SUCKS

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2306
          for JMS@ARIZMIS; Mon,  2-JUN-1986 07:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 09:01:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ab00834; 2 Jun 86 9:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002073; 1 Jun 86 5:41 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: Min/max and bool
Message-ID: <265@brl-sem.ARPA>
Date: 1 Jun 86 06:55:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> (a) is the biggie.  Why add bool when "typedef enum { FALSE, TRUE } bool;"
> works fine?  (Relying on ANSI C's treatment of enums as real ints).
     
Because it wouldn't work.  FALSE=0, TRUE= anything else.
     
-Ron

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2402
          for JMS@ARIZMIS; Mon,  2-JUN-1986 07:28 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 09:13:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ac00834; 2 Jun 86 9:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id aa02077; 1 Jun 86 5:41 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: Casting a postdecrement operand
Message-ID: <266@brl-sem.ARPA>
Date: 1 Jun 86 07:01:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1273@ulysses.UUCP>, jss@ulysses.UUCP (Jerry Schwarz) writes:
> In article <114@romp.UUCP> lwh@romp.UUCP (lwh) writes:
> >        ((struct abc *)cbap)++;
> >to increment cbap by 500. It appears that the ANSI standard doesn't say
> >anything about the legality of this syntax.
>
> "++" requires an lvalue. A cast produces a value but not an lvalue,
> so this is not legal in ANSI (or in K&R ) C.
I find this disgusting but
        ( *((struct abc **)&cbap) )++;
would work.
     
INEWS SUCKS
INEWS SUCKS
INEWS SUCKS
INEWS SUCKS

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2830
          for JMS@ARIZMIS; Mon,  2-JUN-1986 08:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021687; 29 May 86 8:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018952; 29 May 86 8:02 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <6726@utzoo.UUCP>
Date: 23 May 86 18:31:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Yes, I know you said "sometimes re-doing", but that is often impossible,
> under the press of circumstance.
     
The press of circumstance must be firmly resisted if it's going to lead to
shoddy work.  I agree that there is considerable incentive to get things
close enough to correct that major revision at the last minute isn't needed.
     
> ... Beyond a certain minimum size, design/code/debug is faster than
> code/debug.
     
Ah, but is design/code/debug/release/withdraw/revise/really-release faster
than code/debug/try/code/debug/release? :-)  More seriously, I do acknowledge
the need to have some idea of where you're going before you set out to
get there.  And the degree of advance planning needed is indeed a function
of project size.  But getting where you're going and then discovering that
you really want to be somewhere else should be treated as a predictable
part of the development process, not as a rare and surprising exception.
--
Join STRAW: the Society To    Henry Spencer @ U of Toronto Zoology
Revile Ada Wholeheartedly    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2981
          for JMS@ARIZMIS; Mon,  2-JUN-1986 08:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021773; 29 May 86 8:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019419; 29 May 86 8:13 EDT
From: friesen%psivax.uucp@BRL.ARPA
Newsgroups: net.lang.c,net.micro.pc
Subject: Re: double (*parray[15])[];
Message-ID: <1220@psivax.UUCP>
Date: 24 May 86 17:54:31 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <863@cyb-eng.UUCP> topher@cyb-eng.UUCP (Topher Eliot) writes:
>There has been some debate on what the declaration
>    double (*parray[15])[];
>means.  David Herron seems to be arguing that it declares a zero-length
>array of some sort, which some people and/or compilers might interpret as
>being a pointer of the same sort.
[Topher Eliot's parse]
>
>    double (*parray[15])[];
>               ^^^^
>1.  It's an array with 15 elements
>
>    double (*parray[15])[];
>        ^^^^^^^^^^^
>2.  It's an array of 15 pointers.
>
>    double (*parray[15])[];
>           ^^^^^^^^^^^^^^^
>3.  It's an array of 15 pointers to arrays (the sizes of these arrays being
>pointed at is not specified).
>
>    double (*parray[15])[];
>    ^^^^^^^^^^^^^^^^^^^^^^
>4.  It's an array of 15 pointers to arrays of doubles.
>
    This is indeed correct, and the problem with this declaration
stems from #3. The declaration declares an array of pointers to
entities of *undefined* size(not zero size). Due to the way pointer
arithmetic is defined in "C" this is not kosher(the compiler cannot
determine how much to add to the pointer). At least one compiler I
know of "accepts" this declaration by treating the unspecified arrays
as having size 1, thus making the declaration eqiuvalent to:
     
    double *parray[15];    /* Array of pointers to double */
     
Since this is likely what the user really wanted anyway this works
out, but it is still wrong!
--
     
                Sarima (Stanley Friesen)
     
UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ??

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3091
          for JMS@ARIZMIS; Mon,  2-JUN-1986 08:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021852; 29 May 86 8:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019691; 29 May 86 8:18 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <666@bu-cs.UUCP>
Date: 25 May 86 18:41:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Re: To design then code, code then design, a little of each iteratively? etc.
     
Obviously it depends on the problem, let's ignore the trivial cases.
     
One major consideration to always take into account is "who is the customer?"
     
When I am programming something by request/contract of someone else
a whole different set of rules come into play. Before I start coding
the User's Manual is written, delivered to the 'customer' and agreed
to, preferably in writing.
     
99% of the heartache I've encountered in coding for someone else had
to do with delivering the more or less finished product and having
the "customer" suddenly get this surge of creativity upon playing
with the program (gee, why can't you make a "few little changes" to...)
     
At least I can point to the User's Manual that was signed off and possibly
at that point offer to negotiate a new project. They don't like it, but
they can usually understand it.
     
If there are other potential complexities I would go for a Maintainer's
(or System Administrator's) guide. This was important in one case where
I was building a data-base system and I sincerely felt they did not
understand that they needed more disk to do what they wanted. I sent
over some pre-docs with "worksheets" to estimate disk needs and asked
them to please have someone work through them with me a little as in
conversations I saw them waving their hands and all they seemed to
be thinking about was the price of the disk(s).
     
And so on...
     
I think the most dangerous thing that happens to a program that did
not have enough aforethought is the sudden realization that the
data structure(s) involved were not powerful enough to do the job,
this can ripple through an entire software system and practically
require ground-up re-write. I've had it happen.
     
With the hope of not immediately starting the obvious flame-fest,
people who code in FORTRAN are most liable to this failure as they are
strongly motivated to make every problem work in terms of scalars and
arrays.  Not that they *can't* represent a binary tree, but because of
the unnaturalness of that in FORTRAN they will tend to try to ignore
that option until it is too late. Often if FORTRAN is their only
language they aren't very sophisticated in recognizing the problem,
but that's another issue.
     
Generally, in a reasonably well-coded program the algorithms are fairly
easy to replace (how hard would it be to change sort methods for example)
as it involves re-writing a specific module and generally leaving the rest
alone. A change in data structures, however, can almost never be localized
in effect. At the very least, besides the issue at hand, input and output
(and storage/retrieval) routines usually have to be re-written.
     
The conclusion would be, therefore, design your data structures carefully
and with aforethought. If you don't want to design all the algorithms
beforehand keep things modular and recognize what pieces you may want
to replace later.
     
TRAP: Changing the algorithm CAN sometimes demand changing the data structure.
     
When in doubt, sketch it out.
     
In defense of the iterative process this is often actually used to
explore possibilities to use in the design. If the code used in the
"experiments" happens to get used in the final project, all the
more better, but don't let the tail wag the dog.
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3299
          for JMS@ARIZMIS; Mon,  2-JUN-1986 09:31 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022302; 29 May 86 8:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019699; 29 May 86 8:18 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: questions from using lint
Message-ID: <667@bu-cs.UUCP>
Date: 25 May 86 19:07:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Re: User wants interactive, interpreted environment for C development
     
I believe the product SAFE/C from Catalytix Corp (Cambridge, MA?) provides
this. I have never used it but from what I have read and heard (a friend
was one of the developers) that is the basic idea of the product. If someone
has used this product I would be interested in your impressions. It is
available on a variety of machines and I believe is meant to be portable
but the marketing interest would probably have to be there, I dunno, ask em.
     
I think the main problem I would expect from such a product would be the
memory model. I suspect that memory management errors (eg. over-running
a malloc()'d area) could be hard to detect within the interpreted
environment unless carefully and specifically checked for (in which
case, what if I *want* to do some sort of overlaying/equivalencing.)
     
The point is (forgive me) that in the interpreted environment things
would point around differently than in the final compiled environment.
This is one reason why the lack of explicit pointers in LISP is a good
thing (I know, most lisps can allow an internals person to do an (addr x),
but it is highly disrecommended for several reasons in a program.)
     
I remember speaking about this with my friend when he was developing
and, although he agreed that yes indeed, that's a problem, they had
some compromise (I forget, maybe something like enabling/disabling
intensive checking with lintish /*SCREWMEM*/ statements, or maybe
that's just what they were considering at the time, this goes back
a coupla-few years.) I believe one of the main goals of the product
was to provide extensive run-time checking during development/testing.
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3642
          for JMS@ARIZMIS; Mon,  2-JUN-1986 09:35 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022907; 29 May 86 9:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020558; 29 May 86 8:36 EDT
From: Michael Meissner <meissner%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Structure initialization rules question
Message-ID: <366@dg_rtp.UUCP>
Date: 25 May 86 18:08:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <696@moscom.UUCP> noemi@moscom.UUCP writes:
>
>    Why is it that you can only initialize structures when they are global
>    (outside of main() )?  If you initialize a structure within a function
>    you get an "No auto. aggregate initialization" error.  I don't see
>    anywhere in K&R where the structure initialization rules are explained.
     
    Under K&R (probably in appendix A where the real rules are spelled out)
it mentions that only aggreates (read arrays and structures) with static
storage (read static and global) can be initialized.  Ansi X3J11 (as of the
last meeting) allows initializing auto and register aggregates, providing
all members are constant.  The last constraint avoids some nasty problems
with regard to order of evaluation, and makes compilers unduely complex.
     
    As to why you could not initialize an auto aggregate, I think it was
because the PDP-11 did not have a block copy instruction, or that DMR did
not consider structures full fledged items (remember no structure arguments,
structure assignment, etc.).
     
    Michael Meissner, Data General
    ...{ decvax, ihnp4, ... }!mcnc!rti-sel!dg_rtp!meissner

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3492
          for JMS@ARIZMIS; Mon,  2-JUN-1986 09:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022541; 29 May 86 8:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020032; 29 May 86 8:25 EDT
From: Smith <petera%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: The cost of large uninitialized static/global arrays
Message-ID: <2810@utcsri.UUCP>
Date: 21 May 86 20:41:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
     
     
     If you are programming in C and are worried about the size of
your executable file and the time required to load this file off disk
ie as with an editor or other frequently used utility, consider a
reasonably large C program with a declaration of a global or static
array which is pretty big relative to the size of the executable
program. For example consider a program of around 80K with a 64K
array declared but uninitialized until run time eg: something like:
     
     char *bigarray[16384];
     
     Depending on the linker/loader/compiler we may end up with the
executable program occupying 80K+64K on disk. Where 64K of the disk
space is NULL. Hence everytime we execute it, it takes nearly twice
as long to load off disk! And, what does it do during that time? It loads
NULL's into memory! What a complete waste of time and space. Especially
if you are executing the program frequently, nearly half of the load
time is wasted, not to mention nearly half the space occupied by each
copy of the dormant executable file.
     
     While this may be obvious to many experienced assembly language
programmers, it may not be obvious to other programmers. I had learnt
the lesson while programming in 8080 for my old H-8 where memory and
disk space were scarce but had completely forgotten about it because
of the large amount of memory now available on most machines. It only
just hit me again when I happened to look at a uuencoded copy of one of my
programs. The uuencoding was nearly all blanks ie compressed NULLs.
     
     Some compilers/linkers/loaders may avoid this problem by not
storing large uninitialized static/global data in the executable
file, but rather expanding it at load time. In the case of MS-DOS
this appears not to be done. So, the lesson learned is to allocate
your large uninitialized static/global space at run time and then
you do not have to worry about how smart the loader is. This is
probably one major factor why some C programs compile to a large
executable file on one machine but to a significantly smaller file
on another.
     
     Peter Ashwood-Smith
     University Of Toronto.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3789
          for JMS@ARIZMIS; Mon,  2-JUN-1986 09:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 11:28:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ad00834; 2 Jun 86 9:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002081; 1 Jun 86 5:41 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <267@brl-sem.ARPA>
Date: 1 Jun 86 07:15:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <113@watmath.UUCP>, rbutterworth@watmath.UUCP (Ray Butterworth)
 writes:
     
> There is a need for two special types of generic pointers:  one which
> is guaranteed to be aligned and can be cast into any other pointer, and
> one which has no such guarantee and can have any other pointer cast
> into it.  (void*) clearly fits the former.  (char*) almost fits the
> latter (perhaps a new (pointer) type should have been introduced).
> X3J11 defeated the niceness of all this by extending their definition
> of (void*) to fit both requirements.  I really don't understand why
> they would do such a thing.  It gains nothing and loses a lot.
     
Eh?  "void *" is a pointer that is big enough to hold any other pointer.
It makes no attempt at alignment.  Nowhere in C is there any guarantees
on alignment.  You assign an unaligned char into an int pointer on some
machines it will work, some it won't be aligned right, and some will
generate bizarre pointers as a result.  It is a feature of MALLOC that
it never puts anything into that void* it returns that isn't aligned,
but that is extremely implentation dependant.
     
-Ron

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3696
          for JMS@ARIZMIS; Mon,  2-JUN-1986 09:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022977; 29 May 86 9:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020657; 29 May 86 8:38 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <2786@utcsri.UUCP>
Date: 18 May 86 16:22:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <131@stracs.cs.strath.ac.uk> jim@cs.strath.ac.uk (Jim Reid) writes:
>In article <989@dataioDataio.UUCP> bjorn@dataio.UUCP writes:
>>    The state-of-the-art in compilers has progressed on PCs,
>>    so why hasn't anyone come up with a better compiler for
>>    UNIX, or have I just not heard of it?
>>
>Comparisons like that are *totally meaningless* - What about the quality of
                ^^^^^ depending on how many compiles
                you have to wait through.
>the generated code? What "optimisations" do the compilers perform? Do both
>produce much the same symbolic information for debugging? What's involved in
>linking object modules in the two progams? How many passes over the source
>code/expanded code/"parse trees" does each compiler do? The 4BSD compiler has
>at least 5 - 6 if you count linking. First there's the preprocessor, then
>the compiler proper has probably two passes, the assembler has another two
>for good measure (depending on how you look at the assembler). Then there's
>your configuration - how much memory does each system have? How much core
>does each compiler use/need? How much paging or swapping goes on during
>compilation? How much disk traffic - intermediate files etc - is done?
>
Give me a break. Sure, having a separate pre-processor will slow the
compiler down considerably, but is it an advantage?????? It only gives
you a certain amount of convenience in implementing the compiler.
Consider that the cpp has to do lexical analysis as sophisticated as
that done by the compiler, in order to do `#if's. It makes a *lot* of
sense to have the cpp/lexer/parser in a single pass - Much code can be
shared. When you find an identifier, for example, you go look it up in
the #define table before saying you have found an identifier/keyword - as
opposed to going through everything twice. Consider the single
character i/o that will be saved - even if it is done through a pipe.
The only disadvantage is that the cpp and compiler symbol tables must
live together in the same process. If compiler A has more passes than
compiler B, it doesn't mean 'A' is better or more sophisticated - It
could just mean that the implementors of B did a better job.
     
Your argument that the 4.2 compiler is slower because it generates better
code makes sense, but I haven't the slightest idea which one is better
in this area.
     
I know of one *big* reason why the UNIX compiler would be easy to beat
- it produces human-readable assembler. If it produced a binary-coded
assembler, the costs of (1) writing out all that text (2) reading in
all that text [twice] and (3) *lexing* and *parsing* all that &*!@#@
TEXT and looking up all those mnemonics [twice!] would be saved, and no
functionality would be lost. Of course, you would want a
binary-to-human assembler translator as a utitility...
This makes even more sense for any compiler that may have to run off
floppies - the full assembler text can be considerably larger than
the C program, so you would be rather limited in what you could compile
if full assembler were used.
     
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3959
          for JMS@ARIZMIS; Mon,  2-JUN-1986 10:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023104; 29 May 86 9:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021595; 29 May 86 8:55 EDT
From: cg%myrias.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <250@myrias.UUCP>
Date: 23 May 86 20:38:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Jim @ Strathclyde missed the point about the DataLight compiler running
faster on an IBM PC-AT than the standard BSD compiler does on a VAX. The
result is not a comparison of machines, but a comparison of compilers. What
contortions the compiler goes through is irrelevant - how long it takes and
how good the resulting code is are what's important. We all know that most
UN*X C compilers are hogs! I will re-iterate the question that was asked:
Why aren't there any decent C compilers provided with UN*X systems? (Perhaps
there are, and I just don't know about them. By decent I mean that they give
meaningful error messages, never crash or abort, generate good code, and
run quickly.)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3838
          for JMS@ARIZMIS; Mon,  2-JUN-1986 10:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023056; 29 May 86 9:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021460; 29 May 86 8:53 EDT
From: franka%mmintl.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1497@mmintl.UUCP>
Date: 23 May 86 02:03:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5498@alice.uUCp> ark@alice.UUCP writes:
>Frank Adams says:
>
>> As has been noted, one should use restraint in adding new features to a
>> language.  What follows is a list of the features I would support adding to
>> the *next* version of C (after the current standard is complete).
>
>OK, let's see his examples of "restraint:"
>
>> o Min and max operators.  These would get used all over the place.  These
>> should be usable to the left of the assignment operator, as most but not all
>> C operators are.
>
>What would it mean to use these on the left of an assignment,
>and why would you want to use it?
     
It would mean what it usually means.  If "\/" is the minimum operator, then
"a \/= b" would mean "a = a \/ b".  I find it hard to believe that anyone
with any programming experience would need to ask why you would want to use
it.
     
>> o An andif clause for if statements.
>
>What does it do and how would you use it?
     
You would write:
     
  if (A) {
    X
  } andif (B) {
    Y
  } else {
    Z
  }
     
This is equivalent to:
     
   if (!(A)) goto _Z;
   X
   if (B) {
     Y
   } else {
_Z:
     Z
   }
     
>> o The ability to define multi-line pre-processor macros, using #begdef and
>> #enddef statements.  #if and other conditionals in the body of the
>> definition would be evaluated when the macro was not interpreted, not when
>> it is encountered.
>
>Why would you want to use it?
     
To write more sophisticated macros.  For example, one could write a copy
macro which would invoke strcpy in most cases, but a word copy routine to
copy an array of structures whose size is a multiple of a word.  Such a
macro would be machine dependant -- this is exactly the reason for making it
a macro, instead of hard coding the calls.
     
>> o A typeof operator, similar to sizeof.
>
>What would its value be?  Why would you want to use it?
     
"typeof(x)" would be a type, which is the type that x was declared as.  This
is for use primarily in macros.
     
>> o := as a synonym for =.  Compilers could have an option to permit := only.
>
>Why bother?
     
Confusing "=" and "==" in if statements is a common mistake.  If "=" is not
a legal operator, this error becomes very rare.
     
>> o Permit a continue statement in switch, meaning that the next label should
>> be fallen through to.  Compilers and/or lint could produce when a program
>> falls through without a continue statement.
>
>A continue statement is already legal in a switch, as long as that
>switch is enclosed in a for or while.  It means go on to the next
>iteration of the enclosing loop.  Are you proposing to change this?
     
Yes.
     
>> o Any sort of multi-level break statement.  There is no syntacticly clean
>> way of adding this to C.
>
>C already has a multi-level break statement.  It's spelled "goto."
>Putting a goto in a costume doesn't disguise it.
     
You weren't reading very carefully.  This was on my list of things which
should *not* be added.
     
>> o Elimination of the eight-character truncation of internal variable names
>> done by some compilers.  (This may be in the current spec; I haven't read
>> that document.)  The entire length of a variable name should be significant.
>
>Most compilers do this already.
     
So let's make it part of the standard, and those of us who like to write
portable code can start using it.
     
>The trouble with adding new features to C is that there is a very
>strong incentive not to use them.  After all, any program that
>uses some new feature is only going to run on machines that support
>that feature.  I don't think I'm going to be using only one compiler
>for the rest of my life and would like to avoid changing my code
>every time the environment hiccups.
     
This is the whole point of having a standard.  It gives you some assurance
that compilers which use the features will be available.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4121
          for JMS@ARIZMIS; Mon,  2-JUN-1986 10:19 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028153; 29 May 86 11:43 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a026002; 29 May 86 11:27 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA29441; Thu, 29 May 86 11:28:20 edt
Date: Thu, 29 May 86 11:28:20 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605291528.AA29441@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Re:  questions from using lint
     
The conclusion would be, therefore, design your data structures carefully
and with aforethought. If you don't want to design all the algorithms
beforehand keep things modular and recognize what pieces you may want
to replace later.
     
    -Barry Shein, Boston University
     
    Another excellent article Barry! One thing I might add is that
    it has been said (I always forget by who) `show me your data
    structures and the program becomes trivial'. Down with flowcharts!
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    Will this never-ending series of PLEASURABLE EVENTS never cease?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4235
          for JMS@ARIZMIS; Mon,  2-JUN-1986 10:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029876; 29 May 86 13:04 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a027283; 29 May 86 12:47 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA29669; Thu, 29 May 86 12:48:11 edt
Date: Thu, 29 May 86 12:48:11 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605291648.AA29669@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Humor
     
    Re: SAFE/C
     
    I remember speaking about this with my friend when he was developing
    and, although he agreed that yes indeed, that's a problem, they had
    some compromise (I forget, maybe something like enabling/disabling
    intensive checking with lintish /*SCREWMEM*/ statements, or maybe
    that's just what they were considering at the time, this goes back
    a coupla-few years.) I believe one of the main goals of the product
    was to provide extensive run-time checking during development/testing.
     
        -Barry Shein, Boston University
     
Is the /*SCREWMEM*/ directive anything like the BASIC `poke' statement :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    I'll eat ANYTHING that's BRIGHT BLUE!!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5256
          for JMS@ARIZMIS; Mon,  2-JUN-1986 12:58 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 14:31:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa01009; 29 May 86 13:51 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a028521; 29 May 86 13:34 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA29800; Thu, 29 May 86 13:34:33 edt
Date: Thu, 29 May 86 13:34:33 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605291734.AA29800@icst-cmr.ARPA>
To: bentley!kwh@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re: What's wrong with printf( ) , return ?
     
    In article <123@danews.UUCP> danews!lvc writes:
    >I knew that return wasn't an expression.  The fact that you can
    >do `control flow' with , seperating expressions makes me wonder
    >why this wasn't extended to include 'some' statements such as return.
     
    It makes about as much sense as "printf() + return".  Comma in
    this context is an *operator*.  A more serious argument would
    be to allow the statement "return ((void)printf())", which
    would make sense if "void" were a real datatype.
     
    Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
You are mesmerized by control flow. In LISP or FORTH, *every*
statement/function/word returns a value *regardless* of what it does
(magically) to the program counter. Consider that most if's can
be transformed as follows (assuming true and false are expressions:
     
    if (c)            c ?
        true;            true :
    else    false;            false;
     
We are halfway there. Now consider LISPish control flow in C:
     
    typedef int (*PFI)();
     
    C_if(si,oui,non) register PFI si, oui, non;
    {    return (*si)() ? (*oui)() : (*non)();
    }
     
    C_while(cond,body) register PFI loop, body;
    {    register int result;
        while((*loop)()) result = (*body)();
        return(result);
    }
     
We should probably add argument arguments (for arguments sake)
in argv format natch! Oops, we need to have one of these for each
data type! Hey, why don't I just use LISP? Well I do like the data
structures and operators. My point is that control flow is not
magic, that any statement can return a value.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
Is a tattoo real, like a curb or a battleship? Or are we suffering in Safeway?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6461
          for JMS@ARIZMIS; Mon,  2-JUN-1986 15:04 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/02/86 at 16:49:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001238; 29 May 86 14:03 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a029128; 29 May 86 13:48 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA29847; Thu, 29 May 86 13:48:50 edt
Date: Thu, 29 May 86 13:48:50 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605291748.AA29847@icst-cmr.ARPA>
To: ccvaxa!aglew@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re: A good use of a bad feature
     
> >/* Written 10:49 am  May  4, 1986 by root@icst-cmr in net.lang.c */
> >You will find much disagreement on that point, I'm afraid. Fall thru is
> >more flexible. You can always break, but often cases are related so that
> >a particular case requires a superset of another case. It is to DMR's
> >credit that he realized this feature. I sure wouldn't have thought of it.
> >/* End of text from net.lang.c */
>
> And what do you do if you have more than one case which is a superset of
> another? Eg.
     
Exactly what you illustrate.
     
>     case A      case B
>           \    /
>            \  /
>              case C
>                 |
>                 |
>                 break
>
> Dup code or use gotos. The worst is when people use combinations of gotos
> and fall-through:
     
If used indiscriminately. C's beauty is that it is *basically* structured,
with allowance for escape when necessary.
     
>     case A:
>         ...
>         goto case_C;
>     case B:
>         ...
>         /* fall through */
>     case C:
>     case_C:
>         ...
>         break;
>
> There should be one way to do things.
     
There is.
     
> Special case constructs should only be used if they crop up frequently.
     
They do.
     
> I don't think fall through qualifies.
     
It does. Fall thru can simulate non fall thru, but not vice versa.
I have seen several programs (yours maybe?) with
#define when break;case & #define otherwise break;default
     
> Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
> 1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms
     
Well, at least you made up a mickname for yourself.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    We are now enjoying total mutual interaction in an imaginary hot tub...

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6613
          for JMS@ARIZMIS; Mon,  2-JUN-1986 15:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007603; 29 May 86 19:07 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a003989; 29 May 86 18:52 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA16559; Fri, 23 May 86 14:59:26 edt
Date: Fri, 23 May 86 14:59:26 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605231859.AA16559@icst-cmr.ARPA>
To: danews!lvc@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re:  What's wrong with printf() , exit() ?
     
    > What's wrong with
    >     printf("usage: foo bar\n"), exit(1);
    > as above?
    >
     
    Aside from style, exit is a statement syntatically but , requires
    expressions.  The compilers I've used will accept this and do
    what you'd expect.  Why is that ?  Is this a special exeption ?
     
    Compilers may exist that won't accept it.  However, this:
     
        printf("uage: foo bar\n"), return 1 ;
     
    generates a syntactic error message.  If a compiler accepts , exit()
    why not , return ?  Maybe it's too complicated to do, and not worth the
    trouble.
     
    Some uses of , are transparent and useful.  Such as multiple initial-
    izations in a for loop, e.g. for(i = 0 , j = 1; ...).  Doing all the
    relevant initializations in one place is important.  Or in a while loop:
     
        while(readresp(CMD), command)
     
    where readresp is a void function (and has to be) and command is side
    affected several routines down.  Coding this without the , obscures the
    code (at least to me).
     
Why does it have to be a void function? In fact, conceptually, this
makes no sense and would be logically the same as writing:
     
        while ( ,command)
     
which to my compiler (VAX 4.2BSD) is a syntax error. Taking a closer look
at the comma operator reveals that is is relatively unnecessary, seemingly
created for the sole purpose of multiple clauses in the `for' statement.
This reminds me of a similar technique used in APL, <exp> ,0 RHO <exp>,
used to reshape (read cast) the second exp (which is eval'ed first)
into a null vector, which is concatenated onto the first exp. The same
syntax could have been used in C at the expense of runtime:
     
    for ((i = 1) + (j = p); i < j; ++i + j++)
     
The comma operator merely throws the left value away, no combining done.
Note to Doug Gwyn: Hey, this is really the `Omega' function (look ma,
no x) i wrote about awhile back, but it's not the Boolean one.
     
    Larry Cipriani        Nothing is worse than having
    danews!lvc        an itch you can never scratch
     
(Root Boy) Jim Cottrell        <rbj@cmr>
"One man gathers what another man spills"
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6909
          for JMS@ARIZMIS; Mon,  2-JUN-1986 15:35 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003630; 30 May 86 8:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010169; 30 May 86 7:40 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <252@brl-sem.ARPA>
Date: 29 May 86 19:12:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1677@umcp-cs.UUCP>, chris@umcp-cs.UUCP (Chris Torek) writes:
> The real reason for `void *', which everyone seems to be missing,
> is that it provides a generic pointer type.
>
> Of course, if you need such a thing, you can usually get away with
>
>     union all_possible_ptrs {
     
Sorry Chris, but you've missed the point of void * a bit.  First, UNIONS
are only half citizens so you'd have to encapsulate it in a structure, so
things like MALLOC can return it.  Also, having written code on a rather
strangely addressed machine, it won't work for the case every one makes
for void * (malloc).
     
The typical use:
    void * malloc();
    short *x;
     
    x = (short *) malloc(sizeof (short));
     
On the HEP, two problems arise.  The small order bits of the address actually
indicate the partial word size saying:
     
     union  {
        int    *u_intp;
        short    *u_shortp;
    } un;
    short    *x;
     
    int  *malloc();
    un.u_intp = malloc(sizeof (short));
    x = un.u_shortp;
     
will cause unpredicatble results when x is used.  We got this from experience
becuase the 4.2 kernel we were porting uses the above construct all over the
place, assuming that pointers are universal accross all types.
     
-Ron

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7003
          for JMS@ARIZMIS; Mon,  2-JUN-1986 15:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003736; 30 May 86 8:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011670; 30 May 86 8:01 EDT
From: Bob Bickford <rab%well.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: questions from using lint
Message-ID: <1157@well.UUCP>
Date: 27 May 86 04:47:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[WHAT line ea
     
     
In a previous article, an anonymous person writes:
>
> > You people fail to realize that some of us out here don't like lint.
> > It complains too much about what I do. I refuse to go any further
> > than generating no compiler warnings. I know what I'm doing. When I
> > goof, I'll fix it myself. I refuse to add extra casts to keep lint
> > happy.
> >
     Of course, an expert like yourself would not consider stooping to
making modifications to lint which match your programming preferences.
And, of course, since you're omnipotent (at least within your machine)
then there is no point in indirectly soliciting the impartial opinion
of another competent programmer: if there are any bugs, well by God you
put them there on purpose!
     
> >
> > Before you start flaming my style, let me say I am quite good.
> > I am also quite philosophical and attentive to coding style.
> > My outlook is just different. I program for myself. If it is applicable
> > to you, fine. I have my own criteria which I rarely see embraced by
> > others waving standardization flags.
> >
     And of course the desires of your employer to have a working product
that will remain usable even if you suffer an untimely death are completely
irrelevant to your criteria....  What the heck, if another person can't
figure out a few tens of thousands of lines of code without your help,
why they must not be a very good programmer!
     
> >
> > Most of the code I have written was intrinsically non-portable. I *do*
> > appreciate portability as a spectrum concept, but not as a binary one.
> >
     Define 'spectrum' and 'binary' as used in this context.
     
     
     
Responding to the above (and more like it) Greg Paris writes:
>
> Sorry I enclosed so much of the original article above, but I found it
> so surprisingly bizzare, I just couldn't leave any of it out.  I have
> two things to say about it: 1) I'm glad that Mr. XYZZY doesn't work
> here; 2) I'd never recommend him being hired as a programmer, anywhere.
> --
> ++------------------------------------------------------------------++
> ||  Greg Paris    {allegra,linus,raybed2,ccice5,brunix}!rayssd!gmp  ||
> ++------------------------------------------------------------------++
>
     
    I, for one, thoroughly agree with you.  Individual programming style
is one thing; complete contempt for rational coding practice is quite
another.
     
     
--
Robert Bickford     {lll-crg,hplabs}!well!rab

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7303
          for JMS@ARIZMIS; Mon,  2-JUN-1986 16:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004680; 30 May 86 8:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012000; 30 May 86 8:08 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C vs. FORTRAN (was: What should be added to C)
Message-ID: <853@bentley.UUCP>
Date: 26 May 86 18:29:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1594@ecsvax.UUCP> ecsvax!dgary (D Gary Grady) writes:
>Right now Fortran has four things over C:
     
Of which I'd like to address the first two.
     
>o A richer set of floating point operators, including exponentiation and
>  the so-called "in-line" functions (many of which ARE in C).
     
I think you mean "builtin" rather than "inline".  I don't even consider that
a significant difference, much less an advantage of FORTRAN.  Exponentiation
in general is syntactically neater in FORTRAN but semantically identical on
most machines.  Exponentiation with integer exponents is a problem in C; it
isn't even available as a library function!  When the exponent is constant
(usually 2 or 3 in practice) it could easily be coded inline, but it's not
clear whether that's sufficient justification for making it an operator.
     
>o A way of passing different-sized multidimensional arrays to the same
>  subroutine.  (For instance, right now it is not possible to write a
>  function in C that will invert a matrix of arbitrary size without use
>  of some "trick," like making the incoming matrix one-dimensional and
>  hard-coding the subscript computation or using arrays of pointers to
>  pointers.)
     
Again, this is merely a syntactic quibble -- what FORTRAN does is equivalent
to the one-dimensional "trick", but it's hidden from the user.  FORTRAN lets
you use a variable as a bound in an array declaration, in this special case.
That probably wouldn't be too hard to add to C; in fact it might be possible
to generalize it to allow *any* nonstatic array declaration to have variable
size (within reason).
     
Another advantage of FORTRAN is implicit DO loops in I/O statements, and the
related ability to use (constant, at least) repeat counts in FORMATs.  I had
a program that made this painfully clear when it was translated from FORTRAN
to C.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7401
          for JMS@ARIZMIS; Mon,  2-JUN-1986 16:18 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004764; 30 May 86 8:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012015; 30 May 86 8:08 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expression, expression;
Message-ID: <854@bentley.UUCP>
Date: 26 May 86 18:47:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <892@ttrdc.UUCP> ttrdc!levy (Dan Levy) writes:
>I think there may be at least one good reason NOT to do this ...: for
>debugging.  If you have code which is giving mysterious core dump problems,
>Murphy's law says sdb or adb will show the problem occurring on a line with
>multiple statements on it ...
     
Well, what *I* do is look at the *instruction* where it bombed, rather than
the statement.  Of course, for less sophisticated users (or when using a
too-smart debugger that won't disassemble) that may not be an option.  This
brings up an interesting question, though.  Given that the language is
almost completely free-format, why should a debugger be line-oriented rather
than statement- or expression-oriented?  (Probable answer: it's trivial to
"point to" a line.)
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7177
          for JMS@ARIZMIS; Mon,  2-JUN-1986 16:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004531; 30 May 86 8:41 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011994; 30 May 86 8:08 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <852@bentley.UUCP>
Date: 25 May 86 23:36:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1462@mmintl.UUCP> mmintl!franka (Frank Adams) proposes:
>> o Min and max operators.  These would get used all over the place.  These
>> should be usable to the left of the assignment operator, as most but not all
>> C operators are.
     
In article <5498@alice.uUCp> alice!ark responds:
>What would it mean to use these on the left of an assignment,
>and why would you want to use it?
     
I think he means that in addition to MIN and MAX there should be MIN= and MAX=
operators.  I think this is a good reason for making them operators rather than
functions.  "x MIN= y" is clearer than "if (x > y) x = y", since the latter can
easily be misread as "x MAX= y", besides being subject to side effects.
     
>> o An andif clause for if statements.
>
>What does it do and how would you use it?
     
More specifically, how does it differ from "&&"?
     
>> o The ability to define multi-line pre-processor macros, using #begdef and
>> #enddef statements.  #if and other conditionals in the body of the
>> definition would be evaluated when the macro was not interpreted, not when
>> it is encountered.
     
The m4 preprocessor already has this functionality, and more.  Of course, if
using C without UNIX(R), you may not have m4...
     
>> o A typeof operator, similar to sizeof.
>
>What would its value be?  Why would you want to use it?
     
Presumably "typeof(variable)" would be syntactically a dataype, so it's not
really appropriate to call this an "operator".  There's one obvious use,
"p = (typeof(*p) *)malloc(sizeof(*p))".  I guess you could also use it in
"#define swap(x,y) {typeof(x) temp; temp=x; x=y; y=temp;}".  I don't know
that either of these is very useful, though.
     
>> o := as a synonym for =.  Compilers could have an option to permit := only.
     
To help catch "=" vs. "==" errors?  Or just to make PASCAL users happy?  (And
then we could make "<>" a synonym for "!=", and ...)
     
>> o Permit a continue statement in switch [to denote fall-through].
     
I'll address this elsewhere.
     
>> o Any sort of multi-level break statement.
     
No!  If you have code that seems to require a multi-level break, you should
think some more about the problem you're trying to solve.  If it's really
necessary, use a goto.  (I very seldom use even a one-level break, except as
the unique exit point in a "for (;;)" loop when it's too far from either end
to conveniently convert it into a "while" or "do".)
     
>The trouble with adding new features to C is that there is a very
>strong incentive not to use them.  After all, any program that
>uses some new feature is only going to run on machines that support
>that feature.  I don't think I'm going to be using only one compiler
>for the rest of my life and would like to avoid changing my code
>every time the environment hiccups.
     
Does this mean you don't use enum, void, or struct assignment?  The
"best" solution is to add the features to the official definition of
the language, but avoid using them in your code until "all" machines
support those features.
     
>>exchange operator.  This one is quite frequently useful, and the
>>alternatives are ugly.
     
Taking into consideration how bad the alternatives are, it *might* be a
good idea to make this a builtin operator; perhaps ":=:".  Either Andy's
suggestion of a concurrent assignment operator (could this possibly be
made a variant of struct assignment?) or my ",," operator would be more
powerful, if you don't have to worry about side effects.  (How often do
you need "a[i++] SWAP a[j++]" anyway?)
     
>>I do not support the following:
>>
>>o ^^ for logical exclusive or.
     
I agree with you here.  If both sides are true booleans (value zero or
one), either "^" or "!=" will do.  If not, then the user can just use
the standard "cast to boolean", namely "... != 0".  There's no loss of
efficiency since that's exactly how the compiler evaluates an integer
in a boolean context, and it probably makes the code easier to read, too.
     
>>o Doing anything about the array/pointer relationship.  What we have now is
>>a mess, but any attempt to fix it will produce a worse mess, either in the
>>language or with existing code.
     
Well, the change from "=OP" to "OP=" also broke existing code, but was done
quite nicely by phasing it in slowly.  I think it's possible to implement
arrays cleanly and introduce the changes gradually, but it's questionable
whether this should be done to C.  One could instead create a new language
"D" (or "P" if you prefer that sequence), which fixes several problems in C
without trying to be syntactically a superset of it.  A C-to-D translation
program would be a big plus.
     
>>o A separate boolean data type (sigh).  This is a good thing to have in a
>>language, but not a good thing to add to C as it exists.
     
I'm not sure why not.  Assuming all the implicit int/bool conversions stay,
I think the only problems are (a) it isn't really necessary, and (b) it adds
a new reserved word (breaking any programs that use "typedef int bool"!).
     
>>o There should be an option to flag statements of the form if (v = e) ...
>>(Actually, I wouldn't be averse to a coding standard which forbade such
>>things, in favor of if (v = e, v) ...)
     
Urgh.  Are you talking about removing the assignment-has-a-value feature
completely, or a special case for "if (v = e)"?  (I always write this as
"if ((v = e) != 0)" to make it clear that I didn't mean "if (v == e)".)
     
Actually, the main argument in favor of valued assignment is to allow such
things as "while ((c = getchar()) != EOF)".  This really doesn't look so
bad with the unvalued assignment "while (c = getchar(), c != EOF), so it
may not be such a bad idea.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
Wait until you see *my* complete list of ideas!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7529
          for JMS@ARIZMIS; Mon,  2-JUN-1986 16:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004806; 30 May 86 8:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012021; 30 May 86 8:09 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Indentation and braces
Message-ID: <855@bentley.UUCP>
Date: 26 May 86 18:55:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <146@cs.qmc.ac.uk> qmc-cs!liam (William Roberts) writes:
>I use programs like "cb" and "indent" to get my C programs
>indented according to what they *REALLY* mean, as opposed to
>what I intended them to mean (indicated by MY indenting).  This
>can be quite illuminating....
     
I presume you then compare it to the original.  Yes, that's a useful trick.
However, if indentation always reflects your intention, then eliminating the
braces and making indentation significant would prevent this type of bug in
the first place!
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7745
          for JMS@ARIZMIS; Mon,  2-JUN-1986 16:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005103; 30 May 86 8:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012179; 30 May 86 8:13 EDT
From: John Bruner <jdb@S1-C.ARPA>
Newsgroups: net.lang.c
Subject: Re: Throwing one away
Message-ID: <7076@mordor.ARPA>
Date: 27 May 86 20:41:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
   "The management question, therefore, is not *whether* to build a
pilot system and throw it away.  You *will* do that.  The only question
is whether to plan in advance to build a throwaway, or to promise to
deliver the throwaway to customers.  Seen this way, the answer is much
clearer.  Delivering that throwaway to customers buys time, but it does
so only at the cost of agony for the user, distraction for the builders
while they do the redesign, and a bad reputation for the product that
the best redesign will find hard to live down.
   "Hence *plan to throw one away; you will, anyhow.*"
     
    [emphasis in the original]
     
    Frederick P. Brooks, Jr.
    *The Mythical Man-Month*
    Addison-Wesley, 1975
    ISBN 0-201-00650-2
--
  John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
  MILNET: jdb@mordor [jdb@s1-c.ARPA]    (415) 422-0758
  UUCP: ...!ucbvax!dual!mordor!jdb     ...!seismo!mordor!jdb

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7636
          for JMS@ARIZMIS; Mon,  2-JUN-1986 16:45 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004877; 30 May 86 8:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012025; 30 May 86 8:09 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: More extensions to C
Message-ID: <856@bentley.UUCP>
Date: 26 May 86 19:34:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1483@mmintl.UUCP> mmintl!franka (Frank Adams) writes:
>In article <826@bentley.UUCP> kwh@bentley.UUCP writes:
>>[Swap] could be considered a special case of my ",," operator: to exchange
>>x and y, write "x = (y ,, (y = x))".
>
>I would prefer a syntax like "{x, y} = {y, x};"  It's more readable.
     
Yes, for a swap.  The real power of ",," is for removing explicit temporary
once-only variables in general; for example, it allows the function
    int pop() {
        int temp1;
        struct stack *temp2;
        temp1 = stk->top;
        temp2 = stk->next;
        free(stk);
        stk = temp2;
        return (temp1);
    }
to be abbreviated to the macro
    #define    pop()        (stk->top,,(stk=(stk->next,,free(stk))))
(A sort of generalization of the postfix operators.  "++x" means "x=x+1", but
"x++" means "x,,(x=x+1)".)
     
>(BTW, a really good optimizing compiler can optimize out the temporary.  I'm
>not fully up on what optimizers are doing these days, but I doubt that there
>are many compilers which do this.  Optimizing it out is easier if it is
>declared locally ("{int temp = x; x = y; y = temp;}") instead of being
>declared at the top of the routine.)
     
Unfortunately, I think the "clue" gets lost before the optimizing phase.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7832
          for JMS@ARIZMIS; Mon,  2-JUN-1986 16:52 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005136; 30 May 86 8:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012203; 30 May 86 8:14 EDT
From: Stuart Cracraft <cracraft%pyrla.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: more intelligent error reporting in C compiler
Message-ID: <26@pyrla.UUCP>
Date: 27 May 86 15:51:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Does anyone know of any implemented C compilers wherein
error reporting is done cleverly (and tersely). So often
it seems that C compilers produce a maelstrom of error
messages when a simple little brace or parenthesis is
misplaced.
     
    Stuart

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7948
          for JMS@ARIZMIS; Mon,  2-JUN-1986 17:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005186; 30 May 86 8:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012363; 30 May 86 8:17 EDT
From: augart <augart%h-sc2.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <963@h-sc2.UUCP>
Date: 27 May 86 11:09:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>>> o The ability to define multi-line pre-processor macros, using #begdef and
>>> #enddef statements.  #if and other conditionals in the body of the
>>> definition would be evaluated when the macro was not interpreted, not when
>>> it is encountered.
>>
>>Why would you want to use it?
>
>When your macro won't fit on a line, and/or you want to use #if's etc
>as part of the macro, obviously.
     
If your macro won't fit on a line, you can already handle this problem by
finishing off each line except the last with a backslash.
The other addition would be a win, though.
     
Steven Augart
swa@xx.lcs.mit.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8976
          for JMS@ARIZMIS; Mon,  2-JUN-1986 19:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005484; 30 May 86 9:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012908; 30 May 86 8:32 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <3770@sun.uucp>
Date: 27 May 86 21:28:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> That probably wouldn't be too hard to add to C; in fact it might be possible
> to generalize it to allow *any* nonstatic array declaration to have variable
> size (within reason).
     
Where "within reason" presumably includes "not inside a structure
declaration".  Even just having "auto" arrays with variable size would mean
that the offset of an "auto" variable from the stack/frame pointer would not
necessarily be a constant.  What about in a "typedef" (or would that be
treated as a static declaration)?
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.arpa

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9080
          for JMS@ARIZMIS; Mon,  2-JUN-1986 19:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005526; 30 May 86 9:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013069; 30 May 86 8:35 EDT
From: K A Gluck <kurt%rruxg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Simple c question - pointer to array
Message-ID: <118@rruxg.UUCP>
Date: 27 May 86 22:19:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Ok if i have a struct which is named in a typedef as T, I
know how to get an array of pointers to T:   T *a[20];
what I want is a pointer to an array of T's.
     
How do I do it,  please mail I will post final answer.
     
    -kurt
    rruxg!kurt

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9182
          for JMS@ARIZMIS; Mon,  2-JUN-1986 19:33 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005570; 30 May 86 9:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013231; 30 May 86 8:40 EDT
From: Dean Elsner <x@mit-prep.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C, call it PL/2
Message-ID: <36@mit-prep.ARPA>
Date: 28 May 86 02:40:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Sorry, I don't think you can call it PL/2!
IBM was going to call PL/1 "NPL" (New Programming Language?) until
National Physical Laboratories told them not to. They then registered
names PL/1 ... PL/100 (!). I don't think they reserved PL/0.
I don't know what 'registered' means here, but I presume trademarked.
This is from memory, and may be wrong.
x@prep.ai.mit.edu (Dean Elsner)   Disclaimer: I am not me. Much. Often.
--
     
x@prep.ai.mit.edu (Dean Elsner)   Disclaimer: I am not me. Much. Often.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9251
          for JMS@ARIZMIS; Mon,  2-JUN-1986 19:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005630; 30 May 86 9:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013521; 30 May 86 8:48 EDT
From: Mike Wexler <mike%peregrine.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Boolean Operators Slighted in C
Message-ID: <392@peregrine.UUCP>
Date: 27 May 86 22:19:47 GMT
Keywords: if boolean integer
To:       info-c@BRL-SMOKE.ARPA
     
In article <822@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>    Boolean quantities form an important abstract data type distinct from
>    counters, sets, real numbers, etc.  By not making the distinction,
>    the language encourages usage errors, the most notorious being
>        if ( a = b )
>            stuff;
>
>True. It is easily found tho.
             ------
How do I easily find these?
Given the following pseudocode fragment
     int xyz(parameter1,parameter2)
    {
    ...
        if (big_expression_1=big_expression_2) statement;
    ...
    }
Where the "=" should be a "==" and the function is producing unexpected
results how would you easily track down this failure.  By easily I mean
more easily than compiling the program and noticing the error about using
an arithmetic expression where a boolean one was supposed to be.  If this
isn't what you meant by easily, what did you mean?
--
Mike Wexler
Email address:(trwrb|scgvaxd)!felix!peregrine!mike
Tel Co. address: (714)855-3923
;-) Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine :-(

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9354
          for JMS@ARIZMIS; Mon,  2-JUN-1986 19:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012125; 30 May 86 13:09 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a019394; 30 May 86 12:53 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02213; Fri, 30 May 86 12:49:02 edt
Date: Fri, 30 May 86 12:49:02 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605301649.AA02213@icst-cmr.ARPA>
To: dataiodataio!bright@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: C Interpreters
     
> In article <473@cubsvax.UUCP> peters@cubsvax.UUCP (Peter S. Shenkin) writes:
> >What I'm waiting for is an interactive interpretive debugger that runs from
> >vi.  The program would run interpretively until an error was encountered,
> >then place you at the appropriate line in the source file with the error
> >message displayed.  Then you could go into insert mode, make the necessary
> >change, and resume execution.  Normally interpreted languages, like APL,
> >often have such facilities.  Are there insuperable difficulties with doing
> >this with a normally compiled language like C?  (I'm sure it could be done
> >with FORTRAN, since FORTRAN interpreters are well-known... but why have we
> >seen no C interpreters?)
     
"The C Journal" (V1#4 Winter 1986) is crawling with them. Well at least four.
     
> Major difficulties are:
>
> 1) The preprocessor. At any line,
> a macro could be changed, which could change the meaning of the entire
> remainder of the source text. This means that 'incremental compiles' becomes
> 'compile from here to the end of the source text'. Of course, that means
> the parser must have the state of the parse saved at every line..., which
> obviously is impractical.
     
What you say is true, but not insurmountable. It would seem to suffice
to build a linked list of pointers to the beginning of each statement.
If a macro changes any statement so that it is incomplete, a broader parse
would have to be redone.
     
> 2) C isn't line oriented. This means that any line could be any part of
> a statement or expression. Thus, the parser must be able to back up from
> any point to find a 'synchronization point'. But C isn't backwardly
> parseable...
     
Even if reparsing had to be done, you might still resynchronize well
before the EOF, probably at the end of the function. As a related issue,
try disassembling an instruction stream starting in the middle of an
instruction some time. It resynch's pdq.
     
> Why BASIC and FORTRAN can be handled this way:
>
> 1) They don't have a preprocessor.
>
> 2) They are line oriented. All the parser has to do is back up to the
> beginning of the line (or in FORTRAN to the first line that isn't a
> line continuation).
>
> 3) Each line is more or less independently parseable from the rest of
> the program.
>
> Conclusion:
>
> The only fully functional, practical way is to do a reparse of the complete
> source file upon any changes (even on whitespace changes). Turbo Pascal
> works this way, instead of attempting to incrementally compile, Borland
> spent their efforts making the compile step really fast.
>
> An incremental compiler could be made if numerous assumptions and
> restrictions were made about what could be changed. I think the bugs
> and kludges that would result would make it impractical, however.
     
Some restrictions could be made that would avoid the problems you
mention. Most people use macros as symbolic character constants and
small localized `statement functions' (to borrow a term). More exotic
macros are rarely used.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    Psychoanalysis??  I thought this was a nude rap session!!!
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9439
          for JMS@ARIZMIS; Mon,  2-JUN-1986 20:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014106; 30 May 86 13:54 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a020139; 30 May 86 13:31 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02385; Fri, 30 May 86 13:31:10 edt
Date: Fri, 30 May 86 13:31:10 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605301731.AA02385@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, x@mit-prep.ARPA
Subject: Trademarks
     
    Sorry, I don't think you can call it PL/2!
    IBM was going to call PL/1 "NPL" (New Programming Language?) until
    National Physical Laboratories told them not to. They then registered
    names PL/1 ... PL/100 (!). I don't think they reserved PL/0.
    I don't know what 'registered' means here, but I presume trademarked.
    This is from memory, and may be wrong.
     
    x@prep.ai.mit.edu (Dean Elsner)   Disclaimer: I am not me. Much. Often.
     
I believe that a trademark must be associated with a particular product.
Now, why doesn't Johns Hopkins University's Applied Physics Laboratory
sue IBM & Ken Iverson over the name APL :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    Is it clean in other dimensions?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9509
          for JMS@ARIZMIS; Mon,  2-JUN-1986 20:15 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015349; 30 May 86 14:32 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a021279; 30 May 86 14:20 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02565; Fri, 30 May 86 14:19:48 edt
Date: Fri, 30 May 86 14:19:48 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605301819.AA02565@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, well!rab@ICST-CMR.ARPA
Subject: Re: Re: questions from using lint
     
> In a previous article, an anonymous person writes:
> > > You people fail to realize that some of us out here don't like lint.
> > > It complains too much about what I do. I refuse to go any further
> > > than generating no compiler warnings. I know what I'm doing. When I
> > > goof, I'll fix it myself. I refuse to add extra casts to keep lint
> > > happy.
> > >
     
What? You mean after all that I am anonymous.
     
>      Of course, an expert like yourself would not consider stooping to
> making modifications to lint which match your programming preferences.
> And, of course, since you're omnipotent (at least within your machine)
> then there is no point in indirectly soliciting the impartial opinion
> of another competent programmer: if there are any bugs, well by God you
> put them there on purpose!
     
Or at least not you.
     
> > >
> > > Before you start flaming my style, let me say I am quite good.
> > > I am also quite philosophical and attentive to coding style.
> > > My outlook is just different. I program for myself. If it is applicable
> > > to you, fine. I have my own criteria which I rarely see embraced by
> > > others waving standardization flags.
> > >
>      And of course the desires of your employer to have a working product
> that will remain usable even if you suffer an untimely death are completely
> irrelevant to your criteria....  What the heck, if another person can't
> figure out a few tens of thousands of lines of code without your help,
> why they must not be a very good programmer!
     
Exactly. There is not all that much you can do to a language to render
it unintellible. Besides, my style is actually intended to `increase'
readability, not detract from it. You didn't address my points.
     
> > >
> > > Most of the code I have written was intrinsically non-portable. I *do*
> > > appreciate portability as a spectrum concept, but not as a binary one.
> > >
>      Define 'spectrum' and 'binary' as used in this context.
     
Your most reasonable statement. In short, there are no blacks or whites,
only shades of grey. There are `safe' things to do, and these are generally
called `portable'. Then there are more risky things to do. They `may' be
portable to `some' machines, but then they may not be either. We all
know the list, byte order, sizes & formats of pointers, etc.
     
There are also `reasonable' and `unreasonable' architectures. Intels
`small model' and `large model' is outrageous. It is not necessarily
the `machine' that is brain-damaged, just the high level language
mapping that is. I mean, the PDP-11 has a 18 or 22 bit physical
address space crammed into a 16 bit virtual address space. But did
PDP-11 C ever have a small or large model? No! Remapping was done
via magic system calls.
     
It is also possible to choose a bad model on a good machine. Motorola
68k's with 16 bit ints are a goood example.
     
> Responding to the above (and more like it) Greg Paris writes:
> >
> > Sorry I enclosed so much of the original article above, but I found it
> > so surprisingly bizzare, I just couldn't leave any of it out.  I have
> > two things to say about it: 1) I'm glad that Mr. XYZZY doesn't work
> > here; 2) I'd never recommend him being hired as a programmer, anywhere.
> > --
> > ++------------------------------------------------------------------++
> > ||  Greg Paris    {allegra,linus,raybed2,ccice5,brunix}!rayssd!gmp  ||
> > ++------------------------------------------------------------------++
> >
>     I, for one, thoroughly agree with you.  Individual programming style
> is one thing; complete contempt for rational coding practice is quite
> another.
     
It is ironic that out in the real world it was I who bothered everybody
else about their coding practices. Now that I am on the net, I am
beseiged with a bunch of portability freaks. I don't believe in
total absolute portability. And I don't care either. If I want to
move it, I fix it. If you want to move it, you fix it.
Sure, it's nice to snarf up a copy of whiz-bang from net.sources and have
it compile and run nary an edit. And portable techniques will in the
long run help you avoid bugs, but it's a tradeoff.
Programs are never finished, merely abandoned. Running lint does
take time, and the extra casts actually muddy up the code. I don't
even have the time to do the things I want, so why should I go to
extra length to do the things I don't?
     
In addition, if a program won't port, you have to look at it. This
is a good thing to do every once in awhile.
     
> Robert Bickford     {lll-crg,hplabs}!well!rab
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
My uncle Murray conquered Egypt in 53 B.C.  And I can prove it too!!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9596
          for JMS@ARIZMIS; Mon,  2-JUN-1986 20:23 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016823; 30 May 86 15:17 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a022346; 30 May 86 14:56 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02639; Fri, 30 May 86 14:55:11 edt
Date: Fri, 30 May 86 14:55:11 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605301855.AA02639@icst-cmr.ARPA>
To: bentley!kwh@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re: What should be added to C
Cc: ~f@ICST-CMR.ARPA
     
>> o The ability to define multi-line pre-processor macros, using #begdef and
>> #enddef statements.  #if and other conditionals in the body of the
>> definition would be evaluated when the macro was not interpreted, not when
>> it is encountered.
     
The m4 preprocessor already has this functionality, and more.  Of course, if
using C without UNIX(R), you may not have m4...
     
    Howabout just porting MACRO-11 to UNIX without the assembler part?
     
>> o := as a synonym for =.  Compilers could have an option to permit := only.
     
To help catch "=" vs. "==" errors?  Or just to make PASCAL users happy?  (And
then we could make "<>" a synonym for "!=", and ...)
     
    And `#' as a synonym for `!=' for BASIC users :-)
     
>The trouble with adding new features to C is that there is a very
>strong incentive not to use them.  After all, any program that
>uses some new feature is only going to run on machines that support
>that feature.  I don't think I'm going to be using only one compiler
>for the rest of my life and would like to avoid changing my code
>every time the environment hiccups.
     
Does this mean you don't use enum, void, or struct assignment?  The
"best" solution is to add the features to the official definition of
the language, but avoid using them in your code until "all" machines
support those features.
     
    Yes. I might use void, (and actually did `#define void  '
    for documentation purposes) because I can see it has a use.
    I might use structure assignment, but would *never* pass
    one as an argument or return one. Enums I shy away from,
    but only because of my inexperience with them. I also
    avoid from unions and bitfields.
     
    C has undergone four major phases. Original C was too
    permissive with structure members and pointer types,
    and lacked a few data types. Next came K&R C. We now
    have added enums, voids, and structure manipulation.
    Since not all C compilers are UNIX based, some have
    only implemented K&R C, or even a subset of that.
    Therefore they are seldom used in portable code.
    The fourth phase is in progress, ANSI C. Things
    should stabilize after this is done.
     
>>exchange operator.  This one is quite frequently useful, and the
>>alternatives are ugly.
     
my ",," operator would be more powerful,
     
    Please explain.
     
>>o A separate boolean data type (sigh).  This is a good thing to have in a
>>language, but not a good thing to add to C as it exists.
     
I'm not sure why not.  Assuming all the implicit int/bool conversions stay,
I think the only problems are (a) it isn't really necessary, and (b) it adds
a new reserved word (breaking any programs that use "typedef int bool"!).
     
    Never! Just another type incompatibility to worry about.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
Wait until you see *my* complete list of ideas!
     
    As long as you don't believe any of them it's OK :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    Hold the MAYO & pass the COSMIC AWARENESS...
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0791
          for JMS@ARIZMIS; Mon,  2-JUN-1986 22:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 00:24:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014830; 2 Jun 86 15:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002553; 2 Jun 86 15:45 EDT
From: ed gokhman <esg%mtx5a.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: re: what should be added to C
Message-ID: <1333@mtx5a.UUCP>
Date: 28 May 86 20:32:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
C++ makes a few interesting enhancements to its C subset.
While playing with C++, I found at least two new features
to be very usefull:
     
1. inline specifier. This is a better alternative to
   macros in that you may have return values for
   multi-statement macros. Plus, of cause, having
   a frequently used feature defined in language proper
   is nice.
     
2. Reference variables, e.g. int& i, used to provide
   call by reference and implemented as a pointer
   to a variable that is dereferenced every time it is used.
     
I would rather see C++ and Concurrent C making their way
into the ANSI standard, but, if it is unfeasible, at least
their usefull additions to the "old C" should see the
world.
     
                    Ed Gokhman
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0895
          for JMS@ARIZMIS; Mon,  2-JUN-1986 22:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015231; 2 Jun 86 16:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002902; 2 Jun 86 15:52 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: static arguments
Message-ID: <1756@umcp-cs.UUCP>
Date: 31 May 86 10:01:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <170@njitcccc.UUCP> ron@njitcccc.UUCP (Ron DeBlock) writes:
>[Someone] accidently declared the arguments to his function as
>static [...].  I realize that it really makes no sense to do that,
>but the compiler did not flag the "error". [...]  The question is,
>are static arguments legal even though they make no sense?
     
No.
     
>If not, why doesn't the compiler flag the problem?
     
It is buggy.  The 4.3BSD C compiler, whatever its faults, gets this
one right: it complains about an `illegal class'.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1007
          for JMS@ARIZMIS; Mon,  2-JUN-1986 22:53 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015297; 2 Jun 86 16:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003065; 2 Jun 86 15:56 EDT
From: Walter Bright <bright%dataiodataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C : if (a=b)
Message-ID: <1008@dataioDataio.UUCP>
Date: 29 May 86 17:09:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <446@cad.BERKELEY.EDU> keppel@pavepaws.UUCP (David Keppel) writes:
>    How about an option to lint(1) (this doesn't help the people who
>    don't have lint) that looks for conditional clauses with assignment
>    but no test.  Thus
>    if ( (a = expr) == value ) { ...
>    would pass cleanly thru lint, while
>    if ( a = expr ) { ...
>    would generate a message indicating a potential problem.
     
Datalight C generates a warning for this:
    if ( a = expr) {
             ^
    Warning: possible unintended assignment.
     
In fact, it will also generate the same warning for stuff like:
    !(a = expr)
    (e1 == e2 && e3 = e4)
etc.
     
>    There could be a "lint comment" /* BOOLTESTED */ or some such:
>    if ( a = expr ) {             /* BOOLTESTED */
>    that would also serve as documentation to say to another reader of
>    the code "Yes, I really meant '=' and not '=='".
     
The BOOLTESTED is unnecessary. Simply write:
    if ((a = expr) != 0) {
which will not trigger the warning.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1085
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:01 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015534; 2 Jun 86 16:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003076; 2 Jun 86 15:56 EDT
From: Walter Bright <bright%dataiodataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Error recovery (long)
Message-ID: <1009@dataioDataio.UUCP>
Date: 29 May 86 17:15:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <312@uw-nsr.UUCP> john@uw-nsr.UUCP (John Sambrook) writes:
>While on the subject of compilers, I would like to share two other features
>of this compiler that I find useful.
>The second feature is the ability to declare certain data structures as
>"read only." This is done via a compiler switch "-R" and applies to all
>data structures that are initialized to a constant value within the
>compilation unit.
>
>    int a = 1;                    /* "read only" */
>    main() {
>            int    b;                /* "read / write" */
>
>        b = a;        /* this is legal */
>        a = 2;        /* this is not */
>    }
     
The declaration for a can be made 'read only' by declaring it as follows:
     
    const int a = 1;
     
Doing an assignment to a will then cause a syntax error when compiling.
This is in the draft ANSI C spec.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1130
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015562; 2 Jun 86 16:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003679; 2 Jun 86 16:08 EDT
From: ed gokhman <esg%mtx5a.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Simple c question - pointer to array
Message-ID: <1338@mtx5a.UUCP>
Date: 30 May 86 19:29:00 GMT
Posted: Fri May 30 15:29:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
> Ok if i have a struct which is named in a typedef as T, I
> know how to get an array of pointers to T:   T *a[20];
> what I want is a pointer to an array of T's.
     
Kurt,
     
All you need is to express the declaration in English
and then to convert it token by token. If precedence
of the i-th token is higher then (i-1)-th the result
of translation of first i-1 tokens must be parenthesized.
     
In order of decreasing precedence "valid" English tokens
and their C-conversions are (S stands for the string resulting
from the previous step in English-C conversion (possibly,
parenthesised)):
     
English                    C
--------------------------------------------------
<name> is                               <name>
     
function returning                      S ()
     
array of  N                             S [ N ]
     
pointer to                              *S
===================================================
     
For example,
     
English                                 C
--------------------------------------------------
X is a pointer to an array of 20 Ts    ...
     
a pointer to an array of 20 Ts          X
     
an array of 20 Ts                       *X
     
    > precedence of [] is higher then *, so
    >*X should be parenthesizied.
     
an array of 20 Ts                         (*X)
     
Ts                                      (*X)[]
     
...                                     T  (*X)[]
===================================================
     
Similarly,
 "X is a pointer to an array of 10 pointers
to functions returning pointers to arrays of 11 int"
     
would be    int (*(*(*X)[10])())[11]

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1178
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015621; 2 Jun 86 16:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003855; 2 Jun 86 16:11 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: re: what should be added to C
Message-ID: <5565@alice.uUCp>
Date: 31 May 86 15:38:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I would rather see C++ and Concurrent C making their way
> into the ANSI standard, but, if it is unfeasible, at least
> their usefull additions to the "old C" should see the
> world.
     
No, no, NO!
     
The purpose of a standards committee is to codify current
practice, not to engage in wholesale language redesign.
     
C++ is an evolving language.  Its present form should NOT be
frozen into something like ANSI C.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1279
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015738; 2 Jun 86 16:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004241; 2 Jun 86 16:19 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <1636@ecsvax.UUCP>
Date: 31 May 86 15:44:11 GMT
Posted: Sat May 31 11:44:11 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <478@cubsvax.UUCP> peters@cubsvax.UUCP (Peter S. Shenkin) writes:
>All my FORTRAN books call these *intrinsic* functions.  This is equivalent
>in meaning to "built-in."  An "in-line" function sounds more like what would
>be meant by FORTRAN's *statement* function . . .
     
The term "intrinsic" is relatively new to FORTRAN; my late-60s manuals
have never heard of it.  "Intrinsic" and "in-line" (the older term,
still in use among us aging geezers) are synonyms, meaning function
names known to and handled by the compiler (or at least eligible for
such treatment).  For what it's worth, IBM's VS FORTRAN language
reference manual uses "intrinsic" and "in-line" more-or-less
interchangeably.  "Built-in," on the other hand, is poorly defined and
could reasonably be interpreted to mean functions that are a defined
part of the FORTRAN language and hence "built in" to it.
     
You're right, of course, that this no longer belongs in net.lang.c, and
I'm sorry I started it (by trying to point out what changes to C would
make it a better successor to FORTRAN as a language for science and
engineering).
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1230
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:22 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015629; 2 Jun 86 16:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003889; 2 Jun 86 16:12 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <2875@utcsri.UUCP>
Date: 31 May 86 00:03:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1723@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>In article <2786@utcsri.UUCP> greg@utcsri.UUCP (I) write:
>>... having a separate pre-processor will slow the compiler down
>>considerably, but is it an advantage?????? It only gives you a
>>certain amount of convenience in implementing the compiler.
>
>Not so!  There is another advantage.  The preprocessor can be used
>alone, or in combination with programs other than the C compiler.
>This is the `software tools' philosophy: if you can make a clean
>conceptual break in a task, make that break programmatically; you
>then have a set of tools that may be useful in surprising ways.
     
It may also be surprising in useless ways ;-)
The problem with cpp is that it is rather C-specific - it knows the
C comments, and string formats, and that 123.e+12 does *not* contain
an 'e' which is a candidate for #define expansion ( at least it should :-) ).
Constrast to m4 which is a much more general beasty.
In general, though, I agree with this idea.
>
>>If compiler A has more passes than compiler B, it doesn't mean 'A'
>>is better or more sophisticated - It could just mean that the
>>implementors of B did a better job.
>
>Or that the implementors of B were aiming for speed, while those of
>A were aiming for reusability.  Or that A runs on smaller machines;
>this is probably the real reason for those multi-pass PDP-11 compilers.
>They just turned out to be a good idea (in some ways).
>
Yes, and yes.
     
>In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
     
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1351
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015772; 2 Jun 86 16:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004700; 2 Jun 86 16:32 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Casting a postdecrement operand
Message-ID: <1764@umcp-cs.UUCP>
Date: 1 Jun 86 09:04:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Incidentally, if you really *do* want to take a pointer `p' to
type `x', but treat it as a pointer to type `y', the construct
     
    *(y **)&p
     
works (as long as `p' is addressable).  Thus
     
    ((struct abc *)cbap)++;
     
is not legal, but
     
    (*(struct abc **)&cbap)++;
     
is (again, if cbap is addressable).  What it means is machine
dependent!
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1422
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:31 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015862; 2 Jun 86 17:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004718; 2 Jun 86 16:33 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1514@mmintl.UUCP>
Date: 30 May 86 11:58:19 GMT
Posted: Fri May 30 07:58:19 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <852@bentley.UUCP> kwh@bentley.UUCP writes:
>>>o There should be an option to flag statements of the form if (v = e) ...
>>>(Actually, I wouldn't be averse to a coding standard which forbade such
>>>things, in favor of if (v = e, v) ...)
>
>Urgh.  Are you talking about removing the assignment-has-a-value feature
>completely, or a special case for "if (v = e)"?  (I always write this as
>"if ((v = e) != 0)" to make it clear that I didn't mean "if (v == e)".)
>
>Actually, the main argument in favor of valued assignment is to allow such
>things as "while ((c = getchar()) != EOF)".  This really doesn't look so
>bad with the unvalued assignment "while (c = getchar(), c != EOF), so it
>may not be such a bad idea.
     
Actually, I was not proposing removing the assignment-has-a-value feature
anywhere (although I would not put it into a new language I was designing).
The proposal was that it be avoided in if's (and probably while's as well)
as a coding standard.  That is, it would be legal, but not recommended.
     
In fact, I only use the results from an assignment in two cases.  One is to
assign the same value to multiple variables, and the other is in the if/while
case under discussion here.  (Yes, I also normally use "if ((v = e) != 0)").
I may stop using it in this latter case, in favor of the comma operator as
described above.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1491
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015873; 2 Jun 86 17:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004731; 2 Jun 86 16:33 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1518@mmintl.UUCP>
Date: 30 May 86 14:02:40 GMT
Posted: Fri May 30 10:02:40 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <450@cad.BERKELEY.EDU> faustus@cad.UUCP writes:
[Concerning andif]
>I think this looks cleaner, but in any case it isn't an often-encountered
>situation and the semantics aren't obvious.
     
There is no disputing matters of taste.  I find it is an often-encountered
situation, and that the semantics are obvious.
     
>You can write arbitrarily large macros by putting backslashes at the end of
>lines.  This is ugly but it works.
     
This doesn't let you use "#if" in the body of the macro, as my example would
require.  To fully explicate, my example would be:
     
#begdef copy(to, from, number)
#if sizeof(from) % WORD_SIZE == 0
   copyword(to, from, number * sizeof(from) / WORD_SIZE)
#else
   strncpy(to, from, number * sizeof(from))
#endif
#enddef
     
> > Confusing "=" and "==" in if statements is a common mistake.  If "=" is not
> > a legal operator, this error becomes very rare.
>
>It's also an extra character to type.  If you are prone to this sort of
>error, just run your code through grep if | grep = | grep -v == ...
     
Thanks but no thanks.  If one added a separate step to the compilation
process for each type of relatively common error, nothing would ever get
done.  Again, please note that I did not propose outlawing "=" as a
default -- you would have to specify an option to exclude it.
     
> > This is the whole point of having a standard.  It gives you some assurance
> > that compilers which use the features will be available.
>
>If the standard has all the things you enumerate, not many people will follow
>it and it will be worse than no standard at all.
     
This is not consistent with the experience in promulgating standards for
other languages.  FORTRAN 77 differs from the old standard rather more than
the relatively modest set of changes I proposed; it has been widely adopted,
essentially all new FORTRAN compilers adhere to the standard, and such
compilers have been made available for most machines still in use on which
an older compiler is available.
     
Again, I want to emphasize that my proposals are not things to be included
in the current standard (X3J11), but the next one.  It is both too late to
include changes of this magnitude in that standard, and inappropriate to
make this kind of change in the initial standardization of the language.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1548
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:42 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015876; 2 Jun 86 17:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004848; 2 Jun 86 16:36 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <2600061@ccvaxa>
Date: 30 May 86 18:58:00 GMT
Nf-ID: #R:dataioDataio.UUCP:989:ccvaxa:2600061:000:1089
Nf-From: ccvaxa.UUCP!aglew    May 30 13:58:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
>/* Written  3:49 pm  May 28, 1986 by chris@umcp-cs.UUCP */
>In article <2786@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>>... having a separate pre-processor will slow the compiler down
>>considerably, but is it an advantage?????? It only gives you a
>>certain amount of convenience in implementing the compiler.
>
>Not so!  There is another advantage.  The preprocessor can be used
>alone, or in combination with programs other than the C compiler.
>This is the `software tools' philosophy: if you can make a clean
>conceptual break in a task, make that break programmatically; you
>then have a set of tools that may be useful in surprising ways.
     
Unfortunately, there is no longer a clean conceptual break between
the C pre-processor and the compiler: `sizeof' can be used in
pre-processor constant-expressions.
     
I very much doubt that a cpp that parses enough of C to understand
sizeof will be useful in non-C-related applications.
     
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1623
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:50 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015882; 2 Jun 86 17:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004927; 2 Jun 86 16:39 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1978@ihlpg.UUCP>
Date: 31 May 86 18:34:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Why not use the Ada style of putting a label before the loop body - it's
> like giving a name to the loop:
>     complicated_loop: for(;;) {
>         {{{{{
>         break complicated_loop;
>         }}}}}
>     }
> No, it's not really much different from a goto.
> Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
     
It is that little bit different though.  And it is a definate WIN!
When you see a "break <label>" you know the label is on an enclosing block
and not just anywhere as in "goto <label>".
It alsos provides "continue <label>" with little extra cost.
I want BOTH label uses!  But this causes an interpretation problem.
either:
     
       <label> : for () .....
     
       becomes ambiguous: labels loop or is freestanding label?
       You can resolve this by using <label> : ; for() .....
       as a free standing label.
or:
     
    <label> : for () .....
     
    has both meanings: for goto it is free standing(i.e. restarts
        the loop) and for break/continue it labels the loop.
     
This should be fairly easy to add to a C derived(*) compiler.
     
--j.a.tainter (Gods answer to lonely microcomputers)
     
*  derived because once you starting adding things is it really the same
   language.   I propose we call this language ceder for C DERived since
   these changes would *spruce* up the language a bit. :-)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1718
          for JMS@ARIZMIS; Mon,  2-JUN-1986 23:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015894; 2 Jun 86 17:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005080; 2 Jun 86 16:42 EDT
From: rgh%inmet.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Casting a postdecrement operand
Message-ID: <5000043@inmet>
Date: 31 May 86 18:55:00 GMT
Nf-ID: #R:romp.UUCP:114:inmet:5000043:000:919
Nf-From: inmet.UUCP!rgh    May 31 14:55:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
> My version of pcc on the IBM RT PC allows the following expression:
>
>    struct abc { char d[500]; };
>    struct cba { char e[200]; };
>    struct cba *cbap;
>
>    ((struct abc *)cbap)++;
>
> to increment cbap by 500. It appears that the ANSI standard doesn't say
> anything about the legality of this syntax.
     
This is covered in the draft Standard:  (1) a cast does not yield an
lvalue;  (2) the operand of post-inc must be an lvalue.  So the
construct is illegal.
     
Standard-conforming syntax using the same idea is
     
    #define LCAST(typeP, lvalue)       ( *( (typeP *) &lvalue ) )
    #define INC_BY_SIZEOF(ptr, typeD)  ( LCAST(typeD *, ptr)++ )
     
    INC_BY_SIZEOF(cbap, struct abc);
     
Semantically this works only so long as the type that  ptr  points to
has the same alignment requirement as  typeD ,
and (a more subtle point) as long as  typeP
has the same representation as  ptr .
     
    Randy Hudson  {ihnp4,cca!ima}!inmet!rgh

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1793
          for JMS@ARIZMIS; Tue,  3-JUN-1986 00:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015897; 2 Jun 86 17:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005219; 2 Jun 86 16:45 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <697@bu-cs.UUCP>
Date: 29 May 86 14:59:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Re: cpp as a separate pass/program
     
I wonder out loud how hard it would be to turn CPP into a subroutine,
change its main() to cpp_main() and set up the call in the main() of ccom,
and of course figure out a way to get cc to understand that (probably could
just pass the arg list as a single quoted string and break it up in ccom?)
     
If that were done it could be a MAKE option when the compiler were built
(would probably build both so you still had the stand-alone cpp on-line,
but at least now you're sure the code is the same.) Maybe there would be
some externals clashes but I've done this sort of thing before and it's
usually just idiot work (changing names of symbols that clash.)
     
Then again, I agree with Torek, it's not of obvious value, but I think
a compromise like this would be easy enough. I think the current trend
in technology indicates such efforts are probably a waste of time (by
the time you get it debugged and out everyone is running a machine twice
as fast anyhow, you can say any saving is worthwhile but that's not true,
there's a point where I can't tell its there.)
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1870
          for JMS@ARIZMIS; Tue,  3-JUN-1986 00:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015899; 2 Jun 86 17:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005253; 2 Jun 86 16:46 EDT
From: Mike Wexler <mike%peregrine.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Error recovery (long)
Message-ID: <394@peregrine.UUCP>
Date: 1 Jun 86 02:28:34 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Heres how I do it.
>    % mumble foo bar
>    Segmentation violation - core dumped.
    % dbx mumble
    Reading symbolic information..
    Read 98 Symbols
    (dbx) where
    foo(b = 7), line 15 in "mumble.c"
    main(argc = 1, argv = 16776148, 0xfffbdc), line 5 in "mumble.c"
    (dbx) list 15
       15    a=*q;
    (dbx) print q
    q = (nil)
    (dbx) quit
The advantage of this is that dbx will give me all the information I want
and not the information that I don't want.
     
--
Mike Wexler
Email address:(trwrb|scgvaxd)!felix!peregrine!mike
Tel Co. address: (714)855-3923
;-) Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine :-(

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1939
          for JMS@ARIZMIS; Tue,  3-JUN-1986 00:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 02:10:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015997; 2 Jun 86 17:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005687; 2 Jun 86 17:01 EDT
From: mike%peregrine.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: boolean datatype
Message-ID: <393@peregrine.UUCP>
Date: 1 Jun 86 01:41:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
This is not a proposal to change the ANSI standard.  This is just some
ideas some possible ways of improving C.
>Re: builtin bool type
>>I'm not sure why not.  Assuming all the implicit int/bool conversions stay,
>>I think the only problems are (a) it isn't really necessary, and (b) it adds
>>a new reserved word (breaking any programs that use "typedef int bool"!).
>
>(a) is the biggie.  Why add bool when "typedef enum { FALSE, TRUE } bool;"
>works fine?  (Relying on ANSI C's treatment of enums as real ints)
So that the built in statements can use them.
    ...
    int n,get_number();
     
    n=7;
    if (n=get_number()) printf("got 7\n");    /* should have been ==        */
    ...
This is an example of a place where a C compiler with boolean types would catch
a mistake.
    ...
    bool flag,get_yes_or_no();
     
    if (flag=get_yes_or_no()) printf("got yes\n");    /* no mistake        */
    ...
This is an exmaple of a place where most of the idea for finding mistaken
assignments would fail.
     
One possible way to put this in C would be to do the conversion from
int to bool(if the integer is not equal to zero then make it true else
make it false) and generate a warning.  This would add a new reserved
word and would break programs that used bool as an identifier.  At
some future time the warning could become an error message.
     
Another feature I would like to have is a range data type.  I don't
know of a good syntax for putting this in C but it would be nice to
use in programs where are know the possible values of a number but
would like the compiler to figure out an efficient sized slot to put
it in.
    ...
    range hour:1..12; /* create a variable named hour that can vary from */
                /* 1 through 12                                */
    typedef range DAY:1..366;
    DAY day1,day2;
     
    hour+=2;
    day1=day2+100;
}
I will let other people argue about how to index an array by a range.
--
Mike Wexler
Email address:(trwrb|scgvaxd)!felix!peregrine!mike
Tel Co. address: (714)855-3923
;-) Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine :-(

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2799
          for JMS@ARIZMIS; Tue,  3-JUN-1986 02:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 04:38:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015999; 2 Jun 86 17:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005720; 2 Jun 86 17:02 EDT
From: Barry Margolin <barmar@mit-eddie.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <2157@mit-eddie.MIT.EDU>
Date: 2 Jun 86 04:11:04 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <900@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
>By the way, this does raise a question in my mind about how the convention
>of 1, not 0, being the lower bound subscript for an array is gotten around
>efficiently in implementations of Fortran.
     
In the case of one-dimensional arrays, of course, it can be handled at
compile time.  A good optimizer can also recognize the common patterns
of looping over multidimensional arrays, so that the offset can be
simply incrememented rather than requiring subscript calculations on
each iteration (some of the earliest work on Fortran compilers involved
this type of optimization).
     
>  It sounds like it is a royal, CPU-
>wasting pain to have to subtract that pesky correction factor from the ag-
>gregate subscript in coming up with an offset for the address of the array
>element from the base of the array the way Fortran does, unless the computer
>has a hardwired way of accessing an object in memory based on a base address
>(base of the array), an offset (calculated from the subscripts), and a
>correction factor (based on how the array was dimensioned) residing in regis-
>ters and added together automatically.
>I think I recall from days of yore in assembly language programming that
>the IBM 360/370 architecture was set up to allow just this, not surprising
>for a machine from the original inventors of Fortran.  But what about other
>machines, especially the more powerful (scalar) ones?  Do they all share this
>multiple-offset-addressing capability?  (Not that this would be advantageous
>in Fortran only; C could also use such a feature when accessing multiply-
>dimensioned arrays of the type "array[][][]...".)
     
I think many mainframes have such addressing modes.
--
    Barry Margolin
    ARPA: barmar@MIT-Multics
    UUCP: ..!genrad!mit-eddie!barmar

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2863
          for JMS@ARIZMIS; Tue,  3-JUN-1986 02:54 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 04:41:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017857; 30 May 86 15:43 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a022900; 30 May 86 15:20 EDT
Date:     Fri, 30 May 86 15:11:42 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       John Bruner <jdb@S1-C.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Throwing one away
Message-ID:  <8605301511.aa08202@VGR.BRL.ARPA>
     
If you start out with the idea that you'll throw one away,
you'll actually have two successive implementations that
need to be thrown away.  However, management will probably
insist on using the first one anyway.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2919
          for JMS@ARIZMIS; Tue,  3-JUN-1986 02:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016020; 2 Jun 86 17:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005733; 2 Jun 86 17:03 EDT
From: Rob McMahon <cudcv%daisy.warwick.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <149@daisy.warwick.UUCP>
Date: 1 Jun 86 14:23:35 GMT
Posted: Sun Jun  1 14:23:35 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <450@cad.BERKELEY.EDU> faustus@cad.UUCP writes:
>In article <1497@mmintl.UUCP>, franka@mmintl.UUCP writes:
>
> > Confusing "=" and "==" in if statements is a common mistake.  If "=" is not
> > a legal operator, this error becomes very rare.
>
>It's also an extra character to type...
>
     
Are you suggesting we all use single character variable names, or maybe
{letter}{digit} when we need more than 26 ?  I think phasing in ":=" over a
number of years is an excellent idea, first providing a switch to turn on
warnings about "=", then always warning, then maybe giving errors.  The
trouble is "if (a = f())" is just too useful, if you could write
"if (a := f())" it becomes readable too (".. a becomes equal to ..." instead
of "... a equals ...").
--
UUCP:   ...!mcvax!ukc!warwick!cudcv
JANET:  cudcv@uk.ac.warwick.daisy
ARPA:   cudcv@daisy.warwick.ac.uk
PHONE:  +44 204 523037
Rob McMahon, Computer Unit, Warwick University, Coventry CV4 7AL, England

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2983
          for JMS@ARIZMIS; Tue,  3-JUN-1986 03:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017965; 30 May 86 15:46 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a023085; 30 May 86 15:28 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02760; Fri, 30 May 86 15:28:16 edt
Date: Fri, 30 May 86 15:28:16 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8605301928.AA02760@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, peregrine!mike@seismo.css.gov
Subject: Re:  Boolean Operators Slighted in C
     
    In article <822@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
    >Boolean quantities form an important abstract data type distinct from
    >counters, sets, real numbers, etc.  By not making the distinction,
    >the language encourages usage errors, the most notorious being
    >        if ( a = b )
    >            stuff;
    >
    >True. It is easily found tho.
                 ------
    How do I easily find these?
    Given the following pseudocode fragment
         int xyz(parameter1,parameter2)
        {
        ...
            if (big_expression_1=big_expression_2) statement;
        ...
        }
    Where the "=" should be a "==" and the function is producing
    unexpected results how would you easily track down this
    failure.  By easily I mean more easily than compiling the
    program and noticing the error about using an arithmetic
    expression where a boolean one was supposed to be.  If this
    isn't what you meant by easily, what did you mean?
     
You have to compile and execute it because it is legal C. Generally,
they are easy to find because they cause a particular branch to
either always or never be taken. To give an example, I wrote a
simple version of `more' long ago, and goofed as follows:
     
    if ( c = '\n') ++line;
     
When I did ran it, the screen scrolled like a banshee. Simple.
Most conditional expressions are not big either.
     
    Mike Wexler
    Email address:(trwrb|scgvaxd)!felix!peregrine!mike
    Tel Co. address: (714)855-3923
    Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    I want a VEGETARIAN BURRITO to go.. with EXTRA MSG!!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3035
          for JMS@ARIZMIS; Tue,  3-JUN-1986 03:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016024; 2 Jun 86 17:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005778; 2 Jun 86 17:05 EDT
From: Richard Harter <g-rh%cca.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <8126@cca.UUCP>
Date: 30 May 86 06:04:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <> greg@utcsri.UUCP (Gregory Smith) writes:
>In article <1497@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>
>>>> o Any sort of multi-level break statement.  There is no syntacticly clean
>>>> way of adding this to C.
>
>I don't agree.   what about
>statement ::=    break ;
>    |    break constant_exp ;
>
>e.g.    break 2;
>would break the current loop *and* the enclosing one.
>
    This is a chestnut.  'break n' type constructs have been
tried and found wanting.  The problem is that it can make code
maintenance messy -- any time you modify the code by adding a
level of blocking you have to modify all enclosed break statements.
Miss just one and its mystery bug time.
     
    The reason that multilevel breaks are a problem in C is
as follows.  There are two ways in which labels can be used, (a)
as the name of a block, and (b) as a transfer address.  Functions
use labels to name blocks (the body of the function).  Goto's use
labels as transfer addresses.  The clean way to implement multilevel
breaks is to use labelled blocks and name the block you are escaping
in the break statement.  However labels within function bodies as
transfer addresses.  You have a conflict of usage here.  Of course
you could add a block keyword and an escape keyword, e.g.
     
block a {
  ....
  block b {
    ....
    escape a;
    }
  ....
  }
next_statement_after_a;
     
The escape statement transfers control to the next statement after
block labelled a.  Fine, so far, looks clean, is clean.  But are you
sure you know where that statement is?  Maybe what you want is this:
     
begin a
  ....
  begin b
    ....
    escape a;
    end b
  ....
  end a
     
where labelled begins and ends delimit blocks.  Does this (you should
excuse the expression) begin to sound familiar, PL/I fans?  Personally
I think this approach has its points, but it's starting to stray a
fair bit from C.
     
        Richard Harter, SMDS Inc.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3129
          for JMS@ARIZMIS; Tue,  3-JUN-1986 03:17 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016036; 2 Jun 86 17:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005883; 2 Jun 86 17:08 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: ranges
Message-ID: <1774@umcp-cs.UUCP>
Date: 2 Jun 86 06:57:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <393@peregrine.UUCP> mike@peregrine.UUCP (Mike Wexler) writes:
>[...] Another feature I would like to have is a range data type.  I don't
>know of a good syntax for putting this in C but it would be nice to
>use in programs where are know the possible values of a number but
>would like the compiler to figure out an efficient sized slot to put
>it in.
     
Actually, I know of two uses for range types.  You have stated one;
the other is to catch errors where a variable should never take on
values outside certain range(s).  Pascal ranges seem sometimes to
serve one purpose, sometimes another; and the Berkeley Pascal
compiler includes runtime range checking iff one compiles with
`-C'.  Were I designing a language with ranges, I think I would
separate the two uses.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3082
          for JMS@ARIZMIS; Tue,  3-JUN-1986 03:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019846; 30 May 86 18:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000701; 30 May 86 17:46 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc
Subject: Re: double (*parray[15])[];
Message-ID: <367@dg_rtp.UUCP>
Date: 27 May 86 21:01:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> friesen@psivax.UUCP (Sarima (Stanley Friesen))
>> topher@cyb-eng.UUCP (Topher Eliot)
     
>>There has been some debate on what the declaration
>>    double (*parray[15])[];
>>means.
     
> The declaration declares an array of pointers to
> entities of *undefined* size(not zero size).
     
Right.
     
> Due to the way pointer
> arithmetic is defined in "C" this is not kosher(the compiler cannot
> determine how much to add to the pointer). At least one compiler I
> know of "accepts" this declaration by treating the unspecified arrays
> as having size 1, thus making the declaration eqiuvalent to:
>
>     double *parray[15];    /* Array of pointers to double */
     
No, no, no, no, no!  (But almost yes. :-)
     
First, the declaration
     
        double (*a[15])[];
     
is completely kosher, legal, proper, correct, loyal, honorable, brave,
meaningful, trustworthy, and a fine declaration in its own right.
Harbison and Steele (page 69) say
     
    The length of the array, a constant expression, may be omitted as
    long as it is not needed to allocate storage.
     
It does *not* (I say, *NOT*) declare the same thing as
     
        double *a[15];
     
nor can any correct compiler for C take these two declarations to be
equivalent.  On the other hand, the expression (a[n]+m) *is*
meaningless, since the size of the denotation type of the pointer
expression a[n] is unknown, which is the problem Stanley points out
above.
     
     
Now, how do arrays of unknown size get along with pointer arithmetic?
For array subscription to work, what must be known is the size of the
*components* of the array, or the "inter-element spacing" (digression:
size of an element is *not* the same thing as the inter-element spacing,
but in C the latter can be deduced from the former by fiat (not renault,
mind you, this only works for Italian cars :-)).  The size of the
containing array need not be known, only the lower bound (which is
always zero in C).  Thus, the "innermost" array descriptor (following a
pointer declaration, or in a formal argument or external context) may be
of unknown size.
     
From this we see that as formal arguments or externals, these
declarations are legal:
     
        int a[];
        int b[][10];
        int c[][10][10];
     
and these are not
     
        int d[10][];
        int e[10][10][];
        int f[10][][10];
     
and in any context, these declarations are legal
     
        int (*g)[];
        int (*h)[][10];
        int (*i)[][10][10];
     
(I will note that, despite the H&S quote above, the legitimacy of the
 (*)[] declaration with unknown size is not totally clear, but most
 compilers and typecheckers side with me on this.)
     
Now then, the above is mostly the "no, no, no, no, no" part... what
about the "almost yes" part?  Well, it turns out that, due to the
peculiar way pointer/array equivalence works in C, it is impossible to
tell if a pointer-to-foo points to a single foo, or to an element of an
array-of-foo, and therefore if what you want is a pointer which
indicates an array-of-foo, it is often expedient to declare
pointer-to-foo only, and have the array part be implicit via
array-pointer equivalence.  Note well that this notion does *not* make
the two forms identical.  Let's take these definitions:
     
        int *pi, (*pai)[];
     
For one example of non-equivalence, to reference "the nth int" via a
pointer to int, one uses
     
                        *(pi+n)
or, equivalently
                        pi[n]
     
while with a pointer to array of foo, one uses
     
                        (*pai)[n]
     
Uttering "pi" in a value context yields the address of an int (or,
implicitly, the address of the first in an unknown size array of int).
Uttering "pai" in a value context yeilds the address of an array of int.
The distinction between "address of array of int" and "address of the
first element of an array of int" is very important to keep clear.  The
two are definitely *not* the same thing.  (Trust me.  But if you don't,
it might help if you consider what happens when such a pointer is
incremented.)
     
The brevity of the "pi[n]" notation, and the practical equivalence in
use of this to the "(*pai)[]" form, makes pointer-to-foo the normal way
of talking about pointers to arrays in C.  This does *not* mean that the
distinction between these concepts is absent from C, however.
--
"I would have *sworn* that *somebody* understood arrays in C!"
                                --- overheard in the hallway
--
"'Fiat' is Italian for 'hobby'."
                                --- Eric Hamilton
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3176
          for JMS@ARIZMIS; Tue,  3-JUN-1986 03:23 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019938; 30 May 86 18:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000736; 30 May 86 17:48 EDT
From: "Bennett E. Todd III" <bet%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1617@ecsvax.UUCP>
Date: 27 May 86 13:49:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1497@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>In article <5498@alice.uUCp> ark@alice.UUCP writes:
>>Frank Adams says:
>>> o An andif clause for if statements.
>>
>>What does it do and how would you use it?
>
>You would write:
>
>  if (A) {
>    X
>  } andif (B) {
>    Y
>  } else {
>    Z
>  }
>
>This is equivalent to:
>
>   if (!(A)) goto _Z;
>   X
>   if (B) {
>     Y
>   } else {
>_Z:
>     Z
>   }
     
Why not use
     
    if (A) {
        X
        if (B) {
            Y
        }
    } else {
        Z
    }
     
-Bennett
--
     
Bennett Todd -- Duke Computation Center, Durham, NC 27706-7756; (919) 684-3695
UUCP: ...{decvax,seismo,philabs,ihnp4,akgua}!mcnc!ecsvax!duccpc!bet

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4327
          for JMS@ARIZMIS; Tue,  3-JUN-1986 05:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 07:41:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019940; 30 May 86 18:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id aa00753; 30 May 86 17:50 EDT
From: Jerry Schwarz <jss%ulysses.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Casting a postdecrement operand
Message-ID: <1273@ulysses.UUCP>
Date: 28 May 86 14:50:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <114@romp.UUCP> lwh@romp.UUCP (lwh) writes:
>My version of pcc on the IBM RT PC allows the following expression:
>
>        ((struct abc *)cbap)++;
>
>
>to increment cbap by 500. It appears that the ANSI standard doesn't say
>anything about the legality of this syntax.
     
"++" requires an lvalue. A cast produces a value but not an lvalue,
so this is not legal in ANSI (or in K&R ) C.
     
Jerry Schwarz
Bell Labs, MH
     
Comment:
     
Many C compilers (especially those derived from pcc) have a tendency
to "extend C by convenience". That is, they have an algorithm that
generates code on correct C programs. They give an error message only
when that algorithmn runs into trouble.  On some illegal programs the
algorithm doesn't run into any problems and so they generate code
anyway.
     
In this case, I guess that the compiler does not keep track of
whether an expression is an lvalue in the "syntax" rather it detects
it in the "semantics".    In some circumstances it implements a cast
applied to an "identifier"  by changing the data structure to pretend
that the "name" has the modified type.  The combination of these two
results in the behavior you observe.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4421
          for JMS@ARIZMIS; Tue,  3-JUN-1986 05:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019942; 30 May 86 18:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000767; 30 May 86 17:51 EDT
From: David Keppel <keppel@pavepaws.ucb-vax.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C : if (a=b)
Message-ID: <446@cad.BERKELEY.EDU>
Date: 28 May 86 16:19:03 GMT
Sender: news@ucbcad.ARPA
Synopsis: lint
Cc: keppel@pavepaws.ucb-vax.ARPA
To:       info-c@BRL-SMOKE.ARPA
     
< munchies! >
     
    [ discription of problem "'if (a=b)' when I wanted 'if (a==b)'" ]
     
    How about an option to lint(1) (this doesn't help the people who
    don't have lint) that looks for conditional clauses with assignment
    but no test.  Thus
     
    if ( (a = expr) == value ) { ...
     
    would pass cleanly thru lint, while
     
    if ( a = expr ) { ...
     
    would generate a message indicating a potential problem.  There
    could be a "lint comment" /* BOOLTESTED */ or some such:
     
    if ( a = expr ) {             /* BOOLTESTED */
     
    that would also serve as documentation to say to another reader of
    the code "Yes, I really meant '=' and not '=='".
----
    David Keppel                ..!ucbvax!pavepaws!keppel
          "Gospel in, Gospel out: Learning by Osmosis"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4501
          for JMS@ARIZMIS; Tue,  3-JUN-1986 06:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019978; 30 May 86 18:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000575; 30 May 86 17:41 EDT
From: BALDWIN <mike%whuxl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Min/max and bool
Message-ID: <1126@whuxl.UUCP>
Date: 27 May 86 21:41:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Re: new? min and max ops
>>>o Min and max operators.  These would get used all over the place.  These
>>>should be usable to the left of the assignment operator, as most but not all
>>>C operators are.
     
The PDP-11 C compiler had two operators /\ and \/ whose names in the compiler
had something to do with MAX and MIN, I believe.  Unfortunately, they weren't
really implemented -- they were parsed but that's as far as it got.
     
Re: builtin bool type
>I'm not sure why not.  Assuming all the implicit int/bool conversions stay,
>I think the only problems are (a) it isn't really necessary, and (b) it adds
>a new reserved word (breaking any programs that use "typedef int bool"!).
     
(a) is the biggie.  Why add bool when "typedef enum { FALSE, TRUE } bool;"
works fine?  (Relying on ANSI C's treatment of enums as real ints)
--
                        Michael Baldwin
            (not the opinions of)    AT&T Bell Laboratories
                        {at&t}!whuxl!mike

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4638
          for JMS@ARIZMIS; Tue,  3-JUN-1986 06:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019981; 30 May 86 18:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000652; 30 May 86 17:44 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Throwing one away
Message-ID: <1618@ecsvax.UUCP>
Date: 27 May 86 14:38:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <911@brl-smoke.ARPA> Dave-Platt%LADC@HI-MULTICS.arpa (Dave Platt)
 writes:
>I believe your "It has also been said..." can be attributed to Donald
>Knuth;  if I remember correctly, his original wording was "Plan on
>throwing one away, because you will anyhow."
     
Nope, it was Fred Brooks in _The Mythical Man-Month_.  Let's keep our
Ancient Masters straight.
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4762
          for JMS@ARIZMIS; Tue,  3-JUN-1986 06:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020001; 30 May 86 18:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000853; 30 May 86 17:55 EDT
From: Wendy Thrash <wendyt%pyramid.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Args in Regs and Zilog flame
Message-ID: <415@pyramid.UUCP>
Date: 28 May 86 19:31:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The "discussion" so far:
    >>> Wendy Thrash  (that's me)
    >> George Robbins
    > Jim Cottrell
>>>                                                   When we implemented
>>>parameter passing in registers at Zilog, it was a big win.
     
>>*WAS* a big win - meaning maybe it looked good on benchmarks...
     
Yes, including generalized system benchmarks, not just silly little loops.
When we made the kernel with the register-argument compiler, things ran faster.
     
>>2) Because of the register assignment scheme used, you couldn't even blindly
>>   pass a list of variable arguments to a routine like printf that did know
>>   how to deal with them.
     
>    Why not? And who says varargs has to be written in C? It just may
>       have to be written in assembly some day.
     
Well, you could pass things to printf fairly blindly, as I recall.  Printf
itself, though, went through some strange peregrinations to get hold of
its arguments.
     
>>3) setjmp/longjmp got broken with respect to restoring register variable
>>   parameters somewhere along the way.
     
>    Probably difficult, but not impossible. Pyramids seem to work.
     
Zilog's setjmp/longjmp did get broken, and were thought to be more or less
unfixable, but I can't remember why.  They were replaced with routines called
setret and longret, which accomplished pretty much the same thing.
     
As for Pyramids, yes, they work just fine.  Pyramids, though, have an
architecture specifically designed for passing parameters in registers.
     
This is starting to take on the character of religious discussion, so
I might as well bow out with a small flame:
     
-------------------------
[Begin Zilog flame]
     
>>Also, note that Zilog has never delivered its ATT SVID blessed System V port,
>>and that their next series of machines will contain ATT chips running vanilla
>>3Bx software...
     
>    Zilog of course has other problems as well.
     
     
I think the other problems tell the story.  Zilog didn't fail to deliver
because of passing parameters in registers.  About three and a half years
ago, the director of systems engineering left.  He was followed eventually
by the compiler group manager, every staff engineer (a grade above senior
engineer at Zilog) in the place, and most of the senior engineers.
     
Moreover, components couldn't deliver chips.  I did the compiler support
for Zilog's floating point chip over three years ago!  ("What chip?" I hear
you ask.)  I also worked on Z80K support at that time.  (Again, "What chip?")
--
Wendy Thrash   {allegra,cmcl2,decwrl,hplabs,topaz,ut-sally}!pyramid!wendyt
Pyramid Technology Corp, Mountain View, CA  +1 415 965 7200 ext. 3001

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4866
          for JMS@ARIZMIS; Tue,  3-JUN-1986 06:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020003; 30 May 86 18:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001061; 30 May 86 18:02 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <1723@umcp-cs.UUCP>
Date: 28 May 86 20:49:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2786@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>... having a separate pre-processor will slow the compiler down
>considerably, but is it an advantage?????? It only gives you a
>certain amount of convenience in implementing the compiler.
     
Not so!  There is another advantage.  The preprocessor can be used
alone, or in combination with programs other than the C compiler.
This is the `software tools' philosophy: if you can make a clean
conceptual break in a task, make that break programmatically; you
then have a set of tools that may be useful in surprising ways.
     
>It makes a *lot* of sense to have the cpp/lexer/parser in a single
>pass - Much code can be shared.
     
It makes a lot of sense, in terms of time to code generation, to
put everything in a single process.  But I am not now willing to
rewrite the entire cpp/ccom/c2/as sequence as a single program.
It is simply not worth the effort to me.  It might be worth the
effort to others, though.  And again, we would still need a separate
cpp to make the kernel, and I would either have to include the work
`inline' (asm.sed for you 4.1 and 4.2 folks) does, or have a separate
ccom and c2+as phase.
     
>If compiler A has more passes than compiler B, it doesn't mean 'A'
>is better or more sophisticated - It could just mean that the
>implementors of B did a better job.
     
Or that the implementors of B were aiming for speed, while those of
A were aiming for reusability.  Or that A runs on smaller machines;
this is probably the real reason for those multi-pass PDP-11 compilers.
They just turned out to be a good idea (in some ways).
     
In article <250@myrias.UUCP> cg@myrias.UUCP writes:
>What contortions the compiler goes through is irrelevant - how long it
>takes and how good the resulting code is are what's important.
     
Important to whom?  What about those writing the compilers themselves,
or using parts of them?  Did you know that the F77 and Pascal
compilers share the same code generation program, which is itself
a modification of the original second pass of the C compiler proper?
And all the compilers share the assembler, which does the grunge
work of optimising branch instructions on a machine where conditional
branches have a limited distance, but unconditionals do not.
     
>We all know that most UN*X C compilers are hogs! I will re-iterate
>the question that was asked:  Why aren't there any decent C compilers
>provided with UN*X systems?
     
From whom did you buy your UN*X systems?  If Berkeley, what did you
expect from a research institution?  `If it were any good we would
sell it.'  (Who said that?)  If from a `real world' company, complain
away---but not to us!
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5027
          for JMS@ARIZMIS; Tue,  3-JUN-1986 06:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020007; 30 May 86 18:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001122; 30 May 86 18:04 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <450@cad.BERKELEY.EDU>
Date: 28 May 86 22:23:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1497@mmintl.UUCP>, franka@mmintl.UUCP writes:
     
 > You would write:
 >
 >   if (A) {
 >     X
 >   } andif (B) {
 >     Y
 >   } else {
 >     Z
 >   }
 >
 > This is equivalent to:
 >
 >    if (!(A)) goto _Z;
 >    X
 >    if (B) {
 >      Y
 >    } else {
 > _Z:
 >      Z
 >    }
     
It is also equivalent to:
     
    if (A) {
        X
        if (B) {
            Y
        }
    }
    if (!A || !B)
        Z
    }
     
I think this looks cleaner, but in any case it isn't an often-encountered
situation and the semantics aren't obvious.
     
 > To write more sophisticated macros.  For example, one could write a copy
 > macro which would invoke strcpy in most cases, but a word copy routine to
 > copy an array of structures whose size is a multiple of a word.  Such a
 > macro would be machine dependant -- this is exactly the reason for making it
 > a macro, instead of hard coding the calls.
     
You can write arbitrarily large macros by putting backslashes at the end of
lines.  This is ugly but it works.
     
 > Confusing "=" and "==" in if statements is a common mistake.  If "=" is not
 > a legal operator, this error becomes very rare.
     
It's also an extra character to type.  If you are prone to this sort of
error, just run your code through grep if | grep = | grep -v == ...
     
 > >The trouble with adding new features to C is that there is a very
 > >strong incentive not to use them.  After all, any program that
 > >uses some new feature is only going to run on machines that support
 > >that feature.  I don't think I'm going to be using only one compiler
 > >for the rest of my life and would like to avoid changing my code
 > >every time the environment hiccups.
 >
 > This is the whole point of having a standard.  It gives you some assurance
 > that compilers which use the features will be available.
     
If the standard has all the things you enumerate, not many people will follow
it and it will be worse than no standard at all.
     
    Wayne

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5157
          for JMS@ARIZMIS; Tue,  3-JUN-1986 06:53 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020009; 30 May 86 18:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001287; 30 May 86 18:09 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <477@cubsvax.UUCP>
Date: 28 May 86 15:46:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <bentley.853> kwh@bentley.UUCP (KW Heuer) writes:
     
>Another advantage of FORTRAN is implicit DO loops in I/O statements, and the
>related ability to use (constant, at least) repeat counts in FORMATs.  I had
>a program that made this painfully clear when it was translated from FORTRAN
>to C.
     
I agree;  on the other hand, what C has over FORTRAN in this regard is the
ability to keep writing on the same line in subsequent calls to printf();
that is, to *not* insert a newline after WRITEing.
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5333
          for JMS@ARIZMIS; Tue,  3-JUN-1986 07:15 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020014; 30 May 86 18:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001294; 30 May 86 18:10 EDT
From: kjm%ut-ngp.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: What should be added to C; K & R forever; call it PL/2
Message-ID: <3461@ut-ngp.UUCP>
Date: 28 May 86 18:32:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[]
     
>>C already has a multi-level break statement.  It's spelled "goto."
>>Putting a goto in a costume doesn't disguise it.  [Andrew Koenig, I think]
     
>When a human reading a program sees 'break', it is immediately known
>that the current loop is being abandoned. In order to determine the
>effect of a goto, you have to find its destination. If you don't
>believe there is a big difference, try maintaining someone else's
>BAS*C code sometime.  [Greg Smith]
     
In order to determine the effect of a multi-level break, you have to
figure out which block it's terminating.  Maintaining code with lots
of multi-level breaks sounds like a programmer's nightmare, too.
     
Consider: you always know exactly what the goto is going to do.  But with
a multi-level break, it is possible to make a modification which changes
the number of interior blocks between one (or more) break(s) and its (their)
intended target(s).  This sounds like an excellent way to introduce very
subtle bugs.  Thus I think the explicit goto is cleaner in this situation.
     
>You're absolutely right. Let's all use K&R C only for the rest of time.
>[Greg Smith]
     
Given some of the suggestions made on this newsgroup by you, Mr. Smith, by
K. W. Heuer (i.e., indentation instead of braces), and by various others,
this might not be a bad idea at all!!
     
     
[From another article, about what to call "improved" C...]
     
>Sorry, I don't think you can call it PL/2!
>IBM was going to call PL/1 "NPL" (New Programming Language?) until
>National Physical Laboratories told them not to. They then registered
>names PL/1 ... PL/100 (!). I don't think they reserved PL/0.
>[Dean Elsner]
     
How about calling this new language "C--" ? (0.1 :-))
     
--
The above viewpoints are mine.  They are unrelated to
those of anyone else, including my cat and my employer.
     
Ken Montgomery  "Shredder-of-hapless-smurfs"
...!{ihnp4,allegra,seismo!ut-sally}!ut-ngp!kjm  [Usenet, when working]
kjm@ngp.{ARPA,UTEXAS.EDU}  [Old/New Internet; depends on nameserver operation]
kjm@ngp.CC.UTEXAS.EDU      [Very New Internet; may require nameserver operation]

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7140
          for JMS@ARIZMIS; Tue,  3-JUN-1986 09:30 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 11:00:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020058; 30 May 86 18:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001304; 30 May 86 18:10 EDT
From: Ed Nather <nather%ut-sally.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C; K & R forever; call it PL/2
Message-ID: <5019@ut-sally.UUCP>
Date: 28 May 86 22:15:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
C is a tight, internally-consistent, practical and usable language.  Rather
than butcher it, I suggest we leave it the hell alone.  It is the best and
most economical language I have ever used, and I've used more of them than
I can count.
     
--
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.AS.UTEXAS.EDU

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7269
          for JMS@ARIZMIS; Tue,  3-JUN-1986 09:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020063; 30 May 86 18:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001325; 30 May 86 18:11 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <1503@mmintl.UUCP>
Date: 26 May 86 02:12:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6716@utzoo.UUCP> henry@utzoo.UUCP writes:
>More seriously, any grouping-by-indenting scheme should be studied carefully
>for ways in which minor typos could seriously alter the meaning of the
>program in non-obvious ways.
     
I agree, but: why should this be done for grouping by indentation, when it
isn't done for any other language features?  (When was the last time you
wrote "=" instead of "=="?)
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9043
          for JMS@ARIZMIS; Tue,  3-JUN-1986 11:43 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 13:31:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020065; 30 May 86 18:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001334; 30 May 86 18:11 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <1504@mmintl.UUCP>
Date: 26 May 86 02:19:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6726@utzoo.UUCP> henry@utzoo.UUCP writes:
>> ... Beyond a certain minimum size, design/code/debug is faster than
>> code/debug.
>
>Ah, but is design/code/debug/release/withdraw/revise/really-release faster
>than code/debug/try/code/debug/release? :-)
     
But now you're arguing about a different part of the process.  What I want
is design/code/debug/try/[re-design]/code/debug/release.  This often is
faster than leaving out the design phase.
     
>More seriously, I do acknowledge
>the need to have some idea of where you're going before you set out to
>get there.  And the degree of advance planning needed is indeed a function
>of project size.  But getting where you're going and then discovering that
>you really want to be somewhere else should be treated as a predictable
>part of the development process, not as a rare and surprising exception.
     
Agreed.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9225
          for JMS@ARIZMIS; Tue,  3-JUN-1986 12:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020067; 30 May 86 18:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001362; 30 May 86 18:12 EDT
From: Sam Kendall <sam%delftcc.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: Design Process
Message-ID: <145@delftcc.UUCP>
Date: 28 May 86 18:51:46 GMT
Followup-To: net.lang
Posted: Wed May 28 14:51:46 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <908@brl-smoke.ARPA>, rbj%icst-cmr@smoke.UUCP (Jim Cottrell) writes:
> It has also been said that programs should be written twice:
> once to find out what the specs are, then that program should be thrown
> away and the job done right.
     
Yeah, Donald Knuth said (in _The Art of Computer Programming_, I think)
that the best programs he ever saw were written twice, with the source
being accidentally lost in between.  I don't know if he was the first to
say this, but he said it quite a while ago.
     
A peripherally related story: a (former) prof of mine (Ugo Gagliardi
of GSG, Inc. and Harvard University) said that he saw a PBX software
system that had been designed with incredible elegance.  When he asked
the designers how the went about it, they said, "Well, the hardware
wasn't available for several months, so all we could do was sit around
and think about the design."
     
I've moved this discussion, small as it is, to net.lang, since it is
unrelated to C.
     
----
Sam Kendall            { ihnp4 | seismo!cmcl2 }!delftcc!sam
Delft Consulting Corp.        ARPA: delftcc!sam@NYU.ARPA

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9313
          for JMS@ARIZMIS; Tue,  3-JUN-1986 12:12 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020069; 30 May 86 18:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001461; 30 May 86 18:15 EDT
From: Kent Black <kab%reed.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <3542@reed.UUCP>
Date: 28 May 86 03:55:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1497@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>>> o An andif clause for if statements.
>
>You would write:
>
>  if (A) {
>    X
>  } andif (B) {
>    Y
>  } else {
>    Z
>  }
>
>This is equivalent to:
>
>   if (!(A)) goto _Z;
>   X
>   if (B) {
>     Y
>   } else {
>_Z:
>     Z
>   }
     
Which is equivalent to:
     
    if (A)    {
        X;
        if (B)     {
            Y;
        }
    } else    {
        Z;
    }
     
n'est pas?
I find the last easier to read (if not A, skip B altogether, rather than
putting B at the same `level' as its predicate).  Can you provide an
example that is significantly `clearer' (whatever meaningful term you
prefer ;-) with an 'andif' than with nesting in the block?
 (N.B., this is not just another `but we
  don't really NEED that' argument; I found
  the 'andif' obfuscatory.  Consider:
     
      if (A)
        X
     andif (B)
        Y
    andif (C)    /* if A && !B or if A && B ? */
        etc
 )
     
-----------------------------------------
     
>>> o Elimination of the eight-character truncation of internal variable names
>>> done by some compilers.
...
>So let's make it part of the standard, and those of us who like to write
>portable code can start using it.
     
Well, you don't *really* make code portable by defining it to be so ;-)
(no, responses to my foolishness are not necessary)
>Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
>Multimate International    52 Oakland Ave North    E. Hartford, CT 06108
     
-----------------------------------------
     
Kent Black        ...tektronix!reed!kab

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9450
          for JMS@ARIZMIS; Tue,  3-JUN-1986 12:27 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020071; 30 May 86 18:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001468; 30 May 86 18:16 EDT
From: Jim Cathey <jimc%iscuva.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <236@iscuva.UUCP>
Date: 27 May 86 20:39:35 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
I got messed up in figuring out who wrote what here, and had to dump the
names, but that is not the point.
     
>>
>> o := as a synonym for =.  Compilers could have an option to permit := only.
>>
>
>Why?  "Since assignment is about twice as frequent as equality testing
>in typical C programs, it's appropriate that the operator be half as long."
>K&R, p. 17.  Allowing := as a synonym is OK, if you prefer that operator,
>but why would you want to make it manditory?
     
YES, I HATE `:='.  While I admit it is easy to read, the fact that on all the
keyboards I've used except the IBM keypunch, the two symbols are in different
cases and very awkward to type...and yes, I do know about smart editors!
     
>> I do not support the following:
>>
>> o ^^ for logical exclusive or.  Unlike the other "short-circuit" forms (&&
>> and ||), this doesn't save any execution -- both operands must be evaluated.
     
YES!
     
>So what if they both have to be evaluated?  If you need to use some
>kludge to get ^^ (like !a != !b), you will still wind up evaluating both
>operands.  That's just the way XOR works.  Just because it requires more
>work is no reason to exclude it from the language.
     
I think this misses the point.  The short-circuit versions of AND and OR
are just that - SHORT CIRCUIT versions!  These are intended to be used
in place of the regular AND and OR when appropriate, to avoid much extra
if () testing.  I think K&R makes this clear.  I do admit that you can
almost always use the short circuit versions in conditionals even when not
required, for efficiency's sake.  Just gotta watch the side-effects and
parentheses!
     
    if (one_expr | the_other_expr) then_barfo;
    if (one_expr & the_other_expr) then_barfo;
     
will often work just as well as:
     
    if (one_expr || the_other_expr) then_barfo;
    if (one_expr && the_other_expr) then_barfo;
     
provided that the two expressions evaluate to whatever a boolean int is
locally (1 or -1).  {BTW I usually use set_me_true = (1 == 1)}
     
For XOR, where there can be no concept of a short circuit, one should
be using the regular ^ operator instead.  Something like:
     
    if (one_expr ^ the_other_expr) then_barfo;
     
given the above restrictions.  A ^^ operator is syntactically null given
the theme expressed by AND and OR.  Of course, if the expressions being
tested are not 'boolean', then the single-character operators can fail
where the double-character operators will succeed.  If you are using
the double-character operators as boolean-normalizing flavors of the
single-character operators, then I can see the point in wanting a ^^.
This, to me, is not what was intended when && and || were created.
     
--
     
+----------------+
! II      CCCCCC !  Jim Cathey
! II  SSSSCC     !  ISC Systems Corp.
! II      CC     !  Spokane, WA
! IISSSS  CC     !  UUCP: ihnp4!tektronix!reed!iscuva!jimc
! II      CCCCCC !  (509)927-5757
+----------------+
            "With excitement like this, who is needing enemas?"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9642
          for JMS@ARIZMIS; Tue,  3-JUN-1986 12:50 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020081; 30 May 86 18:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001544; 30 May 86 18:18 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <2834@utcsri.UUCP>
Date: 25 May 86 01:44:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1497@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>
>>> o An andif clause for if statements.
>
>You would write:
>
>  if (A) {
>    X
>  } andif (B) {
>    Y
>  } else {
>    Z
>  }
>
>This is equivalent to:
>
>   if (!(A)) goto _Z;
>   X
>   if (B) {
>     Y
>   } else {
>_Z:
>     Z
>   }
>
Interesting - like a switch, but with dynamic conditions. How about
actually writing it like a switch:
     
    switch(){            /* or just 'switch{' */
        when A:    X;
            break;
        when B: Y;
            break;
        default:
            Z;
    }
A and B, are arbitrary expressions which are evaluated in sequence.
Sorry about stealing the extra keyword. Actually, 'case' would work just
as well; and it wouldn't really be confusing, since one type of switch
*must* have a constant exp and the other type would have to have
non-constant expressions in reasonable usage. This would be easy to
compile, and much more readable than an if..else.. etc.
     
>>> o Any sort of multi-level break statement.  There is no syntacticly clean
>>> way of adding this to C.
     
I don't agree.   what about
statement ::=    break ;
    |    break constant_exp ;
     
e.g.    break 2;
would break the current loop *and* the enclosing one.
     
Of course, you can obfuscate this with
     
#define BRKS 3;
...
    break BRKS;    /* ;-) */
     
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9752
          for JMS@ARIZMIS; Tue,  3-JUN-1986 13:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020083; 30 May 86 19:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001559; 30 May 86 18:19 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <2839@utcsri.UUCP>
Date: 25 May 86 21:50:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <890@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>
>Attacking me on both fronts, eh? Well GFY! ...
Good For You?
     
>    (Root Boy) Jim Cottrell        <rbj@cmr>
>    "You used to laugh about
>     Everybody that was hanging out"
     Now you don't talk so loud...
     
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9850
          for JMS@ARIZMIS; Tue,  3-JUN-1986 13:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020123; 30 May 86 19:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001567; 30 May 86 18:19 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Casting a postdecrement operand
Message-ID: <2842@utcsri.UUCP>
Date: 26 May 86 01:25:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <114@romp.UUCP> lwh@romp.UUCP (lwh) writes:
>My version of pcc on the IBM RT PC allows the following expression:
>
>        struct abc { char d[500]; };
>        struct cba { char e[200]; };
>        struct cba *cbap;
>
>        ((struct abc *)cbap)++;
>
>
>to increment cbap by 500. It appears that the ANSI standard doesn't say
>anything about the legality of this syntax.
>
First, a technical point: There is nothing wrong with the `syntax', which
is identical to the syntax of
        (( struct foobar * ) pp )++;
The *semantics*, though, are a different question. You are saying
'Treat cbap as a pointer to a (struct abc); increment that pointer'.
The compiler dutifully adds 500. ( You asked for it, you got it... )
This is perfectly legal, but lint might well want to prod you about it...
Since you are explicitly casting the pointer, though, it should be plain
that you have good reasons to do so.
     
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0128
          for JMS@ARIZMIS; Tue,  3-JUN-1986 13:32 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020132; 30 May 86 19:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001598; 30 May 86 18:20 EDT
From: jdz%wucec2.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: questions from using lint
Message-ID: <1680@wucec2.UUCP>
Date: 27 May 86 23:48:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Gee, I thought GFY stood for "Good For You." Maybe I'm just naive.
     
Couldn't we just ignore Mr. Cottrel's spelling and spend more time and
bandwidth on more substantive things? It may be annoying at times, but I've
noticed he's toned it down quite a bit lately. Besides that, he has on more
than one occasion had something interesting and useful to say.
     
Let's stick to C and ignore English, shall we?
     
As to the use of the comma, I believe it has use only in for and while loops
and that's about it. There's no reason for not using them elsewhere. A pair
of braces require two extra keystrokes. BFHD (Big Fat Hairy Deal).
--
Jason D. Zions            ...!{seismo,cbosgd,ihnp4}!wucs!wucec2!jdz
Washington University Center for Engineering Computing
Box 1045
St. Louis MO 63130  USA        (314) 889-5097
Drink Guinness - the stout with roughage

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0021
          for JMS@ARIZMIS; Tue,  3-JUN-1986 13:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020125; 30 May 86 19:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001572; 30 May 86 18:19 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.bugs,net.lang.c
Subject: Re: C compiler trivium
Message-ID: <2843@utcsri.UUCP>
Date: 26 May 86 02:07:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <271@rtech.UUCP> jas@rtech.UUCP writes:
>Those with pcc-based C compilers may be surprised by the output
>of the following program:
>int x;
>main()
>{    int *ip = &x;
>    switch( (int) ip )
>    {
>      case &x:    printf( "x\n" );    break;
>      default: printf( "other\n" );    break;
>    }
>    exit( 0 );
>}
>This compiles without a complaint on a 3B5 running System V, a Microvax II
>running Ultrix, and a CCI Power 6 running CCI's 4.2 port.  The output
>is "other".  For a clue to what's going on, add a second global int 'y',
>and insert its address as another case in the switch.
>
>Jim Shankland
     
An ICON node in the compiler ( meaning a node containing a constant )
can contain a static address as well - it contains an integer constant, and
another integer which is used to specify a symbol table entry (or internal
label # ). Thus '&x' reduces to a node containing '0' and a reference to x.
'&y+3' will create a node containing '12' and a reference to y (assuming
sizeof(y)==4 ). The 'add-a-case' subroutine forgets to check that no
variable name is involved in the ICON, so 'case &x:' is the same as 'case 0:'
( or indeed, 'case &y:' ):
-------------------------------
addcase(p) NODE *p; { /* add case to switch */
     
    p = optim( p );  /* change enum to ints */
    if( p->in.op != ICON ){
        uerror( "non-constant case expression");
        return;
        }
-------------------------------
The condition for the 'if' clause should be
     
    if( p->in.op != ICON || p->tn.rval != NONAME ){
     
This is about line 850 in cgram.y - actual linage may vary.
I haven't tested this fix, but it *looks* simple ... :-)
Also, it seems to me there should be a 'tfree(p);' before the 'return;'
above - and in the following if-then-error which checks that the case
is in a switch. Messy, messy.
K & R does prohibit `case &x:', BTW.
     
( Gee, I sure hope I haven't published proprietary bugs... )
     
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0322
          for JMS@ARIZMIS; Tue,  3-JUN-1986 13:45 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020136; 30 May 86 19:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001686; 30 May 86 18:23 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C vs. FORTRAN (was: What should be added to C)
Message-ID: <692@bu-cs.UUCP>
Date: 29 May 86 05:09:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
>FORTRAN lets
>you use a variable as a bound in an array declaration, in this special case.
>That probably wouldn't be too hard to add to C; in fact it might be possible
>to generalize it to allow *any* nonstatic array declaration to have variable
>size (within reason).
     
If I remember right DMR said that at some point in time automatic arrays
with variable sizes was in C but they took it out, not sure why though.
I think he said in the early C compilers it was a matter of removing a
comment or thereabouts to re-enable (memory fades...)
     
About the only major complication I see (and this may have been the original
problem) is error handling. Not sure exactly what would happen if it were
impossible to allocate the automatic (then again, that can come up now,
I guess it's just a SIGSEGV or some such, but kinda weird to recover from,
hmm, interesting.) Portability? no, I really can't think of any reason,
it can't vary during the activation of the routine so you just adjust the
stack via a variable rather than a constant (an extra add instruction per
var array, big deal...) No, oh well, seems easy to me, whadidimiss?
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0233
          for JMS@ARIZMIS; Tue,  3-JUN-1986 13:54 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020134; 30 May 86 19:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001620; 30 May 86 18:21 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc
Subject: Re: C'mon, guys!
Message-ID: <2850@utcsri.UUCP>
Date: 27 May 86 15:45:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1194@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes:
>I concede.  But it wasn't pointer-vs.-array that threw me; f[] and *f are
>identical, whereas f[5] and *f are NOT and neither are f[] = {3} and *f.
 ^^^^^^^^^
Wrong. They shouldn't be, anyway.
     
Let's shed a little reality on this:
    int nul_ary[];
    int *p;
    main(){
        int i;
        i = nul_ary[0];
        i = p[0];
    }
------------------ output: ( vax, trimmed )----
    .data
    .comm    _nul_ary,0    ; 0 bytes for nul_ary
    .comm    _p,4        ; 4 bytes for the pointer
    .text
....
    movl    _nul_ary,-4(fp)    ; get i = word @ _nul_ary
    movl    _p,r0        ; get p in r0
    movl    (r0),-4(fp)    ; get i = word pointed to by p
----------------------
nul_ary is treated as an array that happens to have 0 elements, so
*any* subscript is out of range. It can be seen that `i=nul_ary[0]'
will actually do i=(int)p, since the assembler symbols '_nul_ary' and
'_p' are at the same address. Like I said, out of range.
     
All four compilers I tried behaved the same way (tho I think 3 are pcc-based).
     
There are some compilers that represent ( in the symbol table ) an array in
the same way as a pointer. The two are distinguished by setting the array
size to 0 to indicate a pointer. After all, pointers don't have array sizes,
and *nobody* uses 0-sized arrays, right? *wrong*. This is the 'clean' way
of declaring an external array of unspecified size:
     
extern int array[];    /* or array[0] */
     
So some compilers will 'accidentally' give you a pointer for a
declaration like this, simply because the dimension in the symbol table is
set to zero, and the resulting entry is the same as that for a pointer.
I.e. The generated code will behave as if you had said `extern int *array;'
Obviously, if the external variable is an array, it ain't gonna woik.
     
If your compiler produces the same code for both variables in the above
sample prog ( with p and nul_ary ), then it is suffering from this bug.
This should not be construed as a language feature, it is an implementation
botch. Some compilers may get the storage declaration right, and then
get the code generation wrong, so check both.
     
The only compiler that I know for sure has this botch is C/80 for 8080,
which is not full C anyway. From the way this discussion has been going
there must be others. So if you still think f[] and *f are the same, please
check the generated code. Let me/us know about compilers with this bug.
     
BTW, if you say f[]={3,4}; the size of the array is set to 2 elements by
counting initializers, so there will be no problem.
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1469
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020178; 30 May 86 19:25 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa02038; 30 May 86 18:36 EDT
Received: from juliet.caltech.edu by AOS.BRL.ARPA id a020005;
          30 May 86 18:32 EDT
Date:     Fri, 30 May 86 15:31:15 PDT
From:     "William E. Woody" <woody@juliet.caltech.edu>
Message-Id: <860530153115.00h@Juliet.Caltech.Edu>
Subject:  Programming style
To:       info-c@juliet.caltech.edu
Comment:  I want to survive Caltech, I really do.
     
> Programs are never finished, merely abandoned.
>
>        (Root Boy) Jim Cottrell
     
Yeah, abandoned to some other poor slob!
         - William Woody
      NET  Woody%Romeo@Hamlet.Caltech.Edu
   USNAIL  1-54 Lloyd, Caltech / Pasadena, CA 91126

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1212
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 17:15:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020138; 30 May 86 19:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001697; 30 May 86 18:23 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <3788@sun.uucp>
Date: 28 May 86 17:52:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <3754@sun.uucp> guy@sun.uucp (Guy Harris) writes:
> >> I also thought that casting anything into a (void*) would be a big
> >> no-no. ...
     
Guy Harris wrote nothing of the sort.  Karl W. Z. Heuer wrote that.  The "In
article..." crap is put there by *some* versions of "postnews", but not all.
(The version we run here doesn't put it there, for example.)  It is,
therefore, an unreliable indicator, and should probably be deleted before
sending out articles.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.arpa

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1412
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020176; 30 May 86 19:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002022; 30 May 86 18:35 EDT
From: Mike Farren <farren%hoptoad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: The cost of large uninitialized static/global arrays
Message-ID: <842@hoptoad.uucp>
Date: 29 May 86 07:51:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2810@utcsri.UUCP> petera@utcsri.UUCP (Smith) writes:
<<  A whole lot about executables in MS-DOS which have vast numbers of
    zeros embedded in the file >>
     
    If you're using Microsoft C, or the Microsoft Macro Assembler, you
might like to look at the EXEPACK utility, which addresses this very
problem by encoding long runs of identical bytes.  This can result in
quite significant improvement in .EXE file sizes.  (There is also supposed
to be a switch in the latest versions of the linker which will automatically
produce packed executables, but I don't know what it is.)
     
Mike Farren
{hplabs, dual, lll-crg}!well!farren
hoptoad!farren

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1607
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020183; 30 May 86 19:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002181; 30 May 86 18:41 EDT
From: Ed Nather <nather%ut-sally.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: The cost of large uninitialized static/global arrays
Message-ID: <5023@ut-sally.UUCP>
Date: 29 May 86 14:31:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <842@hoptoad.uucp>, farren@hoptoad.uucp (Mike Farren) writes:
> In article <2810@utcsri.UUCP> petera@utcsri.UUCP (Smith) writes:
> <<  A whole lot about executables in MS-DOS which have vast numbers of
>     zeros embedded in the file >>
>
>     If you're using Microsoft C, or the Microsoft Macro Assembler, you
> might like to look at the EXEPACK utility [...]
     
If you're using Microsoft C you don't get global arrays full of nulls
anyway.  I have a program with a global array of 20000 characters plus a
lot of code.  The executable is 10K in size.
     
--
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.AS.UTEXAS.EDU

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1339
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020171; 30 May 86 19:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001891; 30 May 86 18:30 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <1622@ecsvax.UUCP>
Date: 28 May 86 15:39:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In my last two postings I used the term "in-line" with respect to
FORTRAN functions and it occurs to me a quick explanation might be in
order.  An "in-line function" is one that a compiler expands into
in-line machine language as opposed to a procedure call.  Where speed
is of the essence (as it often is in FORTRAN programs), this can make a
significant difference on some machines.  FORTRAN programmers have to
worry about a given function being "in-line" or "out-of-line" if they
want to create one of the same name.  Thus in-line function names
effectively constitute the only "reserved words" in FORTRAN.
     
In addition to the in-line functions, FORTRAN has many other "built-in"
functions, that is, those that are a defined part of the language.
This means that these scientific function names are identical over all
implementations of the language, a very important consideration in
writing huge programs that will be used at many sites on different
equipment.
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1274
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020167; 30 May 86 19:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001868; 30 May 86 18:29 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <1621@ecsvax.UUCP>
Date: 28 May 86 15:21:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <853@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>In article <1594@ecsvax.UUCP> ecsvax!dgary (D Gary Grady) writes:
[listing advantages of FORTRAN over C for scientific work]
>>o A richer set of floating point operators, including exponentiation and
>>  the so-called "in-line" functions (many of which ARE in C).
>
>I think you mean "builtin" rather than "inline".  I don't even consider that
>a significant difference, much less an advantage of FORTRAN.
     
No, I meant "inline."  That's a standard FORTRAN term and I'm surprised
you're not familiar with it.  Anyway, the in-line functions in FORTRAN
include absolute value, imaginary part (of a complex number), real part
(ditto), complex conjugate, explicit truncation, explicit rounding, mod,
sign, positive difference, type conversion, maximum, minimum, and various
Boolean ones.  As I said before, many of these are in C as well, but the
FORTRAN set is certainly richer in those used for scientific coding.
Whether you consider it a significant difference depends on the kind of
programming you do.  As for an explicit exponentiation operator, your
own comments about C's serious limitations constitute an adequate
justification for its addition to the language, I'd say.
     
>>o A way of passing different-sized multidimensional arrays to the same
>>  subroutine.
>Again, this is merely a syntactic quibble -- what FORTRAN does is equivalent
>to the one-dimensional "trick", but it's hidden from the user.
     
Quibble?  We're talking about a hard-coded subscript calculation every
time you refer to an array element.  If it isn't hard to add to the
language (and I agree it shouldn't be), why not add it (as long as we
are talking about language modifications - I understand the view that we
should beware Creeping Featurism).  Interesting suggestion you make that
we might as well extend this to malloc'ed arrays.  Hmm...
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1545
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020181; 30 May 86 19:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002069; 30 May 86 18:36 EDT
From: Garry Wiegand <garry@tcgould.ARPA>
Newsgroups: net.lang.c++,net.lang.c
Subject: Type checking for typedef's (new feature)
Message-ID: <361@batcomputer.TN.CORNELL.EDU>
Date: 28 May 86 17:13:17 GMT
Followup-To: net.lang.c
To:       info-c@BRL-SMOKE.ARPA
     
In a recent article sher@rochester.UUCP (David Sher) wrote:
>I just tripped over another "feature" of c++.
>This feature is that enums are not types.
>They look like types but really are synonomous with sets of
>constant definitions and typedefs of ints.  This strikes me as wrong...
     
I am reminded of a long-standing pet peeve of mine: I can get
type-checking on structures and unions. I can get type-checking
on primitive types (int, float, ...). I CANNOT get type-checking
on datatypes declared via 'typedef' EXCEPT in terms of their underlying
types. (I assume this all is still true in the new language standard.)
     
What I would like is for typedef names to be considered by the compiler as
DIFFERENT from the underlying types. The compiler should then allow an implicit
(or explicit) cast back and forth between the derived and underlying types -
this will avoid breaking existing code. The improvement over the current state
of things will happen when I ask the compiler "please tell me about possibly
nasty implicit casts!"
     
     
Note 1: people who are in the habit of doing things like:
     
        typedef unsigned char    ubyte;
     
   and who want to use this new feature will have to switch to:
     
        #define ubyte  unsigned char
     
   unless they really want "ubytes" to be non-computable.
     
Note 2: At some point (of course) you have to give a value to a derived-
   type variable. If you compile habitually with the new message turned
   on, then in such a situation you'll have to use an explicit cast.
     
Note 3: The same principle could be extended to structures that are equivalent
   though not identical and to enum's.
     
Is it reasonable? Is it hard to implement? Comments? (Followups to
net.lang.c, pls).
--
garry wiegand   (garry%cadif-oak@cu-arpa.cs.cornell.edu)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1696
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:12 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020185; 30 May 86 19:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002288; 30 May 86 18:44 EDT
From: "T.p." <brisco@topaz.ARPA>
Newsgroups: net.lang.c
Subject: problems with the C parser
Message-ID: <5072@topaz.RUTGERS.EDU>
Date: 29 May 86 21:44:01 GMT
Keywords: bitfield,structure,'%&#@*
To:       info-c@BRL-SMOKE.ARPA
     
     
     
     
    I've been trying to translate a program written in Vax
Pascal to C on our Suns.
    My problem arose when I was trying to translate a pascal
variant record structure into a C union structure. The structure type
(in pascal) looked as follows: (keep in mind - both were for 32 bit machines)
     
    newtype = record case selector of
        0:(int: unsigned);
        1:(bool: packed array [0..31] of boolean);
        end
     
     
    Which I had translated into C as:
     
    typedef union {
        int intfield;   /* change the record name - keyword */
        struct bool{unsigned x[32]:1};
        } newtype;
     
     
    The C parser barfed all over this. I tried every combination
of unsigned x:1[32], ..... that I could think of.  Out of frustration
I looked up the syntax of the declarations in K&R and found that the
initial guess had been correct!
    I wanted an integer that I could index into by bit, so I could
avoid using masks (which weren't going to be easily used due to the
methodology of the original program).
    Am I going crazy or is our C parser brain-damaged?  Can anyone
else compile the above structure declaration?
     
     
            "Wah!"
            "No, no. It's 'Wah!'"
            "Wah!"
            "That's better!"
     
                tp.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1808
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020187; 30 May 86 19:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002461; 30 May 86 18:48 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <478@cubsvax.UUCP>
Date: 29 May 86 20:49:56 GMT
Posted: Thu May 29 16:49:56 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <ecsvax.1621> dgary@ecsvax.UUCP (D Gary Grady) writes:
>In article <853@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes:
>>In article <1594@ecsvax.UUCP> ecsvax!dgary (D Gary Grady) writes:
>>>o A richer set of floating point operators, including exponentiation and
>>>  the so-called "in-line" functions (many of which ARE in C).
>>
>>I think you mean "builtin" rather than "inline".  I don't even consider that
>>a significant difference, much less an advantage of FORTRAN.
>
>No, I meant "inline."  That's a standard FORTRAN term and I'm surprised
>you're not familiar with it.  Anyway, the in-line functions in FORTRAN
>include absolute value, imaginary part (of a complex number), real part
>(ditto), complex conjugate, explicit truncation, explicit rounding, mod,
>sign, positive difference, type conversion, maximum, minimum, and...
     
All my FORTRAN books call these *intrinsic* functions.  This is equivalent
in meaning to "built-in."  An "in-line" function sounds more like what would
be meant by FORTRAN's *statement* function, which acts, from the point of
view of the programmer, more-or-less the same way as a a C macro definition.
     
To those who are about to point out ever-so-kindly that this discussion no
longer belongs in net.lang.c, I agree, and, now that I've put in my 2-cents'
worth, I suggest that we either all shut up, or move it to net.lang.f77.
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1903
          for JMS@ARIZMIS; Tue,  3-JUN-1986 16:46 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/03/86 at 18:17:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029754; 3 Jun 86 14:47 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a028686; 3 Jun 86 13:47 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA15632; Tue, 3 Jun 86 13:44:37 edt
Date: Tue, 3 Jun 86 13:44:37 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606031744.AA15632@icst-cmr.ARPA>
To: ccvaxa!aglew@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Non-C uses of CPP
     
    Unfortunately, there is no longer a clean conceptual break between
    the C pre-processor and the compiler: `sizeof' can be used in
    pre-processor constant-expressions.
     
True. The C Puzzle book once claimed that `the preprocessor knows no C'.
This statement is no longer true.
     
    I very much doubt that a cpp that parses enough of C to understand
    sizeof will be useful in non-C-related applications.
     
Calendar uses cpp. So does much Kernel Assembly code. One must be careful
to avoid the C-specific features, but otherwise, it works quite well.
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
CONGRATULATIONS!  Now should I make thinly veiled comments about DIGNITY,
self-esteem and finding TRUE FUN in your RIGHT VENTRICLE??

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4535
          for JMS@ARIZMIS; Tue,  3-JUN-1986 22:52 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 06/04/86 at 00:32:07 CDT
Received: from WISCVM.WISC.EDU by SRI-KL.ARPA with TCP; Mon 2 Jun 86
  08:52:46-PDT
Received: from (MANSFIEL)DHDEMBL5.BITNET by WISCVM.WISC.EDU on 06/02/86
  at 10:52:32 CDT
Date:           Mon, 02 Jun 86 16:39:41 n
To:  info-vax@sri-kl.arpa
From:             Niall Mansfield
  <MANSFIELD%DHDEMBL5.BITNET@WISCVM.WISC.EDU>
Organisation:   European Molecular Biology Laboratory
Postal-address: Meyerhofstrasse 1, 6900 Heidelberg, W. Germany
Phone:          (6221)387-0 [switchboard]  (6221)387-247 [direct]
Subject:        problem with C fopen(), file revision date
     
     
The following program behaves curiously.
When you run it, the revision date of the file it opens
is updated, if that file is a stream_lf file.
If the file is variable length or fixed length, the
revision date is not updated.
     
This even occurs when the file protection is (s,o,g,w:r),
and the file is on a directory which is not mine.
     
Any explanations?
     
#include        <stdio.h>
main(argc, argv)
        int     argc;
        char    **argv;
        {
        FILE    *inf;
        char    line[BUFSIZ];
     
        argc--; argv++;
        if ( (inf = fopen(*argv, "r")) != NULL)
                puts("Opened");
        else
                puts("Can't open");
        }
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4682
          for JMS@ARIZMIS; Tue,  3-JUN-1986 23:06 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/04/86 at 00:54:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020214; 30 May 86 19:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002466; 30 May 86 18:48 EDT
From: Sam Kendall <sam%delftcc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: double (*parray[15])[];
Message-ID: <146@delftcc.UUCP>
Date: 28 May 86 19:03:27 GMT
Posted: Wed May 28 15:03:27 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <367@dg_rtp.UUCP>, throopw@dg_rtp.UUCP writes:
> (I will note that, despite the H&S quote above, the legitimacy of the
>  (*)[] declaration with unknown size is not totally clear, but most
>  compilers and typecheckers side with me on this.)
     
So does K&R.  If anybody wants to argue with me on this, I'll find the
section number.  Basically, the statement on empty brackets is this: in
a sequence of contiguous `[ ]' pairs, only the first `[ ]' can be
empty.  But nowhere is it stated that the empty brackets have to be the
first type modifier.  So `type (*)[]' is okay.
     
----
Sam Kendall            { ihnp4 | seismo!cmcl2 }!delftcc!sam
Delft Consulting Corp.        ARPA: delftcc!sam@NYU.ARPA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4797
          for JMS@ARIZMIS; Tue,  3-JUN-1986 23:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020216; 30 May 86 19:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002476; 30 May 86 18:49 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: problems with the C parser
Message-ID: <1741@umcp-cs.UUCP>
Date: 30 May 86 00:37:51 GMT
Keywords: bitfield, structure
To:       info-c@BRL-SMOKE.ARPA
     
In article <5072@topaz.RUTGERS.EDU>, brisco@topaz.RUTGERS.EDU (T.p.),
wanting to translate a Pascal packed array [0..31] of boolean
writes:
>    ... I [tried]:
>
>    typedef union {
>        int intfield;   /* change the record name - keyword */
>        struct bool{unsigned x[32]:1};
>        } newtype;
>
>    The C parser barfed all over this. I tried every combination
>of unsigned x:1[32], ..... that I could think of.  Out of frustration
>I looked up the syntax of the declarations in K&R and found that the
>initial guess had been correct!
     
Hrum.  Where in K&R did you find something that implies the above
is in any way correct?  Try instead chapter 6, page 138:
     
    Other restrictions to bear in mind: fields are unsigned; they
    may be stored only in int's (or, equivalently, unsigned's);
    THEY ARE NOT ARRAYS; [emphasis mine] they do not have addresses,
    so the & operator cannot be applied to them.
     
Arrays must be addressible; bit fields are not addressible; and
therefore there are no arrays of bit fields, nor are there bit
fields of arrays.
     
As for solving the original problem---obtaining the equivalent
of `packed array [0..31] of boolean'---you will probably have to
make do with macros, e.g.:
     
    #define    BIT(name, index) ((name) & (1 << (index)))
    #define BIS(name, index) ((name) |= 1 << (index))
    #define BIC(name, index) ((name) &= ~(1 << (index)))
     
You can, at this point, dispense with the union:
     
    typedef long newtype;
     
is probably the best way to go: it is even portable to 16-bitters.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6486
          for JMS@ARIZMIS; Wed,  4-JUN-1986 03:17 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003921; 3 Jun 86 18:12 EDT
Received: from ics.uci.edu by SMOKE.BRL.ARPA id a006967; 3 Jun 86 18:02 EDT
Received: from localhost by ICS.UCI.EDU id a003249; 3 Jun 86 15:01 PDT
To: info-c@BRL-SMOKE.ARPA
Subject: Re: ranges
In-reply-to: Your message of 2 Jun 86 06:57:19 GMT.
             <1774@umcp-cs.UUCP>
Date: Tue, 03 Jun 86 15:00:28 -0800
From: Scott Menter <escott@uci-icsa.ARPA>
     
     
Chris Torek writes:
> In article <393@peregrine.UUCP> mike@peregrine.UUCP (Mike Wexler) writes:
>>[...] Another feature I would like to have is a range data type.  I don't
>>know of a good syntax for putting this in C but it would be nice to
>>use in programs where are know the possible values of a number but
>>would like the compiler to figure out an efficient sized slot to put
>>it in.
>
> Actually, I know of two uses for range types.  You have stated one;
> the other is to catch errors where a variable should never take on
> values outside certain range(s).
     
Well, actually it might be kind of nice to have a C compiler with an
option to do the kind of array bounds checking Chris implies, whether
or not a range type is implemented.  I suppose this would be hard in
the case of automatic variables and arguments like:
     
    int foo( arg )
    char arg[ ];
     
Still, it might be nice for the easy case of, say:
     
    static char * strings[ CONSTANT_VAL ];
     
While we're at it, though, what if we *did* use a range type to
subscript an array.  Maybe I'm neglecting something obvious, but
how would the compiler deal with this situation:
     
    int foo( )
    {
    char someval[ range ];    /* "range" is, say, 1..10 or something */
     
        foo2( someval );
    }
     
    int foo2( stringarg )
    char * stringarg;
     
etc...
     
Seems to me that it would be impossible to detect range errors in
"foo2()", especially if it is in a distinctly compiled unit from
"foo()".  In that case, the error checking that range type
implementation provides would be limited to the scope in which it is
defined, and no further.  Of course, if the argument to "foo2()" read
"char stringarg[ range ]" then I suppose it would work, but then you lose
the ability to say things like "stringarg++".  Or, I guess, you could
pass "range" as another parameter to "foo2()".
     
Well, I'm more of a C hacker than a C implementor, so I imagine that
some of you implementors out there will set me straight, if that's
required.
     
------------------------------------------------------------------------
E. Scott Menter                            Internet:  escott@ics.uci.edu
UCI Research Support Group                UUCP: ...!ucbvax!ucivax!escott
     
"...Say, Foz, about my vocals..."
------------------------------------------------------------------------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6541
          for JMS@ARIZMIS; Wed,  4-JUN-1986 03:22 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004397; 3 Jun 86 20:13 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a008635; 3 Jun 86 20:01 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA16302; Tue, 3 Jun 86 19:57:33 edt
Date: Tue, 3 Jun 86 19:57:33 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606032357.AA16302@icst-cmr.ARPA>
To: brl.arpa!gwyn@seismo.css.gov, dgary%ecsvax.uucp@BRL.ARPA,
    ecsvax!dgary%mcnc.csnet@CSNET-RELAY.ARPA
Subject: Re:  C vs. FORTRAN (was: What should be added to C)
Cc: info-c@BRL-SMOKE.ARPA
     
    There are a number of good reasons for building integer exponents into
    the language, one of which is the possibilities for optimization.  An
     
Doug, I am surprised that you ignored DMR's rationale for not putting
exponentiation into C, or were you merely requesting a library function.
Yes, I know you didn't write this but I'm responding to you here anyway.
     
    obvious one is converting x**3 into x*x*x, not to mention having the
    compiler recognise at what level one should not do this optimization.
    More subtle is the use of "algebraic" optimizations.  For instance,
    converting
     
        a*x**3 + b*x**2 + c*x + d
    to
        d + x * (c + x * (b + a*x))
     
    which replaces eight multiplications with three and not only executes
    faster but (most of the time) greatly reduces precision problems.
    Granted that this can be coded by the programmer; how many do you think
    will actually do it?  Yup...
     
Anyone who wants the benefits. It could be argued that by allowing
programs to be optimised, you promote laziness in coding techniques.
In this example, the notation looks quite similar to the original
form, especially if you write it backwards.
     
Any optimizer smart enuf to make this transformation should be able to
do the same for the longhand as well: a*x*x*x + ...
     
By making it harder to code poorly, you make it harder to code well by
comparison. Don't give away all our wizardly secrets :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    - if it GLISTENS, gobble it!!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6659
          for JMS@ARIZMIS; Wed,  4-JUN-1986 03:39 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/04/86 at 05:33:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020227; 30 May 86 19:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002533; 30 May 86 18:51 EDT
From: KW Heuer <kwh%bentley.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <864@bentley.UUCP>
Date: 30 May 86 03:24:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3788@sun.uucp> guy@sun.UUCP (Guy Harris) writes:
>> In article <3754@sun.uucp> guy@sun.uucp (Guy Harris) writes:
>> >> I also thought that casting anything into a (void*) would be a big
>> >> no-no. ...
>
>Guy Harris wrote nothing of the sort.  Karl W. Z. Heuer wrote that.
     
Wrong squared.  It was watmath!rbutterworth who wrote it.
     
Karl W. Z. Heuer (ihnp4!bentley!kwh), the Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6722
          for JMS@ARIZMIS; Wed,  4-JUN-1986 03:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020229; 30 May 86 19:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002584; 30 May 86 18:53 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1509@mmintl.UUCP>
Date: 4 Jun 86 04:06:38 GMT
Posted: Wed Jun  4 00:06:38 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <1617@ecsvax.UUCP> bet@ecsvax.UUCP (Bennett E. Todd III) writes:
>In article <1497@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>>   if (!(A)) goto _Z;
>>   X
>>   if (B) {
>>     Y
>>   } else {
>>_Z:
>>     Z
>>   }
>
>Why not use
>
>    if (A) {
>        X
>        if (B) {
>            Y
>        }
>    } else {
>        Z
>    }
     
Because this doesn't execute Z when A is true but B is false.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6801
          for JMS@ARIZMIS; Wed,  4-JUN-1986 03:52 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020236; 30 May 86 19:41 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002639; 30 May 86 18:55 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <2600058@ccvaxa>
Date: 28 May 86 19:01:00 GMT
Nf-ID: #R:mmintl.UUCP:1463:ccvaxa:2600058:000:1457
Nf-From: ccvaxa.UUCP!aglew    May 28 14:01:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
~> Things that should/could be added to C, or C++, or...
     
typeof
    typeof would be a compile time operator that would
    have a (possibly compressed and tokenized) form of
    the type used in declaring its argument (a variable)
    inserted in its place.
     
    If the C preprocessor ever gets sophisticated enough
    to be a true macro processor, typeof should return a
    string that macro operations can parse and disassemble
    as they will. In particular, typeof(typedef-name)
    should return the type used in declaring the type-name,
    and so on.
     
lambda
    Wherever you may have a variable, it should be possible
    to substitute a literal constant of the appropriate type.
    C fails this test for arrays, which hasn't been so serious
    for the applications I've seen (I don't like having to declare
    COMPLEX constants as initialized variables, but C has so many
    other weaknesses for constants that I don't care - I'll wait
    for C++ constructors) -- more importantly, C also fails this
    test for function-pointers.
     
    When I pass a function pointer to, say, an integration routine,
    I would like to not have to go to the bottom of the file
    somewhere and write the function. f it's a short, anonymous
    function that I'm not going to use anywhere else, I want to
    declare it in place.
     
    I've used preprocessors that let you do this:
        integrate(from,to,
            float lambda(x) float x; {return x*x;}
        )
    and move the declaration to the end and create a special name
    for it.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6868
          for JMS@ARIZMIS; Wed,  4-JUN-1986 03:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020304; 30 May 86 19:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002872; 30 May 86 19:04 EDT
From: Walter Bright <bright%dataiodataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1006@dataioDataio.UUCP>
Date: 28 May 86 17:35:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2823@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>In article <5498@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes:
>>> o The ability to define multi-line pre-processor macros, using #begdef and
>>> #enddef statements.  #if and other conditionals in the body of the
>>> definition would be evaluated when the macro was not interpreted, not when
>>> it is encountered.
     
I thought that multi-line macros could be done by terminating the line
with a \. Such as:
    #define abc(d)    a \
            = \
            d;
By the way, Datalight C allows things such as:
    #define abc(d) a =    \
        #if XYZ == 47    \
            54;    \
        #else        \
            56;    \
        #endif
The preprocessor commands are considered as part of the macro text, and
are parsed as preprocessor commands after the macro has been expanded.
     
>>> o A typeof operator, similar to sizeof.
>    x = (typeof x ) malloc ( n * sizeof( *x ));
     
The macro I always wanted to write is:
     
    #define swap(a,b) { typeof(a) temp;    \
                temp = (a);        \
                (a) = (b);        \
                (b) = temp;        \
              }
     
>>> o := as a synonym for =.  Compilers could have an option to permit := only.
     
Clutter. It's easier to cause the compiler to generate a warning
for constructs such as:
    if (a=b) { ... }
     
>>> o Any sort of multi-level break statement.  There is no syntacticly clean
>>> way of adding this to C.
>>C already has a multi-level break statement.  It's spelled "goto."
>>Putting a goto in a costume doesn't disguise it.
>When a human reading a program sees 'break', it is immediately known
>that the current loop is being abandoned. In order to determine the
>effect of a goto, you have to find its destination. If you don't
>believe there is a big difference, try maintaining someone else's
>BAS*C code sometime.
     
There's no problem finding where a goto goes to if you have only one or
two in a function. Gotos only become a problem when you have a snarl
of them. What I find confusing is four page functions, with 47 levels
of ifs and {}s, and trying to figure out where control flow goes when a
break happens. You have to count }s, or run a listing and connect the
{}s with a pen.
     
I've had people do greps for gotos on my code, show me an out-of-
context list of the 14 they found in 10,000 lines of C, and tell me
that my code was bad.
     
Using only structured programming constructs only guarantees that the
flow graph for your program will be reducible, it doesn't guarantee
that your program is structured. The only purpose to having a reducible
flow graph is if your optimizer can't handle irreducible ones.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6941
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020358; 30 May 86 20:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003051; 30 May 86 19:10 EDT
From: John Sambrook <john%uw-nsr.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Error recovery (long)
Message-ID: <312@uw-nsr.UUCP>
Date: 29 May 86 06:00:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
[]
     
Regarding error recovery in C compilers, I like the error recovery
provided by the Data General C compiler.  Here is an example of a
botched program:
     
    main() {
        int    a = 0    /* missing ";" */
     
        printf("a: %s\n",  (a == 1) ? "1" : "?"; /* missing ")" */
    }
     
When compiled the following is written on stderr:
     
    Error 502 severity 2 beginning on line 4 (Line 4 of file main.c)
        printf("a: %s\n",  (a == 1) ? "1" : "?";
        ^
    Syntax Error.
    A symbol of type ";" has been inserted before this symbol.
     
     
    Error 502 severity 2 beginning on line 4 (Line 4 of file main.c)
        printf("a: %s\n",  (a == 1) ? "1" : "?";
                                               ^
    Syntax Error.
    A symbol of type ")" has been inserted before this symbol.
     
In this example the compiler produced a program that executed correctly.
     
To be fair, both errors are "errors of omission."  I believe, but do not
assert, that these errors are easier to repair than other types of errors.
In the event of serious errors the compiler will cease code generation and
only check the remaining input.  I don't know the parsing method used in
this compiler; it does not seem to suffer from poor error recovery as do
many recursive-descent parsers.
     
While on the subject of compilers, I would like to share two other features
of this compiler that I find useful.  I have not found these features in
other C compilers that I have used, although I have heard that the VAX/VMS
C compiler is very good.
     
The first feature is the ability to generate a stack trace ("traceback")
in the event of a serious error.  There are two compiler switches that
control the amount of information in a traceback.  The "-Clineid" switch
causes the offending line number to be included while the "-Cprocid" switch
causes the procedure name to be included.
     
The second feature is the ability to declare certain data structures as
"read only." This is done via a compiler switch "-R" and applies to all
data structures that are initialized to a constant value within the
compilation unit.
     
Here is an example program that demonstrates both features:
     
    int a = 1;                    /* "read only" */
     
    main() {
            int    b;                /* "read / write" */
     
        /* this is legal */
        b = a;
     
        /* prove it */
        printf("a: %d  b: %d\n", a, b);
     
        /* this is not */
        a = 2;
     
        /* lie detector */
        printf("Can't happen\n");
    }
     
This program was compiled with "cc -R -Clineid -Cprocid main.c -o main."
Executing the program produced the following output on stderr:
     
    a: 1  b: 1
     
    ERROR         71237.
    from line 13 of main.
     
    Call Traceback:
     
    from fp=16000002722,  pc=16001754200,   line 10 of main
    from fp=          0,  pc=16001762472
     
    Hardware protection violation: Write access denied.
     
In the traceback the phrase "line 10" is because "-Clineid" was
specified at compile time.  The phrase "of main" is because "-Cprocid"
was specified at compile time.  Note though that the two "offending"
line numbers differ.  I suspect that this is because the last line to
execute successfully was at line 10; line 13 did not execute successfully
but rather generated a processor trap.
     
Some people might say that this compiler is too verbose, or that the
features cost too much in terms of execution overhead.  I have not found
this to be the case.  And, while I hate to see any tracebacks, I find
them to be far better than:
     
    % mumble foo bar
    Segmentation violation - core dumped.
    %
     
Please note that I do not intend to participate in any "holy wars."
I do not speak for Data General nor do I receive any compensation
from them.  I just felt that this might be of interest to the readers
of this group.
     
--
John Sambrook                Work: (206) 545-2018
University of Washington WD-12        Home: (206) 487-0180
Seattle, Washington  98195        UUCP: uw-beaver!uw-nsr!john

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7000
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:10 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/04/86 at 05:59:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021223; 31 May 86 0:18 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a004197; 31 May 86 0:04 EDT
Date:     Fri, 30 May 86 23:57:43 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  double (*parray[15])[];
Message-ID:  <8605302357.aa11035@VGR.BRL.ARPA>
     
The important thing to realize is that both the * and the [] (with
or without anything inside the brackets) are operators that always
dereference one level of whatever they are applied to.  In C, type
declarations model a usage context for the thing being defined
that would (if such usage actually occurred in the code) produce a
result of a specified simpler type.  Correct usage requires that
the dereferencing levels in terms of an expression match properly
(the meaning of this depends on the operators being applied).
As you (Wayne) explained, empty [] are permitted only in limited
contexts: those where the length of the array is not necessary for
the compiler to be able to generate correct code to access elements
of the array.  Empty [] are never the same as * except in formal
function parameter type declarations (this is a historical kludge).

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7050
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021347; 31 May 86 1:02 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a004336; 31 May 86 0:45 EDT
Date:     Sat, 31 May 86 0:35:56 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  C vs. FORTRAN (was: What should be added to C)
Message-ID:  <8605310035.aa11325@VGR.BRL.ARPA>
     
C could use an exponentiation operation, all right, but not as a
language entity (^ and ** are both already taken!).  If nobody
else does, I may post a very nice (long) integer-integer power
library routine.  However, unless X3J11 is quickly talked into
specifying it, don't expect your UNIX supplier to provide it.
It took years to persuade AT&T to pick up the directory access
routines.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7107
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:17 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021350; 31 May 86 1:03 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa04336; 31 May 86 0:45 EDT
Date:     Sat, 31 May 86 0:39:31 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Garry Wiegand <garry@tcgould.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Type checking for typedef's (new feature)
Message-ID:  <8605310039.aa11328@VGR.BRL.ARPA>
     
Your proposal (that typedefs create real, independent basic types)
is reasonable enough; it's merely too late.  Enums now look like
they are going to be "really" ints, officially.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7166
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:23 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021379; 31 May 86 1:15 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a004362; 31 May 86 0:55 EDT
Date:     Sat, 31 May 86 0:48:01 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Walter Bright <bright%dataiodataio.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  What should be added to C
Message-ID:  <8605310048.aa11335@VGR.BRL.ARPA>
     
> The macro I always wanted to write is:
>
>    #define swap(a,b) { typeof(a) temp;    \
>                temp = (a);        \
>                (a) = (b);        \
>                (b) = temp;        \
>              }
     
This doesn't work for complicated types or even arrays.
(The macro-expanded syntax is not correct in such cases.)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7250
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:31 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021382; 31 May 86 1:16 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa04362; 31 May 86 0:55 EDT
Date:     Sat, 31 May 86 0:54:16 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       John Sambrook <john%uw-nsr.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Error recovery (long)
Message-ID:  <8605310054.aa11340@VGR.BRL.ARPA>
     
Any decent UNIX debugger provides stack traceback, on either a stopped
child or on the core image resulting from abnormal termination.
     
"cc -R" is not the right solution to the read-only data issue, since
it is insufficiently selective.  X3J11 has proposed a "const" type
modifier keyword that can (and should) be used in defining any data
that will not be modified during program execution (literal strings
would be that way by default).

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7319
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021591; 31 May 86 2:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id aa04766; 31 May 86 1:39 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <1181@brl-smoke.ARPA>
Date: 31 May 86 05:39:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In a response of mine that hasn't yet appeared in our news system
(don't ask), I misinterpreted Walter Bright's use of the proposed
"typeof" in a definition of a swap() macro.  I still had ccvaxa!aglew's
second "typeof" suggestion in mind.  My comment should be taken as
a criticism of the latter, only.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7405
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022789; 31 May 86 7:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010199; 31 May 86 7:41 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: malloc()
Message-ID: <113@watmath.UUCP>
Date: 29 May 86 13:05:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Ah, but if you have a function prototype such as:
>     extern void free(void *);
> and then try to free a pointer to a struct, you are implicitly casting
> the struct pointer to a void *. Generating an error on this would
> make void * fairly useless.
     
But if I were king, free() wouldn't take a (void*).
Almost the only place (void*) would be used is by malloc().
     
There is a need for two special types of generic pointers:  one which
is guaranteed to be aligned and can be cast into any other pointer, and
one which has no such guarantee and can have any other pointer cast
into it.  (void*) clearly fits the former.  (char*) almost fits the
latter (perhaps a new (pointer) type should have been introduced).
X3J11 defeated the niceness of all this by extending their definition
of (void*) to fit both requirements.  I really don't understand why
they would do such a thing.  It gains nothing and loses a lot.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7489
          for JMS@ARIZMIS; Wed,  4-JUN-1986 04:55 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022792; 31 May 86 7:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010279; 31 May 86 7:43 EDT
From: David desJardins <desj@ucbbrahms.ARPA>
Newsgroups: net.lang.c
Subject: Re: Type checking for typedef's (new feature)
Message-ID: <14056@ucbvax.BERKELEY.EDU>
Date: 30 May 86 10:28:03 GMT
Sender: usenet@ucb-vax.ARPA
To:       info-c@BRL-SMOKE.ARPA
     
In article <361@batcomputer.TN.CORNELL.EDU>
 garry%cadif-oak@cu-arpa.cs.cornell.edu.arpa writes:
>What I would like is for typedef names to be considered by the compiler as
>DIFFERENT from the underlying types. The compiler should then allow an
>implicit (or explicit) cast back and forth between the derived and under-
>lying types -- this will avoid breaking existing code. The improvement over
>the current state of things will happen when I ask the compiler "please tell
>me about possibly nasty implicit casts!"
>
>Is it reasonable? Is it hard to implement? Comments?
     
   Yes.  No.  This is how almost all typed languages (except C) handle
their types, and I agree that it is vastly preferable.  But don't hold
your breath waiting for C programmers to give up their super-weak typing.
     
   -- David desJardins
     
P.S. If you want to flame me do so via mail; I don't read this group...

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7541
          for JMS@ARIZMIS; Wed,  4-JUN-1986 05:01 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022800; 31 May 86 7:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010304; 31 May 86 7:44 EDT
From: Peter Ludemann <ludemann%ubc-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <262@ubc-cs.UUCP>
Date: 30 May 86 01:54:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2786@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>I know of one *big* reason why the UNIX compiler would be easy to beat
>- it produces human-readable assembler. If it produced a binary-coded
>assembler, the costs of (1) writing out all that text (2) reading in
>all that text [twice] and ...
     
Sorry, not true.  The deSmet C compilers (for IBM-PC and Macintosh)
produce human readable assembler and they are still fast.  For example,
on my Mac, I can compile about 3000 lines per minute (including i/o
to and from floppies), although I do use a RAM disk for the temp files
(the compiler is 3 passes, the last being the assembler).  Incidentally,
I think that deSmet (or C-ware) makes fine products at a good price;
they are also very responsive to bug reports --- I have received
written replies every time.
     
(Incidentally, the deSmet C on the Mac beat almost all the benchmarks
in the recent Byte article, both for compiling and for run-time code.)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7596
          for JMS@ARIZMIS; Wed,  4-JUN-1986 05:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022853; 31 May 86 8:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010184; 31 May 86 7:40 EDT
From: David Roth <dar%cbuxd.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C parser wanted
Message-ID: <319@cbuxd.UUCP>
Date: 16 May 86 16:45:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
*** REPLACE THIS LINE WITH YOUR MESSAGE ***
     
Hi Folks,
     
I've posted this request to net.wanted and net.sources already.  But now
I realize some people in this newsgroup may have what I'm looking for.
     
So, if anyone out there has Public Domain sources (in C or Pascal) to a
C parser that can be be fairly easily backended with a homegrown code
generator, please accept my profuse thanks in advance and contact me at:
     
ihnp4!burl!bu-3b5!wjb
Work: (919)228-3812
Home: (919)275-5283 (call collect)
     
Please note that I (will miss/have missed) any discussion about this on
the net, since I don't have access (this is being posted for me by a
friend).
     
                --Bill

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7672
          for JMS@ARIZMIS; Wed,  4-JUN-1986 05:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022859; 31 May 86 8:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010330; 31 May 86 7:45 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C, call it PL/2
Message-ID: <1628@ecsvax.UUCP>
Date: 29 May 86 13:51:58 GMT
Keywords: trademark, copyright, PL/I
To:       info-c@BRL-SMOKE.ARPA
     
In article <36@mit-prep.ARPA> x@mit-prep.ARPA (Dean Elsner) writes:
>Sorry, I don't think you can call it PL/2!
>IBM was going to call PL/1 "NPL" (New Programming Language?) until
>National Physical Laboratories told them not to. They then registered
>names PL/1 ... PL/100 (!). I don't think they reserved PL/0.
>I don't know what 'registered' means here, but I presume trademarked.
>This is from memory, and may be wrong.
>x@prep.ai.mit.edu (Dean Elsner)   Disclaimer: I am not me. Much. Often.
     
Sounds like an Urban Legend to me.  In the US it is not possible to
register a trademark until it has actually been used in trade.  Hence
stories of tobacco companies registering names like Acapulco Gold
against the possibility of legalized marijuana are, sadly, bogus.
     
On the other hand it is possible to register unused trademarks in other
countries.  Some Australians, for instance, make money by speculating in
trademarks.  If a new American company shows promise, they register the
name Down Under.  Then if the US firm wants to use its own trademark
there, it finds it must pay a royalty to some sneaky solicitor...
Perhaps PL/2 et al are already registered there.
     
I just had a vision of all these people at Australian Usenet sites
heading for Canberra to register C++.  What have I done...
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9125
          for JMS@ARIZMIS; Wed,  4-JUN-1986 08:17 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022867; 31 May 86 8:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010675; 31 May 86 7:58 EDT
From: William Roberts <liam%cs.qmc.ac.uk@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: := instead of = ?
Message-ID: <152@cs.qmc.ac.uk>
Date: 29 May 86 10:23:29 GMT
Posted: Thu May 29 10:23:29 1986
To:       info-c@BRL-SMOKE.ARPA
     
Summary:
Expires:
Sender:
Followup-To:
Xpath: ukc eagle
     
For the time being, you can catch a lot of the typos by putting
     
                if (5==x) ...
instead of      if (x==5) ...
     
I *know* it looks very strange, but losing an = in the first
causes the compiler to mutter about illegal lhs of assignment.
Losing an = in the second, however....
--
     
William Roberts                 ARPA: liam@UK.AC.qmc.cs
Queen Mary College              UUCP: liam@qmc-cs.UUCP
LONDON, UK

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8996
          for JMS@ARIZMIS; Wed,  4-JUN-1986 08:18 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/04/86 at 09:26:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022861; 31 May 86 8:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010550; 31 May 86 7:53 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Trademarks (was "What should be added to C, call it PL/2")
Message-ID: <308@cbmvax.cbmvax.cbm.UUCP>
Date: 30 May 86 19:51:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Summary: PL/2-PL/100 not protected names
>
>>Sorry, I don't think you can call it PL/2! ...
     
> Sounds like an Urban Legend to me.  In the US it is not possible to
> register a trademark until it has actually been used in trade.  Hence
> stories of tobacco companies registering names like Acapulco Gold
> against the possibility of legalized marijuana are, sadly, bogus.
     
> D Gary Grady
> Duke U Comp Center, Durham, NC  27706
> (919) 684-3695
> USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary
     
Though that may be independent of the amount of trade involved.  During the
last days of the Trameil administration at CBM, and before the PCjr was
shipped by CBM, Jack managed to ship a few copies of a "Peanut" computer,
which was later to be renamed.  As far as I know, the name was trademarked
at the time; certainly IBM didn't use it (though they may have decided against
it for other reasons as well).
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,inhp4,allegra,seismo}!cbmvax!daveh
     
    "Let me control a planet's oxygen supply,
     and I don't care who makes the laws"
                -Great Culuthu's Starry Wisdom Band
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1993
          for JMS@ARIZMIS; Wed,  4-JUN-1986 12:51 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022898; 31 May 86 8:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010906; 31 May 86 8:06 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What ever happened to %r in printf ?
Message-ID: <5554@alice.uUCp>
Date: 30 May 86 18:37:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> The %r tells printf to use &fmt as the address of a
> printf formatting string, and to get the arguments
> for it off the stack.  I don't know if it would
> work if fmt contained another %r.  Can vprintf be
> used to produce the same result ?
     
Vprintf and varargs.h can be used to produce a very
similar result, but portably.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1678
          for JMS@ARIZMIS; Wed,  4-JUN-1986 12:52 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022894; 31 May 86 8:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010896; 31 May 86 8:06 EDT
From: Kenneth Ng <ken%njitcccc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <171@njitcccc.UUCP>
Date: 31 May 86 03:04:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <963@h-sc2.UUCP>, augart@h-sc2.UUCP (augart) writes:
> >>> o The ability to define multi-line pre-processor macros, using #begdef and
> >>> #enddef statements.  #if and other conditionals in the body of the
> >>> definition would be evaluated when the macro was not interpreted, not when
> >>> it is encountered.
> >>Why would you want to use it?
> >When your macro won't fit on a line, and/or you want to use #if's etc
> >as part of the macro, obviously.
>
> If your macro won't fit on a line, you can already handle this problem by
> finishing off each line except the last with a backslash.
> The other addition would be a win, though.
C will not allow you to put #if's into a multiple line
macro, the backslash only allows you to continue the same line
on the next line.  It does NOT allow you to start another line.
     
--
Kenneth Ng: uucp(unreliable) ihnp4!allegra!bellcore!njitcccc!ken
        bitnet(prefered) ken@njitcccc.bitnet
     
New Jersey Institute of Technology
Computerized Conferencing and Communications Center
Newark, New Jersey 07102
     
Vulcan jealousy: "I fail to see the logic in prefering Stonn over me"
Number 5: "I need input"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3584
          for JMS@ARIZMIS; Wed,  4-JUN-1986 15:28 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/04/86 at 14:53:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022928; 31 May 86 8:44 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011367; 31 May 86 8:22 EDT
From: emjej%uokvax.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Throwing one away
Message-ID: <3000079@uokvax.UUCP>
Date: 28 May 86 14:18:00 GMT
Nf-ID: #R:brl-smoke.ARPA:911:uokvax.UUCP:3000079:000:601
Nf-From: uokvax.UUCP!emjej    May 28 09:18:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
/* Written 9:40 pm May 15, 1986 by Dave-Platt%LADC@HI-MULTICS.arpa in
 net.lang.c */
I believe your "It has also been said..." can be attributed to Donald
Knuth;  if I remember correctly, his original wording was "Plan on
throwing one away, because you will anyhow."
/* End of text from net.lang.c */
     
Doubtless a flood of corrections will appear, but...it was Fred Brooks, in
*The Mythical Man-Month*.  "Plan on throwing one away, because you will
anyhow.  The only question is whether you will deliver the throwaway to
your customers." is as near as I can reproduce it from memory.
     
                    James Jones

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3687
          for JMS@ARIZMIS; Wed,  4-JUN-1986 15:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022930; 31 May 86 8:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011397; 31 May 86 8:23 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <2600059@ccvaxa>
Date: 30 May 86 02:56:00 GMT
Nf-ID: #R:mmintl.UUCP:1463:ccvaxa:2600059:000:549
Nf-From: ccvaxa.UUCP!aglew    May 29 21:56:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
~> Multi-level breaks
     
I have never liked breaks with a numeric argument; I cut my teeth on
WATFOR/WATFIV, and I can assure you that they do *not* make things
much clearer.
     
Why not use the Ada style of putting a label before the loop body - it's
like giving a name to the loop:
     
    complicated_loop: for(;;) {
        {{{{{
        break complicated_loop;
        }}}}}
    }
     
No, it's not really much different from a goto.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6165
          for JMS@ARIZMIS; Wed,  4-JUN-1986 21:51 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/04/86 at 23:39:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028569; 4 Jun 86 22:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002677; 4 Jun 86 21:48 EDT
From: Kenneth Ng <ken%njitcccc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <178@njitcccc.UUCP>
Date: 2 Jun 86 14:46:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <477@cubsvax.UUCP>, peters@cubsvax.UUCP (Peter S. Shenkin) writes:
> In article <bentley.853> kwh@bentley.UUCP (KW Heuer) writes:
>
>
> I agree;  on the other hand, what C has over FORTRAN in this regard is the
> ability to keep writing on the same line in subsequent calls to printf();
> that is, to *not* insert a newline after WRITEing.
Try looking up what the "+" in column 1 does in the format.
It supresses the carriage advance.  The nestablility of the
format enables some very fancy tricks to be used in formating
output.  In my 18 line fortran game of life I printed the header,
put stars around the grid, printed the grid, and did a top of form
on every other generation, using one format and one write statement.
     
--
Kenneth Ng: uucp(unreliable) ihnp4!allegra!bellcore!njitcccc!ken
        bitnet(prefered) ken@njitcccc.bitnet
     
New Jersey Institute of Technology
Computerized Conferencing and Communications Center
Newark, New Jersey 07102
     
Vulcan jealousy: "I fail to see the logic in prefering Stonn over me"
Number 5: "I need input"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6265
          for JMS@ARIZMIS; Wed,  4-JUN-1986 22:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/04/86 at 23:51:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028614; 4 Jun 86 22:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002799; 4 Jun 86 21:52 EDT
From: mash%mips.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <493@mips.UUCP>
Date: 2 Jun 86 08:33:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3844@sun.uucp> guy@sun.uucp (Guy Harris) writes:
>...discussion why cpp functionality must be available...
>So there are ways of doing it without "cpp" being a separate program, but
>the important point is that it still isn't just a matter of hiding "cpp"s
>functionality in the lexical analyzer.
We've found it handy to use "cpp" as pre-pass to FORTRAN, PASCAL, C [of course]
and assembler: greatly eases multi-language software work.
>
>> and I would either have to include the work `inline' (asm.sed for you 4.1
>> and 4.2 folks) does, or have a separate ccom and c2+as phase.
>
>Or borrow the idea AT&T-IS has been talking about (see the note on
>"Assembler windows" in the article "The Evolution of C - Past and Future" in
>the recent UNIX edition of the AT&T Bell Laboratories Technical Journal -
>October 1984, Vol. 63 No. 8 Part 2), where the "asm" keyword is used
>differently:
>
>    ...description of asm f(arg1, arg2, ...) {...}
>
>This has the advantage that it makes it easier to drop into assembler when
>you absolutely have to, and the disadvantage that it makes it easier to drop
>into assembler when you *don't* have to.
     
Although asm() can be very useful on occasion, it's a sad thing, and it
just about wrecks the use of good optimizing compilers.  Unless I recall
incorrectly, there wasn't much of this in PDP-11 days, but it really
got popular on machines with slow subroutine calls.  From experience,
I much prefer a good optimizing compiler on a machine with fast calls:
the wish for "asm" drops away pretty quickly.  This leads to another
set of questions: real data would be appreciated:
Who uses asm?
On what machines?
How much performance was it worth?
Why did you use it?
    Structural reasons? (i.e., getting to privleged ops)
    Performance of small functions (i.e., spl?())
    Other performance (like getting long moves inline).
Did you use it inside the kernel, in libraries, or
    in application code?
Have you ever been bitten by compiler changes wrecking the code?
Do you have equivalent asm() code for 2 or more machines?
--
-john mashey    DISCLAIMER: <generic disclaimer, I speak for me only, etc>
UUCP:     {decvax,ucbvax,ihnp4}!decwrl!mips!mash, DDD:      408-720-1700, x253
USPS:     MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6394
          for JMS@ARIZMIS; Wed,  4-JUN-1986 22:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 00:02:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028620; 4 Jun 86 22:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003009; 4 Jun 86 21:59 EDT
From: JC van Winkel <jcvw%ark.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: K&R C syntax definition
Message-ID: <743@ark.UUCP>
Date: 2 Jun 86 09:31:43 GMT
Posted: Mon Jun  2 09:31:43 1986
To:       info-c@BRL-SMOKE.ARPA
     
The definition that can be found in 'The C programming language' by K&R
(appendix A) is incomplete and not LL(1).
     
Does anyone know if there is a exact syntax (LL(1)) definition of the K&R C
language ?
     
thanks.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6456
          for JMS@ARIZMIS; Wed,  4-JUN-1986 22:22 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 00:10:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028628; 4 Jun 86 22:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003060; 4 Jun 86 22:00 EDT
From: Eric Black <eric%chronon.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <279@chronon.chronon.UUCP>
Date: 2 Jun 86 23:06:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2600059@ccvaxa> aglew@ccvaxa.UUCP writes:
>
>~> Multi-level breaks
>
>Why not use the Ada style of putting a label before the loop body - it's
>like giving a name to the loop:
>
>    complicated_loop: for(;;) {
>        {{{{{
>        break complicated_loop;
>        }}}}}
>    }
>
>No, it's not really much different from a goto.
     
Sure it's different!  The keyword "break" conveys much more information; it
implies an exit from some sort of loop or other shapely control flow
construct (what shape is "switch"?), whereas "goto" can mean just
about anything, including jumping INTO another control construct.
Having a name attached to it helps make it clear which control construct
is being exited.  There is no way that "break" can land you in the
middle of another block, or a "for" loop, or "do...while", but a "goto"
could.  This makes it easier to understand what is written.
     
The question is, just how much semantic content is to be attached to
that name?  I assume the compiler should complain if the name can't
be found as a valid label in a containing control construct; the name
is not just a comment for human consumption.
    firstloop: while(1) {
        /* something */
    }
    secondloop: while(1) {
        /* something else */
        break firstloop;
    }
     
But should the compiler FORCE the break to refer to the construct
which is named?
    outerloop: while(1) {
        /* something */
        innerloop: for(i=0; i<IMAX; i++) {
            /* something else */
            break outerloop;
        }
    }
     
This is something which is kind of awkward to express now without
either a goto (horrors!) or setting some flag which is examined inside
the outer loop but outside the inner one.
     
I like the idea of the compiler understanding the name attached to
a break statement, and warning if it thinks you're doing something
you don't expect ("do what I mean, not what I say!"); I think the
pre-processor should inspect and *enforce* similar labels on
#if/#ifdef blocks as well.  But again, I'm not at all sure that it
should do more than flag apparently out-of-place labels, or change
the semantics of the program if it were identical except without
the attached labels.  Scream about what it thinks I said, yes, but
don't presume to do what it thinks I meant!
     
--
Eric Black   "Garbage In, Gospel Out"
UUCP:        {sun,pyramid,hplabs,amdcad}!chronon!eric

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6514
          for JMS@ARIZMIS; Wed,  4-JUN-1986 22:27 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028635; 4 Jun 86 22:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003172; 4 Jun 86 22:04 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C ( really = in boolean context )
Message-ID: <2881@utcsri.UUCP>
Date: 1 Jun 86 15:58:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1514@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>In article <852@bentley.UUCP> kwh@bentley.UUCP writes:
>>>>o There should be an option to flag statements of the form if (v = e) ...
>>>>(Actually, I wouldn't be averse to a coding standard which forbade such
>>>>things, in favor of if (v = e, v) ...)
>>
>>Urgh.  Are you talking about removing the assignment-has-a-value feature
>>completely, or a special case for "if (v = e)"?  (I always write this as
>>"if ((v = e) != 0)" to make it clear that I didn't mean "if (v == e)".)
>>
>
>Actually, I was not proposing removing the assignment-has-a-value feature
>anywhere (although I would not put it into a new language I was designing).
>The proposal was that it be avoided in if's (and probably while's as well)
>as a coding standard.  That is, it would be legal, but not recommended.
>
Somebody mentioned that Lint could warn about using an assignment value
in a boolean context - unless you said /* BOOLEUSED */. I think the
warning is a good idea, but the new special comment is not. You can just
as easily write ( (v=e)!=0 ) and get same code on any non-silly compiler.
( Note I did not say "good optimizing compiler", which are widely believed
to be capable of witchcraft :-) ). ( v=e, v ) would probably get you the
same code, too - ditto ( v=e, v!=0). The comma-less version may be
a mite faster in some cases. The presence of a 0 encourages the programmer
to be explicit as to what kind of zero is being used:
     
        while( p=p->link, p != NULL ){ ...
     
I wouldn't mind a compiler warning if an assignment op were used in
*any* boolean context ( including being the operand of !, ||, && , and
the expr. before a ? ).  Note that boolean context is inherited by the
RHS of a ',' and by e2 and e3 in e1?e2:e3.
     
--
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6656
          for JMS@ARIZMIS; Wed,  4-JUN-1986 22:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028689; 4 Jun 86 22:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003462; 4 Jun 86 22:12 EDT
From: D Gary Grady <dgary%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <1643@ecsvax.UUCP>
Date: 2 Jun 86 14:47:14 GMT
Posted: Mon Jun  2 10:47:14 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <900@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
>I can't understand Grady's point about "hard-coded subscript calculation"
>except that true, the programmer in C would need to enter in the code to
>do the subscript calculations to get the appropriate single subscript,
     
That WAS my point; it's harder to write and to read than something more
straightforward.  As you note, the preprocessor can be used to improve
readability somewhat, but you still wind up with something inconsistent
with local multidimensional arrays.  If you think this is a trivially
picky objection, you probably haven't had a lot of experience trying to
convince scientists there's more to life than Fortran.
     
>By the way, this does raise a question in my mind about how the convention
>of 1, not 0, being the lower bound subscript for an array is gotten around
>efficiently in implementations of Fortran.
     
It depends on the compiler, but the basic idea is to do an algebraic
rearrangement of the subscript calculation.  A simple example avoiding
such details as element-width should suffice to make this clear:  Given
a 2-d array dimensioned (M, N) from which you want the element (i,j),
you need to compute:
     
    base + (i-1) + n*(j-1)
     
A bit of algebra gives us:
     
    base - 1 - n + n*i + j
     
the first three terms of which are in principle computable at compile
time.  A common trick is to use that value in place of the actual base
address, and generate code as if the array subscripts did start at
zero.  In practice, alas, this is sometimes not possible (consider the
case of a huge n).  In that event we must take consolation in the fact
that decrements are fast and cheap.
--
D Gary Grady
Duke U Comp Center, Durham, NC  27706
(919) 684-3695
USENET:  {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6773
          for JMS@ARIZMIS; Wed,  4-JUN-1986 22:55 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028698; 4 Jun 86 22:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003604; 4 Jun 86 22:17 EDT
From: gordon@sneaky
Newsgroups: net.lang.c
Subject: Re: Indentation and braces
Message-ID: <-18363551@sneaky>
Date: 31 May 86 03:15:00 GMT
Nf-ID: #R:bentley.UUCP:855:sneaky:-18363551:000:1629
Nf-From: sneaky!gordon    May 30 22:15:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
> ...
> However, if indentation always reflects your intention, then eliminating the
> braces and making indentation significant would prevent this type of bug in
> the first place!
>
> Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
     
Does anyone have an ANSI standard for where you're supposed to set your
tab stops?  Determining "amount of indentation" from the whitespace
characters in the source isn't that straightforward.  Try ordering
these sequences of leading white space (presumed to be preceeded by
a newline or the beginning of the file, and followed by a statement)
by "amount of indentation", without having to supply information
to the compiler about what kind of terminal the source was written for
(which isn't usually, of course, the same as the terminal, if any, you
are running the compilation from):
     
9 spaces
2 tabs
15 spaces
16 spaces
17 spaces
1 space, 2 tabs
3 tabs
5 spaces, tab, 1 space, tab
3 spaces, formfeed, 3 spaces, tab, tab
3 spaces, formfeed, 15 spaces
formfeed, 15 spaces
2,000 spaces, formfeed, 6 spaces
7 spaces, tab, 7 spaces, tab
2 tabs, 1 space
4 spaces, tab, 4 spaces, tab
null string (statement starts in first character of the line)
formfeed
     
Is control-K (VT) defined as white space?  If so, you get more interesting
and confusing combinations.
     
Your terminal's tabs ARE set at column (left edge = column 1) 7, 15, 30,
and 72, aren't they?  :-)
     
Do tabs expand relative to the edge of the terminal, or the edge of the
window the compiler is running in?  What happens if the window changes
during compilation?
     
                Gordon Burditt
                ...!convex!ctvax!trsvax!sneaky!gordon

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8000
          for JMS@ARIZMIS; Thu,  5-JUN-1986 01:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 03:02:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028610; 4 Jun 86 22:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002795; 4 Jun 86 21:52 EDT
From: mash%mips.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: what should be added to C [generic comments on process]
Message-ID: <492@mips.UUCP>
Date: 2 Jun 86 08:04:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5565@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes:
>> I would rather see C++ and Concurrent C making their way
>> into the ANSI standard, but, if it is unfeasible, at least
>> their usefull additions to the "old C" should see the
>> world.
>No, no, NO!
>The purpose of a standards committee is to codify current
>practice, not to engage in wholesale language redesign.
>
>C++ is an evolving language.  Its present form should NOT be
>frozen into something like ANSI C.
     
I second Andy's comments, not just because I agree with them,
but because the note was one of the few comments in this discussion to
rise above the nitty details into a more generic observation.
It is important to find general rules and use them to solve problems,
rather than using nothing but special cases.  Andy has stated 2 rules:
     
1. Things should evolve for a while before they get standardized.
     
2. Standards committees should codify practice, not invent things.
     
To this, I'd like to add a few observations on past evolution of C,
then propose a few more rules to add to Andy's:
     
OBSERVATIONS ON THE PAST:
Here have been a horde of C variants, even just inside Bell Labs
[before I left, I had a huge file folder full of memos on them]:
a) Minor changes, which have either disappeared, or been
incorporated into C [a while ago].
b) Pre-processors to assist specific application areas.
I think some of these survived, although they usually didn't
spread too far outside the inventors' turf.
c) Major reworks.  Those that added relatively little new
functionality generally died off. C++ has done OK.
     
You wouldn't believe how many times the same things were (re)invented
in slightly different ways, used a while, and died out.
     
Now, some more proposed rules:
     
0A. Ecological niche: when you invent a language, make sure it has a
real niche in the world that doesn't overlap too much with existing ones:
    a) Make it an efficient way to handle a different applications
    area (i.e., like snobol, lisp, apt, smalltalk, etc)
    OR
    b) Make it an effective way to handle an existing problem domain,
    but a different (usually higher) level, i.e., assembler -> C,
    or C -> awk, or C -> shell, or COBOL -> 4GL.
    BUT NOT:
    make yet another language of the C/PASCAL/FORTRAN level of power,
    but with a slightly different syntax.
In general, it means that of the zillions of languages invented or
proposed, only a few will become widely used.
[Read Sammet's "Programming Languages: History & Fundamentals, or
Wexelblat's "History of Programming Languages", for example].
     
0B. Design parsimony.  Do the original design with a few (at most!)
knowledgable people, avoiding kitchen-sinks, and striving for a small
number of constructs, and examining each proposed feature for
its true contribution.  [Yes, motherhood, but given some of the past
discussion in this newsgroup, it may be worth pondering.]
     
1A. When it's still new, tweak it fast and hard in response to real usage.
     
1B. When it gets older, think much harder about tweaking it,
especially in non-upward compatible ways, unless the tweaks are agreed
to add great functionality. Especially, avoid adding extra ways to say the
same thing.
     
1C. If it's successful, it will spawn variants.
     
     
2A. When it's old, it is ABSOLUTELY USELESS AND A WASTE OF TIME TO
PROPOSE MINOR CHANGES, ESPECIALLY THOSE THAT EASILY BREAK EXISTING
CODE.  THEY WILL NOT HAPPEN.  THEY SHOULDN'T HAPPEN.  [I know it's
fun to propose changes and argue about them, and it is sometimes
useful, but IT'S TOO LATE TO DO THIS FOR C.]  Go on to something else,
like C++, or what C needs to survive good optimizing compilers, or
what features would be needed to give a language to replace C at a much
higher level, or...
     
Thus, we have:
     
0A: Ecological niche: make sure it has a place to live.
0B: Design parsimony: don't feed it too much, too early.
1: Let it evolve.
    1A: When young, tweak it.
    1B: As it ages, tweak it less.
    1C: If it lives, it will have siblings.
2: When it's almost (but not quite) ancient, standardize the family.
2A: At this point, it's too late to make the parents over; start working
on the children instead, while there's still hope.
--
-john mashey    DISCLAIMER: <generic disclaimer, I speak for me only, etc>
UUCP:     {decvax,ucbvax,ihnp4}!decwrl!mips!mash, DDD:      408-720-1700, x253
USPS:     MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8151
          for JMS@ARIZMIS; Thu,  5-JUN-1986 01:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 03:13:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028715; 4 Jun 86 22:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003794; 4 Jun 86 22:22 EDT
From: Mike Meyer <mwm@opal.ucb-vax.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <774@jade.BERKELEY.EDU>
Date: 2 Jun 86 12:29:58 GMT
Sender: usenet@jade.ucb-vax.ARPA
To:       info-c@BRL-SMOKE.ARPA
     
In article <1518@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>This is not consistent with the experience in promulgating standards for
>other languages.  FORTRAN 77 differs from the old standard rather more than
>the relatively modest set of changes I proposed; it has been widely adopted,
>essentially all new FORTRAN compilers adhere to the standard, and such
>compilers have been made available for most machines still in use on which
>an older compiler is available.
     
The thing about F77 (and FIV vs FII) is that most of the features in
the F77 standard had already been implemented - or at least something
similar to them - in most compilers already.  The standard was, as
someone (many someones?) keep saying, an effort in standardizing
existing practices, not creating new ones.  The most significant
change that wasn't in general use was the 0-iteration do loop; the
change that caused the most howling (at least the most amusing
howling) was not printing a field of "*"'s for values that wouldn't
fit in the format field specified. I think that your proposed
changes are more serious than those two cases.
     
In light of this, the way to get people to adopt your proposed
extensions (or anyone elses, for that matter!) is to add them to a C
compiler, make it generally available, and convince people to use
those features. Having a good book that teaches C + those features
will help a lot, too.
     
    <mike

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8287
          for JMS@ARIZMIS; Thu,  5-JUN-1986 01:45 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028720; 4 Jun 86 22:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003937; 4 Jun 86 22:28 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Declaring pointer to array of structures, within a structure
Message-ID: <5582@alice.uUCp>
Date: 3 Jun 86 14:41:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Now this seems to work perfectly well, and lint says nary a word about
> this code except for a complaint about the possible alignment problem
> from the cast of malloc(), which I presume is normal.  But what bugs me
> is that in my typedef of bar, I don't say that member d is a pointer to
> an ARRAY of struct foo, I just say that it is a pointer to one struct foo.
> Is this kosher, or have I violated some subtle but important distinction
> between arrays and pointers to them?  Remember, I'd like to be able to
> treat member d as I would the name of any other array in referencing
> the memory it points to.
     
You're doing the right thing.
     
In C, the size of an array can only be a constant.  However,
the name of an array is almost always translated to a pointer
to its zeroth element.  Thus you can use a pointer in essentially
all contexts where you might use an array.  The only difference
I can think of is that sizeof(BAR->d) will be the size of a
pointer rather than the amount of memory you allocated.
     
Incidentally, you don't need to write (BAR->d)[5] because
-> binds more tightly than [] .  You can therefore write BAR->d[5] .

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8491
          for JMS@ARIZMIS; Thu,  5-JUN-1986 02:22 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 04:08:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028797; 4 Jun 86 23:09 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002503; 4 Jun 86 21:46 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA18397; Wed, 4 Jun 86 11:02:47 edt
Date: Wed, 4 Jun 86 11:02:47 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606041502.AA18397@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, mtx5a!esg@seismo.css.gov
Subject: re: what should be added to C
     
    2. Reference variables, e.g. int& i, used to provide
       call by reference and implemented as a pointer
       to a variable that is dereferenced every time it is used.
     
                        Ed Gokhman
     
You are not adding any new functionality, you are merely stating it
another way. We don't like it. However, I will clue you in on another
abominable coding practice of mine; if you are only going to use the
datum by reference, say for [sg]tty, declare it as an array of 1!
     
    Conventional            Yours Truly
     
    struct sgttyb buf;        struct sgttyb buf[1];
    gtty(fd,&buf);            gtty(fd,buf);
    buf.sg_flags &= ~ECHO;        buf->sg_flags &= ~ECHO;
    stty(fd,&buf);            stty(fd,buf);
     
Say what you will, at least it's portable!
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
The FALAFEL SANDWICH lands on my HEAD and I become a VEGETARIAN...

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1326
          for JMS@ARIZMIS; Thu,  5-JUN-1986 06:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028817; 4 Jun 86 23:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004361; 4 Jun 86 22:42 EDT
From: iscoe%milano.uucp@BRL.ARPA
Newsgroups: net.lang,net.lang.c,net.lang.pascal,net.wanted
Subject: Re: Summary of Pascal-to-C translator
Message-ID: <1593@milano.UUCP>
Date: 3 Jun 86 21:15:47 GMT
Sender: iscoe%milano.uucp@BRL.ARPA
Keywords: pascal, C
To:       info-c@BRL-SMOKE.ARPA
     
Although the Whitesmith compiler produces C as an intermediate step, it
does not support most popular Pascal extensions.  In particular, it does
not have string support.
     
I spoke to the TGL people about 2 years ago.  They developed the system
for their own use, and decided to market it to recoup some of their
costs.  I assume that it works (although it seems a little pricey).
     
Neil Iscoe  Iscoe@mcc.ARPA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1240
          for JMS@ARIZMIS; Thu,  5-JUN-1986 06:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028813; 4 Jun 86 23:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004357; 4 Jun 86 22:42 EDT
From: rlb%zaiaz32.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: What should be added to C (booleans)
Message-ID: <167@zaiaz32.UUCP>
Date: 2 Jun 86 14:06:11 GMT
Posted: Mon Jun  2 10:06:11 1986
To:       info-c@BRL-SMOKE.ARPA
     
>
> provided that the two expressions evaluate to whatever a boolean int is
> locally (1 or -1).  {BTW I usually use set_me_true = (1 == 1)}
>
     
This worries me, much the same as when I see someone code:
     
    #define    FALSE    0
    #define    TRUE    !FALSE
     
Makes me think that the person writing may really not know that a C
"boolean" expression (expression formed with the logical/relational operators)
is *defined* to be either 1 or 0.
     
...ihnp4!zaiaz!rlb                           -Ron Burk

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1183
          for JMS@ARIZMIS; Thu,  5-JUN-1986 07:00 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 08:05:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028804; 4 Jun 86 23:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id aa04260; 4 Jun 86 22:39 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Declaring pointer to array of structures, within a structure
Message-ID: <1792@umcp-cs.UUCP>
Date: 3 Jun 86 23:47:54 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <909@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
>typedef struct bar {
>    char *c;
>    struct foo *d;    /* Is this right, to point to an ARRAY of struct foos,
>                please read on */
>};
     
You left out the type name for the typedef, but other than that,
yes, it is correct.
     
>... But what bugs me is that in my typedef of bar, I don't say
>that member d is a pointer to an ARRAY of struct foo, I just say
>that it is a pointer to one struct foo.  Is this kosher, or have
>I violated some subtle but important distinction between arrays
>and pointers to them?
     
It is fine.  All a compiler needs to implement an unchecked
one-dimensional array is a base address and an element size;
and a pointer to any `object with size' supplies both.
     
>Remember, I'd like to be able to treat member d as I would the
>name of any other array in referencing the memory it points to.
     
The clause `in referencing ...' is important.  Given (e.g.)
     
    struct bar bar_array[10];
     
the compiler `knows' how many `bar_array' elements there are.
`sizeof bar_array' returns the number of bytes occupied by the
entire array; and a compiler could insert subscript checking
on accesses to bar_array[i].  However, given
     
    struct bar *bar_pointer;
     
the compiler only `knows' that `bar_pointer' is of type `pointer
to struct bar' and that `*bar_pointer' is of type `struct bar';
`sizeof bar_pointer' gives the number of bytes occupied by the
pointer, and a compiler is much harder pressed to come up with
`subscript' checking for bar_pointer[i] (though it *can* be done).
     
>When I tried to say d is a pointer to an array of struct foo and tried:
>
>    struct foo *(d[]);
>    or
>    struct foo (*d)[];
     
The second is a `pointer to array of struct foo' in cdecl syntax.
(The first is `array of pointer to struct foo', not what you asked
for.)  In the latter case case the array part carries no number of
elements, which creates a bit of a problem if one writes `d[i]':
to find d[i], the compiler must go to the i'th `d', but how big is
each d[j], 0 <= j < i?  (Answer:  somewhere between zero `struct
foo's and an infinite number of `struct foo's.  This is no help.)
A compiler could still handle (*d)[i], though:  no matter how big
(*d) is, its address is zero bytes away from the address of (*d);
and (*d)[0] is `sizeof (struct foo)' bytes big.  Zero times anything
is zero, so the size of d[0], a.k.a. (*d), is unimportant.
     
(Actually, I have glossed over something.  The size of (*d) must
be known if different pointers are different sizes, else how is
the compiler to generate the correct dereference instruction?  On
most machines all pointers are the same size, and one can get away
with a generic dereference instruction.  In general, the more
information you feed your compiler---assuming it is correct---the
better.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2935
          for JMS@ARIZMIS; Thu,  5-JUN-1986 09:32 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001010; 5 Jun 86 5:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008469; 5 Jun 86 5:41 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What ever happened to %r in printf ?
Message-ID: <6762@utzoo.UUCP>
Date: 3 Jun 86 23:38:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Does anyone know why the %r formatting option of printf was
> never documented on older UNIX systems ?  It doesn't exist
> on the Sys 5 Rel 2 we have.
     
There is no portable way to write the corresponding argument.  vprintf
(in cooperation with varargs.h) is intended as a portable way to get
the same effect.
--
Usenet(n): AT&T scheme to earn
revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3254
          for JMS@ARIZMIS; Thu,  5-JUN-1986 09:35 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001023; 5 Jun 86 5:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008478; 5 Jun 86 5:42 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Error recovery (long)
Message-ID: <1538@mmintl.UUCP>
Date: 3 Jun 86 17:29:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <312@uw-nsr.UUCP> john@uw-nsr.UUCP writes:
>I don't know the parsing method used in
>this compiler; it does not seem to suffer from poor error recovery as do
>many recursive-descent parsers.
     
My impression is that the quality of the error recovery has little to do
with the parsing method used, and a great deal to do with how much effort is
investing in making the error recovery good.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3040
          for JMS@ARIZMIS; Thu,  5-JUN-1986 09:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 11:07:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001014; 5 Jun 86 5:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008473; 5 Jun 86 5:41 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Type checking for typedef's (new feature)
Message-ID: <6763@utzoo.UUCP>
Date: 3 Jun 86 23:44:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> What I would like is for typedef names to be considered by the compiler as
> DIFFERENT from the underlying types....
> Is it reasonable? Is it hard to implement? Comments?...
     
Not unreasonable.  Not too hard to implement.  Not C, either.  Too many
existing programs would break.  Typedef is often used to parameterize
machine-dependencies like integer sizes, where the "macro" interpretation
of typedef is necessary.  It's much too late to change this now.
--
Usenet(n): AT&T scheme to earn
revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2831
          for JMS@ARIZMIS; Thu,  5-JUN-1986 10:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029403; 5 Jun 86 1:15 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a005743; 5 Jun 86 1:05 EDT
Received: from (BJORNDAS)CLARGRAD.BITNET by WISCVM.WISC.EDU on 06/04/86
  at 15:42:15 CDT
Date: 4 JUN 86 11:24-PST
From:  BJORNDAS%CLARGRAD.BITNET@wiscvm.ARPA
To:  INFO-C@BRL-SMOKE.ARPA
Subject: swap() macro
     
> The macro I always wanted to write is:
>
>    #define swap(a,b) { typeof(a) temp;    \
>                temp = (a);        \
>                (a) = (b);        \
>                (b) = temp;        \
>              }
     
Perhaps some of you more expert in C than I can respond to the macro
     
#define SWAP(type_,a,b) {type_ temp = (a); (a) = (b); (b) = temp;}
     
This should work for most cases, shouldn't it?
     
Sterling Bjorndahl              BITNET: BJORNDAS at CLARGRAD
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3454
          for JMS@ARIZMIS; Thu,  5-JUN-1986 10:15 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001150; 5 Jun 86 6:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008499; 5 Jun 86 5:42 EDT
From: David DiGiacomo <david%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Casting a postdecrement operand
Message-ID: <3925@sun.uucp>
Date: 4 Jun 86 20:00:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1764@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>Incidentally, if you really *do* want to take a pointer `p' to
>type `x', but treat it as a pointer to type `y', the construct
>
>    *(y **)&p
>
>works (as long as `p' is addressable).  Thus
>
>    ((struct abc *)cbap)++;
>
>is not legal, but
>
>    (*(struct abc **)&cbap)++;
>
>is (again, if cbap is addressable).  What it means is machine
>dependent!
     
This is disgusting... why not use
     
    cbap = (struct cba *) ((caddr_t) cbap + sizeof(struct abc));
     
?
     
--
David DiGiacomo  {decvax, ihnp4, ucbvax}!sun!david  david@sun.arpa
Sun Microsystems, Mt. View, CA  (415) 960-7495

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9079
          for JMS@ARIZMIS; Thu,  5-JUN-1986 20:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/05/86 at 22:18:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001163; 5 Jun 86 6:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008563; 5 Jun 86 5:44 EDT
From: Ben Cranston <zben%umd5.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <1002@umd5.UUCP>
Date: 5 Jun 86 02:33:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2157@mit-eddie.MIT.EDU> barmar@mit-eddie.UUCP (Barry Margolin) :
     
>In article <900@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
     
>>By the way, this does raise a question in my mind about how the convention
>>of 1, not 0, being the lower bound subscript for an array is gotten around
>>efficiently in implementations of Fortran.
>>... pain to have to subtract that pesky correction factor from the ag-
>>gregate subscript in coming up with an offset for the address of the array
>>element from the base of the array the way Fortran does, unless the computer
>>has a hardwired way of accessing an object in memory based on a base address
>>(base of the array), an offset (calculated from the subscripts), and a
>>correction factor (based on how the array was dimensioned) residing in regis-
>>ters and added together automatically.
     
>I think many mainframes have such addressing modes.
     
Of course, the simplest method of doing this is to decrease the base address
of the array by the correction factor.  This tack is taken on the Sperry 1100.
The major problem with it is making sure that the <base-offset> does not go
negative, as the two high bits in the address field on the Sperry enable the
automatic incrementation of the index register [i.e. (*p++) ] and indirecting
which can cause really funny things to happen.
     
So, the software kluge is that the compiler can create something called a
"minadr specification" in the relocatable binary, and the system linking
loader interprets that as a request to relocate that array "no lower than"
the specified address.  In the worst case it might have to move the segment
[Sperry calls them "banks"] start address above the default 40000 (8)...
     
Then there was the user who said:
     
CASE ZIPCODE OF
20904: ROUTE1;
20905: ROUTE2;
20906: ROUTE3;
     
and made the Pascal compiler generate [J $-20903,X] without a "minadr"...
     
--
"We're taught to cherish what we have   |          Ben Cranston
 by what we have no longer..."          |          zben@umd2.umd.edu
                          ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9213
          for JMS@ARIZMIS; Thu,  5-JUN-1986 20:54 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001167; 5 Jun 86 6:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008721; 5 Jun 86 5:49 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C vs. FORTRAN (was: What should be added to C)
Message-ID: <914@ttrdc.UUCP>
Date: 3 Jun 86 22:20:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <178@njitcccc.UUCP>, ken@njitcccc.UUCP (Kenneth Ng) writes:
>In article <477@cubsvax.UUCP>, peters@cubsvax.UUCP (Peter S. Shenkin) writes:
>> In article <bentley.853> kwh@bentley.UUCP (KW Heuer) writes:
>> I agree;  on the other hand, what C has over FORTRAN in this regard is the
>> ability to keep writing on the same line in subsequent calls to printf();
>> that is, to *not* insert a newline after WRITEing.
>Try looking up what the "+" in column 1 does in the format.
>It supresses the carriage advance.  The nestablility of the
>format enables some very fancy tricks to be used in formating
>output.  In my 18 line fortran game of life I printed the header,
>put stars around the grid, printed the grid, and did a top of form
>on every other generation, using one format and one write statement.
>Kenneth Ng: uucp(unreliable) ihnp4!allegra!bellcore!njitcccc!ken
     
_18 line_ fortran game of life?  Can you post that (in net.lang.f77 of course)?
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0765
          for JMS@ARIZMIS; Fri,  6-JUN-1986 00:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001252; 5 Jun 86 6:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008460; 5 Jun 86 5:40 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  questions from using lint
Message-ID: <6755@utzoo.UUCP>
Date: 2 Jun 86 18:31:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >More seriously, any grouping-by-indenting scheme should be studied carefully
> >for ways in which minor typos could seriously alter the meaning of the
> >program in non-obvious ways.
>
> I agree, but: why should this be done for grouping by indentation, when it
> isn't done for any other language features?  (When was the last time you
> wrote "=" instead of "=="?)
     
Because it's the right thing to do, even if our predecessors didn't always
do it.  "Neglect of duty does not cease by repetition to be neglect of duty."
--
Usenet(n): AT&T scheme to earn
revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0815
          for JMS@ARIZMIS; Fri,  6-JUN-1986 00:52 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001256; 5 Jun 86 6:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008886; 5 Jun 86 5:53 EDT
From: Mike Wexler <mike%peregrine.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler features
Message-ID: <398@peregrine.UUCP>
Date: 3 Jun 86 18:09:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1755@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>In article <312@uw-nsr.UUCP> john@uw-nsr.UUCP (John Sambrook) writes:
> ...
>(The 4.2BSD dbx is terribly buggy.  To repeat the old war cry:
>`fixed in 4.3'---which (fanfare please) *has been released!*...)
Also fixed in Sun Unix. And probably other implementation of 4.2.
>
>>The second feature is the ability to declare certain data structures as
>>"read only." This is done via a compiler switch "-R" and applies to all
>>data structures that are initialized to a constant value within the
>>compilation unit.
>
>Surprise!  4BSD has the very same feature.  It is even documented.
>(At least in 4.3; if it is not documented in 4.2, well, `fixed in
>...'.)  This is perhaps most useful to make the text of string
>constants sharable.
This feature is documented on the Sun.
>
     
--
Mike Wexler
Email address:(trwrb|scgvaxd)!felix!peregrine!mike
Tel Co. address: (714)855-3923
;-) Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine :-(

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0898
          for JMS@ARIZMIS; Fri,  6-JUN-1986 01:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001294; 5 Jun 86 6:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008983; 5 Jun 86 5:57 EDT
From: Christopher Caldwell <chris%sol.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Additions/modifications to C library
Message-ID: <121@sol.UUCP>
Date: 3 Jun 86 22:11:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
*** REPLACE THIS LINE WITH YOUR MESSAGE ***
     
I have been reading articles from the net on and off for about a year now.
If this kind of thing has been posted before, please flame me via email ...
     
I am trying to create C programs on a microForce-1A (M68010 System V UNIX box)
to download to one of their cards (CPU-1C).  I am able to download code
that does not use any of their standard libraries by emulating the various
systems calls.  However, their standard libraries do stack checking and
annoying port dependant system calling.  I do not have the source to anything.
     
Therefore, I think I will end up writing my own equivalent of the C library.
     
Firstly, is there such think as a public domain C library?  (Why are you
all laughing so hard?)
     
Secondly, I have committed the ultimate sin of programmers everywhere and
added some improvements to mine.  In particular, I no longer use printf.
Instead, I use "format".  I.e.:
     
    format("The answer is {i}.\n",an_int_variable);
     
The braces denote a substitution (Like "%" in printf), but the options are
different.  ('{{' means just print a '{')  A substitution is of the form (EBNF):
     
    '{' <type-letter> { <modifier-character> [ <modifier-value> ] } '}'
     
Available type letters so far are:
     
    s    string (Char *)
    i    int
    l    long
    c    character
    f    float (double)
    S    Another format string (I smell recursion)
     
Available modifers (and their defaults) are:
     
    l(0)    Number of columns to take up, value will be left justified
    r(0)    Number of columns to take up, value will be right justified
    c(0)    Number of columns to take up, value will be centered
    m(0)    Maximum number of columns display of data
    .(6)    Number of places to display to the right of the decimal point
    b(10)    Base of number
    p(32)    Ascii value of pad character for l, r or c.
    u(0)    Unsigned status (signed=0, unsigned!=0)
    n(1)    Count of times to repeat string
     
If a modifer value is followed by a string of digits then that string is
converted to an integer and used as the modifier's value, else the value will
be taken from the next argument to format.
     
Some ridiculous variable type/modifer combinations exist:
    What is an unsigned string (or character) of base 8 with 4 trailing
        decimal places? (All three modifiers are ignored)
    Do you really want to see floating point variables in base 3?  (Yes!)
    What does centering a left or right justifed variable look like?
        (The last justification character is the one used)
     
Now, an example program:
     
    main()
    {
    int i;
     
    format("Left justified integer:  '{il10}'\n",1234);
    format("###{f.1c}###\n",123.4,20);
    format("Octal:  {lb8r11pu1}\n",01234L,'0');
    format("Truncate this:  {sm10}\n", "This is a test" );
    format("Print 5 arfs:  {sn5}\n","arf");
    i = 1;
    format("Do it {i} time{sn}.\n",i,"s",i!=1);
    i = 2;
    format("Do it {i} time{sn}.\n",i,"s",i!=1);
    format("Center this: ###{Sc20p}###\n","Answer={i}",'$',1234);
    exit(0);
    }
     
and its standard output:
     
    Left justified integer:  '1234      '
    ###        123.4       ###
    Octal:  00000001234
    Truncate this:  This is a
    Print 5 arfs:  arfarfarfarfarf
    Do it 1 time.
    Do it 2 times.
    Center this: ###$$$$$Answer=1234$$$$###
     
The following flavors of format are available:
     
    format( formatstring, args... )        Send to standard out
    fformat( stream, formatstring, args... )Send to specified stream
    i = cformat( formatstring, args... )    Calculate number of chars
    sformat( buf, formatstring, args... )    Send to the character array buf
    ptr = mformat( formatstring, args... )    Malloc enough space for result
                        (and trailing 0), put the
                        result in malloced space, and
                        return pointer to it
                Also, as a kluge:
    ptr = sformat( NULL, formatstring, args... )
     
mformat (and sformat with a NULL array), perform the format twice,
once to find out how many characters needed to malloc, and the next
time to fill up the array.
     
I have been using these routines extensively for downloaded applications, and
am now using them for my UNIX programs as well.  The only disadvantage I can
find with them is that simple formats require more characters to specify
than with printf.  I.e. to print a two character integer with printf requires
three characters (%2d), but with format requires five ({ir4}).
     
Advantages:
    Easier to understand justification
    Centering available
    More flexible padding (instead of just spaces or zeros)
    Arbitrary base output (2 to 36)
    Complex formats available ("S")
    Arbitrarily lengthed everything (up do what you can malloc)
    And from my point of view, I have the source!
     
I am also working on a replacement for scanf which uses the same style
of modifiers.  In particular, it will be able to malloc space for strings
it has parsed, and the equivalent of "sscanf" will return some kind
of indication of where it stopped parsing the string.  If this is possible
to do with sscanf, I don't know how.
     
Comments and opinions are welcome.
     
If people want the source, I am certainly willing to post it or email it.
     
Also, what do netlanders think of a tiny revision to C?  Namely, to be able
to specify the base of an integer in the form <base>_<number>.  For instance
to specify 10 (base 10) in base 2, one might type 2_1010.  Yes, once again,
I am opting for full generality.  Also, I must admit, I find 0<number> and
0x<number> confusing.  I much prefer 8_777 to 0777.
     
Christopher M. Caldwell
...decvax!ittatc!sii!dmcnh!sol!chris
16 Columbia Drive, VIBRAC Corporation, Amherst, NH 03031, (603)882-6777
13B Bobby's Lane, Milford, NH 03055, (603)673-2249

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1042
          for JMS@ARIZMIS; Fri,  6-JUN-1986 01:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001319; 5 Jun 86 6:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009272; 5 Jun 86 6:04 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: Re: Datalight faster than 4.2, why?
Message-ID: <486@cad.BERKELEY.EDU>
Date: 4 Jun 86 22:10:35 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2600061@ccvaxa>, aglew@ccvaxa.UUCP writes:
> I very much doubt that a cpp that parses enough of C to understand
> sizeof will be useful in non-C-related applications.
     
You're wrong: /lib/cpp doesn't recognise sizeof, /lib/ccom does.
     
    Wayne

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1223
          for JMS@ARIZMIS; Fri,  6-JUN-1986 01:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001323; 5 Jun 86 6:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009276; 5 Jun 86 6:05 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C
Message-ID: <487@cad.BERKELEY.EDU>
Date: 4 Jun 86 22:57:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1518@mmintl.UUCP>, franka@mmintl.UUCP (Frank Adams) writes:
> This doesn't let you use "#if" in the body of the macro, as my example would
> require.  To fully explicate, my example would be:
>
> #begdef copy(to, from, number)
> #if sizeof(from) % WORD_SIZE == 0
>    copyword(to, from, number * sizeof(from) / WORD_SIZE)
> #else
>    strncpy(to, from, number * sizeof(from))
> #endif
> #enddef
     
You can't use sizeof in a #if anyway.  You can only use constants and
pre-defined cpp symbols.  (Pardon me if you're talking about a different
compiler -- I'm using 4.3 cc.)
     
It is not clear what you are trying to do with your macro anyway.  Is 'from'
always a char *? If so  you don't need the sizeof.  Can it be a pointer to
anything?  In that case you don't want to use strncpy, and you would want to
write sizeof (*from), if it worked.
     
In most of the cases where you want to do something like this, you can
put the #if's outside of the #define's anyway, and if you can't, the
macro is probably complex enough to make into a function.
     
> >It's also an extra character to type.  If you are prone to this sort of
> >error, just run your code through grep if | grep = | grep -v == ...
>
> Thanks but no thanks.  If one added a separate step to the compilation
> process for each type of relatively common error, nothing would ever get
> done.  Again, please note that I did not propose outlawing "=" as a
> default -- you would have to specify an option to exclude it.
     
I meant that suggestion as a sort of "cleaning up a several months' worth of
code and finding little bugs" device.  I would say that in the normal process
of finding bugs you will locate = / == problems pretty quickly, and after
you use the language for a while you just learn not to do things like that.
I personally think that := is sort of ugly anyway...
     
If you really want a lot of extra checking, soup up lint a bit... You don't
have to get your own private lint through any standards committees...
     
    Wayne

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1390
          for JMS@ARIZMIS; Fri,  6-JUN-1986 01:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001327; 5 Jun 86 6:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009284; 5 Jun 86 6:05 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: nonzero lower bounds in arryas
Message-ID: <1848@umcp-cs.UUCP>
Date: 5 Jun 86 00:28:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1775@umcp-cs.UUCP> I wrote:
>Actually, in all cases [nonzero lower bounds] can be handled at
>compile time, with ... virtual origin[s].
     
As someone pointed out, this discussion originated with someone's
`wish list' item of run-time subscript bounding a la FORTRAN's
     
    SUBROUTINE FOO(M, N, A)
    INTEGER M, N
    INTEGER A(M,N)
     
declarations.  In such cases virtual origins still work, but must
be computed at run time, e.g., at entry to FOO above.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1502
          for JMS@ARIZMIS; Fri,  6-JUN-1986 01:50 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001333; 5 Jun 86 6:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009389; 5 Jun 86 6:08 EDT
From: "K. Richard Magill" <rich%hal.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: problem with unions (query)
Message-ID: <175@hal.UUCP>
Date: 4 Jun 86 15:51:00 GMT
Keywords: unions casts types return
To:       info-c@BRL-SMOKE.ARPA
     
I have a problem saying what I want to say.  The basics look like:
(vax 4.2)
     
typedef union {
    char *c;
    int *i;
} U;
     
U f()
{
    return("mumble");
}
     
Which naturally is of the wrong type but casting the (char *) into
(U) doesn't work either.  This works but is ucky and -O doesn't rip out "one".
     
U f()
{
    U one;
     
    one.c = "mumble";
    return(one);
}
     
Am I missing something obvious?
     
K. Richard Magill
...decvax!cwruecmp!hal!rich

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1622
          for JMS@ARIZMIS; Fri,  6-JUN-1986 02:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001340; 5 Jun 86 6:41 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009398; 5 Jun 86 6:09 EDT
From: William Sommerfeld <wesommer@mit-trillian.ARPA>
Newsgroups: net.lang.c
Subject: System specific preprocessor symbol for VMS C
Message-ID: <654@mit-trillian.MIT.EDU>
Date: 4 Jun 86 19:46:30 GMT
Keywords: VMS, preprocessor
To:       info-c@BRL-SMOKE.ARPA
     
What is the "automatic preprocessor-defined symbol" defined by VAX/VMS
C?  (similar to "vax" on VAX Unix, "sun" on a SUN, etc..).  Please
reply via mail.  Don't ask me why I need this.  Thanks.
     
     
                    Bill Sommerfeld
                    MIT Project Athena
                    ARPA: wesommer@athena.mit.edu
                    UUCP: mit-eddie!wesommer

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2535
          for JMS@ARIZMIS; Fri,  6-JUN-1986 04:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/06/86 at 06:02:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016803; 5 Jun 86 15:09 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a023042; 5 Jun 86 14:01 EDT
Received: from (MAILER)TCSVM.BITNET by WISCVM.WISC.EDU on 06/05/86 at
  13:02:50 CDT
Received: by TCSVM (Mailer X1.22) id 9442; Thu, 05 Jun 86 09:35:53 CVT
Date:         Thu, 5 Jun 1986 09:30:05 CVT
From:           Dan Smith <SYSBDES%TCSVM.BITNET@wiscvm.ARPA>
Subject:      Re: Why Datalite is faster etc etc....
To:  INFO-C@BRL-SMOKE.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
     
John mashey writes:
     
> Who uses asm?
I do...
     
> On what machines?
On PC/PC-Clones and IBM 3081
     
> How much performance was it worth?
Only on the PC/PC-Clones did I do it for performance.  On this machine
the weird pointer structure imposed by the (ahem) segmented memory made
one set of routines time critical in a application I was working on.
Recoding just those routines in asm produced a 50% increase in perf.
These functions were only 2-3 lines of C but VERY heavily used.
     
> Why did you use it?
>   Structural reasons? (i.e., getting to privleged ops)
On VM/SP I did it to access the Raw I/O on a Tape drive
     
>   Performance of small functions (i.e., spl?())
In the PC stuff it was to make the pointer math work at a reasonible
speed.  (Intel really bit the big one on that segmented memory stuff)
     
>   Other performance (like getting long moves inline).
Not yet..  Most C packages already have a long move function that is
Quick enough.  And if you are moving alot of stuff the call/return
overhead is small compared to the actual move loop/instruction/whatever..
     
> Did you use it inside the kernel, in libraries, or
>    in application code?
Application code libraries..  Haven't had much chance to hack kernels yet
     
> Have you ever been bitten by compiler changes wrecking the code?
Not Yet.. The most likely failure path would be a change to the call/ret
sequence or in how the local var frame is set up.  Most of the compilers
I have used are mature enough where this has not changed in quite a while
     
> Do you have equivalent asm() code for 2 or more machines?
Nope.. Most of this code is specific per machine.  I do have equivalent
code for the speed up changes tho,  IN C!!   (The hardware in question
has brain damage.. Normal machines don't need the fix)
     
     
Dan Smith (aka MadMan)
BITNET:     SYSBDES@TCSVM
ARPA:       SYSBDES%TCSVM.BITNET@WISCVM.WISC.EDU
UUCP:       ...psuvax1!tcsvm.bitnet!sysbdes
            real soon now !tu-pul!ludwig!ds
Ma Bell:    (504) 865-5631
Real Paper: Tulane University
            Tulane Computer Services
            Attn: Dan Smith, Systems Group
            6823 St. Charles Ave.
            New Orleans,  LA 70118-5698

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5814
          for JMS@ARIZMIS; Fri,  6-JUN-1986 09:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/06/86 at 11:19:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002027; 6 Jun 86 12:11 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a006574; 6 Jun 86 11:07 EDT
To: rlb%zaiaz32.UUCP@seismo.css.gov
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: What should be added to C (booleans)
In-reply-to: Your message of 2 Jun 86 14:06:11 GMT.
         <167@zaiaz32.UUCP>
Date: 05 Jun 86 10:44:37 EDT (Thu)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     
In article <167@zaiaz32.UUCP>, rlb@zaiaz32.uucp writes:
     
> >
> > provided that the two expressions evaluate to whatever a boolean int is
> > locally (1 or -1).  {BTW I usually use set_me_true = (1 == 1)}
> >
>
> This worries me, much the same as when I see someone code:
>
>     #define    FALSE    0
>     #define    TRUE    !FALSE
>
> Makes me think that the person writing may really not know that a C
> "boolean" expression (expression formed with the logical/relational operators)
> is *defined* to be either 1 or 0.
     
Of course, if you're worried about porting your code to systems with broken
C compilers (and if you've ever had to port code to a system with a broken
compiler, you worry about such things), then it is perfrectly reasonable
to #define TRUE to be (1 == 1) and FALSE to (1 == 0).  Besides, what will
you do when X3J11 redefines TRUE to be 17 and false to be -6 in the draft
to be published July, 2047 :-)?
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/506
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter@BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6675
          for JMS@ARIZMIS; Sat,  7-JUN-1986 08:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/07/86 at 10:23:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000358; 7 Jun 86 11:15 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a011628; 6 Jun 86 22:00 EDT
Date:     Fri, 6 Jun 86 21:50:59 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Root Boy Jim <rbj@ICST-CMR.ARPA>
cc:       brl.arpa!gwyn@seismo.css.gov, dgary%ecsvax.uucp@BRL.ARPA,
          ecsvax!dgary%mcnc.csnet@CSNET-RELAY.ARPA, info-c@BRL-SMOKE.ARPA
Subject:  Re:  C vs. FORTRAN (was: What should be added to C)
Message-ID:  <8606062150.aa10039@VGR.BRL.ARPA>
     
Please get your attributions straight.  With all these things I never
said getting credited to me, people are being misled as to who or what
I really am..

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6758
          for JMS@ARIZMIS; Sat,  7-JUN-1986 08:43 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/07/86 at 10:29:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa00358; 7 Jun 86 11:16 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a011704; 6 Jun 86 22:42 EDT
Date:     Fri, 6 Jun 86 22:39:19 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Donn Seeley <donn%utah-gr.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  what should be added to C [generic comments on process]
Message-ID:  <8606062239.aa10198@VGR.BRL.ARPA>
     
If this was intended to apply to the X3J11 committee, it was way off base.
I just got back from my first X3J11 meeting, and they are all very bright
experienced C compiler implementors and programmers, doing an excellent
job of arriving gradually at a consensus that precisely specifies a
language that EVERYbody should be able to accept.  This is no small feat.
     
Be warned that early draft standards were WORKING DRAFTS with many known
problems, which appear to be nearly all resolved at this point.  The
standard has not been released for public review, because it has not been
ready yet.  When it is, everyone will undoubtedly be able to find a few
things that might affect their existing code, but I assure you that the
implementors are the ones who will bear the brunt of adaptation.  There
is simply no way for a single language to simultaneously permit all the
implementation-specific features that programmers have chosen to exploit.
     
There have been very few actual inventions by X3J11, and the ones that
are now in the draft standard were put there to address specific needs
that were indicated as being major concerns for a large number of users.
For example, Reiser CPP users have sometimes used "invisible comments"
to paste tokens together into one in macros.  However, this violates
K&R's intent, which was taken literally by compiler implementors who
did not start with AT&T source code.  This is a classic case where two
user constituencies collide, and they can't both be blessed by the
standard.  Therefore the rule is what K&R had in mind, BUT the function
that was absent that caused programmers to use the trick in the first
place was invented so that there would be SOME way to give them what
they wanted.  One could think of several ways of doing this; be assured
that almost every imaginable variation was thoroughly explored, with the
consensus being what is now in the draft (## operator).  This could
still change either before or because of public review.
     
Given the conflicting demands, I believe the proposed standard will be
an excellent compromise solution.  It has a chance of being voted out
to the public within a few months, depending on how the few remaining
major issues are addressed; please wait for the final form before
judging the result.
     
The above is not necessarily the opinion of the Army nor of X3J11;
I speak here solely from my own personal viewpoint.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6804
          for JMS@ARIZMIS; Sat,  7-JUN-1986 08:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/07/86 at 10:31:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id ab00358; 7 Jun 86 11:16 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a011788; 6 Jun 86 23:02 EDT
Date:     Fri, 6 Jun 86 22:54:05 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       "K. Richard Magill" <rich%hal.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  problem with unions (query)
Message-ID:  <8606062254.aa10390@VGR.BRL.ARPA>
     
What you are missing is that if the function returns type U,
then you must return something of type U or else return something
assignment-compatible with it.  A (char *) is not compatible
with a union.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8974
          for JMS@ARIZMIS; Sat,  7-JUN-1986 13:48 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 06/07/86 at 15:26:35 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Wed 4 Jun 86 08:13:37-PDT
Date:  4 JUN 1986 11:12:53 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: MANSFIELD%DHDEMBL5.BITNET@WISCVM.WISC.EDU
cc: info-vax@sri-kl.arpa
Subject:  Re: problem with C fopen(), file revision date
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
    The following program behaves curiously.  When you run it, the revision,
    date of the file it opens is updated, if that file is a stream_lf file.,
    If the file is variable length or fixed length, the revision date is not,
    updated.
     
    This even occurs when the file protection is (s,o,g,w:r), and the file is
    on a directory which is not mine.
     
    Any explanations?
     
    #include        <stdio.h>
    main(argc, argv)
            int     argc;
            char    **argv;
            {
            FILE    *inf;
            char    line[BUFSIZ];
     
            argc--; argv++;
            if ( (inf = fopen(*argv, "r")) != NULL)
                    puts("Opened");
            else
                    puts("Can't open");
            }
The VAX C RTL has to do some strange hacking to make stream files work right.
(Long story.  Basically, as far as RMS is concerned, stream files are just
as record oriented as other files, so you can't position to arbitrary bytes.
But C requires that you be able to do this.  So the C RTL ignores RMS and does
block I/O, which sometimes requires fixing up the file header - which is why
stream files don't work quite right over DECnet, and probably ultimately is
why this program acts as it does.)  Apparently there are some changes in VMS
V4.4, which has a new version of the C RTL - try it and see what happens.
     
                            -- Jerry
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0095
          for JMS@ARIZMIS; Sat,  7-JUN-1986 15:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/07/86 at 17:34:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001648; 7 Jun 86 18:27 EDT
Received: from mit-multics.arpa by SMOKE.BRL.ARPA id a002287; 7 Jun 86 18:06 EDT
Date:  Sat, 7 Jun 86 17:55 EDT
From:  Paul Schauble <Schauble@MIT-MULTICS.ARPA>
Subject:  Crossing enumeration types
To:  Info-C@BRL-SMOKE.ARPA
Message-ID:  <860607215530.328603@MIT-MULTICS.ARPA>
     
Is this program legal according to s strict interpretation of the new
ANSI standard? By common usage? Is this something lint should/does
complain about?
     
enum days {mon, tue,wed} day;
enum colors {red,green,blue} color;
     
main ()
{
    day = green;
    set_color (day);
}
set_color(thiscolor)
enum colors thiscolor;
{...
}
     
I expect at least two complaints about mixing types colors/days. Out
there in the big cruel world, how often am I going to be disappointed?
     
          Paul
          Schauble at MIT-Multics.arpa
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3138
          for JMS@ARIZMIS; Sun,  8-JUN-1986 03:12 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 06/08/86 at 05:00:00 CDT
Received: from WASHINGTON.ARPA by SRI-KL.ARPA with TCP; Sat 7 Jun 86
  13:23:28-PDT
Date: Sat 7 Jun 86 13:20:01-PDT
From: Joe Kelsey <Joe@WASHINGTON.ARPA>
Subject: Re: problem with C fopen(), file revision date
To: LEICHTER-JERRY@YALE.ARPA
cc: MANSFIELD%DHDEMBL5.BITNET@WISCVM.WISC.EDU, info-vax@SRI-KL.ARPA,
    Joe@WASHINGTON.ARPA
In-Reply-To: Message from "<LEICHTER-JERRY@YALE.ARPA>" of Wed 4 Jun 86
  11:12:53-PDT
Message-ID: <12212986769.11.JOE@WASHINGTON.ARPA>
     
This problem with the C library was fixed in 4.4.  However, I seem to
be having problems with Unix filenames...I haven't explored the problem
very much yet.  I only verified that the library no longer "touches"
stream files opened for read access.
     
/Joe
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0979
          for JMS@ARIZMIS; Tue, 10-JUN-1986 10:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/10/86 at 12:01:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012247; 10 Jun 86 12:49 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a017627; 10 Jun 86 12:37 EDT
Received: from Riesling.ms by ArpaGateway.ms ; 10 JUN 86 09:29:33 PDT
Sender: Alan_Walker.WGCERX@xerox.ARPA
Date: 10 Jun 86 08:27:36 PDT (Tuesday)
Subject: Re: C vs. FORTRAN (was: What should be added to C)
From: rgh%inmet.uucp@BRL.ARPA
To: info-c@BRL-SMOKE.ARPA
Message-ID: <860610-092933-1786@Xerox>
     
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
From: Barry Margolin <barmar@mit-eddie.ARPA>
Subject: Re: C vs. FORTRAN (was: What should be added to C)
To: info-c@BRL-SMOKE.ARPA
Return-Path: <info-c-request@BRL.ARPA>
Redistributed: Xerox-Info-C^.x@XEROX.ARPA
Received: from BRL-AOS.ARPA by Xerox.COM ; 02 JUN 86 16:44:00 PDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015999; 2 Jun 86 17:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005720; 2 Jun 86 17:02 EDT
Newsgroups: net.lang.c
Message-ID: <2157@mit-eddie.MIT.EDU>
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
     
In article <900@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
>By the way, this does raise a question in my mind about how the convention
>of 1, not 0, being the lower bound subscript for an array is gotten around
>efficiently in implementations of Fortran.
     
In the case of one-dimensional arrays, of course, it can be handled at
compile time.  A good optimizer can also recognize the common patterns
of looping over multidimensional arrays, so that the offset can be
simply incrememented rather than requiring subscript calculations on
each iteration (some of the earliest work on Fortran compilers involved
this type of optimization).
     
>  It sounds like it is a royal, CPU-
>wasting pain to have to subtract that pesky correction factor from the ag-
>gregate subscript in coming up with an offset for the address of the array
>element from the base of the array the way Fortran does, unless the computer
>has a hardwired way of accessing an object in memory based on a base address
>(base of the array), an offset (calculated from the subscripts), and a
>correction factor (based on how the array was dimensioned) residing in regis-
>ters and added together automatically.
>I think I recall from days of yore in assembly language programming that
>the IBM 360/370 architecture was set up to allow just this, not surprising
>for a machine from the original inventors of Fortran.  But what about other
>machines, especially the more powerful (scalar) ones?  Do they all share this
>multiple-offset-addressing capability?  (Not that this would be advantageous
>in Fortran only; C could also use such a feature when accessing multiply-
>dimensioned arrays of the type "array[][][]...".)
     
I think many mainframes have such addressing modes.
--
    Barry Margolin
    ARPA: barmar@MIT-Multics
    UUCP: ..!genrad!mit-eddie!barmar

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1536
          for JMS@ARIZMIS; Tue, 10-JUN-1986 11:46 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/10/86 at 12:50:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013861; 10 Jun 86 13:35 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a017613; 10 Jun 86 12:37 EDT
Received: from Riesling.ms by ArpaGateway.ms ; 10 JUN 86 09:25:07 PDT
Sender: Alan_Walker.WGCERX@xerox.ARPA
Date: 10 Jun 86 08:26:05 PDT (Tuesday)
Subject: Re: Casting a postdecrement operand
From: rgh%inmet.uucp@BRL.ARPA
To: info-c@BRL-SMOKE.ARPA
Message-ID: <860610-092507-1781@Xerox>
     
Return-Path: <info-c-request@BRL.ARPA>
Redistributed: Xerox-Info-C^.x@XEROX.ARPA
Received: from BRL-AOS.ARPA by Xerox.COM ; 02 JUN 86 16:42:06 PDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015894; 2 Jun 86 17:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005080; 2 Jun 86 16:42 EDT
Newsgroups: net.lang.c
Message-ID: <5000043@inmet>
Nf-ID: #R:romp.UUCP:114:inmet:5000043:000:919
Nf-From: inmet.UUCP!rgh    May 31 14:55:00 1986
     
     
> My version of pcc on the IBM RT PC allows the following expression:
>
>    struct abc { char d[500]; };
>    struct cba { char e[200]; };
>    struct cba *cbap;
>
>    ((struct abc *)cbap)++;
>
> to increment cbap by 500. It appears that the ANSI standard doesn't say
> anything about the legality of this syntax.
     
This is covered in the draft Standard:  (1) a cast does not yield an
lvalue;  (2) the operand of post-inc must be an lvalue.  So the
construct is illegal.
     
Standard-conforming syntax using the same idea is
     
    #define LCAST(typeP, lvalue)       ( *( (typeP *) &lvalue ) )
    #define INC_BY_SIZEOF(ptr, typeD)  ( LCAST(typeD *, ptr)++ )
     
    INC_BY_SIZEOF(cbap, struct abc);
     
Semantically this works only so long as the type that  ptr  points to
has the same alignment requirement as  typeD ,
and (a more subtle point) as long as  typeP
has the same representation as  ptr .
     
    Randy Hudson  {ihnp4,cca!ima}!inmet!rgh

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9089
          for JMS@ARIZMIS; Fri, 13-JUN-1986 02:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/13/86 at 03:56:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019294; 10 Jun 86 16:58 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a006045; 10 Jun 86 16:37 EDT
Received: from Riesling.ms by ArpaGateway.ms ; 10 JUN 86 13:36:15 PDT
Sender: Alan_Walker.WGCERX@xerox.ARPA
Date: 10 Jun 86 08:31:19 PDT (Tuesday)
Subject: Re:  C vs. FORTRAN (was: What should be added to C)
From: rgh%inmet.uucp@BRL.ARPA
To: info-c@BRL-SMOKE.ARPA
Message-ID: <860610-133615-2067@Xerox>
     
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
To: brl.arpa!gwyn@seismo.css.gov, dgary%ecsvax.uucp@BRL.ARPA,
 ecsvax!dgary@mcnc.CSNET
Subject: Re:  C vs. FORTRAN (was: What should be added to C)
Cc: info-c@BRL-SMOKE.ARPA
Return-Path: <info-c-request@BRL.ARPA>
Redistributed: Xerox-Info-C^.x@XEROX.ARPA
Received: from BRL-AOS.ARPA by Xerox.COM ; 03 JUN 86 19:30:16 PDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004397; 3 Jun 86 20:13 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a008635; 3 Jun 86 20:01 EDT
Received: by icst-cmr.ARPA (4.12/4.7)    id AA16302; Tue, 3 Jun 86 19:57:33 edt
Message-Id: <8606032357.AA16302@icst-cmr.ARPA>
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
     
    There are a number of good reasons for building integer exponents into
    the language, one of which is the possibilities for optimization.  An
     
Doug, I am surprised that you ignored DMR's rationale for not putting
exponentiation into C, or were you merely requesting a library function.
Yes, I know you didn't write this but I'm responding to you here anyway.
     
    obvious one is converting x**3 into x*x*x, not to mention having the
    compiler recognise at what level one should not do this optimization.
    More subtle is the use of "algebraic" optimizations.  For instance,
    converting
     
        a*x**3 + b*x**2 + c*x + d
    to
        d + x * (c + x * (b + a*x))
     
    which replaces eight multiplications with three and not only executes
    faster but (most of the time) greatly reduces precision problems.
    Granted that this can be coded by the programmer; how many do you think
    will actually do it?  Yup...
     
Anyone who wants the benefits. It could be argued that by allowing
programs to be optimised, you promote laziness in coding techniques.
In this example, the notation looks quite similar to the original
form, especially if you write it backwards.
     
Any optimizer smart enuf to make this transformation should be able to
do the same for the longhand as well: a*x*x*x + ...
     
By making it harder to code poorly, you make it harder to code well by
comparison. Don't give away all our wizardly secrets :-)
     
    (Root Boy) Jim Cottrell        <rbj@cmr>
    - if it GLISTENS, gobble it!!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9201
          for JMS@ARIZMIS; Fri, 13-JUN-1986 02:33 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019296; 10 Jun 86 16:59 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a006056; 10 Jun 86 16:37 EDT
Received: from Riesling.ms by ArpaGateway.ms ; 10 JUN 86 13:37:44 PDT
Sender: Alan_Walker.WGCERX@xerox.ARPA
Date: 10 Jun 86 08:31:30 PDT (Tuesday)
Subject: Re: ranges
From: rgh%inmet.uucp@BRL.ARPA
To: info-c@BRL-SMOKE.ARPA
In-Reply-to: Your message of 2 Jun 86 06:57:19 GMT.
 <1774@umcp-cs.UUCP>
Message-ID: <860610-133744-2071@Xerox>
     
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
To: info-c@BRL-SMOKE.ARPA
Subject: Re: ranges
In-reply-to: Your message of 2 Jun 86 06:57:19 GMT.
 <1774@umcp-cs.UUCP>
From: Scott Menter <escott@ICS.UCI.EDU>
Return-Path: <info-c-request@BRL.ARPA>
Redistributed: Xerox-Info-C^.x@XEROX.ARPA
Received: from BRL-AOS.ARPA by Xerox.COM ; 03 JUN 86 15:25:11 PDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003921; 3 Jun 86 18:12 EDT
Received: from ics.uci.edu by SMOKE.BRL.ARPA id a006967; 3 Jun 86 18:02 EDT
Received: from localhost by ICS.UCI.EDU id a003249; 3 Jun 86 15:01 PDT
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
     
     
Chris Torek writes:
> In article <393@peregrine.UUCP> mike@peregrine.UUCP (Mike Wexler) writes:
>>[...] Another feature I would like to have is a range data type.  I don't
>>know of a good syntax for putting this in C but it would be nice to
>>use in programs where are know the possible values of a number but
>>would like the compiler to figure out an efficient sized slot to put
>>it in.
>
> Actually, I know of two uses for range types.  You have stated one;
> the other is to catch errors where a variable should never take on
> values outside certain range(s).
     
Well, actually it might be kind of nice to have a C compiler with an
option to do the kind of array bounds checking Chris implies, whether
or not a range type is implemented.  I suppose this would be hard in
the case of automatic variables and arguments like:
     
    int foo( arg )
    char arg[ ];
     
Still, it might be nice for the easy case of, say:
     
    static char * strings[ CONSTANT_VAL ];
     
While we're at it, though, what if we *did* use a range type to
subscript an array.  Maybe I'm neglecting something obvious, but
how would the compiler deal with this situation:
     
    int foo( )
    {
    char someval[ range ];    /* "range" is, say, 1..10 or something */
     
        foo2( someval );
    }
     
    int foo2( stringarg )
    char * stringarg;
     
etc...
     
Seems to me that it would be impossible to detect range errors in
"foo2()", especially if it is in a distinctly compiled unit from
"foo()".  In that case, the error checking that range type
implementation provides would be limited to the scope in which it is
defined, and no further.  Of course, if the argument to "foo2()" read
"char stringarg[ range ]" then I suppose it would work, but then you lose
the ability to say things like "stringarg++".  Or, I guess, you could
pass "range" as another parameter to "foo2()".
     
Well, I'm more of a C hacker than a C implementor, so I imagine that
some of you implementors out there will set me straight, if that's
required.
     
------------------------------------------------------------------------
E. Scott Menter                            Internet:  escott@ics.uci.edu
UCI Research Support Group                UUCP: ...!ucbvax!ucivax!escott
     
"...Say, Foz, about my vocals..."
------------------------------------------------------------------------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1846
          for JMS@ARIZMIS; Fri, 13-JUN-1986 08:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019691; 10 Jun 86 17:49 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a005747; 10 Jun 86 16:30 EDT
Received: from Riesling.ms by ArpaGateway.ms ; 10 JUN 86 13:30:07 PDT
Sender: Alan_Walker.WGCERX@xerox.ARPA
Date: 10 Jun 86 08:34:17 PDT (Tuesday)
Subject: Re: What should be added to C
From: rgh%inmet.uucp@BRL.ARPA
To: info-c@BRL-SMOKE.ARPA
Message-ID: <860610-133007-2060@Xerox>
     
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Subject: Re: What should be added to C
To: info-c@BRL-SMOKE.ARPA
Return-Path: <info-c-request@BRL.ARPA>
Redistributed: Xerox-Info-C^.x@XEROX.ARPA
Received: from BRL-AOS.ARPA by Xerox.COM ; 02 JUN 86 14:18:54 PDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015862; 2 Jun 86 17:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004718; 2 Jun 86 16:33 EDT
Newsgroups: net.lang.c
Message-ID: <1514@mmintl.UUCP>
Posted: Fri May 30 07:58:19 1986
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
     
In article <852@bentley.UUCP> kwh@bentley.UUCP writes:
>>>o There should be an option to flag statements of the form if (v = e) ...
>>>(Actually, I wouldn't be averse to a coding standard which forbade such
>>>things, in favor of if (v = e, v) ...)
>
>Urgh.  Are you talking about removing the assignment-has-a-value feature
>completely, or a special case for "if (v = e)"?  (I always write this as
>"if ((v = e) != 0)" to make it clear that I didn't mean "if (v == e)".)
>
>Actually, the main argument in favor of valued assignment is to allow such
>things as "while ((c = getchar()) != EOF)".  This really doesn't look so
>bad with the unvalued assignment "while (c = getchar(), c != EOF), so it
>may not be such a bad idea.
     
Actually, I was not proposing removing the assignment-has-a-value feature
anywhere (although I would not put it into a new language I was designing).
The proposal was that it be avoided in if's (and probably while's as well)
as a coding standard.  That is, it would be legal, but not recommended.
     
In fact, I only use the results from an assignment in two cases.  One is to
assign the same value to multiple variables, and the other is in the if/while
case under discussion here.  (Yes, I also normally use "if ((v = e) != 0)").
I may stop using it in this latter case, in favor of the comma operator as
described above.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1634
          for JMS@ARIZMIS; Fri, 13-JUN-1986 08:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/13/86 at 08:54:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019296; 10 Jun 86 16:59 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a006056; 10 Jun 86 16:37 EDT
Received: from Riesling.ms by ArpaGateway.ms ; 10 JUN 86 13:37:44 PDT
Sender: Alan_Walker.WGCERX@xerox.ARPA
Date: 10 Jun 86 08:31:30 PDT (Tuesday)
Subject: Re: ranges
From: rgh%inmet.uucp@BRL.ARPA
To: info-c@BRL-SMOKE.ARPA
In-Reply-to: Your message of 2 Jun 86 06:57:19 GMT.
 <1774@umcp-cs.UUCP>
Message-ID: <860610-133744-2071@Xerox>
     
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
To: info-c@BRL-SMOKE.ARPA
Subject: Re: ranges
In-reply-to: Your message of 2 Jun 86 06:57:19 GMT.
 <1774@umcp-cs.UUCP>
From: Scott Menter <escott@ICS.UCI.EDU>
Return-Path: <info-c-request@BRL.ARPA>
Redistributed: Xerox-Info-C^.x@XEROX.ARPA
Received: from BRL-AOS.ARPA by Xerox.COM ; 03 JUN 86 15:25:11 PDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003921; 3 Jun 86 18:12 EDT
Received: from ics.uci.edu by SMOKE.BRL.ARPA id a006967; 3 Jun 86 18:02 EDT
Received: from localhost by ICS.UCI.EDU id a003249; 3 Jun 86 15:01 PDT
GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV
     
     
Chris Torek writes:
> In article <393@peregrine.UUCP> mike@peregrine.UUCP (Mike Wexler) writes:
>>[...] Another feature I would like to have is a range data type.  I don't
>>know of a good syntax for putting this in C but it would be nice to
>>use in programs where are know the possible values of a number but
>>would like the compiler to figure out an efficient sized slot to put
>>it in.
>
> Actually, I know of two uses for range types.  You have stated one;
> the other is to catch errors where a variable should never take on
> values outside certain range(s).
     
Well, actually it might be kind of nice to have a C compiler with an
option to do the kind of array bounds checking Chris implies, whether
or not a range type is implemented.  I suppose this would be hard in
the case of automatic variables and arguments like:
     
    int foo( arg )
    char arg[ ];
     
Still, it might be nice for the easy case of, say:
     
    static char * strings[ CONSTANT_VAL ];
     
While we're at it, though, what if we *did* use a range type to
subscript an array.  Maybe I'm neglecting something obvious, but
how would the compiler deal with this situation:
     
    int foo( )
    {
    char someval[ range ];    /* "range" is, say, 1..10 or something */
     
        foo2( someval );
    }
     
    int foo2( stringarg )
    char * stringarg;
     
etc...
     
Seems to me that it would be impossible to detect range errors in
"foo2()", especially if it is in a distinctly compiled unit from
"foo()".  In that case, the error checking that range type
implementation provides would be limited to the scope in which it is
defined, and no further.  Of course, if the argument to "foo2()" read
"char stringarg[ range ]" then I suppose it would work, but then you lose
the ability to say things like "stringarg++".  Or, I guess, you could
pass "range" as another parameter to "foo2()".
     
Well, I'm more of a C hacker than a C implementor, so I imagine that
some of you implementors out there will set me straight, if that's
required.
     
------------------------------------------------------------------------
E. Scott Menter                            Internet:  escott@ics.uci.edu
UCI Research Support Group                UUCP: ...!ucbvax!ucivax!escott
     
"...Say, Foz, about my vocals..."
------------------------------------------------------------------------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7142
          for JMS@ARIZMIS; Sun, 15-JUN-1986 13:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/15/86 at 15:22:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020529; 10 Jun 86 20:55 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a008458; 10 Jun 86 20:46 EDT
Received: from Riesling.ms by ArpaGateway.ms ; 10 JUN 86 17:47:59 PDT
Sender: Alan_Walker.WGCERX@xerox.ARPA
Date: 10 Jun 86 08:32:08 PDT (Tuesday)
Subject: boolean datatype
From: rgh%inmet.uucp@BRL.ARPA
To: info-c@BRL-SMOKE.ARPA
Message-ID: <860610-174759-1066@Xerox>
     
Return-Path: <info-c-request@BRL.ARPA>
Redistributed: Xerox-Info-C^.x@XEROX.ARPA
Received: from BRL-AOS.ARPA by Xerox.COM ; 02 JUN 86 16:42:38 PDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015997; 2 Jun 86 17:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005687; 2 Jun 86 17:01 EDT
Newsgroups: net.lang.c
Message-ID: <393@peregrine.UUCP>
     
This is not a proposal to change the ANSI standard.  This is just some
ideas some possible ways of improving C.
>Re: builtin bool type
>>I'm not sure why not.  Assuming all the implicit int/bool conversions stay,
>>I think the only problems are (a) it isn't really necessary, and (b) it adds
>>a new reserved word (breaking any programs that use "typedef int bool"!).
>
>(a) is the biggie.  Why add bool when "typedef enum { FALSE, TRUE } bool;"
>works fine?  (Relying on ANSI C's treatment of enums as real ints)
So that the built in statements can use them.
    ...
    int n,get_number();
     
    n=7;
    if (n=get_number()) printf("got 7\n");    /* should have been ==        */
    ...
This is an example of a place where a C compiler with boolean types would catch
a mistake.
    ...
    bool flag,get_yes_or_no();
     
    if (flag=get_yes_or_no()) printf("got yes\n");    /* no mistake        */
    ...
This is an exmaple of a place where most of the idea for finding mistaken
assignments would fail.
     
One possible way to put this in C would be to do the conversion from
int to bool(if the integer is not equal to zero then make it true else
make it false) and generate a warning.  This would add a new reserved
word and would break programs that used bool as an identifier.  At
some future time the warning could become an error message.
     
Another feature I would like to have is a range data type.  I don't
know of a good syntax for putting this in C but it would be nice to
use in programs where are know the possible values of a number but
would like the compiler to figure out an efficient sized slot to put
it in.
    ...
    range hour:1..12; /* create a variable named hour that can vary from */
                /* 1 through 12                                */
    typedef range DAY:1..366;
    DAY day1,day2;
     
    hour+=2;
    day1=day2+100;
}
I will let other people argue about how to index an array by a range.
--
Mike Wexler
Email address:(trwrb|scgvaxd)!felix!peregrine!mike
Tel Co. address: (714)855-3923
;-) Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine :-(

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3052
          for JMS@ARIZMIS; Thu, 19-JUN-1986 15:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/19/86 at 14:41:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001347; 17 Jun 86 2:01 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a002580; 17 Jun 86 1:07 EDT
Received: from MIT-MULTICS.ARPA by VGR.BRL.ARPA id aa01450; 17 Jun 86 0:56 EDT
Date:  Tue, 17 Jun 86 00:49 EDT
From:  Paul Schauble <Schauble@MIT-MULTICS.ARPA>
Subject:  Header file strings.h
To:  Info-c@BRL.ARPA, Info-Unix@BRL.ARPA
Message-ID:  <860617044924.856525@MIT-MULTICS.ARPA>
     
I am trying to port a program from Unix to MS-DOS.  It makes use of a
header file <strings.h>.  This is not supplied with Microsoft C.  Could
someone please enlighten me as to what this contains?
     
Please reply directly, as I don't always read Info-Unix.
     
          Thanks in advance,
          Paul
          Schauble at MIT-Multics.arpa
Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7810
          for JMS@ARIZMIS; Sun, 22-JUN-1986 23:12 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/23/86 at 00:44:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013495; 17 Jun 86 14:49 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a017854; 17 Jun 86 13:38 EDT
Received: from (MAILER)UCF1VM.BITNET by WISCVM.WISC.EDU on 06/17/86 at
  12:40:01 CDT
Received: by UCF1VM (Mailer X1.23) id 0704; Tue, 17 Jun 86 13:36:56 EST
Date:         Tue, 17 Jun 1986 13:36:03 EST
From:           Jim Ennis <JIM%UCF1VM.BITNET@wiscvm.ARPA>
Subject:      IBM PC C question
To: info-c <INFO-C@BRL-SMOKE.ARPA>
     
This is not a pure C question but I am hoping somebody can help me with
this question for a friend:
     
=========================================================================
     
Date:         Tue, 3 Jun 1986 01:11 EST
From:           Brian Blau  <BLAU%UCF1VM.BITNET@WISCVM.WISC.EDU>
Subject:      IBM-PC screen size
     
Is is possible to reset the screen so that only a small window is
accessable to DOS? If so do we do this by setting something inside
DOS or do we have to program the video controller? ( we do not want
scrunched characters , just to restrain the number of vertical and
horizontal lines in on the screen )
     
We do not want to use TURBO Pascal's Window function, this information
will be used for C functions.
     
Also any information concerning programming the video controller
would be helpful.
     
        Thanks for the help,
     
           Brian Blau and Earl Baugh
           <BLAU%UCF1VM.BITNET@WISCVM.WISC.EDU> and
           <BAUGH%UCF1VM.BITNET@WISCVM.WISC.EDU>
Acknowledge-To:  <BLAU@UCF1VM>

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1934
          for JMS@ARIZMIS; Tue, 24-JUN-1986 10:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 06/23/86 at 12:00:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016239; 17 Jun 86 17:28 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a022675; 17 Jun 86 16:24 EDT
Received: from PICA-LCA.ARPA by VGR.BRL.ARPA id aa10712; 17 Jun 86 16:17 EDT
Date:     Tue, 17 Jun 86 16:15:33 EDT
From:     "1LT Dennis G. Rears" (FSAC) <drears@ARDEC.ARPA>
To:       Paul Schauble <Schauble@MIT-MULTICS.ARPA>
cc:       Info-c@BRL.ARPA, Info-Unix@BRL.ARPA
Subject:  Re:  Header file strings.h
Message-ID:  <8606171617.aa10712@VGR.BRL.ARPA>
     
Paul Schauble writes:
     
>I am trying to port a program from Unix to MS-DOS.  It makes use of a
>header file <strings.h>.  This is not supplied with Microsoft C.  Could
>someone please enlighten me as to what this contains?
     
   <strings.h>  contains the data types for the string
operations - strcat, strncat, strtok, strcpy, etc.  I have used the
strings functions many times without using this header file.  If
you are checking the return codes of the functions explicitly define
the functions.  Example:
     
char *strcat(), *strcmp();
int strlen;
     
   I believe Microsoft C libraries contains the string functions. In
that case just explicitly define the functions. If they don't  you might
have to write the string functions yourself.
     
Dennis

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1227
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007320; 20 Jun 86 12:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022422; 20 Jun 86 12:17 EDT
From: Stanley Friesen <friesen%psivax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: enums, pcc & all that
Message-ID: <1272@psivax.UUCP>
Date: 18 Jun 86 21:41:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <212@pyuxv.UUCP> cim2@pyuxv.UUCP writes:
>
>Unfortunatly those that be decided to do a STUPID, DUMB and
>and CRETINOUS implementation of enums as integers (from those that
>bring you unary+ ...)
>
    As long as I can do a switch with enum cases!! Without this
enums are almost useless for most of the puposes I would want to use
them. Also array indexing by enums would be *nice*, though declaring
the array as haiving an enum index would be an acceptible requirement.
>
>The only compiler I know which does enums right is Microsoft 3.0 on the IBM-PC.
     
    Does it allow switches on enums?? If not, then it *isn't* right!
--
     
                Sarima (Stanley Friesen)
     
UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ??

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0687
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:28 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/27/86 at 11:02:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016239; 17 Jun 86 17:28 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a022675; 17 Jun 86 16:24 EDT
Received: from PICA-LCA.ARPA by VGR.BRL.ARPA id aa10712; 17 Jun 86 16:17 EDT
Date:     Tue, 17 Jun 86 16:15:33 EDT
From:     "1LT Dennis G. Rears" (FSAC) <drears@ARDEC.ARPA>
To:       Paul Schauble <Schauble@MIT-MULTICS.ARPA>
cc:       Info-c@BRL.ARPA, Info-Unix@BRL.ARPA
Subject:  Re:  Header file strings.h
Message-ID:  <8606171617.aa10712@VGR.BRL.ARPA>
     
Paul Schauble writes:
     
>I am trying to port a program from Unix to MS-DOS.  It makes use of a
>header file <strings.h>.  This is not supplied with Microsoft C.  Could
>someone please enlighten me as to what this contains?
     
   <strings.h>  contains the data types for the string
operations - strcat, strncat, strtok, strcpy, etc.  I have used the
strings functions many times without using this header file.  If
you are checking the return codes of the functions explicitly define
the functions.  Example:
     
char *strcat(), *strcmp();
int strlen;
     
   I believe Microsoft C libraries contains the string functions. In
that case just explicitly define the functions. If they don't  you might
have to write the string functions yourself.
     
Dennis

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7759
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023255; 22 Jun 86 0:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001536; 21 Jun 86 23:42 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: What should be added to C, call
Message-ID: <2600064@ccvaxa>
Date: 18 Jun 86 15:17:00 GMT
Nf-ID: #R:isis.UUCP:797:ccvaxa:2600064:000:547
Nf-From: ccvaxa.UUCP!aglew    Jun 18 10:17:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
... > Multiple way ifs and cases:
     
I prefer a syntax something like this:
     
    IF x < y THEN ....
    :: x = y THEN ....
    :: x > y THEN ....
    ENDIF
     
where :: means "evaluate alternative concurrently", and is distinct from
"else" in that it applies no sequentialization of the tests.
     
For people into theory, this is really just a guarded statement `a la
Dijkstra.
     
And, no, I do not propose to put this into C.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6556
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:30 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008073; 20 Jun 86 13:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021964; 20 Jun 86 12:10 EDT
From: kjm%ut-ngp.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <3544@ut-ngp.UUCP>
Date: 19 Jun 86 18:37:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[]
     
>There is a 429 year precedent of using the symbol = for equality.
     
There is a multi-billion year precedent for the non-existance of
computers on this planet.  Does that mean we should trash all of them?
     
>[...] is equalle to: I will sette as I doe often in woorke vse,
>a paire of paralleles, or Gemowe lines of one lengthe, thus:
>=, {a very long equals sign} bicause noe .2. thynges, can be moare equalle."
     ^^^^^^^^^^^^^^^^^^^^^^^
     
C has this already.  To wit: '=='.
     
--
The above viewpoints are mine.  They are unrelated to
those of anyone else, including my cat and my employer.
     
Ken Montgomery  "Shredder-of-hapless-smurfs"
Member of HASA -- Heathen and Atheistic Scum Alliance
...!{ihnp4,allegra,seismo!ut-sally}!ut-ngp!kjm  [Usenet, when working]
kjm@ngp.{ARPA,UTEXAS.EDU}  [Old/New Internet; depends on nameserver operation]
kjm@ngp.CC.UTEXAS.EDU      [Very New Internet; may require nameserver operation]

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6676
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:33 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023126; 22 Jun 86 0:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001650; 21 Jun 86 23:45 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <4275@sun.uucp>
Date: 19 Jun 86 18:55:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Is it really worth using a notation that is contrary to that of the more
> universal mathematics, and thus guaranteed to confuse novices and catch pros
> off-guard in order to type "=" instead of ":="?  I think adding a few
> characters to improve readability and understandability is worth the
> time and effort.
     
Is it really worth changing a well-established language syntax, in such a
way that would break the hell out of existing programs, in order to conform
with what is admittedly the dominant notation?  I think leaving C alone to
keep from breaking existing programs and programmers is worth the confusion
it may cause to some people.
     
> Consequently, I wrote a pre-processor for C called ac68 that uses := for
> assignment, = for equality, and has all the cumulative operators in the
> style of Algol 68: +:=, -:=, *:=, &:=, <<:=, etc.  Unfortunately, the C
> and dbx messages refer to the operators that get generated.  Still, the
> code is a lot more readable.
     
Unless you advertise the language accepted by this preprocessor as a
language which is similar to C, but is NOT C, I sincerely doubt that.  I
find that the fake ALGOL 68 crap that Steve Bourne used to write the Bourne
shell and "adb" to make the code a lot *less* readable.  Let C be C!
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7829
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023286; 22 Jun 86 0:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002029; 21 Jun 86 23:57 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: enums, pcc & all that
Message-ID: <2600065@ccvaxa>
Date: 19 Jun 86 13:51:00 GMT
Nf-ID: #R:pyuxv.UUCP:212:ccvaxa:2600065:000:974
Nf-From: ccvaxa.UUCP!aglew    Jun 19 08:51:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
In this discussion of enums, I thought I'd mention a quick and pleasant
tool. I don't know if it has been mentioned before - hell, I might have
mentioned it! but it is useful:
     
I get tired of seeing
     
    #define MASK1   0x01
    #define MASK2   0x02
    #define MASK3   0x04
    ...
    #define MASKN   0x8000000
     
and even the corresponding enum is a pain.
So, a filter that expands
     
    enum_mask { MASK1, MASK2, MASK3 ... MASKN }
     
into the appropriate series of #defines or enums is useful.
     
Of course, I realize that this violates the type rule; or, rather, I need to
declare a type which is a Cartesian product of the masks. And that really
should be a struct. Unfortunately, many compilers are too dumb to recognize
that lots of tiny bit field operations in a struct really can be done with
a single logical operation. Too bad.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1099
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:37 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007304; 20 Jun 86 12:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022391; 20 Jun 86 12:17 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <488@cubsvax.UUCP>
Date: 19 Jun 86 19:25:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <brl-smok.1331> kelem@aero2.arpa writes:
>There is a 429 year precedent of using the symbol = for equality.
>
>The original rationale for using = for equality was given by Robert Recorde
>in 1557.
>The explanation was "... to auoide the tediouse repetition of these woordes:
>is equalle to: I will sette as I doe often in woorke vse,
>a paire of paralleles, or Gemowe lines of one lengthe, thus:
>=, {a very long equals sign} bicause noe .2. thynges, can be moare equalle."
....
>1.  There are over four centuries of mathematics using = for equals.
>Using = to mean assignment is begging for confusing code.
>2.  Assignment is a relatively new concept and a new notation is warrented.
>":=" has enough precedent to serve this purpose.
     
Assignment is also ancient in mathematics.  It is usually invoked in formal
writing by a phrase such as "Let z equal x/y".  In informal writing, such
as Recorde's "worke vse," it occurs as "z = x/y".  What's recent
is the need to distinguish between a statement of equivalence (C's "==")
and the active process of giving a symbol a value (C's "=").  Presumably
this came about when mathematicians had to start talking to machines too
stupid to be able to infer the distinction from context, instead of to
other mathematicians.  In any case, I think it's inaccurate to state that "="
traditionally means only one of those things;  certainly the spelled-out
version, "equal," is used for both meanings in formal mathematics.
     
This all started with the observation that it's easy to say "if( a = b )"
when one means "if( a == b )".  Most of us probably do this now and then,
but it's not really that big a deal, is it?  (That is, it's one of the things
we look for when debugging, right?)
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6413
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/27/86 at 15:44:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa07337; 20 Jun 86 12:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022468; 20 Jun 86 12:18 EDT
From: Ed Nather <nather%ut-sally.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <5166@ut-sally.UUCP>
Date: 20 Jun 86 00:06:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In one important sense, the use of "=" as an assignment operator is
extremely unfortunate (though widespread) because, historically, it
meant "equality" in the mathematical sense.  Thus the phrase
     
    i = i + 1
     
is impossible unless i has the value "infinity".  We have come to
understand this, however, to mean "increase the value of i by 1"
so the sense of "equality" has been replaced by the time-dependent
assignment process.
     
Equality has bad connotations in many ways: it implied, at one time,
a "universal, timeless" sort of equivalence, and many mathematicians
came to think of things being "eternally equal" -- in the sense that
time-dependence did not enter.  Yet the essential character of a
computer (when it is up) is change with time.  So even the use of
"==" for equality isn't the same: the phrase
     
    if(i == 1)
     
says "if i CURRENTLY has the value 1, then ..." which has the implication
of change, or at least potential change, built in.
     
Early Algol used a left-pointing arrow as the assignment operator, but that
was not included in the ASCII character set; that decision may be one of
the costliest technical blunders of our time.
     
--
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.AS.UTEXAS.EDU

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1476
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:39 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007328; 20 Jun 86 12:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022438; 20 Jun 86 12:18 EDT
From: Geoff Kimbrough <geoff%ism780c.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <2595@ism780c.UUCP>
Date: 19 Jun 86 18:21:54 GMT
Followup-To: /dev/null
Keywords: macros, side effects, Obfuscation
To:       info-c@BRL-SMOKE.ARPA
     
In article <1201@brl-smoke.ARPA> Schauble@MIT-MULTICS.ARPA writes:
>Can someone construct a version that makes
>
>    int *a, *b;
>    swap (*a++,*b++);
>
>work right?
     
#define SWAP(a,b) {int *A= &(a),*B= &(b),temp; temp= *A; *A= *B; *B= temp;}
    /* Or, for more generality.  */
#define SWAP(type,a,b) {type *A = &(a),*B = &(b),temp; temp = *A; *A = *B; \
    *B = temp;}  /* invoked as SWAP( int, *a++, *b++ );     */
     
As has been pointed out, macros generally don't work when given arguments
with side effects, (arguments? parameters? formals? who cares, if you
understand what I mean)  However, if you're careful to have the arguments
appear ONLY ONCE in the expansion, you can get the results you're after.
This trick only works with macros that have pointers as arguments, of
course.
     
I *don't* think this macro should be *used*, since it's got to be slower to
do all the extra pointer chasing and such than to break up your statement
into  {  swap(*a,*b); a++; b++; }.  If you're concerned about having to
insert extra braces, I don't even want to talk to you ( 8^) ), I just got
through reading an entirely uncommented program with:
    while ( something ) /* <-- no curly brace */
        if ( whatever ) {
            hundreds of statements on several pages;
            with 8 space tabs, the code dissappeared off the
            right margin, and gradually walked back, until:
        }
    /* <-- no curly here either */
Took me over an hour just to confirm that the braces matched up.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0814
          for JMS@ARIZMIS; Fri, 27-JUN-1986 22:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016512; 17 Jun 86 18:05 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a023263; 17 Jun 86 17:44 EDT
Received: from [8.7.0.2] by VGR.BRL.ARPA id aa14570; 17 Jun 86 17:31 EDT
To: "1LT Dennis G. Rears" (FSAC) <drears@ARDEC.ARPA>
cc: Paul Schauble <Schauble@MIT-MULTICS.ARPA>, Info-c@BRL.ARPA,
    Info-Unix@BRL.ARPA
Subject: Re: Header file strings.h
In-reply-to: Your message of Tue, 17 Jun 86 16:15:33 EDT.
         <8606171617.aa10712@VGR.BRL.ARPA>
Date: 17 Jun 86 17:30:45 EDT (Tue)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
Message-ID:  <8606171731.aa14570@VGR.BRL.ARPA>
     
In article <8606171617.aa10712@VGR.BRL.ARPA>,
"1LT Dennis G. Rears" (FSAC) <drears@ardec.ARPA> writes:
     
> Paul Schauble writes:
>
> >I am trying to port a program from Unix to MS-DOS.  It makes use of a
> >header file <strings.h>.  This is not supplied with Microsoft C.  Could
> >someone please enlighten me as to what this contains?
>
>    <strings.h>  contains the data types for the string
> operations - strcat, strncat, strtok, strcpy, etc.  I have used the
     
More precisely, it contains the external declarations of these functions.
One could misinterpret the above statement to mean that <strings.h> contains
the data types *manipulated* by the string functions (which it does not).
     
> strings functions many times without using this header file.  If
> you are checking the return codes of the functions explicitly define
> the functions.  Example:
>
> char *strcat(), *strcmp();
     
In every implementation of strcmp() with which I am familiar, it returns (int),
not (char *).  Its return value is suitable for the old Fortran 3-way IF (i.e.,
returns < 0 if string-1 comes before string-2 in dictionary order, = 0 if they
are the same, and > 0 if string-1 comes after string-2).
     
> int strlen;
     
This should read:
     
    int    strlen ();
     
>
>    I believe Microsoft C libraries contains the string functions. In
> that case just explicitly define the functions. If they don't  you might
> have to write the string functions yourself.
>
> Dennis
>
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/506
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0198
          for JMS@ARIZMIS; Sat, 28-JUN-1986 12:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/27/86 at 20:44:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023606; 22 Jun 86 1:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002957; 22 Jun 86 0:28 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: What should be added to C, call it PL/2
Message-ID: <4327@sun.uucp>
Date: 21 Jun 86 04:18:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >You don't want to call it PL/2 anyway because it's not PL/1 it is PL/I.
>
> On Multics (the distant ancestor of UNIX), it's PL/1; the compiler is
> called "pl1", programs are foo.pl1, etc.  Considering the (historical)
     
So what?  GE/Honeywell didn't invent the language, IBM did, so if IBM says
it's PL/I it's PL/I.  Furthermore, the fact that the command name of the
compiler, and the language suffix, is ".pl1" doesn't mean that the
language's name is PL/1; what does the Multics *documentation* call it?
     
> But then, Multics PL/1 is a systems programming language, used to
> write most of the system, and is somewhat different (in programming
> environment, at least) from IBM PL/I.
     
The language Multics is implemented in is quite recognizable as PL/I, and
isn't some other language called "PL/1".  It was used as a systems
programming language, but it isn't a systems programming language in the
sense that that's *all* it could be used for.  It implemented all the other
grot, so you could write a payroll program in Multics PL/I if you were so
inclined.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7532
          for JMS@ARIZMIS; Sat, 28-JUN-1986 12:24 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/27/86 at 18:12:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023149; 22 Jun 86 0:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001654; 21 Jun 86 23:45 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Crossing enumeration types
Message-ID: <4278@sun.uucp>
Date: 19 Jun 86 19:01:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> enum days {mon, tue,wed} day;
> enum colors {red,green,blue} color;
>
> main ()
> {
>     day = green;
>     set_color (day);
> }
> set_color(thiscolor)
> enum colors thiscolor;
> {...
> }
>
> Is this program legal according to s strict interpretation of the new
> ANSI standard?
     
Yes.  "enum"s are just fancy integral types, whose values have names.
     
> By common usage?
     
Yes, in the sense that the code will compile and do what you'd expect it to
do given that "enum"s are fancy "int"s.
     
> Is this something lint should/does complain about?
     
It does complain; I would argue that it should.  The complaints should be
warnings, since the code is technically correct.  However, the code stands a
good chance of being in error anyway, so the complaints are justified.
Casts should suppress the complaint, so that if this is what the person
intended to do they can say so.
     
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7964
          for JMS@ARIZMIS; Sat, 28-JUN-1986 13:55 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023302; 22 Jun 86 0:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002284; 22 Jun 86 0:05 EDT
From: C Waldman <cgw%mruxe.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <115@mruxe.UUCP>
Date: 20 Jun 86 15:36:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
     
In article <1331@brl-smoke.ARPA>,  kelem@aero2.arpa writes:
     
> There is a 429 year precedent of using the symbol = for equality.
     ...quote deleted...
> 1.  There are over four centuries of mathematics using = for equals.
> Using = to mean assignment is begging for confusing code.
>
> 2.  Assignment is a relatively new concept and a new notation is warrented.
> ":=" has enough precedent to serve this purpose.
>
> Is it really worth using a notation that is contrary to that of the more
> universal mathematics, and thus guaranteed to confuse novices and catch pros
> off-guard in order to type "=" instead of ":="?  I think adding a few
> characters to improve readability and understandability is worth the
> time and effort.
     
No, no, no!  It seems like you are a little confused about the meaning
of the equals sign in mathematics. It's true that math uses = for equals,
C uses = for equals too.  The problem is that there are three meanings
of 'equals':  "math uses = for equality" is a true, but totally ambiguous
statement. The three meanings, as I see them:
     
A)  test for equality,      as in 'is x equal to 6?'    (interrogative)
     
B)  assignment of equality, as in 'let x equal 6!'      (imperative)
     
C)  assertion of equality,  as in 'on a right triangle the square
         of the hypotenuse is equal to the sum of the squares of
         the two shorter sides.'                        (declarative)
     
Meanings B and C (and rarely A) are used in math, with only one
symbol (=); and your claim that "assignment is a relatively new
concept" is erroneous.
     
In programming, we do not state theorems (yes, there are some
programs that can chew up theorems, but they don't classify as
programming languages),  we are interested in telling the computer
to DO something: therefore we are interested in meanings
A and B.  They are both 'equals', but in different senses.  We
need two symbols to avoid ambiguity. As a user of both C and Pascal,
I can appreciate the logic in using the shorter symbol for the
more commonly used meaning (I HATE typing :=, especially since
you have to hit SHIFT to get the colon, half the time, if I'm
typing fast, I get :+).  If anything, maybe I would agree with
a different symbol for meaning A, like ?= or =? or something,
but it's not worth making a change. If it ain't broke, don't
fix it.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7631
          for JMS@ARIZMIS; Sat, 28-JUN-1986 13:56 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023161; 22 Jun 86 0:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001661; 21 Jun 86 23:45 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Boolean datatypes (really about enum types and the PCC)
Message-ID: <4279@sun.uucp>
Date: 19 Jun 86 19:14:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> The proposed draft ANSI C standard doesn't seem to require that compilers
> treat enums as anything other than ints.  If people are writing programs
> which employ enums strictly as ints, the utility of enums in type
> verification seems to be nil and compiler warnings will just be obnoxious.
     
I wouldn't say their utility was nil.  I don't know how many people
literally use them strictly as ints; it would seem kind of silly to set some
"int" variable to 33 by doing
     
    enum bag_of_numbers { thirty_three = 33, sixty_six = 66, ... };
     
    variable = thirty_three;
     
I suspect that in most cases an "enum" is being used roughly the same way
it's used in other languages, to represent a member of a collection of named
objects.  The difference in C is that you can bind values to these names,
either because the values are imposed by some external agency (error codes
in a protocol or from an external device, etc.) or because one wishes to
implement some function whose domain is the set of values for that "enum"
using some efficient trick involving arithmetic on the underlying value of
the "enum".  As such,
     
    enum apples { jonathan, ... } apple;
    enum oranges { jaffa, ... } orange;
     
    if (apple == orange) {
        ...
    }
     
would be, well, comparing apples and oranges, and should get a warning.
     
You can use casts to override this;
     
    if (apple == (enum apples) orange)
     
should not give a warning.
     
Another reason why "enum"s need to be treated as ints is that you may want
to use them as subscripts.  Other languages handle this by supporting
subrange types and treating an array as a mapping from some integral or
enumerated type to some other type, so that you declare the bounds of an
array by giving the type to be used as an index.  You don't do this in C
(for one thing, C doesn't support subranges, so you can't declare a
10-element array by saying its index is the subrange 1..10; for another
thing, C's notion of array indexing is a bit strange), so you can't say
"this array has "enum apples" as its subscript.
     
I hope future ANSI C compilers don't treat "enum"s totally like arrays.  For
one thing, they'd better not put "this is just an integral type of some
particular size" in the debugger's symbol table; they should specify that
it's an enumerated type and give the names of the type's values.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3463
          for JMS@ARIZMIS; Sat, 28-JUN-1986 14:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/28/86 at 16:03:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023372; 22 Jun 86 0:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001639; 21 Jun 86 23:44 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: time(2 or 3)
Message-ID: <4270@sun.uucp>
Date: 19 Jun 86 18:45:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <2021@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) shows
> >>    somevar1 = time(0);
> >
> >       Specifically, time() is a function returning long, taking
> >a _pointer_ to long...;
> >Change to:
> >    ...
> >    somevar1 = time((long *) 0);
>
> Of course Chris is right;  I just ':r some_prog_of_mine' that _worked_(!)...
     
More precisely, that happened to work on the machine you built it on.  "This
program works" (which almost always means "this program works on some subset
of the machines on which it could conceivably work) is not equivalent to
"this program is correct".  There are *lots* of machines on which "somevar =
time(0);" will *not* work, and such machines have perfectly legal C
implementations.  Those of you on VAXes, Suns, Pyramids, 3Bs, etc. may not
think it matters to write type-correct code, since you can get away with not
doing so; however, you'll regret it the day somebody wants your program
ported to, say, a PC using the large memory model, or a small 68000-based
machine using 16-bit "int"s.
     
Chris' complaint was perfectly legitimate, as would "lint"s complaint about
the same statement (you *do* run "lint", of course).
     
> Of course, it helps my case a bit that _my_ manual (albiet an old V7)
> has the following in time(2):  (honest)
>
>     long time(0)          <<<< this is what I recommended.
     
Yes, the V7 manual is old, and you could get away with that sort of thing on
the PDP-11 where V7 was first done.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3692
          for JMS@ARIZMIS; Sat, 28-JUN-1986 14:50 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023401; 22 Jun 86 0:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id aa02489; 22 Jun 86 0:11 EDT
From: flaps%utcs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: microsoft C considered stupid
Message-ID: <1986Jun20.01:10:46.477@utcs.uucp>
Date: 20 Jun 86 05:10:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
I have just received MS C for the IBM PC/AT running MS-DOS.
     
The manuals, besides being poorly and sometimes inaccurately written,
encourage all sorts of stupid things.  I would like to share two things
with you.
     
1. They have instituted a pre-processor conditional of the form
    #if defined(MANIFEST_CONSTANT).  Furthermore, the manual notes that
    use of #ifdef is "discouraged" (though at least they support it).
    Here in net.lang.c several C revision proposals have been rejected on
    the grounds that they don't add enough to the language to merit the
    inconvenience of a change.  This change from #ifdef adds absolutely
    nothing to the language!
     
2. The manual does not permit something of the form:
    struct tag { typedeclaration value; ... };
    although the compiler does.  The manual requires that you actually
    declare something with the struct.  This is not a feasible restriction
    on C and in fact MS C is not so restricted.
     
In other words, my complaint about MS C is that there are mindless restrictions
(in typical IBM style).  The examples in the book are all stupid and unclear.
I don't know how I would learn C there if I hadn't first learned it here.
     
--
Alan "IBM-hater" Rosenthal
{decvax|cbosgd|linus}!ihnp4!utcs!flaps, utzoo!utcs!flaps

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3885
          for JMS@ARIZMIS; Sat, 28-JUN-1986 14:55 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023413; 22 Jun 86 0:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002614; 22 Jun 86 0:14 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2110@umcp-cs.UUCP>
Date: 21 Jun 86 07:10:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <115@mruxe.UUCP> cgw@mruxe.UUCP (C Waldman) writes:
[Mathematical use of the symbol `=' includes three meanings:
test for equality, assignment of equality, and assertion of
equality.]
>[When programming] we are interested in telling the computer
>to DO something: therefore we are interested in [the first two]
>meanings....  We need two symbols to avoid ambiguity.
     
Fine so far; I think everyone agrees on this (with the exception
mentioned in some of the unquoted text of theorem-proving languages).
     
>... If anything, maybe I would agree with a different symbol for
>[the first] meaning..., like ?= or =? or something, but it's not
>worth making a change. If it ain't broke, don't fix it.
     
Here is where you will, with some, `run into a brick wall' (as they
never did say in Bree).  Some will claim that it *is* broken,
because people do at times write
     
    if (var = expr) ...
     
when they in fact meant
     
    if (var == expr) ...
     
As for myself, I believe that anyone can do bad things in any
language (includin' English like I's a-doin' right here now right
before your very own eyes doncha know :-) ), and that the proper
measure of a language is not how difficult it makes writing bad
code, but rather how easy it makes writing good code.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3996
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:03 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023425; 22 Jun 86 0:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002739; 22 Jun 86 0:19 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: microsoft C considered stupid
Message-ID: <2111@umcp-cs.UUCP>
Date: 21 Jun 86 08:21:34 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1986Jun20.01:10:46.477@utcs.uucp> flaps@utcs.uucp
(Alan J Rosenthal) writes:
>1. They have instituted a pre-processor conditional of the form
>    #if defined(MANIFEST_CONSTANT).
     
They have not instituted it.  It has been around since V7, at
the latest.  It is quite useful; things like
     
    #if (defined(x) || defined(y)) && defined(z)
     
are fairly tricky (not to mention confusing) to write without this.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4147
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023577; 22 Jun 86 1:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002850; 22 Jun 86 0:24 EDT
From: dmr%dutoit.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Where did ++ come from?
Message-ID: <2140@dutoit.UUCP>
Date: 21 Jun 86 08:22:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Phaedrus@eneevax guessed that a lot of notation in C came from PDP-11
assembly language, and Chris Torek's reply did indeed drag me out
of my torpor.
     
Nothing in the C syntax came from the PDP-11, because all the relevant
parts were imported from B, which was in use before the PDP-11
existed.  In fact things are somewhat the other way around; the reason
the Unix PDP-11 assembler resembles B (and C) more than does DEC's, is
that I wrote the first Unix PDP-11 assembler, in B, before we had a DEC
assembler.  It was written from the machine description.  It used * and
$ rather than @ and # because the former were analogous respectively to
the B notation and to other assembly languages I knew, and (equally)
because @ and # were the kill and erase characters.
     
As to ++ and --:  these were Thompson inventions as far as I know,
or at least the idea of using them in both prefix and postfix form.
No doubt the autoincrement cells in the PDP-7 contributed to the idea,
but there was a significant generalization, or rather isolation of the
significant operations into ++ -- and *, as Chris pointed out.
     
If you haven't heard of autoincrement cells, here is the idea: certain
locations (010-017) in low memory in the PDP-7 (and also the -8, but
just one cell, probably 010), acted like ordinary memory locations,
unless indirection was applied through them.  In that case, after the
indirect reference, 1 was automatically added to them.  It was useful
for stepping through arrays, especially because these machines lacked
index registers.
     
* came from the version of BCPL we were using.  (Pure BCPL used "rv"
for "*" and "lv" for "&").
     
By the way,  B had assignment versions of all the binary operators,
including === and =!=.  Since it didn't have &&, the question of =&&
did not arise.  The ones missing from C were dropped for lack of interest.
     
    Dennis Ritchie

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4219
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023583; 22 Jun 86 1:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002882; 22 Jun 86 0:25 EDT
From: Tom Armistead <toma%killer.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: pointers to functions
Message-ID: <237@killer.UUCP>
Date: 20 Jun 86 20:41:10 GMT
Keywords: can you cast them?
To:       info-c@BRL-SMOKE.ARPA
     
The delima - Is it possible to cast a 'pointer to' a function?
     
What I have is a char * that holds the address of a function.
int    foo();
char    *addr = foo;
Would it be possible to call the function foo() via the variable addr?
     
Secondly is it possible to have an array of type 'pointer to' function.
i.e.
int  (*function)()[SIZE];
something like the above, I was able to achieve this using this:
struct    fct {
            int  (*func)();
            } f_array[SIZE];
function()
{
    int x;
    printf("offset: ");
    scanf("%d",&x);
    (*f_array[x].func)();
}
Is there another way???
     
Something to think about...
Thanx in advance for **ANY** help,
- Tom
     
---
UUCP:
     ihnp4!cuae2!tuxa!we53!sw013b! \
                                    \dj3b1!killer!toma
                                    /
           drillsys!infoswx!convex!/
     
Tom Armistead

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4374
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023591; 22 Jun 86 1:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002926; 22 Jun 86 0:27 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: microsoft C considered stupid
Message-ID: <5682@alice.uUCp>
Date: 21 Jun 86 14:12:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> 1. They have instituted a pre-processor conditional of the form
>    #if defined(MANIFEST_CONSTANT).  Furthermore, the manual notes that
>    use of #ifdef is "discouraged" (though at least they support it).
>    Here in net.lang.c several C revision proposals have been rejected on
>    the grounds that they don't add enough to the language to merit the
>    inconvenience of a change.  This change from #ifdef adds absolutely
>    nothing to the language!
     
Well maybe.  But Microsoft didn't invent this usage.
Try it on your favorite Unix system and see for yourself.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4473
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023599; 22 Jun 86 1:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002952; 22 Jun 86 0:28 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: microsoft C considered stupid
Message-ID: <4326@sun.uucp>
Date: 21 Jun 86 04:13:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> 1. They have instituted a pre-processor conditional of the form
>     #if defined(MANIFEST_CONSTANT).  Furthermore, the manual notes that
>     use of #ifdef is "discouraged" (though at least they support it).
>     Here in net.lang.c several C revision proposals have been rejected on
>     the grounds that they don't add enough to the language to merit the
>     inconvenience of a change.
     
Microsoft didn't institute this.  John Reiser did when he was at Bell Labs.
This feature has been in UNIX since Version 7, and has been documented since
System V.  It is also in the ANSI C draft standard.
     
> This change from #ifdef adds absolutely nothing to the language!
     
Wrong.  You can't say
     
    #ifdef FOO || BAR
     
to include code if FOO or BAR is defined, but you can say
     
    #if defined(FOO) || defined(BAR)
     
This is useful, and has in fact been used in a number of programs.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4753
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023645; 22 Jun 86 1:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003119; 22 Jun 86 0:33 EDT
From: Allan Black <allan%cs.strath.ac.uk@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <193@stracs.cs.strath.ac.uk>
Date: 20 Jun 86 17:20:22 GMT
Posted: Fri Jun 20 17:20:22 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <1201@brl-smoke.ARPA> Schauble@MIT-MULTICS.ARPA writes:
>Can someone construct a version that makes
>    int *a, *b;
>    swap (*a++,*b++);
>work right?
     
#define swap(p,q) {int *x = &(p), *y = &(q); int z = *x; *x = *y; *y = z;}
     
This will only work for type 'int'; if you want to make it more general, try
something like:
{long *x = (long)(&(p)) etc.
But be careful with something like that - there's no typechecking, so you
can easily mix pointers up, with disastrous results!
     
--
UUCP:    ...!seismo!mcvax!ukc!strath-cs!allan
DARPA:    allan%cs.strath.ac.uk@ucl-cs    JANET:    allan@uk.ac.strath.cs
     
"This doesn't seem to be working, sir!"
"Yes, but I was trying to ignore it so that YOU wouldn't look stupid!"
                -- Monty Python's Flying Circus

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4667
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023639; 22 Jun 86 1:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003091; 22 Jun 86 0:32 EDT
From: MKR <mkr%mmm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Switch case common code
Message-ID: <953@mmm.UUCP>
Date: 19 Jun 86 18:31:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <134@danews.UUCP> lvc@danews.UUCP (Larry Cipriani) writes:
>The 'best' I think that can be done is to do something like:
>
>    switch (switch_variable)
>    {
>    case a: ...
>        ...
>        goto common;
>        break;
>
>    case b: ...
>        ...
>    common:    common_code_for_a_and_b
>        break;
>
>    case c: ...
>        ...
>        break;
>    }
>
>Larry Cipriani        AT&T Network Systems
     
    Why not:
     
int common_stuff()
{
    blahblahblah
}
     
main()
{
...
    switch (thnad) {
    case A:
        do the A stuff;
        common_stuff();
        break;
    case B:
        do the B stuff;
        common_stuff();
        break;
    case C:
        do the C stuff;
        break;
    }
     
I thought that's what functions were for.
     
    --MKR

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4832
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023651; 22 Jun 86 1:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003189; 22 Jun 86 0:34 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: pointers to functions
Message-ID: <2128@umcp-cs.UUCP>
Date: 22 Jun 86 01:06:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[I could swear this has been answered before, but here goes:]
In article <237@killer.UUCP> toma@killer.UUCP (Tom Armistead) writes:
>The delima - Is it possible to cast a 'pointer to' a function?
     
Possible: yes; portable: no.
     
>What I have is a char * that holds the address of a function.
>int    foo();
>char    *addr = foo;
>Would it be possible to call the function foo() via the variable addr?
     
Technically, that should be `char *addr = (char *) foo;'.  If this happens
not to lose important information, you can subsequently successfully use
     
    value = (*(int (*)())addr)(arg1, arg2, ...);
     
The cast `(int (*)())', odd-looking though it may be, coerces the type
to `pointer to function returning int'.
     
>Secondly is it possible to have an array of type 'pointer to' function.
>i.e.
>int  (*function)()[SIZE];
     
Certainly it is possible; you just need to construct the proper
declaration.  For example, feeding the description
     
    declare f as array 10 of pointer to function returning int
     
through cdecl produces
     
    int (*f[10])()
     
There are at least two programs that do what cdecl does; as I recall,
the one I do not have was posted less than three months ago to either
net.sources or mod.sources.  Cdecl itself was posted to net.sources
over a year ago.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4960
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:55 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023891; 22 Jun 86 1:48 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a003562; 22 Jun 86 1:29 EDT
Date:     Sun, 22 Jun 86 1:29:39 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       flaps%utcs.uucp@BRL.ARPA
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  microsoft C considered stupid
Message-ID:  <8606220129.aa00298@VGR.BRL.ARPA>
     
Alan "IBM-hater" Rosenthal posted an article flaming MicroSoft C for
its "stupidity" (in his opinion).  While I don't much like IBM PCs, I
like ignorant flames even less.  Rosenthal's posting may have confused
some inexperienced C programmers, so correction may be useful.  In the
following, lines starting with > are Rosenthal's original remarks.
     
>The manuals, besides being poorly and sometimes inaccurately written,
>encourage all sorts of stupid things.  I would like to share two things
>with you.
>
>1. They have instituted a pre-processor conditional of the form
>    #if defined(MANIFEST_CONSTANT).  Furthermore, the manual notes that
>    use of #ifdef is "discouraged" (though at least they support it).
>    Here in net.lang.c several C revision proposals have been rejected on
>    the grounds that they don't add enough to the language to merit the
>    inconvenience of a change.  This change from #ifdef adds absolutely
>    nothing to the language!
     
First, this is not a MicroSoft invention.  It has been in many C
compilers, including UNIX PCC, for years.  (Actually it is "macro name"
that is tested, not just "MANIFEST_CONSTANT".)  Second, having an
explicit predicate does add something over #ifdef; it is more general:
    #if defined(BRL) && !defined(pdp11)    /* I use this a lot! */
     
>2. The manual does not permit something of the form:
>    struct tag { typedeclaration value; ... };
>    although the compiler does.  The manual requires that you actually
>    declare something with the struct.  This is not a feasible restriction
>    on C and in fact MS C is not so restricted.
     
It's hard to make sense of this out of context, but if it precludes
    struct foo { int bar 123; };
as I suspect it does ("value" smacks of initializer to me), then it is
a perfectly correct restriction.
     
>In other words, my complaint about MS C is that there are mindless restrictions
>(in typical IBM style).  The examples in the book are all stupid and unclear.
>I don't know how I would learn C there if I hadn't first learned it here.
     
It is not clear that Rosenthal *has* learned C or even how to read
manuals.  One has to admit that at least one MicroSoft C user was
apparently not adequately served by their documentation; not having
seen it, I don't know whether the blame for that lies with MicroSoft
or with the user.  But the flame was certainly off the mark.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5076
          for JMS@ARIZMIS; Sat, 28-JUN-1986 15:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025298; 22 Jun 86 5:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006486; 22 Jun 86 5:43 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <827@bu-cs.UUCP>
Date: 22 Jun 86 00:56:53 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
I'll risk stating it even more strongly than has been said so far:
     
It is not even clear that assignment and equality are clearly
distinguished in any mathematical sense, you just think they
are because you are applying a particular model of the machine
you are computing on. One can envision an environment where the
distinction breaks down even further:
     
A few years ago I worked for a company which had me write a
compiler with a very similar syntax to C (actually, a superset)
who's semantics created a constraint network for a directed
graph pseudo-machine.
     
Basically, '=' was simply an assertion that at this point in
the computation this statement was 'true' or should be made
such (or, possibly, an error if it was not.)
     
Full blown expressions were allowed on either sides of an
'assignment' thus:
     
    j = 5;
    i + 4 = j;
     
simply meant that by the time the second statement was executed
if 'i' was empty it was to be given the value '1'. If it was not
empty it either already was '1' or indicated an error. Thus statements
could be run 'backwards' to infer missing data or verify existing
state of the data base. Essentially the whole program ran at once
in parallel (as far as the semantics were concerned, not in fact)
so the phrase above "by the time the second statement was executed..."
is simply a pedagogical convenience.
     
I think such an example should sufficiently blur rigid views
towards assignment and equality.
     
Another point would be that I have never seen a mathematician hesitate
to introduce notational systems when convenient.
     
Yet another point would be it is not clear that programming and
it's languages *isn't* mathematics, rather than two things to be
judged side by side. Perhaps the paradigm has shifted?
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5231
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:07 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029854; 22 Jun 86 16:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011883; 22 Jun 86 15:42 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <5688@alice.uUCp>
Date: 22 Jun 86 14:27:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> #define swap(x, y) \
>   if (1) \
>   { \
>     register int *xp, *yp, t; \
>     xp = &(x); \
>     yp = &(y); \
>     t = *xp; \
>     *xp = *yp; \
>     *yp = t; \
>   } \
>   else
>
> --------------------------------
>
> The "if (1) ... else" allows the user to put a semicolon after the macro
> invocation, and makes code such as
>
>   if (today == tuesday)
>     swap(*a++, *b++);
>   else
>     swap(*c++, *d++);
>
> work correctly.
     
On the other hand, if you forget a semicolon:
     
    if (x < y)
        swap (x, y)
    printf ("%d %d\n", x, y);
     
you will spend a long time wondering why it doesn't print anything.
     
Of course, if you write in C++, you can say:
     
    inline void swap (int& x, int& y)
    {
        register int t = x;
        x = y;
        y = t;
    }
     
and be done with it.  It's a true function, the compiler checks
types for you, you can define several swap functions for different
types, and so on.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5295
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001512; 22 Jun 86 19:35 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a013565; 22 Jun 86 18:58 EDT
Received: from (MAILER)ICNUCEVM.BITNET by WISCVM.WISC.EDU on 06/22/86
  at 18:00:49 CDT
Received: by ICNUCEVM (Mailer X1.23) id 6425; Mon, 23 Jun 86 00:55:07
  SET
Date:         Mon, 23 Jun 86 00:48 SET
From:           Enzo Rossi <AN1108%ICNUCEVM.BITNET@wiscvm.ARPA>
Subject:      MSC 3.0 system() patch
To:  INFO-C@BRL-SMOKE.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
If someone have a patch for MSC 3.0 system() library function
to make it work well with the SWITCHAR = '-'
please send me infos.
     
Thank you in advance.
Enzo.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5376
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004141; 23 Jun 86 0:35 EDT
Received: from mit-multics.arpa by SMOKE.BRL.ARPA id a017385; 23 Jun 86 0:25 EDT
Date:  Mon, 23 Jun 86 00:21 EDT
From:  Paul Schauble <Schauble@MIT-MULTICS.ARPA>
Subject:  SWAP macro
To:  Info-C@BRL-SMOKE.ARPA
Message-ID:  <860623042119.539068@MIT-MULTICS.ARPA>
     
I've gotten lots of respones to my request for a form of the macro that
would make
  swap(*a++, *b++);
 work.  Almost all of them missed the point.  The swap requires a
temporary.  Generating that temporary requires knowing the type.
Several of the solutions would work fine if *a and *b were int's, but I
never said that.
     
Recall the my original message was posted as a justification for a
typeof macro, akin to sizeof.  I find that the need to generate
temporaries in a macro is not uncommon.  Unless one is willing to do a
different version of the macro for each type, you need a way to generate
a new variable of the same type as one of the macro args.  The language
provides no way to do this.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5422
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006340; 23 Jun 86 4:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019396; 23 Jun 86 3:44 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: non-built-in exponentiation (Re: What should be added to C)
Message-ID: <1003@ttrdc.UUCP>
Date: 22 Jun 86 04:44:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1371@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes:
>/*
>    LPow -- long exponentiation (no overflow detection)
>    last edit:    86/06/16    D A Gwyn
>    SCCS ID:    @(#)lpow.c    1.1
>*/
>long
>LPow( base, exponent )            /* returns base^exponent */
>    register long    base;
>    register long    exponent;
>    {
>    register long    result;        /* result accumulator */
>    /* handle simple special cases separately: */
>    if ( base == 0 )
>        return 0;        /* exp. < 0 should be EDOM */
>    else if ( base == 1 )
>        return 1;
>    else if ( base == -1 )
>        return exponent % 2 == 0 ? 1 : -1;
>    else if ( exponent < 0 )
>        return 0;
>    /* general case with exponent >= 0: */
>    result = 1;
>    for ( ; ; )    /* LOOP INVARIANT: result*base^exponent */
>        {
>        if ( exponent % 2 != 0 )
>            result *= base;
>        if ( (exponent /= 2) == 0 )
>            break;        /* result now stable */
>        base *= base;
>        }
>    return result;
>    }
     
Question.  Why not use
     
    exponent & 01
     
rather than
     
    exponent % 2
     
(other than consideration of portability to machines with one's complement
integers, which could be #ifdef'd easily enough)?  The latter is at least
three times slower when I spot checked it on a 3B20 (which has one-instruction
opcodes for both tests) and I doubt the VAX or other machines are much better
with a general-purpose "modulo".
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3599
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:24 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023395; 22 Jun 86 0:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002468; 22 Jun 86 0:11 EDT
From: jrv%siemens.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Re: C'mon, guys! (Really, pointer pe
Message-ID: <32700003@siemens.UUCP>
Date: 20 Jun 86 13:25:00 GMT
Nf-ID: #R:cubsvax:-48700:siemens:32700003:000:3300
Nf-From: siemens!jrv    Jun 20 09:25:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
Peter Shenkin writes:
     
>Just a quick remark.  When I was learning C, I understood that "*pi" meant "the
>contents of pi," but somehow had difficulty conceptualizing why the declaration
>"int *pi;" declares pi as a pointer to an int;  that is, I knew it was a
>convention I had to memorize, but it didn't seem mnemonic to me.  Then, about
>a month ago, revelation!:  read this as "the contents of pi is an integer;"
>which implies, "pi is that which contains (or points to)" an integer.  Somehow
     
    Interesting how the same words have completely different meanings
    for two people. The revelation which helps Peter keep pointers
    straight uses the exact words which helps me make the *distinction*
    between pointers and what they point to.
     
    For me contents of pi is a *pointer* to an integer. I do not make
    the association of "contains (or points to)" as the same thing. In
    fact I emphasis the difference.
     
    I agree that the declaration of pointers and their use is not
    consistent. Two statements which to the novice C programmer look
    very similar have different results:
     
        In a declaration:
     
            Int *pi = abcd;
     
        will store a value in the pointer variable pi.
        While in the middle of code:
     
            *pi = wxyz;
     
        will store a value where pi points.
     
    In the C classes I have taught this inconsistency did not appear to
    be a major stumbling point. When asked at the end of the semester
    what was the hardest topic in the course the overwhelming response
    is, "POINTERS, POINTERS, POINTERS". It was there general use not so
    much the declaration/initialization. Each semester I have added more
    material but have still not gotten to the point where the confusion
    level has been reduced to my satisfaction.
     
    I don't think that this is
    peculiar (sp?) to C. The extra level of indirection is a difficult
    concept to grasp whether it is in C or PASCAL or whatever. It is
    like riding a bicycle: once you know how you never forget; likewise
    once you understand pointers you know them for life. (There are
    probably several concepts which fall into this category. Recursion
    is another one that comes to mind.)
     
    (Jim, stop the semester ended over a month ago! In a minute the bell
    hasn't rung yet. :-) The one technique which I use often when I am
    attempting to keep a pointer staight is the "cover-up" technique.
    If I want to know what data type a variable is I go back to the place
    where it is declared and cover over what I am interested in and what
    remains is the data type of the object. For a simple example:
     
        Int *pi;
     
        given 'pi' cover this over in the declaration and you get
            'Int *'. So 'pi' is a pointer to an integer. 'pi'
            contains a pointer to an integer.
     
        or given '*pi' cover it in the declaration and you get 'Int'.
            So '*pi' is an integer. '*pi' contains an intger.
     
    Enough.
     
>it made thinking about the declarations easier.  It's occurred to me that maybe
>everyone else in the world sees this from day 1, but for us dumb folks, having
>this reading pointed out would probably make the learning process easier....
>
>Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
>{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA
>
     
     
Jim Vallino
Siemens Research and Technology Lab.
Princeton, NJ
{allegra,ihnp4,seismo,philabs}!princeton!siemens!jrv

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5509
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017729; 23 Jun 86 11:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000647; 23 Jun 86 10:19 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <1007@ttrdc.UUCP>
Date: 23 Jun 86 03:43:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <370@anasazi.UUCP>, steve@anasazi.UUCP (Steve Villee) writes:
>> Can someone construct a version that makes
>>
>>     int *a, *b;
>>     swap (*a++,*b++);
>>
>> work right?
>>           Paul Schauble at MIT-Multics.arpa
>
>#define swap(x, y) \
>  if (1) \
>  { \
>    register int *xp, *yp, t; \
>    xp = &(x); \
>    yp = &(y); \
>    ...
>--- Steve Villee (ihnp4!mot!anasazi!steve)
     
CAUTION.  This will fail on:
     
    register int i, j;
    swap(i,j);
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5599
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa28349; 23 Jun 86 16:15 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a010062; 23 Jun 86 15:56 EDT
Date:     Mon, 23 Jun 86 15:53:11 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  non-built-in exponentiation (Re: What should be added to C)
Message-ID:  <8606231553.aa18625@VGR.BRL.ARPA>
     
I wrote
    exponent % 2
because that was what I meant.  If your compiler cannot optimize
    expr % 2 == 0
to use a low-order bit test (two's complement only!), then perhaps
you should get somebody to improve your compiler.  (The SVR2 VAX
PCC generates remarkably ugly code for this, by the way.)
     
I'm a software engineer, not a speed phreak; I prefer code to be
correct regardless of any particular machine architecture.
     
The algorithm I posted is so much more efficient than the "obvious"
method that concerns for microefficiency are relatively unimportant.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5701
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:42 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029907; 23 Jun 86 18:40 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a011646; 23 Jun 86 17:39 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA05634; Mon, 23 Jun 86 17:37:40 edt
Date: Mon, 23 Jun 86 17:37:40 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606232137.AA05634@icst-cmr.ARPA>
To: aglew@GSWD-VMS.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: enums, pcc & all that
     
    I get tired of seeing
     
        #define MASK1   0x01
        #define MASK2   0x02
        #define MASK3   0x04
        ...
        #define MASKN   0x8000000
     
Me too. That is like a #define ONE 1, #define TWO 2, etc. Why not
#define MASK(x) (1 << (x))    /* or x-1 if you like */
     
    and even the corresponding enum is a pain.
     
Or define the bit numbers as enums and generate masks from them.
enum bits { ox, ow, or, gx, gw, gr, ux, uw, ur, sticky, sgid, suid };
#define SUID MASK(suid);    /* danger! */
     
    So, a filter that expands
     
        enum_mask { MASK1, MASK2, MASK3 ... MASKN }
     
    into the appropriate series of #defines or enums is useful...
     
...Once in a blue moon.
     
    Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:
    ihnp4!uiucdcs!ccvaxa!aglew 1101 E. University, Urbana, IL
    61801    ARPAnet: aglew@gswd-vms
     
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    ...My vaseline is RUNNING...

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5963
          for JMS@ARIZMIS; Sat, 28-JUN-1986 16:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001767; 23 Jun 86 22:02 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a012704; 23 Jun 86 21:48 EDT
Date:     Mon, 23 Jun 86 21:39:47 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       info-c@BRL.ARPA
cc:       rbj@ICST-CMR.ARPA
Subject:  LPow correction
Message-ID:  <8606232139.aa23238@VGR.BRL.ARPA>
     
Jim Cottrell pointed out to me that 0^0 should be 1, not 0
as I had it in my posted LPow() function.  I thought I had
a reason for making it 0, but since I'm unable to reconstruct
that line of reasoning, and *especially* since I can show
(using l'Hospital's rule) that
    limit of x^x as x->0+ is precisely 1,
I am amending our master copy of LPow() to handle exponent 0
as another special case.  Just insert
    if ( exponent == 0 )
        return 1;
in front of the other special cases.  This will make 0^n
zero for n > 0, 1 for n == 0, and 0 (should be infinite)
for n < 0.  The latter is the only known inaccuracy and is
due entirely to not wanting to clutter the algorithm with
error handling; if you want to add error handling this is
the place (recommend setting EDOM and returning MAX_LONG).

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5976
          for JMS@ARIZMIS; Sun, 29-JUN-1986 13:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003460; 24 Jun 86 1:03 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a013349; 24 Jun 86 0:13 EDT
Received: from ICST-CMR.ARPA by VGR.BRL.ARPA id aa24114; 24 Jun 86 0:06 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06263; Tue, 24 Jun 86 00:05:34 edt
Date: Tue, 24 Jun 86 00:05:34 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606240405.AA06263@icst-cmr.ARPA>
To: gwyn@BRL.ARPA
Subject: Re:  LPow correction
Cc: Info-C@BRL.ARPA
     
    Jim Cottrell pointed out to me that 0^0 should be 1, not 0
    as I had it in my posted LPow() function.  I thought I had
    a reason for making it 0, but since I'm unable to reconstruct
    that line of reasoning, and *especially* since I can show
    (using l'Hospital's rule) that
        limit of x^x as x->0+ is precisely 1,
     
I hadn't thought of it that way. That's what's neat about the truth,
it has so many ways of making itself known! As I also mentioned,
infinite series often generate aught to the naught and call it unity.
As you well know, zero factorial is also one.
BTW, 'tis          ^
        l'Hopital's Rule (the caret is a circumflex accent).
The Eagles even wrote a song about it:
"Take it to the Limit One More Time" (original joke).
     
    I don't care what APL does.
     
When it applies to math you do. If you have one handy you might try
expanding the power series for e^x:
     
infinity ->    <X>
        ---      n
     x    \     x        (I definitely didn't use eqn :-)
    e   =    /    ---
        ---     n!
        n=0
     
My favorite one liner is `1 + +/ % ! i 12' (where `%' is DIVIDE (reciprocal)
and `i' is IOTA). Twelve is a good approximation to infinity here. Anyway,
you can see what happens when x is zero. All the other terms flake out
except the first, which has to be one. Isn't this fun?
     
One last piece of humor: My favorite Star Trek line was when Spock said
(of some physical phenomenon) "It has increased in strength by
one to the fourth power!" He obviously didn't have your function.
     
    Take care now,
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Gibble, Gobble, we ACCEPT YOU - - -
     
P.S. That was Zippy's approcksimation to the Gobble Gobble I owe you.
               /^\
                |___I used up all my x's in previous postings

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1947
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:27 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 00:10:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014542; 28 Jun 86 22:55 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a004451; 28 Jun 86 22:41 EDT
Date:     Sat, 28 Jun 86 22:31:29 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       flaps%utcs.uucp@BRL.ARPA
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  microsoft C considered stupid
Message-ID:  <8606282231.aa01972@VGR.BRL.ARPA>
     
If you had not called MicroSoft "stupid" I would have replied politely.
Perhaps they are stupid, but your posted examples did not demonstrate that.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9086
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007696; 28 Jun 86 13:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002617; 28 Jun 86 12:54 EDT
From: Mark Biggar <markb%sdcrdcf.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: SWAP macro (utter insanity+interesting question)
Message-ID: <2859@sdcrdcf.UUCP>
Date: 27 Jun 86 16:06:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
IT still doesn't work for REGISTER variables!
     
Mark Biggar
{allegra,burdvax,cbosgd,hplabs,ihnp4,akgua,sdcsvax}!sdcrdcf!markb

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8776
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:34 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007642; 28 Jun 86 13:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002275; 28 Jun 86 12:42 EDT
From: Tim Smith <tim%ism780c.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Where did ++ come from?
Message-ID: <2657@ism780c.UUCP>
Date: 27 Jun 86 01:49:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2140@dutoit.UUCP> dmr@dutoit.UUCP writes:
> It used * and $ rather than @ and # because the former were
> analogous respectively to the B notation and to other assembly
> languages I knew, and (equally) because @ and # were the kill and
> erase characters.
     
So, why does C use # for the preprocessor instead of $?
--
Tim Smith                       USENET: sdcrdcf!ism780c!tim || ima!ism780!tim
"hey, bay-BEE'...hey, bay-BEE'" Compuserve: 72257,3706
                Delphi || GEnie: mnementh

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8525
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:34 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007401; 28 Jun 86 13:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002067; 28 Jun 86 12:35 EDT
From: jlc%afinitc.uucp@BRL.ARPA
Newsgroups: net.lang.c,net.math
Subject: Math subroutines for C.
Message-ID: <636@afinitc.UUCP>
Date: 25 Jun 86 16:43:57 GMT
Posted: Wed Jun 25 12:43:57 1986
To:       info-c@BRL-SMOKE.ARPA
     
{}
    Our company is looking for information on math packages written in C.
We are particularly interested in statistic, box-jenkins forcasting, fast
fourier transforms, and simplex optimum routing.  We would prefer PD functions
and need the sources included.  The systems we are currently using are IBM-ATs
with SCO Xenix Sys-5.  Please mail responses to me as I do not read these
groups very often.  If there is sufficient interest I will post the results
in a couple of weeks.
                Thanks,
                Gerald L. Collins
                {ihnp4 | seismo}!wucs!afinitc!jlc

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8214
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/28/86 at 17:52:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007073; 28 Jun 86 12:41 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001290; 28 Jun 86 12:12 EDT
From: "Robert D. Silverman" <bs%linus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Exponetiation
Message-ID: <174@linus.UUCP>
Date: 25 Jun 86 18:52:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > I'm confused. I've been trying to figure out a quick and easy way
> > to exponetiate to a fraction (ie. x^(4.25))  and also be able to
> > figure out the power when given the base and the result.
>
> a^b is exp(b*ln(a)).  So, if x = a^b and you know a and x,
>
>     exp(b*ln(a)) = x
>     b * ln(a) = ln(x)
>     b = ln(x) / ln(a)
     
Better make sure that a,x > 0 before using this well known trick.
Bob Silverman

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8947
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:37 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007664; 28 Jun 86 13:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002422; 28 Jun 86 12:48 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  LPow correction
Message-ID: <494@cubsvax.UUCP>
Date: 26 Jun 86 19:49:12 GMT
Posted: Thu Jun 26 15:49:12 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <brl-smok.1611> rbj@icst-cmr.arpa (Root Boy Jim) writes:
>My favorite one liner is `1 + +/ % ! i 12' (where `%' is DIVIDE (reciprocal)
>and `i' is IOTA). Twelve is a good approximation to infinity here. Anyway,
>you can see what happens when x is zero. All the other terms flake out
>except the first, which has to be one. Isn't this fun?
     
Whoops, don't you mean:
        1 + +/ (x ^ i12) % (! i12)
??  (Ya need x^n in the numerator of each term....  I'm using "^" for
exponentiation.)
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8439
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007369; 28 Jun 86 13:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001753; 28 Jun 86 12:26 EDT
From: " G.R.Tomasevich" <grt%twitch.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: #if foo vs #if defined(foo)
Message-ID: <379@twitch.UUCP>
Date: 25 Jun 86 12:22:56 GMT
Keywords: Sys 5.2
To:       info-c@BRL-SMOKE.ARPA
     
Our compiler does not need a defined(), or at least I did not try whether
it is even accepted.  The following example works fine:
     
#if squat||foo
int yes;
#else
int no;
#endif
main() {}
     
if the 'cc' command includes either '-Dsquat' or '-Dfoo', then 'yes' is
selected, else 'no' is selected.  E.g.: 'cc -Dfoo -E c.c'
System: VAX-11/785 running UNIX 5.2
--
    George Tomasevich, ihnp4!twitch!grt
    AT&T Bell Laboratories, Holmdel, NJ

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9012
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:47 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007685; 28 Jun 86 13:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002506; 28 Jun 86 12:51 EDT
From: nigel <nigel%minster.uucp@BRL.ARPA>
Newsgroups: net.micro.amiga,net.lang.c
Subject: Re: Nonsense in BYTE reader columns
Message-ID: <837@minster.UUCP>
Date: 25 Jun 86 22:22:02 GMT
Posted: Wed Jun 25 22:22:02 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <1502@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>)
 writes:
>In article <827@minster.UUCP> nigel@minster.UUCP (nigel) writes:
>>The apporach of 'sugaring' C is not unusual - have you looked at the source
>>code for sh?
>
>Practically every UNIX system programmer I know couldn't STAND
>Bourne's pseudo Algol-68 (also used in "adb").  Fortunately
>this was fixed in SVR2 (I think Dave Korn did the clean-up).
>
     
Read my original article carefully; I pass no comment on the readability of
sh - merely that sugaring was used.
     
>>This looks more like FORTRAN that Pascal ... now that I do take exception to.
>
>If you want Pascal, use Pascal.  Not looking like Pascal is not
>a language deficiency!
     
Looking like FORTRAN is. A Pascal programmer moving over to C does not need
help with comprehension of operators such as <=, as they occur in Pascal.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9810
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:47 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 06/28/86 at 22:31:21 CDT
Received: from cu-arpa.cs.cornell.edu by SRI-KL.ARPA with TCP; Wed 25 Jun 86
  14:15:17-PDT
Message-Id: <8606252114.AA09168@cu-arpa.cs.cornell.edu>
Received: by cu-arpa.cs.cornell.edu (5.31/4.30)
    id AA09168; Wed, 25 Jun 86 17:14:50 EDT
Date: Wed, 25 Jun 86 17:15:32 EDT
From: George Boyce <george@vax1.ccs.cornell.edu>
Newsgroups: mod.computers.vax
Subject: Vaxstation and the console port
Expires:
References:
Sender:
Reply-To: george@vax1.ccs.cornell.edu (George Boyce)
Followup-To:
Distribution:
Organization: Cornell Computer Services, Ithaca NY
Keywords:
Apparently-To: info-vax@sri-kl.arpa
     
Has anyone been able to plug in and use an LN03 printer via the console
port of a vaxstation running VMS 4.2/4.4 and workstation software V2.0?
The manual says in one place (Graphics Programmers Guide, 1.1.7) that
only LA50s or LA210 can be used. I tried an LN03 and the system hangs
when the device is powered on or off. I tried an LA34 and that worked.
     
Any help and/or patches would be appreciated.
     
George Boyce, Academic Computing, Cornell University
george@vax1.ccs.cornell.edu, george@crnlcs.bitnet
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7615
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:47 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026160; 26 Jun 86 19:55 EDT
Received: from ibm.com by SMOKE.BRL.ARPA id a001205; 26 Jun 86 19:16 EDT
Date: 26 June 1986, 19:09:19 EDT
From: "JOSHUA W. KNIGHT" <JOSH@ibm-sj.ARPA>
To:   info-c@BRL-SMOKE.ARPA
     
Subject:  Re:  Re: pointers to functions
     
In article <214@bsdpkh.UUCP> lathan@bsdpkh.uucp (Ken Latham) writes:
     
 > A BETTER IDEA is to declare 'funcptr' as a type
 >
 >     typedef int (* funcptr)();
 >
 > then use it ...
 >
 >     funcptr foo[1028];
 >
 > This is much clearer.
 >
 > incidentally,    ( (int *())addr)();  would do it     (I think?)
     
As I read the latest copy I have of the draft ANSI C standard, whether
or not this last works is implementation dependent.  More concretely, it
does not work on the AT&T 370 C compiler.
     
Any opinions expressed or implied are mine and not my employers.
     
     
            Josh Knight
            IBM T.J. Watson Research Center
josh@ibm.com, josh@yktvmh.BITNET

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8018
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006741; 28 Jun 86 12:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000800; 28 Jun 86 11:56 EDT
From: Rex Ballard <rb%ccird1.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Additions to C - range checking
Message-ID: <523@ccird1.UUCP>
Date: 24 Jun 86 03:58:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
One common reference that kills is the old "is this in range"
test.
     
typically, this is written:
     
if((5<a)&&(a<50)) do_something(a);
     
suppose instead of a, you use a->b->c->d, all that pointer
arithmetic gets done twice? (maybe it is optimized but its harder
to read).
     
How about:
     
if (5<a<50) do_something(a);
     
this would currently be interpreted as
     
if((5<a)<50).  since, if a=100 (5<a) evaluates to 1 and 1<50, it
is true for any number greater than 5 right?
     
this can be real useful for pre-checking an array bounds, a
int (f[])(); type switch, and even skipping over a case statement.
     
Is this impossible to parse?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9132
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007708; 28 Jun 86 13:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002638; 28 Jun 86 12:55 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: SWAP macro
Message-ID: <857@bu-cs.UUCP>
Date: 28 Jun 86 00:45:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
And then again, there's always this sort of thing (look in 4.2's
/usr/include/sys/mbuf.h for a strong precedent):
     
#define swap(x,y,t) { \
            t *p1 = &(x), *p2 = &(y), tmp; \
 \
            tmp = *p1; \
            *p1 = *p2; \
            *p2 = tmp; \
        }
     
which is called with something like:
     
    swap(x,y,double);
     
really not a bad thing (or is it too much bother for the programmer to
know what type s/he is working with?)  Still doesn't work with
registers of course (but I don't think typeof() would solve that
problem either.) Also, pointer types would have to be typedef'd to be
useful as swap(x,y,char *) would not quite work (but w/ a typedef
it works fine.)
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7756
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006546; 28 Jun 86 11:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000593; 28 Jun 86 11:45 EDT
From: Mark Biggar <markb%sdcrdcf.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <2857@sdcrdcf.UUCP>
Date: 24 Jun 86 21:02:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3007@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>In article <1201@brl-smoke.ARPA> Schauble@MIT-MULTICS.ARPA (Paul Schauble)
 writes:
>>Can someone construct a version that makes
>>
>>    int *a, *b;
>>    swap (*a++,*b++);
>>
>>work right?
>>
>#define swap( a,b ) { int *p1,*p2,t;\
>    p1= &(a); p2= &(b); t= *p1;*p1= *p2;*p2=t;}
>
>No, it isn't pretty.
>how about:
>
>#define swap(a,b) fswap(&(a),&(b))
>fswap(a,b) int *a,*b;
>{    etc.
     
BOTH of these die a horrible death if either argument is declared
"register".
     
Mark Biggar
{allegra,burdvax,cbosgd,hplabs,ihnp4,akgua,sdcsvax}!sdcrdcf!markb

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7688
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/28/86 at 17:40:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006534; 28 Jun 86 11:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000576; 28 Jun 86 11:44 EDT
From: Walter Bright <bright%dataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: microsoft C considered stupid
Message-ID: <1030@dataio.UUCP>
Date: 23 Jun 86 17:33:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1986Jun20.01:10:46.477@utcs.uucp> flaps@utcs.uucp (Alan J
 Rosenthal) writes:
>I have just received MS C for the IBM PC/AT running MS-DOS.
>The manuals, besides being poorly and sometimes inaccurately written,
>encourage all sorts of stupid things.
>1. They have instituted a pre-processor conditional of the form
>    #if defined(MANIFEST_CONSTANT).  Furthermore, the manual notes that
>    use of #ifdef is "discouraged" (though at least they support it).
>    Here in net.lang.c several C revision proposals have been rejected on
>    the grounds that they don't add enough to the language to merit the
>    inconvenience of a change.  This change from #ifdef adds absolutely
>    nothing to the language!
     
Ah, but it does add an important capability! It is very convenient to do:
     
#if defined(abc) && defined(def) || defined(ghi)
    code...
#endif
     
I need this capability as I write code that is ported to as many as 8
different C compilers and machines.
     
Of course, the feature already exists, because if an identifier is not
defined it is replaced with 0 in #if expressions, but I think that's
a worse kludge.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7352
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:52 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028624; 25 Jun 86 22:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000920; 25 Jun 86 21:54 EDT
From: Landon Noll <chongo%nsc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Winners of the 1986 International Obfuscated C Code Contest
Message-ID: <3661@nsc.UUCP>
Date: 25 Jun 86 04:07:22 GMT
Keywords: obfuscate,winners,1986
To:       info-c@BRL-SMOKE.ARPA
     
The following program:
     
>    The grand prize (most well-rounded in confusion):
>
>          Larry Wall
>        <lines deleted to save space>
>
>          {allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
>    -----------------------------------------------------------------------
>    #define _c(C)_ (C)&('|'+3):c_()(C)>>('\n'-3) __ /**/
>        <lines deleted to save space>
     
does not compile on most System V systems.  Several Sys V /lib/ccp's have
problems with the first define.  The following modification allows it
compile:
     
    1c1
    < #define _c(C)_ (C)&('|'+3):c_()(C)>>('\n'-3) __ /**/
    ---
    > #define _c(C)_ (C)&('|'+3):c_()(C)>>('\n'-3) __; /**/
     
Our decisions are final.  But we can say:  "sorry about that folks!"
     
Next year, we would like to obtain help in running 'nominated' programs
in different machines.  We will solicit such help near the proper time.
     
chongo <oops, but we still think it is this year's best> /\__/\

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7206
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:56 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028599; 25 Jun 86 22:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000818; 25 Jun 86 21:51 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.micro.amiga,net.lang.c
Subject: Re: Nonsense in BYTE reader columns
Message-ID: <6849@utzoo.UUCP>
Date: 24 Jun 86 03:39:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> ...[redefining C syntax with macros]... The
> point wasn't that you SHOULD do things this way, but that you COULD.  And
> there's nothing wrong with someone programming that way, if it increases
> their efficiency and doesn't hinder the quality of the code...
     
Provided that they realize that they're easing their own learning process
a bit (c'mon, guys, how long does it take competent people to learn how
to write "{}" and "=="?) at the price of having their own private dialect
of C.  In a more general context, yes there *is* something wrong with it:
the result will be less intelligible to experienced C programmers, should
they happen to hire any; existing C-oriented tools probably will not work
on it; if they ever start mixing it with normal C they'll have real fun;
if they ever start having to look at normal C they won't know how to cope.
     
When I first encountered C, about eleven years ago, I did something quite
similar.  I eventually gave it up.  The benefits were superficial and
the compatibility hassles weren't worth it.
     
> ...If you prefer
> "real" C, just run the other person's program through a selective pre-
> processor...
     
How do I run it back again when I want to give my improvements back to him?
For that matter, how do I apply a patch he sends me?
     
> That's one of the really wonderful things about C: the
> preprocessor.  Why not use it?
     
Because it can make things harder just as readily as it can make things
easier.  See the Obfuscated C Contest for some exaggerated but telling
examples.  Knowing how to use a nifty facility is easy; knowing when *not*
to use it is harder but more important.
--
Usenet(n): AT&T scheme to earn
revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9298
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007881; 28 Jun 86 13:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002730; 28 Jun 86 12:58 EDT
From: der Mouse <mouse%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <444@mcgill-vision.UUCP>
Date: 25 Jun 86 01:49:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1228@brl-smoke.ARPA>, rbj@icst-cmr (Root Boy Jim) quotes
>     Can someone construct a version that makes
>         int *a, *b;
>         swap (*a++,*b++);
>     work right?
and writes
> Probably not. In general, macros don't work on arguments that have side
 effects.
     
How about the following, which assumes the  arguments have addresses (no
bitfields  or  register  variables  need  apply).    I  would  advise  C
portability purists to hit n; this code is pretty gross.
     
#define swap(x,y) \
{ register char *t1 = (char *)&(x);    \
  register char *t2 = (char *)&(y);    \
  register int n = sizeof((x));        \
  register int i;            \
  for (i=0;i<n;i++)            \
   { *t1 ^= *t2;            \
     *t2 ^= *t1;            \
     *t1 ^= *t2;            \
    }                    \
}
     
I *told* you it was gross.   But it should work, if not  on all machines
out there,  on a  large subclass  (let's see, byte-addressable machines,
any other restrictions folks?).
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     philabs!micomvax!musocs!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
        mcvax!seismo!cmcl2!philabs!micomvax!musocs!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7854
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006717; 28 Jun 86 12:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000607; 28 Jun 86 11:46 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Switch case common code - (without a function)
Message-ID: <143@danews.UUCP>
Date: 24 Jun 86 13:11:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> int common_stuff()
> {
>     blahblahblah
> }
>
> main()
> {
> ...
>     switch (thnad) {
>     case A:
>         do the A stuff;
>         common_stuff();
>         break;
>     case B:
>         do the B stuff;
>         common_stuff();
>         break;
>     case C:
>         do the C stuff;
>         break;
>     }
>
> I thought that's what functions were for.
>
>     --MKR
     
One of the requirements of the original request is that
a function not be used.
     
A reason not to use a function is that the scoping rules
get in the way, and force one to either use lots of global
varibles (yuck) or pass the function addresses of variables
and manipulate them through indirection (still yucky).
     
Another is that in a realtime process you might want to keep
the number of function calls to a minimum.
--
     
Larry Cipriani        AT&T Network Systems
danews!lvc        "Nothing is worse than an itch you can never scratch."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9892
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026462; 25 Jun 86 19:16 EDT
Received: from nosc.arpa by SMOKE.BRL.ARPA id a011016; 25 Jun 86 18:58 EDT
Received: by bass.ARPA (5.31/4.7)
    id AA02968; Wed, 25 Jun 86 15:59:39 PDT
Received: by cod.ARPA (5.31/4.7)
    id AA03974; Wed, 25 Jun 86 15:59:35 PDT
Message-Id: <8606252259.AA03974@cod.ARPA>
Date: Wed, 25 Jun 86 13:47:32 PDT
Ppath: crash!noscvax!info-c@BRL-SMOKE.ARPA
From: Jerry Fountain <pnet01!gof@NOSC.ARPA>
To: crash!noscvax!info-c@BRL-SMOKE.ARPA
Subject: swap()
     
     
A pair of easy swap(x,y) routines that uses *No* temporary
storage can be seen below:
     
#define swap(x,y)   (y^=(x^=(y^=x)))
     
int swap_all(x,y,size)
     
    char  *x,*y;
    int   size;
     
{   int   count;
    for (count = 0 ; count < size ;count++)
       swap(x[count],y[count]);
    return(count);
}
     
     
It works quickly and, if used with the function, can swap any
size or type data area.  For simple int or long types the macro
will work fine as long as you avoid the usual problems such as
swap(a++,y++)   or anything similar.  A normal call to the
function to swap two arrays might be:
     
     float  first[100], second[100];
             .
         .
         .
     swap_all(first,second,sizeof(first));
             .
         .
     
     
It is a good idea that the sizeof() argument be the smaller of
the two areas to avoid swapping to much data.
---------------------------------------------------------------------
Jerry Fountain  (crash!gof@noscvax.ARPA)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8568
          for JMS@ARIZMIS; Sun, 29-JUN-1986 14:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007393; 28 Jun 86 13:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002019; 28 Jun 86 12:33 EDT
From: Neal Ziring <nz%wucs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: pointers to functions
Message-ID: <1688@wucs.UUCP>
Date: 26 Jun 86 02:06:53 GMT
Keywords: can you cast them?
Posted: Wed Jun 25 22:06:53 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <237@killer.UUCP> toma@killer.UUCP (Tom Armistead) writes:
 > The delima - Is it possible to cast a 'pointer to' a function?
 > What I have is a char * that holds the address of a function.
 > int    foo();
 > char    *addr = foo;
 > Would it be possible to call the function foo() via the variable addr?
     
Not sure about this, but I think
                  i = ( int (*)())addr(arg1,arg2,arg3);
will work.
     
 > Secondly is it possible to have an array of type 'pointer to' function.
 > i.e.
 > int  (*function)()[SIZE];
 > something like the above, I was able to achieve this using this:
 > struct    fct {
 >             int  (*func)();
 >             } f_array[SIZE];
 > Is there another way???
     
Yes, you can declare the array directly, and even initialize it.
     
int do_err();
int do1();
int do2();
     
int (*f_array[])() = { do_err, do1, do2 };
     
     
 > Thanx in advance for **ANY** help,
 > - Tom
     
Get cdecl!  That is the program I used to get the declarations above.
It is a neat program that translates between ~English and C declarations.
     
--
...nz (Neal Ziring at WU ECL  -  we're here to provide superior computing.)
     
    {seismo,ihnp4,cbosgd}!wucs!nz   OR   nz@wucs.UUCP
     
    "You could get an infinite number of wires into this !*$$#!?! junction
                         box, but we usually don't go that far in practice"
                --   Employee of London Electricity Board, 1959

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7943
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006729; 28 Jun 86 12:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000641; 28 Jun 86 11:49 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Precedent for use of =
Message-ID: <445@cbmvax.cbmvax.cbm.UUCP>
Date: 24 Jun 86 17:22:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Here is where you will, with some, `run into a brick wall' (as they
> never did say in Bree).  Some will claim that it *is* broken,
> because people do at times write
>
>     if (var = expr) ...
>
> when they in fact meant
>
>     if (var == expr) ...
>
> As for myself, I believe that anyone can do bad things in any
> language (includin' English like I's a-doin' right here now right
> before your very own eyes doncha know :-) ), and that the proper
> measure of a language is not how difficult it makes writing bad
> code, but rather how easy it makes writing good code.
> --
I could just as easily write in PASCAL, M2, or ADA
     
   IF var := expr THEN ...
     
when I mean
     
   IF var = expr THEN ...
     
Of course the compiler will flag me about this, but what I get for that
compiler error message is the loss of my assignment OPERATOR, replaced
by a special case of assignment, the assignment STATEMENT.  Certainly there
may be less chance of error with the PASCAL style arrangement, at least
for beginners.  But I KNOW C, and even at 4:00 AM I don't think I've made
the assignment/comparison transposition error for a few years.  But I use
assignment as an operator ALL THE TIME.  The PASCAL syntax is like much
about PASCAL versus C; PASCAL forces you into a limited means of expression
in return for catching your errors for you.  This is like giving a dull
scalpel to a surgeon; he can't cut himself with it.
     
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
> UUCP:    seismo!umcp-cs!chris
> CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
   A quote usually goes here, but its currently being rennovated.
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8482
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007381; 28 Jun 86 13:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001931; 28 Jun 86 12:31 EDT
From: Dwight Wilson <ecf_bdw%jhunix.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Fun with & and *
Message-ID: <3082@jhunix.UUCP>
Date: 26 Jun 86 20:19:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
In a previous article I wrote that one could use the macro:
     
     #define pointer_to(X)  X *
     
in order to allow declarations of the form
     
     pointer_to(float)  x;
     
There are a couple more things I would like to say about this.
     
First, this will work on more complicated expressions, not just
the basic types.  For instance you could declare
     
     
     pointer_to(struct treenode {
                   int                         nodelabel;
                   pointer_to(struct treenode) right;
                   pointer_to(struct treenode) left;
                })  head;
     
this is the same as
     
     struct treenode {
               int nodelabel;
               struct treenode *right;
               struct treenode *left;
             }  *head;
     
Let's not get into an argument over which is better, I prefer the
second form myself, but can easily understand why some people would
like the first one.
     
     
Finally, the use of this macro is not limited to declarations.
Suppose we have defined the treenode structure as above.  We could
the write:
     
   newnode = (pointer_to(struct treenode)) malloc (sizeof (struct treenode));
     
instead of
     
   newnode = (struct treenode *) malloc (sizeof (struct treenode));
     
Again, which form to use is a matter of personal taste.
     
                                                          -Dwight

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9346
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007889; 28 Jun 86 13:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002750; 28 Jun 86 12:59 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: #if foo vs #if defined(foo)
Message-ID: <1063@watmath.UUCP>
Date: 27 Jun 86 19:46:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Our compiler does not need a defined(), or at least I did not try whether
> it is even accepted.  The following example works fine:
>
> #if squat||foo
> int yes;
> #else
> int no;
> #endif
> main() {}
     
A CPP which silently takes undefined symbols to be 0 can be quite
dangerous.  Consider the following case with these definitions
in a header file.
     
#define squat 10
#define foo 3 /* set to 0 if we don't want to process foos */
     
Now foo is defined and things work just the way they were intended to.
But suppose a year later, a change must be made because in a completely
different section of code we now want to handle dynamic foos, and so
the definition of foo can no longer be a fixed 3, but must be
#define foo (3*y)
extern int y;
where "y" is an external int which either contains 0, 1, 2, or 3.
Now to the person making this change there doesn't seem to be anything
wrong with it, as he is innocently unaware of the "#if squat||foo"
buried thousands of lines of code away.  But what happens when CPP
processes this "#if squat||foo" line?  CPP will expand this to
"#if squat||(3*y)".
A broken CPP, such as was recommended, would decide that the undefined
token "y" should be 0 and thus produce the "no" case regardless of the
value of the external int "y".  This is clearly not what the person
making the change wanted to happen, nor is it what the person originally
writing the "#if" wanted to happen.  How long will it be before this
newly introduded bug is detected, and how long will it take for someone
to figure out what has gone wrong?  Possibly a long time if this "#if"
is in a seldom-used section of code.
     
A reasonable CPP would would have issued an error that the token "y"
is undefined.  The problem would have been detected almost immediately
and certainly before anything was installed since the code no longer
compiles.  It would have shown where the problem was, and it would
have been trivial for the person making the change to turn the
"#if" into a "if(".  (Well not in this case since the "int no" isn't
executable, but you get the idea I hope.)
     
I think the effort of having to use "#ifdef x" or "#if defined(x)"
instead of lazily using "#if x" is well worth it.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8271
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:01 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007085; 28 Jun 86 12:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001361; 28 Jun 86 12:14 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Casting a postdecrement operand
Message-ID: <815@steinmetz.UUCP>
Date: 24 Jun 86 19:39:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1295@ulysses.UUCP> jss@ulysses.UUCP (Jerry Schwarz) writes:
>>
>> The variable 'cbap' is a pointer. The cast '(struct abc *)' is a
>> pointer cast. I can use '((struct abc *)cbap)' with indirects and
>> subscripts and anywhere that I can use an Lvalue, so I really believe
>> that the expression is legal.
>>     -bill davidsen
>
>Being a pointer value is not the same as being an lvalue. The places
>that require lvalues are left hand side of assignments, and operands
>of the increment and decrement operations. In none of these locations
>is '((struct abc*)cbap)' legal.
     
>> subscripts and anywhere that I can use an Lvalue, so I really believe
                         ^^^^^^
A thousand pardons! I was thinking about Lvalues, and wrote Lvalue
where I meant "address value". The point I was making (trying to amke)
was that the result of the cast operation is legen *in* an Lvalue,
where a pointer would be, not that I thought it was an Lvalue as is.
  Example:
    *((float *) ptr) = 4.5; /* ptr is char * type */
     
The other question was the legality of a cast on increment, and rather
than read books and standards, I actually tried it, based on the theory
that what happened in most places is "current practice". So far I have
found 3 of seven compilers which compile code for
  ((float *) ptr)++; /* ptr type is char * */
so I make no claims one way or the other.
     
NOTE: I am not claiming that either of these is portable or useful, but
that's not the same thing as valid. Current practice is why enums are
done as integers rather than being truly a distinct data type. They
were added because the preprocessor ran out of symbol space as far as I
know.
     
Thanks to the people who pointed out the poor explanation in the
earlier posting. All were polite except one jerk who sent six screens
of flames and a ficticious .signature at the end. I hope this didn't
confuse anyone.
--
    -bill davidsen
     
  ihnp4!seismo!rochester!steinmetz!--\
                                       \
                    unirot ------------->---> crdos1!davidsen
                          chinet ------/
         sixhub ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9252
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:01 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007734; 28 Jun 86 13:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002683; 28 Jun 86 12:57 EDT
From: flaps%utcs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: microsoft C considered stupid
Message-ID: <1986Jun26.05:21:07.10111@utcs.uucp>
Date: 26 Jun 86 09:21:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
In article <1986Jun20.01:10:46.477@utcs.uucp> I write words which I have come
to eat, namely that microsoft is to blame for adding #if defined(macro_name) to
C and that this is a useless extension.  Uncomfortably many people have pointed
out to me that microsoft did not in fact make the addition and that it is in
fact useful for compound conditions.
     
In article <1566@brl-smoke.ARPA> gwyn@brl.ARPA calls me "ignorant" and
observes that "It is not clear that Rosenthal *has* learned C" and seems not
to understand my complaint about the manual section concerning struct
declarations explained below.  (The other flamers were polite.)  He also
explains that it is #if defined(macro_name) rather than (manifest_constant).
I believe that the microsoft manual is in error here, but I forgot to check
this earlier this evening.
     
What I did check from the microsoft manual (Microsoft C Language Reference,
copyright 1984, 1985 by Microsoft Corporation, document number 8416L-300-00),
is their explanation of the struct declaration.  On page 57 they offer the
following two syntaxes for struct declarations:
     
   struct [tag] {member-declaration-list} declarator [, declarator...];
   struct tag declarator [, declarator...];
     
Now neither one of these can generate the frequent declarations of the form:
     
    struct record {
        char data[80];
        struct record *next;
    };
     
, as this is missing a non-optional "declarator".  Almost needless to say,
this ridiculous restriction is not actually enforced by the compiler.
However, on page 59 there are five examples none of which involves a style
similar to my struct record declaration above, so it would appear that the
writers of the manual are unaware of this syntax or have ulterior motives
for not writing it down.
     
On page 55, enum declarations are defined in exactly the same way which I
believe is equally erroneous.
     
Furthermore, I believe that it would be a big mistake to remove #ifdef from
the language, because it is still being widely used, and unlike the reserved
word question (if you add reserved words to the language you restrict it, in
a sense), removing #ifdef would allow no new programs (such as, for example,
removing 'entry' would, because you could then call a variable 'entry').
     
--
Alan J Rosenthal
{decvax|cbosgd|linus}!ihnp4!utcs!flaps, utzoo!utcs!flaps

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9609
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:01 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028583; 25 Jun 86 22:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000696; 25 Jun 86 21:47 EDT
From: latham%bsdpkh.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: pointers to functions
Message-ID: <214@bsdpkh.UUCP>
Date: 24 Jun 86 07:11:07 GMT
Keywords: can you cast them?
To:       info-c@BRL-SMOKE.ARPA
     
In article <237@killer.UUCP> toma@killer.UUCP (Tom Armistead) writes:
>The delima - Is it possible to cast a 'pointer to' a function?
>
>What I have is a char * that holds the address of a function.
>int    foo();
>char    *addr = foo;
>Would it be possible to call the function foo() via the variable addr?
>
>Secondly is it possible to have an array of type 'pointer to' function.
>i.e.
>int  (*function)()[SIZE];
>something like the above, I was able to achieve this using this:
... etc
>Thanx in advance for **ANY** help,
>
>Tom Armistead
     
FIRST, char *addr = foo;  is a BAAADDDD idea! and NO you can't call foo with it
   ( well you can but .... )
     
Try,
    int (* addr)() = foo;
     
or in general :
     
    int (* funcptr)();
     
SECOND an array of such pointers is declared :
     
    int (* funcptr[])();
     
    (* funcptr[])  being an array of pointers;
    (* funcptr[])()  ... to functions;
    int (* funcptr[])(); returning an integer;
     
A BETTER IDEA is to declare 'funcptr' as a type
     
    typedef int (* funcptr)();
     
then use it ...
     
    funcptr foo[1028];
     
This is much clearer.
     
incidentally,    ( (int *())addr)();  would do it     (I think?)
     
     
            Ken Latham, AT&T-IS (via AGS Inc.), Orlando , FL
     
            uucp: ihnp4!bsdpkh!latham

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8704
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:02 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/28/86 at 18:03:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007413; 28 Jun 86 13:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002149; 28 Jun 86 12:37 EDT
From: Michael Meissner <meissner%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Header file strings.h
Message-ID: <421@dg_rtp.UUCP>
Date: 26 Jun 86 15:25:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <240@killer.UUCP> tad@killer.UUCP (Tad Marko) writes:
>
>I use the functions quite often, but the header file for MSC is string.h.
>I recently ported a program from MSC to an NBI 4044 running 4.2BSD, and the
>only change necessary was to change
>
>#include <string.h>
>
>to
>
>#include <strings.h>
>
>everything worked fine after that.  Perhaps this and several other MSC
>differences are the result of it complying to the new ANSI C standard?
     
    It goes back a little further than ANSI & BSD.  In the ongoing war
to make System V & BSD mutually incompatible {1/2 -) I guess}, BSD systems
define the string functions in <strings.h>, and System V (and probably
System III before it) use <string.h>.  The ANSI committee started with
one of the /usr/group working documents.  The /usr/group standard was
originally based upon System III.  The time line looks somewhat like:
     
    v7
    |\
    | \-----------------------------------------------------\
    |                            |
    System III-----\                    BSD 4.1
    |        \                    |
    |        /usr/group starts-------\        BSD 4.1{a,b,c}
    |        |            |        |
    System V\    |            ANSI starts    |
    |    |    |            |        BSD 4.2
    |    |    /usr/group 1st std.    |        |
    |    |    |            |        |
    |    \-------/usr/group continues    |        |
    |        |            |        |
    System V.2    becomes IEEE P1003    issues 4/30/85     |
    |        |            public bulletin    |
    SVID----\    |            |        |
    |    |    issues P1003.1        |        |
    |    X/OPEN    |            |        |
present    ...        ...            ...        ...
    |        |            |        |
future    System V.3    revisied std?        public review    BSD 4.3
    (ships?)                (Sept 1986?)    (ships?)
     
     
* Note, the time line is distorted somewhat.
     
    Michael Meissner
    Data General
    ...{ decvax, ucbvax, inhp4 }!mcnc!rti-sel!dg_rtp!meissner

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8312
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:03 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007094; 28 Jun 86 12:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001576; 28 Jun 86 12:20 EDT
From: Bob Devine <devine%vianet.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C types cheat sheet
Message-ID: <13@vianet.UUCP>
Date: 26 Jun 86 00:20:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
  Here is a table of how to interpret C declarations.  It lists the
possible combinations of arrays, pointers, and functions for up to
three choices.  It also shows what combinations are illegal.
     
  I'm posting this because I found it helpful, in its side-by-side display,
in explaining tricky declarations (ie, int (*paf)[](); versus int (*apf[])();)
for those times when talking it through doesn't help.  Let me plug Chris Torek's
cdecl program: use of it helps show people how C constructs a declaration.
     
  This listing came from Joe Treat.  Where he got it is unknown.
     
Bob Devine
------------------------ cut here ----------------------------------------
int i;        /* integer */
int *p;        /* pointer to integer */
int a[];    /* array of integer */
int f();    /* function returning integer */
     
int **pp;    /* pointer to pointer to int */
int (*pa)[];    /* pointer to array of int */
int (*pf)();    /* pointer to function returning int */
int *ap[];    /* array of pointer to int */
int aa[][];    /* array of array of int */
int af[]();    /* array of int functions (ILLEGAL)*/
int *fp();    /* function returning pointer to int */
int fa()[];    /* function returning array of int (ILLEGAL)*/
int ff()();    /* function returning function returning int (ILLEGAL)*/
     
int ***ppp;    /* pointer to pointer to pointer to int */
int (**ppa)[];    /* pointer to pointer to array of int */
int (**ppf)();    /* pointer to pointer to function returning int */
int *(*pap)[];    /* pointer to array of pointer to int */
int (*paa)[][];    /* pointer to array of array of int */
int (*paf)[]();    /* pointer to array of function returning int (ILLEGAL)*/
int *(*pfp)();    /* pointer to function returning pointer to int */
int (*pfa)()[];    /* pointer to function returning array of int (ILLEGAL)*/
int (*pff)()();    /* pointer to function returning function returning int
(ILLEGAL)*/
int **app[];    /* array of pointer to pointer to int */
int (*apa[])[];    /* array of pointer to array of int */
int (*apf[])();    /* array of pointer to function returning int */
int *aap[][];    /* array of array of pointer to int */
int aaa[][][];    /* array of array of array of int */
int aaf[][]();    /* array of array of function returning int (ILLEGAL)*/
int *afp[]();    /* array of function returning pointer to int */
int afa[]()[];    /* array of function returning array of int (ILLEGAL)*/
int aff[]()();    /* array of function returning function returning int
(ILLEGAL)*/
int **fpp();    /* function returning pointer to pointer to int */
int (*fpa())[];    /* function returning pointer to array of int */
int (*fpf())();    /* function returning pointer to function returning int */
int *fap()[];    /* function returning array of pointer to int (ILLEGAL)*/
int faa()[][];    /* function returning array of array of int (ILLEGAL)*/
int faf()[]();    /* function returning array of function returning int
(ILLEGAL)*/
int *ffp()();    /* function returning function returning pointer to int
(ILLEGAL)*/
int ffa()()[];    /* function returning function returning array of int
(ILLEGAL)*/
int fff()()();    /* function returning function returning function returning
 int (ILLEGAL)*/

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8094
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006885; 28 Jun 86 12:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000934; 28 Jun 86 12:00 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: SWAP macro (utter insanity+interesting question)
Message-ID: <844@bu-cs.UUCP>
Date: 25 Jun 86 05:47:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
The attached bit of total brain-damage seems to do the job in YAW (yet
another way.) I don't actually proffer it as a solution that you might
use, no way, don't bother...BUT
     
Interesting question:
     
What is the semantics of:
     
        sizeof(*ip++)
     
?? Try it before you guess, I was shocked (late entry for the
obfuscated C contest??) The semantics I found are essential for
my solution.
     
P.S. It compiled and ran correctly on (code follows):
     
    Hardware    OS        Software    Notes
    --------    ---        --------    ---------------
    SUN3/180    UNIX4.2 R3.0    PCC
    DEC2060        TOPS-20 5.4    MIT/PCC        provided bcopy()
    ATT/3B5        UNIX SYSVR2    C        used memcpy()
    IBM3090/200    VPS/VM        PCC        provided bcopy()
    Encore/MultiMax    UNIX 4.2    PCC
    VAX/750        UNIX 4.2    PCC
    VAX/780        VMS4.3        VMS/C        provided bcopy()
    Celerity/1200    UNIX 4.2    PCC
    DG MV/10000    AOS/VS 6.03    MVUX 2.01/C    used memcpy()
     
I also tried it on the SUN, DEC2060, IBM3090, MV10000 and VAX750 with
double's instead of ints and it compiled and worked fine, I don't have
the energy right now to go through all the others, requests accepted.
     
It also passes lint.
     
YOW, am I portable yet?
     
    -Barry Shein, Boston University
____________
#include <stdio.h>
     
#define swap(x,y) \
     { \
       char t1[sizeof(x)], t2[sizeof(t1)]; \
       char *p, *q; \
 \
       p = (char *) &(x); \
       q = (char *) &(y); \
       bcopy(p,t1,sizeof(t1)); \
       bcopy(q,t2,sizeof(t1)); \
       bcopy(t2,p,sizeof(t1)); \
       bcopy(t1,q,sizeof(t1)); \
     }
     
main(argc,argv) int argc; char **argv;
{
  int ai[2], *ip = ai;
  int bi[2], *ip2 = bi;
     
  ai[0] = 1;
  ai[1] = 2;
  bi[0] = 3;
  bi[1] = 4;
  swap(*ip++,*ip2++);
  printf("ai[0] = %d *ip = %d bi[0] = %d *ip2 = %d\n",
     ai[0], *ip, bi[0], *ip2);
  exit(0);
}
     
Should print out something like:
     
ai[0] = 3 *ip = 2 bi[0] = 1 *ip2 = 4
     
If I said I used memcpy() I added:
     
#define bcopy(x,y,z) memcpy(y,x,z)
     
If I said I provided bcopy() I added:
     
bcopy(from,to,n) char *from, *to; int n;
{
    while(n--) *to++ = *from++;
}

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7573
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025207; 26 Jun 86 18:33 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a029546; 26 Jun 86 17:31 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA01014; Thu, 26 Jun 86 17:30:10 edt
Date: Thu, 26 Jun 86 17:30:10 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606262130.AA01014@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, utzoo!henry@seismo.css.gov
Subject: Re: Nonsense in BYTE reader columns
     
> > ...[redefining C syntax with macros]... The
> > point wasn't that you SHOULD do things this way, but that you COULD.  And
> > there's nothing wrong with someone programming that way, if it increases
> > their efficiency and doesn't hinder the quality of the code...
>
> Provided that they realize that they're easing their own learning process
> a bit (c'mon, guys, how long does it take competent people to learn how
> to write "{}" and "=="?) ...
     
That's not the point. The one statement model is a deficient one. If braces
were always required, the difference would be syntactic only. The attempt
was to make C more robust by limiting the possibility of error.
     
> ... at the price of having their own private dialect of C.
> In a more general context, yes there *is* something wrong with it:
> the result will be less intelligible to experienced C programmers, should
> they happen to hire any;
     
Who are we kidding? If you can read one dialect, you can read them all,
at least any reasonable attempt. Everyone's personal style creates
another `dialect' if you will. It's not that big of a deal.
     
> existing C-oriented tools probably will not work on it;
     
You have a point here. However, maybe the tools should be table driven.
     
> if they ever start mixing it with normal C they'll have real fun;
     
Yes and no. While it is often claimed that one should be consistent in
one's coding style, often several people (including later incarnations
of yourself) work on a program or project. If you modify your old code
do you slip back into the bad habits you grew out of?
     
> if they ever start having to look at normal C they won't know how to cope.
     
People who have enuf gumption to attempt to change things will also have
enuf smarts to make the adjustment. Really now, Henry, you have such a
dim view of people's capabilitys. Do you suggest that Bourne can't
read vanilla C?
     
> When I first encountered C, about eleven years ago, I did something quite
> similar.  I eventually gave it up.  The benefits were superficial and
> the compatibility hassles weren't worth it.
     
I would agree with the first point here. In the end, it is a big pain to
maintain a whole other set of standards that mean little to anyone but
oneself. On the other hand, one must please oneself.
     
> > ...If you prefer "real" C, just run the other person's program
> > through a selective preprocessor...
>
> How do I run it back again when I want to give my improvements back to him?
     
You tell him what a jerk he is for not using your style in the first place :-)
You scored another point. Perhaps you hand tailor your patch for this guy.
Perhaps you replace the entire function. Perhaps you make him do it.
Or perhaps, if you are civic minded, you write an inverse translator.
     
> For that matter, how do I apply a patch he sends me?
     
Run the patches thru the preprocessor.
     
> > That's one of the really wonderful things about C: the
> > preprocessor.  Why not use it?
>
> Because it can make things harder just as readily as it can make things
> easier.  See the Obfuscated C Contest for some exaggerated but telling
> examples.  Knowing how to use a nifty facility is easy; knowing when *not*
> to use it is harder but more important.
     
Using the OCC as an example proves nothing. The spirit is completely
different. I agree that the power inherent in CPP tempts one to toy
with the language definition. Usually, people do what they think will
add to the clarity and robustness of their work.
     
> Usenet(n): AT&T scheme to earn
> revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
> late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry
     
 I like your signature lines. Hope you like Zippy's.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
Here I am at the flea market but nobody is buying my urine sample bottles..

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9190
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:07 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007723; 28 Jun 86 13:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002646; 28 Jun 86 12:55 EDT
From: Larry Wall <lwall%sdcrdcf.uucp@BRL.ARPA>
Newsgroups: net.lang,net.text,net.lang.c
Subject: Re: Cute little liar program (for hackers only)
Message-ID: <2860@sdcrdcf.UUCP>
Date: 27 Jun 86 19:26:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <301@zuring.UUCP> dik@zuring.UUCP (Dik T. Winter) writes:
> This brings on another question.  Is it possible to create non-trivial
> input to {t,d}itroff that reproduces itself?  (By non-trivial I mean
> it should contain at least one line starting with period or apostrophe,
> because, as a silly co-worker pointed out to me, the empty file
> reproduces itself.  Also .sy should not be permitted.)
     
Well...
     
I took this as a challenge, and wrote something that may do what you want.
I don't have {t,d}itroff real handy, but I did come up with a self-reproducing
nroff script, so you might try it out with {t,d}itroff and see if it works.
Not only was it NOT trivial, it was durn near impossible!  I had to get rather
devious.  If there's an Obfuscated Nroff Code Contest in the near future,
consider this my entry for it.
     
Since there may be some people who wouldn't try doing this until they find
out that it IS possible, I'll just say to them that it is.  Have fun.  So that
I don't spoil their fun, the one I wrote follows both in uuencoded and rot13
format for those who aren't interested in trying to solve the problem
themselves.  I had another version that used '.eo' to reduce the number of
escape characters, but it came out to the same number of bytes, and more lines,
so I won't post it.  If anyone can shorten this one, they're welcome to try.
To run this,
     
    uudecode this_article
    nroff self.n >self.out
    cmp self.n self.out
     
(By the way, I leave you with the challenge to make a C/nroff program that
compiles without error and prints out "hello world\n" either way.  Yes, it
can be done.  If anything it's easier than the self-reproducer, but that's
not saying much.  Definitely an AHA! type problem.)
     
Larry Wall
sdcrdcf!lwall
     
THE UUENCODED VERSION:
     
begin 664 self.n
M+F5C.`HN96U:6@HN;G)Y>3$P,#`M,3(*+FYR>GHQ,#`M,0HN;F8*+F1E6%@*
M+G1R.#AN*'EY"C@X(3@X(3@X)#$*+G1R.#AN*'IZ"BYA;5I:+BX*.#@A.#@A
M+EA8.#@D,0HN;G)N;#`M,0HN+BX*+BX*+EA8+F5C.0HN6%@N96U:6@HN6%@N
M;G)Y>3$P,#`M,3(*+EA8+FYR>GHQ,#`M,0HN6%@N;F8*+EA8+F1E6%@*+EA8
M+G1R.3EN*'EY"BY86#DY(3DY(3DY)#$*+EA8+G1R.3EN*'IZ"BY86"YA;5I:
M+BX*+EA8.3DA.3DA+EA8.3DD,0HN6%@N;G)N;#`M,0HN6%@N+BX*+EA8+BX*
`
end
     
(***SPOILER WARNING***)
Reading the ROT13 version may give you clues you don't want, despite the
encryption.

THE ROT13 VERSION:
     
Abgr gung gur frpbaq unys vf vqragvpny gb gur svefg unys, jvgu gur
rvtugf genafyngrq gb avarf naq n .KK cercraqrq.
     
.rp8
.rzMM
.aell1000-12
.aemm100-1
.as
.qrKK
.ge88a(ll
88!88!88$1
.ge88a(mm
.nzMM..
88!88!.KK88$1
.aeay0-1
...
..
.KK.rp9
.KK.rzMM
.KK.aell1000-12
.KK.aemm100-1
.KK.as
.KK.qrKK
.KK.ge99a(ll
.KK99!99!99$1
.KK.ge99a(mm
.KK.nzMM..
.KK99!99!.KK99$1
.KK.aeay0-1
.KK...
.KK..

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1063
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:08 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 06/28/86 at 23:45:55 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Mon 23 Jun 86
  20:11:19-PDT
Received: from virginia by csnet-relay.csnet id ab23140; 23 Jun 86 23:08 EDT
Received: by uvacs.UUCP (4.12/5.1.UVA)
    id AA21677; Mon, 23 Jun 86 09:39:10 edt
Posted-Date: Mon, 23 Jun 86 09:34:42 edt
Received: by edison.UUCP (4.12/5.6.edison)
    id AA04569; Mon, 23 Jun 86 09:34:42 edt
Date: Mon, 23 Jun 86 09:34:42 edt
From: John Owens <edison!jso%virginia.csnet@CSNET-RELAY.ARPA>
Message-Id: <8606231334.AA04569@edison.UUCP>
Subject: Re: main() and entry points in C
Newsgroups: mod.computers.vax
To: info-vax@SRI-KL.ARPA
Cc: LEICHTER-JERRY@YALE.ARPA
References: <8606180820.AA08276@ucbvax.Berkeley.EDU>
     
--  So I pulled out my 4.2bsd documentation and checked out ld.  It says this:
--
--      [In the command description]  The entry point of the output is the
--      beginning of the first routine (unless the -e option is specified).
--
--      [The description of -e]  The following argument is taken to be the
--      name of the entry point of the loaded program; location 0 is the
--      default.
--
--  Note that these two statements are not obviously consistent [....]
--  the "first routine" would have to be at 0, hence its address would be
--  at 0 - but that's NULL!)  Nor do they account for main().  I see no
--  reference at all to _start().
     
Your 4.2bsd documentation set (if you got it from Berkeley) refers to
VAXen only, where the first routine *is* at location 0; the loader
just loads sequentially.  (C does *not* guarantee that address 0
doesn't contain anything, but that's another discussion.)  The loader
itself knows nothing about main or start; those are features of C, and
have nothing to do with any other language that ld might load.  You
just might be writing in assembler....
     
--  Since you mentioned System V, I checked some AT&T 3B2 ld documentation I
--  have here.  The only references to the entry point are as follows:
--                [....]
--  Again, no reference to _start() - or to what the entry point would be if
--  -e were left out.  The documentation of the cc command doesn't say either.
--  But note that your "simple" example, and hardwired entry point, are
--  apparently NOT ld's doing, but cc's!
     
The documentation seems to be lacking here.  (I've never been very
fond of ATTIS's rewritten documentation.)  The definition of the C
language really does require that main be the starting point; I
suppose that didn't need to be part of the man page.  start is not a
user-visible feature, and certainly doesn't have to have that name.
The hardwired entry point is a ld feature; the reference to main a
feature of C.  Nonetheless, the entry point will still be the first
routine.  Read on....
     
--  I tried your little foo program out on our local Celerity (4.2bsd).
--  "cc foo" produces "Undefined: _main", and running the resulting a.out
--  produces an immediate "Invalid address".  However, a foo.o gets left
--  around.  So I did an "ld foo.o".  This led to "Undefined: _printf".
     
When cc invokes ld, it looks something like this:
    /bin/ld /lib/crt0.o foo.o -lc        [-X flags and such left off]
The crt0 file is loaded at address 0, and refers to main and exit.
foo.o must satisfy main, and /lib/libc.a will satisfy printf and exit.
     
--  Well, getting there.  I tried
--  "ld foo.o /lib/libc.a".  No errors!  Running a.out produces "Hello world",
--  followed by an access violation.  Adding an explict exit(0) fixes that.
     
This is certainly not supported.  You were lucky.  It's dependent on
the implementation of the exec(2) system call whether or not you'll
get your command line arguments this way.
     
--  [...] but are you
--  still going to bet that the first routine WON'T end up as the entry point?
     
I won't bet on anything if the loader isn't invoked properly....
     
--  At worst, I was claiming that a lot of non-portable C code got written
--  under Unix (since K&R certainly contains nothing to indicate that
--  there can be an entry point other than main()).  And if you don't
--  believe THAT, then you haven't looked at much Unix code.
     
That code you've been looking at is going to have a hard time being
ported to most UNIX systems then, much less any other system with a C
compiler.  I've been porting, adapting, and randomly mangling C code
for UNIX from a variety of sources for years, and haven't run into a
single program that doesn't have an entry point of main().  Would you
refer me to such a program that I might have access to, like something
from USENET, a USENIX tape, or a System V or BSD distribution?
     
--                              -- Jerry
     
    John Owens @ General Electric Company
    edison!jso%virginia@CSNet-Relay.ARPA        [old arpa]
    edison!jso@virginia.EDU                [w/ nameservers]
    jso@edison.UUCP                    [w/ uucp domains]
    {cbosgd allegra ncsu xanth}!uvacs!edison!jso    [roll your own]
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7516
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/28/86 at 17:32:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024532; 26 Jun 86 17:37 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa28498; 26 Jun 86 16:46 EDT
Received: from LABS-B.BBN.COM by VGR.BRL.ARPA id aa03417; 26 Jun 86 16:40 EDT
To: cbosgd!std-c@ucb-vax.ARPA
cc: info-c@BRL.ARPA, rgenter@BBN-LABS-B.ARPA
Subject: making it easier to use unions
Date: 26 Jun 86 16:29:49 EDT (Thu)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
Message-ID:  <8606261640.aa03417@VGR.BRL.ARPA>
     
     Quite often, one will see a union used in a context similar to the
following:
     
    struct    device    {
        union    {
            unsigned short    _dr_word1;
            struct    {
                unsigned _dr_bit1  : 1;
                unsigned _dr_bit2  : 1;
                unsigned _dr_value : 3;
                unsigned       : 2;
                unsigned _dr_ctrl  : 1;
                unsigned _dr_val2  : 8;
            } _dr_w1;
        } _dr_u1;
     
        unsigned short    dr_data;
     
        union    {
            < another control word >
        } _dr_u2;
    };
     
followed by a whole bunch of #defines like:
     
    #define    dr_word1    _dr_u1._dr_word1
    #define    dr_bit1        _dr_u1._dr_w1._dr_bit1
    #define    dr_value    _dr_u1._dr_w1._dr_value
     
usually bracketed by a comment saying something about "making it easier to
access the bit fields."  The reason for using the union in the first place
is that you want to write your device driver in an obvious manner - if you
want to assert the 'bit1' bit in the first control register, you want to
say something like:
     
    dp->dr_bit1 = 1;
     
(we'll ignore the issue of bit-field ordering and portability for now) - yet
you have to actually write the control register as a word because it is a
write-only register and the only bit manipulation instructions your processor
executes are read-modify-write, causing you to keep a software copy of the
register.
     
     It would be nice if we could do away with the intermediate labels
on structures/unions used in this manner.  It seems to me that it
should be possible given the constraint that within the enclosing
context for the structure/union declaration in question, field names
must be unique.  In my mind, this is merely an extension of insisting
that field names within a structure/union declaration be unique.
     
     Using the above example, we could define 'struct device' as:
     
    struct    device    {
        union    {
            unsigned short    dr_word1;
            struct    {
                unsigned dr_bit1  : 1;
                unsigned dr_bit2  : 1;
                unsigned dr_value : 3;
                unsigned       : 2;
                unsigned dr_ctrl  : 1;
                unsigned dr_val2  : 8;
            };    /* <= note there is no label here */
        };        /* <= nor here */
     
        unsigned short    dr_data;
     
        union    {
            < another control word >
        };        /* <= nor here */
    };
     
Then if you had a variable 'dp' declared as (struct device *), you could
just reference dp->dr_bit1 directly, without going through all of that
#define nonsense and without saying dp->_dr_u1._dr_w1._dr_bit1.  Only objects
of type 'struct device' would be able to reference the fields 'dr_bit1', etc.,
without generating a warning ("warning: illegal member use: dr_bit1").
     
     Now, someone tell me why this would be bad to add to X3J11.  My
apologies if it has already been added; my copy is the April 30, 1985 draft
and I haven't incorporated the 9 articles worth of changes which were
posted a couple of months ago into it yet (1/2 :-).
     
(By the way, accessing device registers is not the only application for
using structures/unions as shown.  Other applications include protocol
implementations, and interpreting binary files with complex record formats.)
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8642
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007425; 28 Jun 86 13:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002158; 28 Jun 86 12:38 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: SWAP macro
Message-ID: <424@dg_rtp.UUCP>
Date: 26 Jun 86 21:53:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Schauble@MIT-MULTICS.ARPA (Paul Schauble)
> I've gotten lots of respones to my request for a form of the macro that
> would make
>   swap(*a++, *b++);
>  work.  Almost all of them missed the point.  The swap requires a
> temporary.  Generating that temporary requires knowing the type.
> Several of the solutions would work fine if *a and *b were int's, but I
> never said that.
     
Yes, you did say that.  Your original posting gave the code fragment as:
     
>     int *a, *b;
>     swap (*a++,*b++);
     
This leads to the reasonable assumption that you were talking about the
case where a and b are integers.  Especially when the arguments you
mention have side effects, a notoriously difficult problem.
     
I think it completely justified that readers would assume you were
asking if there was any way to write a swap macro that works in the
presense of side effects.  In fact, I don't really see any other
plausible interpretation of the original posting.
     
> Recall the my original message was posted as a justification for a
> typeof macro, akin to sizeof.  I find that the need to generate
> temporaries in a macro is not uncommon.  Unless one is willing to do a
> different version of the macro for each type, you need a way to generate
> a new variable of the same type as one of the macro args.  The language
> provides no way to do this.
     
True, it does not.  But your original article did not mention "sizeof",
nor "typeof", nor propose any extensions to C.  Nor did it reference any
articles that did these things.  In any event, C *would* allow a macro
such as
     
        swap(a,b,int)
        swap(c,d,struct s *)
     
like so:
     
        #define swap(a,b,type) \
        {   type t;\
            t=a; a=b; b=t;\
        }
     
The trick to supress side effects can also be done, if needed.
     
        #define swap(a,b,type) \
        {   typedef type tdtype;\
            tdtype t, *pa = &(a), *pb = &(b);\
            t = *pa; *pa = *pb; *pb = t;\
        }
or
        #define swap(a,b,type) \
        {   type t; type *pa = &(a); type *pb = &(b);\
            t = *pa; *pa = *pb; *pb = t;\
        }
     
Note that these swap macros can only handle types that have no postfix
operators (that is, no [] or ()).  A typedef name must be supplied for
such cases.  Note also that the usual shortcomings of such macros apply.
     
Lastly, the stated problem can be solved fairly portably *without*
typeof.  That is, a fairly portable swap macro which works even for
arguments of unknown types, and works even in the presense of
side-effects is possible.  In vanilla C yet.
     
        #define swap(a,b) \
        {   char t[sizeof(a)], *pa = (char *)&(a), *pb = (char *)&(b);\
            memcpy(t,pa,sizeof(a)); memcpy(pa,pb,sizeof(a));\
            memcpy(pb,t,sizeof(a));\
        }
     
Limitations:
  - The usual problems with this macro being a bracketed construct at
        top level.
  - The usual name-hiding problems.
  - a and b must be the same type, and can't be register or bitfield.
  - It had better be legal on your machine to cast a pointer to any type
        you intend to swap to a pointer to character, and this cast must
        yield a manipulable character pointer.
  - Moving data of any type with character operations must yield valid
        data.
  - memcpy had better be builtin (or a macro) or this will run slower
        than ... well, pretty slow anyhow.
     
You wouldn't catch *me* using this macro, but it *does* solve the
stated problem, fairly portably, without resort to typeof.
     
--
"Typeof?  We don't need no steenkeen typeof!"
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8353
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007106; 28 Jun 86 12:44 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001593; 28 Jun 86 12:21 EDT
From: "Joseph D. Shapiro" <shap%bunker.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: SWAP macro
Message-ID: <1212@bunker.UUCP>
Date: 26 Jun 86 12:37:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1577@brl-smoke.ARPA> Schauble@MIT-MULTICS.ARPA (Paul Schauble)
 writes:
>I've gotten lots of respones to my request for a form of the macro that
>would make
>  swap(*a++, *b++);
> work.  Almost all of them missed the point.  The swap requires a
>temporary.  Generating that temporary requires knowing the type.
>Several of the solutions would work fine if *a and *b were int's, but I
>never said that.
>
     
ok, then, how about
     
#define swap(x,y) \
    { \
        char * px = (char *)&(x); \
        char * py = (char *)&(y); \
        char t; \
        int i; \
        for (i=sizeof(x); i; i--) \
        { \
            t = *px; \
            *px++ = *py; \
            *py++ = t; \
        } \
    }
     
Note that the sizeof(x) is a compiler constant and will not generate any
code which might induce a side effect.
     
Also, no flames about using char pointers, please, such use is
guarenteed both in K&R and ANSI.
     
Let me also say that I am neutral on the typeof() debate, I did
this just for the challenge.
     
For the doubtful, here is a working program.  I have chosen x and y
to be structs to remove any (most anyway) doubt.  Program passes lint.
     
------ cut here ----
     
#define swap(x,y) \
    { \
        char * px = (char *)&(x); \
        char * py = (char *)&(y); \
        char t; \
        int i; \
        for (i=sizeof(x); i; i--) \
        { \
            t = *px; \
            *px++ = *py; \
            *py++ = t; \
        } \
    }
     
#define peek(exp) printf("%s(%d): %s == %d\n",__FILE__,__LINE__,"exp",exp)
     
struct sss
{
    int i;
    long l;
    char c;
} a,b, *pa, *pb;
     
main()
{
    a.i=1;
    a.l=2;
    a.c=3;
     
    b.i=11;
    b.l=22;
    b.c=33;
     
    peek(a.i);
    peek(a.l);
    peek(a.c);
    peek(b.i);
    peek(b.l);
    peek(b.c);
     
    pa= &a;
    pb= &b;
     
    peek(pa);
    peek(pb);
     
    swap( *pa++, *pb++ );
     
    peek(pa);
    peek(pb);
     
    peek(a.i);
    peek(a.l);
    peek(a.c);
    peek(b.i);
    peek(b.l);
    peek(b.c);
}
--
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
     
Joseph D. Shapiro            "He who hesitates
Bunker Ramo Information Systems         is lunch"
     
...ittatc!bunker!shap
...decvax!bunker!shap

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2496
          for JMS@ARIZMIS; Sun, 29-JUN-1986 15:16 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 06/29/86 at 00:26:17 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Wed 25 Jun 86 07:57:59-PDT
Date: 25 JUN 1986 10:59:22 EST
From: <LEICHTER-JERRY@YALE.ARPA>
cc: info-vax@sri-kl
Subject:  Re: main() and entry points in C
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
To: John Owens <edison!jso%virginia.csnet@CSNET-RELAY.ARPA>
In-Reply-To: John Owens <edison!jso%virginia.csnet@CSNET-RELAY.ARPA>, Mon, 23
 Jun 86 09:34:42 edt
     
In general, I agree with what you say.  A couple of small comments:
     
    C does *not* guarantee that address 0 doesn't contain anything, but
    that's another discussion.
C DOES guarantee that the integer constant 0, cast to any pointer type, will
never be equal to a pointer to any actual object of that type.  In principle,
the cast could change the bit pattern; it almost never does - certainly it
does not on a VAX.  Thus, _start == NULL.  Most users will never see this,
but an implementer of _start() would.  (Minor point, but the fact is there IS
an inconsistency - nothing keeps you from doing an extern void _start() and
looking at the resulting pointer.)
     
    --  Well, getting there.  I tried
    --  "ld foo.o /lib/libc.a".  No errors!  Running a.out produces "Hello
    --  world", followed by an access violation.  Adding an explict exit(0)
    --  fixes that.
     
    This is certainly not supported.  You were lucky.  It's dependent on
    the implementation of the exec(2) system call whether or not you'll
    get your command line arguments this way.
Actually, I've since been informed that, while argc is passed correctly, argv
is screwy and envp isn't there at all.
     
    --  [...] but are you
    --  still going to bet that the first routine WON'T end up as the entry
    point?
     
    I won't bet on anything if the loader isn't invoked properly....
That gets to the crux of things:  The "proper" way to invoke the loader is
undocumented - you must use cc.  How then do you deal with a program written
in multiple languages?  Basically, you ask a wizard....
     
I find it rather amusing that Unix, which (quite properly) argues for separate
modules with separate functions, and clean interfaces between them, glues the
loader and the C compiler together in a very ad hoc, undocumented way!  (Side
comment:  You at least understand what Unix is doing here.  I had a couple of
other correspondents on this issue who had no real idea what was going on, and
ended up effectively claiming that the loader really is part of the compiler.
If that's the case, (a) it's going to be very hard to deal with multiple
compilers, ever; (b) it becomes hard to justify why the loader doesn't do more
to help the compiler/user out - e.g., check for type clashes in external
function calls.  This would have been trivial to do if the implementers had
wanted to, with minimal overhead, and much faster than lint.  Yes, it would
have required additional facilities in C - argument definitions as in ANSI C -
but then the language, compiler, and loader were developed by the same people
at the same time.  As for those other correspondents, their lack of knowledge
didn't slow them down a bit in defending their incorrect religeous state-
ments....)
     
    --  At worst, I was claiming that a lot of non-portable C code got written
    --  under Unix (since K&R certainly contains nothing to indicate that
    --  there can be an entry point other than main()).  And if you don't
    --  believe THAT, then you haven't looked at much Unix code.
     
    That code you've been looking at is going to have a hard time being
    ported to most UNIX systems then, much less any other system with a C
    compiler.  I've been porting, adapting, and randomly mangling C code
    for UNIX from a variety of sources for years, and haven't run into a
    single program that doesn't have an entry point of main().  Would you
    refer me to such a program that I might have access to, like something
    from USENET, a USENIX tape, or a System V or BSD distribution?
If you read more closely what I said, you'll see that I didn't claim to have
any examples of this kind of thing...I just claimed that, somewhere out
there, they were likely to exist.  I know the people who did the VAX C com-
piler and run-time support, and they've tried really hard to be compatible
with Unix.  Unfortunately, that can be very hard to do, since Unix programs
make use of a lot of undocumented "features".  For example:  There is abso-
lutely nothing in any definition of C that says that in:
     
    f(a,b)
    int a,b;
    {    int *x;
     
        x = &a + sizeof(int);
        ...
    }
     
x will point to b.  In a field-test version of VAX C V2.0, this was NOT true.
(The VMS procedure-call spec says that the argument list is owned by the
CALLING procedure, which may place it in read-only memory, re-use it, etc.;
the CALLED procedure may only read it.  In that version of C, if you ever
took the address of a formal argument, the value passed was copied to a
temporary cell on entry, and the address you got was of the temporary.  As
far as documented C semantics are concerned, this is a completely correct
implementation - but it prevents you from screwing with the caller's argument
list.)  Anyway, cries of pain came from all over:  Despite the existence of
varargs - which WAS provided with that release, BTW - it turns out that there
are LOTS of C programs that assume you can scan through an argument list this
way.  So the final version of V2 put things back as they were, requiring a
waiver of conformance with this aspect of the procedure-call spec.  (As it
happens, VAX C (currently) always builds argument lists on the stack and then
discards them, so you can screw around to your heart's content - but try it
with a FORTRAN caller, and things get really weird....)
     
Anyway, given that Unix programmers have historically grasped at ANYTHING they
can find the least justification for in the documentation - or no justifica-
tion at all - "compatibility" has to mean "put in EVERYTHING you can, even if
you can't think of anyone who's using it.  Someone will come along who wants
it, some day...."  Since the "entry point is the first routine" IS, in fact,
documented - even if only for wizards! - supporting it couldn't hurt....
     
        John Owens @ General Electric Company
                            -- Jerry
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5925
          for JMS@ARIZMIS; Sun, 29-JUN-1986 21:26 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 06/29/86 at 01:53:52 CDT
Received: from USC-ISIF.ARPA by SRI-KL.ARPA with TCP; Wed 25 Jun 86 17:13:22-PDT
Date: 25 Jun 1986 16:34:45 PDT
Subject: Re: VT240 EMULATOR
From: Douglas M. Olson <dolson@USC-ISIF.ARPA>
To: <S211LAUW%HTIKHT5.BITNET@WISCVM.WISC.EDU>
cc: INFO-VAX@SRI-KL.ARPA
In-Reply-To: (Message from "<S211LAUW%HTIKHT5.BITNET@WISCVM.WISC.EDU>" of Fri,
  20 Jun 86 11:19 N)
     
Check the recently issued (July 86) Digital Review pages 105-108; they
ran a comparison against two 240-emulators for the IBM PC.  The
compared products are poly-COM/240 by Polygon, Inc, and SmarTerm 240
from Persoft Inc.  Review by Jeffrey Steinberg, extracted w/o
permission below:
     
"...allows the user of an IBM PC,XT or AT...with color graphics
adaptor, EGA or Hercules card...to emulate a VT240.  SmarTerm also
extends Tektronix 4010 and 4014 compatibility...Minimum hardware,
...256KB for poly-COM, 512KB for SmarTerm.  poly-COM ...640 x 200
pixels in high-res mode, 320 x 200 in medium res...SmarTerm can
display 256 x 800 pixels with the Hercules card, only 200 x 640 with
the IBM card.  File transfers...poly-COM, ascii and poly-XFR..
SmarTerm, ascii, xmodem, Kermit and PDIP.
...Setting up the operating environment is where the two products
differ the most: SmarTerm has a far more advanced and user-friendly
interface than poly-COM does.
     
...[massive cut here...lots of product-use details]...
     
"While both SmarTerm 240 and poly-COM/240 give the user the same VT240
emulation, SmarTerm 240's expanded file-transfer capabilities,
advanced user interface, programming ability and extensive online help
make this package a far superior terminal emulator."
     
Of course, in a neat little box beside  the article, the magazine
included a product description of poly-COM's latest and greatest,
poly-STAR.  I don't think the magazine reviewed the product, and I
question their including the sales claims of a product ("...poly-STAR
*will* support...poly-STAR *will* also allow...") next to their
careful product review.  But hey, thats THEIR integrity on the line,
what do I care.
     
I briefly used a previous incarnation of the Persoft product, called
SmarTerm 100 (one guess, folks...) and found it very nice.  I haven't
used either of the two reviewed products and sorry, have very little
interest in anything on a big blue machine these days...
     
One other note of interest: I have heard of a program termed CALL, a
terminal emulator for the IBM-PC, which currently does VT100 emulation
and which the author is upgrading to do 240 emulation.  The author is
Captain Rich Blomseth, *on active duty in the air force* and stationed
at HQ AFOTEC, Kirtland AFB, NM.  I believe that his intention is that
this be available to AF activities free-of-charge...possibly to
others.
     
Disclaimer: I have no financial, personal or other relationship with
the proprietors of these products or this magazine, etc, etc.
     
Doug (dolson @ Ada20.ARPA, soon-to-be @ Ada20.ISI.EDU)
-------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1110
          for JMS@ARIZMIS; Mon, 30-JUN-1986 09:04 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 10:57:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024488; 29 Jun 86 11:50 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a014408; 29 Jun 86 11:41 EDT
To: der Mouse <mouse%mcgill-vision.uucp@harvard.ARPA>
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: swap() macro
In-reply-to: Your message of 25 Jun 86 01:49:00 GMT.
         <444@mcgill-vision.UUCP>
Date: 29 Jun 86 11:40:38 EDT (Sun)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
One small problem: you forgot to increment t1 and t2 inside the for loop.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1347
          for JMS@ARIZMIS; Mon, 30-JUN-1986 09:15 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028411; 25 Jun 86 22:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000650; 25 Jun 86 21:46 EDT
From: Ben Cranston <zben%umd5.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <1048@umd5.UUCP>
Date: 24 Jun 86 18:11:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Paul Schauble <Schauble@mit-multics.arpa> asks:
> Can someone construct a version that makes
>     int *a, *b;
>     swap (*a++,*b++);
>> work right?
     
Steve Villee <ihnp4!mot!anasazi!steve> replies:
     
> #define swap(x, y) \
>   if (1) \
>   { \
>     register int *xp, *yp, t; \
>     xp = &(x); \
>     yp = &(y); \
>     t = *xp; \
>     *xp = *yp; \
>     *yp = t; \
>   } \
>   else
     
and goes on to site some special cases in which the "if" implementation
is a big win.  Other examples have also been given.
     
Since the original question was about swapping (int *)s, why do not the
given examples involve (int **)s, i.e. pointers to pointers to ints?
     
Nailing jelly to a tree again...
     
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2099
          for JMS@ARIZMIS; Mon, 30-JUN-1986 09:45 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 13:15:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026430; 29 Jun 86 14:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015531; 29 Jun 86 13:48 EDT
From: timg%mc0.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: LPow correction
Message-ID: <303@mc0.UUCP>
Date: 27 Jun 86 16:08:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1604@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>Jim Cottrell pointed out to me that 0^0 should be 1, not 0
>as I had it in my posted LPow() function.
     
     
    Sorry to bring it up, but Jim Cottrell is wrong, 0^0 is an indeterminate
form, as you will find by looking in any elementary calculus book (eg. Anton).
This form should be treated just as 0/0.
     
Tim Graham
Jet Propulsion Laboratory
(818) 577-6689

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2481
          for JMS@ARIZMIS; Mon, 30-JUN-1986 09:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 13:41:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026686; 29 Jun 86 14:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015759; 29 Jun 86 13:56 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  LPow correction
Message-ID: <2129@ihlpg.UUCP>
Date: 27 Jun 86 23:58:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>         limit of x^x as x->0+ is precisely 1,
>
> I hadn't thought of it that way. That's what's neat about the truth,
> it has so many ways of making itself known! As I also mentioned,
Truth?  What truth?  This isn't a truth, it's a consequence of the
definition of the system as self consistant.  1 + 1 = 2 is not truth
either, it is a definition from a number of integer addition systems.
If your going to talk mathese please avoid terms like truth and reality.
Neither of these concepts have any place in math.
>     (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
--j.a.tainter

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2666
          for JMS@ARIZMIS; Mon, 30-JUN-1986 09:56 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 13:56:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026716; 29 Jun 86 14:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015818; 29 Jun 86 13:58 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: pointers to functions
Message-ID: <1012@ttrdc.UUCP>
Date: 27 Jun 86 17:32:34 GMT
Keywords: can you cast them?
To:       info-c@BRL-SMOKE.ARPA
     
In article <1688@wucs.UUCP>, nz@wucs.UUCP writes:
     
>Get cdecl!
>It is a neat program that translates between ~English and C declarations.
     
Someone, please, tell me how I can go about getting cdecl for SysVR2.  Is
it available from mod.sources?  (Past queries to mod.sources have apparently
never reached the moderator.)  Or is it for sale (from whom?).  Thanks.
     
Dan.
ihnp4!ttrdc!levy

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2971
          for JMS@ARIZMIS; Mon, 30-JUN-1986 10:06 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 14:21:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027002; 29 Jun 86 14:48 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a016596; 29 Jun 86 14:43 EDT
Date:     Sun, 29 Jun 86 14:37:05 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Tainter <tainter%ihlpg.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  LPow correction
Message-ID:  <8606291437.aa05018@VGR.BRL.ARPA>
     
>>>    limit of x^x as x->0+ is precisely 1
> This isn't a truth, it's a consequence of the definition of the system
> as self consistant.
     
Fortunately I don't subscribe to the school of thought that says all
mathematics is simply rearrangement of symbols according to formal rules.
As a physicist/engineer, the above limit has real meaning for me.
So there.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3023
          for JMS@ARIZMIS; Mon, 30-JUN-1986 10:10 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 14:21:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026988; 29 Jun 86 14:48 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa16567; 29 Jun 86 14:43 EDT
Date:     Sun, 29 Jun 86 14:30:17 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Arthur David Olson <ado%elsie.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Failure of "long x(cp) char * cp; { return *((long *) cp); }" is
  a bug?
Message-ID:  <8606291430.aa04898@VGR.BRL.ARPA>
     
No, it's not a bug; interpreting an arbitrary address as that of a long
integer is simply meaningless on most machines (the VAX is a rare exception).
The machine code that uses such an address to reference a long integer
datum generally traps the operation as an error.
     
Moving the data somewhere else with an aligned address of course works;
but the compiler can't do that for you, since casting a pointer to
another type should not cause data movement.  The compiler is bound by
the spirit of C to do its best to perform exactly the operation you
specify, not to reinterpret it as something more complicated and then
shuffle things around "behind the scenes" to try to "help" you out.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2770
          for JMS@ARIZMIS; Mon, 30-JUN-1986 10:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 14:07:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026745; 29 Jun 86 14:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015851; 29 Jun 86 13:59 EDT
From: Jan Stein <jan%myab.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Winners of the 1986 International Obfuscated C Code Contest
Message-ID: <146@myab.UUCP>
Date: 28 Jun 86 02:01:11 GMT
Keywords: obfuscate,winners,1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
In article <3656@nsc.UUCP> chongo@nsc.UUCP writes:
>    Best one liner:
>    Join the 3 lines into one line.  Compile and link to the
>    filename 'a.out'.  Execute it the following 2 character
>    argument: ^M^L (Return/Formfeed).  Passes lint.
     
You get a better result if you compile and link to the filename
'timeinGMT'. Then execute it with:
     
    timeinGMT ; echo ''
     
-=-
    Jan Stein
  {seismo,okstate,garfield,decvax,philabs}!mcvax!enea!chalmers!myab!jan

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3359
          for JMS@ARIZMIS; Mon, 30-JUN-1986 11:06 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 15:23:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028134; 29 Jun 86 16:12 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a016904; 29 Jun 86 15:54 EDT
To: Arthur David Olson <ado%elsie.uucp@harvard.ARPA>
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a
  bug?
In-reply-to: Your message of 28 Jun 86 21:02:03 GMT.
         <6152@elsie.UUCP>
Date: 29 Jun 86 15:52:46 EDT (Sun)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
I don't think you can call that a compiler bug.  There are machines where
returning the long pointed at by a character pointer makes no sense (e.g.,
PDP-10).  This is one of those cases that lint calls questionable, and
rightfully so.
     
In any case, you provided a cast, which implies that "you know what you are
doing."  It's no more a compiler bug for your example to trap than it is for
     
    main ()
    {
        * (long *) main = 0x12345678;
    }
     
to trap on any machine that protects text space from user writes.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3832
          for JMS@ARIZMIS; Mon, 30-JUN-1986 11:21 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 06/29/86 at 16:35:27 CDT
Received: from ucbvax.Berkeley.EDU by SRI-KL.ARPA with TCP; Sat 28 Jun 86
  20:40:18-PDT
Received: by ucbvax.Berkeley.EDU (5.52/1.14)
    id AA15901; Sat, 28 Jun 86 20:24:07 PDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Sat 28 Jun 86
  20:24:10-PDT
Received: from bu-cs.bu.edu by CSNET-RELAY.ARPA id aa00874; 28 Jun 86 23:26 EDT
Return-Path: <bzs@bu-cs.bu.edu>
Received: by bu-cs.bu.edu (5.31/4.7)
    id AA15763; Sat, 28 Jun 86 23:24:23 EDT
Date: Sat, 28 Jun 86 23:24:23 EDT
From: Barry Shein <bzs%bu-cs.bu.edu@csnet-relay.arpa>
Message-Id: <8606290324.AA15763@bu-cs.bu.edu>
To: info-vax%ucbvax@sri-kl.arpa
Subject: Re: main() and entry points in C
     
     
>From: LEICHTER-JERRY@YALE.ARPA
  ...an attempt to explain _start(), ld, C, null pointers etc...
     
There are so many horrendous mistakes in this article it would take
a month to straighten it out.
     
Suffice it to say I simply hope no takes it seriously, he tries to
state things as if he knows what he is talking about, but he doesn't.
     
Perhaps he could post his article to INFO-C or net.lang.c and
find out how far off it is on almost everything.
     
Trust me folks, this is one to ignore.
     
    -Barry Shein, Boston University
     
[Must I have the energy to go point by point just to warn readers? no.]

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2286
          for JMS@ARIZMIS; Mon, 30-JUN-1986 11:48 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 13:34:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026644; 29 Jun 86 14:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015692; 29 Jun 86 13:54 EDT
From: Arthur David Olson <ado%elsie.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a bug?
Message-ID: <6152@elsie.UUCP>
Date: 28 Jun 86 21:02:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
As I understand it, the code produced by some compilers from
     
    long x(cp)
    char * cp;
    {
        return *((long *) cp);
    }
     
will cause core dumps if the value of cp isn't "appropriately aligned".
When dealing with such compilers, you get to do something like
     
    long x(cp)
    char * cp;
    {
        long l;
     
        function_to_do_arbitrary_copying((char *) &l, cp, sizeof l);
        return l;
    }
     
to avoid core dumps.
     
Isn't this really a compiler bug?  Doesn't the cast in the
        return *((long *) cp);
give the compiler all the evidence it needs that it should, *on its own*,
produce code that's the equivalent of the function call?
     
Does the latest version of X3J11 have anything to say on the matter?
--
Bug/s is a Volkswagen/Warner Brothers trademark.
--
    UUCP: ..decvax!seismo!elsie!ado        ARPA: elsie!ado@seismo.ARPA
    DEC, VAX, Elsie & Ado are Digital, Borden & Shakespeare trademarks.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2706
          for JMS@ARIZMIS; Mon, 30-JUN-1986 11:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 14:02:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026731; 29 Jun 86 14:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015842; 29 Jun 86 13:59 EDT
From: G|ran Uddeborg <uddeborg%chalmers.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Winners of the 1986 International Obfuscated C Code Contest
Message-ID: <617@chalmers.UUCP>
Date: 28 Jun 86 02:01:06 GMT
Keywords: obfuscate,winners,1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <3656@nsc.UUCP> chongo@nsc.UUCP writes:
>Worst abuse of the C preprocessor:
>
>    Jim Hague
>    University of Kent at Canterbury
>    Canterbury, Kent
>    UK
>
>    ..mcvax!ukc!jmh
>-------------------------------------------------------------------------------
>#define    DIT    (
>#define    DAH    )
>#define    __DAH    ++
>#define DITDAH    *
>#define    DAHDIT    for
>#define    DIT_DAH    malloc
>#define DAH_DIT    gets
>#define    _DAHDIT    char
>_DAHDIT _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3d2f16g7c8a90l?e'b.s;i,d:"
     
There's a bug here.  _DAH_[] should be initiated to
     
_DAHDIT _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3c2g16g7c8a90l?e'b.s;i,d:"
                          ^ ^
     
Try input "2", and you'll see the bug.
--
"For me, UNIX is a (way of) being."
     
    G|ran Uddeborg
    UUCP:  {seismo,mcvax}!enea!chalmers!uddeborg
    CSnet: uddeborg@chalmers.csnet

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2864
          for JMS@ARIZMIS; Mon, 30-JUN-1986 11:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 14:14:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026784; 29 Jun 86 14:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016029; 29 Jun 86 14:04 EDT
From: sbanner1 <sbanner1%uvicctr.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: SWAP macro
Message-ID: <174@uvicctr.UUCP>
Date: 25 Jun 86 16:42:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1577@brl-smoke.ARPA> Schauble@MIT-MULTICS.ARPA (Paul Schauble)
 writes:
>I've gotten lots of respones to my request for a form of the macro that
>would make
>  swap(*a++, *b++);
> work.  Almost all of them missed the point.  The swap requires a
>temporary.  Generating that temporary requires knowing the type.
>Several of the solutions would work fine if *a and *b were int's, but I
>never said that.
>
>Recall the my original message was posted as a justification for a
>typeof macro, akin to sizeof.  I find that the need to generate
>temporaries in a macro is not uncommon.  Unless one is willing to do a
>different version of the macro for each type, you need a way to generate
>a new variable of the same type as one of the macro args.  The language
>provides no way to do this.
     
I don't think you were reading all of the replys too closely.  While
I can see the use of the 'typeof' operator [not macro], there is a
relatively easy way to do this, as atleast one person mentioned :
     
    #define swap(type, a, b)  {type temp ... }
     
Granted this can get a bit ugly if you will need three or four
types, or if they are complex, but the facility *IS* there.
     
Disclamer : The veiws expressed here may not be shared my anyone else
on the face of the earth.
     
                               S. John Banner
     
!uw-beaver!uvicctr!sbanner1   :UUCP
ccsjb@uvvm   :Bitnet

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2060
          for JMS@ARIZMIS; Mon, 30-JUN-1986 12:02 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 13:14:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026409; 29 Jun 86 14:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015457; 29 Jun 86 13:45 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: #if foo vs #if defined(foo)
Message-ID: <3026@utcsri.UUCP>
Date: 27 Jun 86 15:56:15 GMT
Keywords: Sys 5.2
To:       info-c@BRL-SMOKE.ARPA
     
In article <379@twitch.UUCP> grt@twitch.UUCP ( G.R.Tomasevich) writes:
>Our compiler does not need a defined(), or at least I did not try whether
>it is even accepted.  The following example works fine:
>
>#if squat||foo
>int yes;
>#else
>int no;
>#endif
>main() {}
>
>if the 'cc' command includes either '-Dsquat' or '-Dfoo', then 'yes' is
>selected, else 'no' is selected.  E.g.: 'cc -Dfoo -E c.c'
>System: VAX-11/785 running UNIX 5.2
>--
     
This seems very wrong to me. If foo is defined (as 1), and squat isn't,
shouldn't that come out as
     
#if squat||1
     
which should be rejected by the cpp as containing a non-constant ?
     
What if '#define squat 0' and '#define foo 0' ?? The expression
becomes 0||0 which is false.
     
This compiler here (4.2BSD) backs me up on the second point, but not
on the first ( i.e. the given example works ). Apparently any symbol in
a #if expression becomes '0'.
     
What if squat or foo are defined as something other than a constant?
This device cannot replace #if defined(a)|| defined(b) in general.
     
--
"Shades of scorpions! Daedalus has vanished ..... Great Zeus, my ring!"
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2418
          for JMS@ARIZMIS; Mon, 30-JUN-1986 12:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 13:39:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026672; 29 Jun 86 14:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015744; 29 Jun 86 13:56 EDT
From: "John R. Jackson" <acz@PUCC-K.ARPA>
Newsgroups: net.lang.c
Subject: What to do with lots of registers
Message-ID: <1409@pucc-k>
Date: 27 Jun 86 16:19:43 GMT
Keywords: register
To:       info-c@BRL-SMOKE.ARPA
     
Sorry this is lengthy, but here goes.
     
I do maintenance and development on the C compiler for the CDC Cyber
205 supercomputer.
     
Among other oddities about the hardware are a very large set of general
purpose registers (256 of them!).  All (non-vector) operations are
performed register to register, so it is best to have as many variables
declared register as possible.  Since most C programs do not often use
the register declaration, I need to study how to automatically promote
locals.
     
I am aware of some work done at HCR in this area, and would appreciate
any information they can give me.  I would also appreciate any ideas
anyone has.  I am aware of the problems of anything pointing to
anything, but it will be better to help most of the cases and then go
back and disable the promotion where it causes problems (via the auto
keyword???).
     
A second use of the register file could be to hold global variables.
Since most routines only have a few local variables, even promoting
everything will not use the registers fully.  One possibility I am
considering is an extension to the register declaration to specify what
register the variable should be assigned to.  Something like:
     
    sub (parm)
    register parm; {
        register (0x9a) global;
        .
        .
        .
    }
     
The register storage declaration for parm would be treated as normal,
i.e.  the next available free register will be assigned.  The global
declaration would force register #9A to be used.  Variables declared in
this way would not be saved across function calls, unless they happen
to overlap a register that will be saved anyway.  The scope would be
the routine the variable was declared in.
     
An alternative, or extension, would allow the register storage class to
be used outside the function body, again with the syntax extension to
specify a particular register.  The scope would then be the rest of the
source file just like any other external or static variable.
     
Note that I am not particularly interested in the portability issue.
My intent is to provide a performance boost for programs designed for
the 205.  This compiler already has so many syntax extensions for
vector references, one more isn't going to make any difference.
     
Does the C standard say anything about either of these issues?  By the
way, how do I get a copy?
     
Please reply by mail as much as possible, as I do not want to start a
net war about this.
     
Thanks in advance.
     
John R. Jackson                Senior 205 Systems Programmer
ARPANET: jrj@asc.Purdue.EDU        Purdue University Computing Center
     or  jrj@purdue-asc.ARPA        Mathematical Sciences Bldg.
BITNET:  JACKSON@PURCCVM        West Lafayette, IN 47907
USENET:  jrj@pucc-j.UUCP        317/494-1787

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2896
          for JMS@ARIZMIS; Mon, 30-JUN-1986 12:48 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/29/86 at 14:16:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026798; 29 Jun 86 14:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016093; 29 Jun 86 14:06 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: My pointer stuff:  C caught me again
Message-ID: <2201@umcp-cs.UUCP>
Date: 29 Jun 86 03:56:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Perhaps I just have an odd mind, but all this pointer/array stuff
never really bothered me.
     
In article <1267@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes:
>struct sfld (*__cursf)[] = (struct sfld (*)[]) 0;
>
>if ((__cursf = (struct sfld (*)[]) calloc(n, sizeof (struct sfld)))
>    == (struct sfld (*)[]) 0) ...
>
>This was intended to allocate an array and assign it to a variable of type
>``pointer to array of (struct sfld).  I suspect the type is wrong but I'm not
>sure how to decalre such a beastie; I suspect that it *does* *not* *exist*
>*at* *all* in C, now that I've played with it.
     
Why not simply use a `pointer to struct sfld'?  If you intend to
use this as `__cursf[i].field', that is what you need.
     
>The other section looks like this:
>
>struct menu {
>    int m_rec;
>    struct cmd *m_cmd;
>};
>
>struct menu cmdtab[] = {
>    orders,        ocmdarr,
>    customer,    ccmdarr,
>    -1,        (struct cmd *) 0,
>};
     
This looks reasonable to me.
     
>The dichotomy
     
What dichotomy?  Using my declarations everything is identical;
in
     
    /* given `int a[N];' */
    a;
     
the type of the expression `a' is `pointer to int'.
     
>between these otherwise identical sections (as far as the
>``pointer to an array'' is concerned)
     
You should to have a two-dimensional array in mind in the first
place before using `pointer to array N'.  In
     
    /* int b[M][N]; */
    b;
     
the type of the expression `b' is `pointer to array N of int'.
(Note that if this is dereferenced, it becomes `array N of int',
which in a normal expression is then immediately converted to
`pointer to int'.  `normal' here means `not a target of sizeof'.)
     
>is that an array DECLARED in C causes the array name to become
>a CONSTANT.
     
Not quite, but close.  When used as an rvalue the constant has
type `pointer to' whatever one element of that array might be.
     
>Whereas the malloc()'ed one is a POINTER VARIABLE.
     
No, it is a pointer expression, with type `pointer to' whatever
one element of that array might be.  Once it has been assigned to
a pointer variable, then that is indeed a pointer variable.
     
There are certainly other ways of handling the typing of arrays;
C does it by making arrays second class objects, which is occasionally
regrettable, but not too hard to deal with.
     
>+---------------
>| Anyhow, the insightful stuff follows:
>|
>| > BUT:  the arrangement in memory is identical!
>+---------------
     
The arrangement in memory of any array of any dimension is flat.
`int a[2][5]' is, aside from typing information, identical to
`int a[10]'.  This has never bothered me.
     
>The actual problem comes from C's closeness to the machine hardware:
>
>    the malloc()'ed one is type (int *), to the C compiler (to me, int [])
     
Yes.
     
>    the declared one is type (int []), to the C compiler
     
Yes.  Note that the first dimension of the array is unimportant after
allocation, so the type *is* (int []), not (int [5]) or whatnot.
(Again, `sizeof' is peculiar; ignore it.)
     
>        (which defines (int []) as (int *))
     
Only in `most places' (this is perhaps what bothers people; `sizeof'
is `peculiar', and so are declarations of formals).
     
>+---------------
>| "Why isn't the correct type of an int array name (int [])?"
>|
>| *GOOD* question.  *VERY* good question.  The answer is "just because".
>| Or, if you want to be insulting, because DMR slipped a cog.  This is
>| *THE* *MOST* *CONFUSING* thing about C, by far.  An array name, when
>| evaluated, does *NOT* *NOT* *NOT* yield an array type.  This is the
>| single greatest lunacy of the C language.  It might be argued that this
>| is the *ONLY* great lunacy in C, although the declaration-mirrors-use
>| rule probably ought to be considered a great lunacy as well.  (In case
>| you can't tell, these nasty remarks about array name evaluation in C are
>| my opinions only, and only about 60% serious.  Others differ with me.
>| However, it is objective fact that this one point causes more confusion
>| and error than any other construct in C.  By far.)
>+---------------
     
Again, it has never bothered me.  Arrays are second class objects;
you cannot quite name one outside a data declaration.  Functions
are likewise second class: a function name, when evaluated, does
not yeild a function type, but rather a function pointer.  Lunacy?
I guess you should reserve a place in the nut-house for me (though
it is arguable that at UMCP, I am already there :-) ).
     
Incidentally,
     
    int (*p)[];
     
is not really a useful declaration.  Pretend you are a compiler:
tell me how to find p[3][1] (or, if you prefer, (*(p+3))[1]).
Try again with
     
    int (*p)[5];
     
and see if that makes a difference.
     
[answers below]
     

     
The rule for pointer addition is `multiply the integer value by
the size (in bytes) of the pointed-to object, then add that to the
address given by the pointer.'  Given `int (*p)[]', we want to find
p[3][1].  This is equivalent to *((*(p+3))+1).  Do the innermost
expression first: p+3.  Following the pointer addition rule, multiply
3 by the size of whatever p points to.  p points to `int []'.  How
big is this?  Got me.  It is *not* (sizeof (int *)).  See what your
compiler says about `sizeof (int [])'.
     
For `int (*p)[5]' and the same reference, we take the size of
whatever p points to, and p points to `int [5]'.  How big is this?
Well, it depends on your machine, but let us suppose you have a
Vax; we get 5*4 = 20 bytes.  We take the address of location (p +
20 bytes), not the contents, as the type of *p is `int []' (the
first subscript drops out of any array type), and since this is
used in another expression, convert the type to `int *'.  We now
want to add one to this pointer, so again we follow the pointer
addition rule and take the size of the type of the pointed-to object
(int), which is four bytes, and multiply by 1 (remember, we are
now doing *(<thing> + 1)).  <thing> happens to be (p + 20 bytes),
to which we add 4 bytes.  The location of p[3][1] is thus (p + 24
bytes), and the type is `int'.  If `p' is a register (call it r11),
the expression
     
    i = p[3][1];
     
should compile to
     
    movl    24(r11),_i
     
and indeed it does.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7655
          for JMS@ARIZMIS; Mon, 30-JUN-1986 17:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 10:45:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021502; 30 Jun 86 11:36 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002114; 30 Jun 86 11:22 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06915; Mon, 30 Jun 86 11:19:44 edt
Date: Mon, 30 Jun 86 11:19:44 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606301519.AA06915@icst-cmr.ARPA>
To: cubsvax!peters@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re:  exp(x) in APL
     
> In article <brl-smok.1611> rbj@icst-cmr.arpa (Root Boy Jim) writes:
> >My favorite one liner is `1 + +/ % ! i 12' (where `%' is DIVIDE (reciprocal)
> >and `i' is IOTA). Twelve is a good approximation to infinity here. Anyway,
> >you can see what happens when x is zero. All the other terms flake out
> >except the first, which has to be one. Isn't this fun?
>
> Whoops, don't you mean:
>         1 + +/ (x ^ i12) % (! i12)
> ??  (Ya need x^n in the numerator of each term....  I'm using "^" for
> exponentiation.)
     
Of course! In the general case that is. Your expression is a function,
whereas mine is a long name for a constant (the function evaluated at zero,
or a very familiar looking number).
     
I said it was my favorite one liner because that's what it is. I type it
in without the carriage return and say `Guess what this is!' I could
have done `)origin 0' before and changed 12 to 13, but that's two lines.
I could also have dispensed with the first `1' and changed `i12' to
`0,i12', or `_1 + i13' (`_' is negation for constants).
     
> Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
> {philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA
     
Nice to know someone out there is awake and paying attention.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    MMM-MM!! So THIS is BIO-NEBULATION!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7940
          for JMS@ARIZMIS; Mon, 30-JUN-1986 18:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 12:01:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023969; 30 Jun 86 12:48 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002343; 30 Jun 86 11:32 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06966; Mon, 30 Jun 86 11:29:51 edt
Date: Mon, 30 Jun 86 11:29:51 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606301529.AA06966@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, mirror!fred@seismo.css.gov
Subject: Re:  C programming course wanted.
     
    We are currently looking for a beginner/intermediate C programmers
    class in the Boston area. We have investigated on-site courses but
    due to the small number of people, they do not seem cost effective.
     
    I am not a regular reader of this group so please reply by mail.
     
    Fred Nesseralla {mit-eddie,ihnp4!inmet,wjh12,cca,datacube}!mirror!fred
    Mirror Systems    2067 Massachusetts Ave.
    617-661-0777    Cambridge, MA, 02140
     
Why don't you just read K&R? That's the way REAL PROGRAMMERS do it.
And none of them newfangled cheap imitations either. Keep the Faith.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
I'm RELIGIOUS!!  I love a man with a HAIRPIECE!!  Equip me with MISSILES!!

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8661
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:00 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 15:23:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002846; 30 Jun 86 16:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009523; 30 Jun 86 15:42 EDT
From: #Bill_Stewart <wcs%ho95e.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <733@ho95e.UUCP>
Date: 29 Jun 86 00:43:48 GMT
Posted: Sat Jun 28 20:43:48 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <1201@brl-smoke.ARPA> Schauble@MIT-MULTICS.ARPA writes:
>Can someone construct a version that makes
>    int *a, *b;
>    swap (*a++,*b++);
>work right?
     
I'm not sure I can define what "work right" means in a swap :-)
--
# Bill Stewart, AT&T Bell Labs 2G-202, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8736
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:03 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 15:31:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002905; 30 Jun 86 16:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009632; 30 Jun 86 15:45 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a
  bug?
Message-ID: <5721@alice.uUCp>
Date: 29 Jun 86 19:07:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Isn't this really a compiler bug?  Doesn't the cast in the
>         return *((long *) cp);
> give the compiler all the evidence it needs that it should, *on its own*,
> produce code that's the equivalent of the function call?
     
When you cast a pointer type to another pointer type,
you have stepped outside the bounds of the language.
The implementation is entitled to do as it pleases.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8987
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 15:57:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003177; 30 Jun 86 16:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009926; 30 Jun 86 15:50 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2208@umcp-cs.UUCP>
Date: 30 Jun 86 03:27:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
>Why can't C be like everybody else?
     
It is too late for C to be like anything else; it is like C.  Besides,
if it were exactly like (say) Pascal, it would *be* Pascal.  There is
room for many languages.
     
>Practically every language uses the equals sign, "=", to test for
>equality, not as an assignment operator.
     
Perhaps you know more languages than I.  Let me list those whose
syntax I remember, and count `= for assigment' vs. `= for equality'
(or both).
     
    Assignment        Equality
    ----------        --------
                Algol
                APL
    awk
                        BASIC (really both)
    FORTRAN
                Icon
                        Lisp (neither really)
                Mesa
                Pascal
    Snobol
     
Well, 5 to 3 in favour of `= for equality', though APL and Mesa are
perhaps special cases: back-arrow is not available for assignment on
my H19.
     
>Kernighan and Ritchie, in their infinite wisdom, decide
>instead to use "=" for assignments and to create a new operator, "==" to
>test for equality.  Gee, that must have required brains, the brains of
>a 3 year old.
     
Both Brian Kernighan and Dennis Ritchie have quite a bit of experience
designing and using languages.  Rather than spewing insults, it
might be more productive to do some studies as to whether the
symbols used for assignment and testing affect programming speed
and error rates, for both novice and experienced programmers.
Perhaps they did what they did because of some particular insight
that others have missed, or perhaps it was a mistake.  As far as
I can tell, you have not even attempted to determine this
experimentally.
     
>If they had my brains, they would have used Pascal's method.  Better yet,
>they should have let someone else write up C.
     
>Edward Jung, Stevens Institute of Technology
>JUNG_E@SITVXB.BITNET
     
If C were different, it would be different.  That tells us nothing.
C as it is now is quite obviously rather popular.  How many languages
have you designed, and who is using them?
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8911
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:19 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 15:50:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002796; 30 Jun 86 16:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009505; 30 Jun 86 15:42 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Pointers and Arrays
Message-ID: <2206@umcp-cs.UUCP>
Date: 29 Jun 86 16:10:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2201@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>Perhaps I just have an odd mind, but all this pointer/array stuff
>never really bothered me.
     
Or perhaps I simply read K&R, chapter 5, Pointers and Arrays.  I
needed to refer to K&R recently (see article <2204@umcp-cs.UUCP>),
and while I was looking at it, I just happened to stumble across
some text in this chapter that seems to me quite clear.  Let me
give some excerpts, with commentary.  (Suggestion: while reading
this, imagine me grinning teasingly at points.  I hope the tone
comes across properly, but I have spent enough time revising this
now---great grief, an hour and a half now!)
     
  It is also necessary to declare the variables that participate
  in all of this:
     
    int x, y;
    int *px;
     
  The declaration of x and y is what we've seen all along.  The
  declaration of the pointer px is new.
     
    int *px;
     
  is intended as a mnemonic; it says that the combination *px is
  an int, that is, if px occurs in the context *px, it is equivalent
  to a variable of type int.  In effect, the syntax of the declaration
  for a variable mimics the syntax of expressions in which the
  variable might appear.  This reasoning is useful in all cases
  involving complicated declarations.  For example
     
    double atof(), *dp;
     
  says that in an expression atof() and *dp have values of type
  double.
     
So much for understanding declarations.  K&R said it all, eight
years ago.
     
  ... Any operation which can be acheived by array subscripting
  can also be done with pointers.  The pointer version will in
  general be faster but, at least to the uninitiated, somewhat
  harder to grasp immediately.
     
K&R seem to have a gift for understatement.
     
  The correspondence between indexing and pointer arithmetic is
  evidently very close.  In fact, a reference to an array is
  converted by the compiler to a pointer to the beginning of the
  array.  The effect is that an array name *is* a pointer expression.
  ...
     
(Note `expression', not `variable'.  The above does not apply to
sizeof.)
     
  There is one difference between an array name and a pointer that
  must be kept in mind.  A pointer is a varible, so pa=a and pa++
  are sensible operations.  But an array name is a *constant*, not
  a variable: constructions like a=pa or a++ or p=&a are illegal.
     
`p = &a' is much like `p = &3': illegal by fiat, not because it
cannot be done.  If it were legal, `&a' would have type `pointer to
<type of a>' (compare with `a', which has type `pointer to <type of
a[0]>').
     
  When an array name is passed to a function, what is passed is the
  location of the beginning of the array.  Within the called function,
  this argument is a variable, just like any other variable, and so
  an array name argument is truly a pointer, that is, a variable
  containing an address.  ...
     
  As formal parameters in a function definition,
     
    char s[];
     
  and
     
    char *s;
     
  are exactly equivalent; ...
     
This is all in the context of singly-dimensioned arrays, but with
the proper mindset applies to multi-dimensional arrays without
trouble.  (With the wrong mindset it leads to much confusion.)
K&R will have more to say about this later.
     
Note that this is where sizeof starts acting odd:  A compiler
treats the following as equivalent:
     
       array          pointer
       -----          -------
    f(arr)            f(ap)
    int arr[];        int *ap;
    {            {
        ...            ...
     
     
    f(a2)            f(a2p)
    int a2[][5];        int (*a2p)[5];
    {            {
        ...            ...
     
The second equivalent pointer version is neither `int **a2p' nor
`int *a2p'; nor for that matter is it `int *a2p[5]'.  This is
consistent, if (painfully apparently, given recent net.lang.c
articles) confusing.
     
  5.7  Multi-Dimensional Arrays
     
  C provides for rectangular multi-dimensional arrays, though in
  practice they tend to be much less used than arrays of pointers. ...
     
  ... In C, by definition a two-dimensional array is really a one-
  dimensional array, each of whose elements is an array.  Hence
  subscripts are written as
     
    day_tab[i][j]
     
  rather than
     
    day_tab[i, j]
     
  as in most languages. ...
     
What they do *not* mention is that day_tab[i,j] is a valid expression,
and tends to surprise people.  Lint does not, unfortunately, warn
about these.
     
  If a two-dimensional array is to be passed to a function, the
  argument declaration in the function *must* include the column
  dimension; the row dimension is irrelevant, since what is passed
  is, as before, a pointer.
     
What did I tell you?
     
Note that this *is* consistent.  One cannot pass an array as an
argument to a function.  Pointers, however, are fine, *including
pointers to arrays*.  Given a two or more dimensional array,
the array `constant' is converted to a pointer to an array of
one fewer dimensions.  This is now a *pointer*, and remains a
pointer until dereferenced.  For example, in
     
    int day_tab[2][13] = { ... };
     
the following are type-correct calls:
     
    f2d(p) int (*p)[13]; { ...  }
     
    f1d(p) int *p; { ...  }
     
    proc()
    {
                    /* argument types: */
        f2d(day_tab);        /* pointer to array 13 of int */
        f2d(&day_tab[0]);    /* pointer to array 13 of int */
     
        f1d(day_tab[0]);    /* pointer to int */
        f1d(&day_tab[0][0]);    /* pointer to int */
    }
     
Calling f2d(&day_tab[0][0]) passes the right *value* but the wrong
*type*.  That it happens to work is not an excuse to do it.  If C
were different, it would be different, but it is not, so it is not.
     
To return to K&R:
     
  5.10 Pointers vs. Multi-dimensional [sic] Arrays
     
(So they are not consistent with capitalisation in section names.)
     
  Newcomers to C are sometimes confused about the difference between
  a two-dimensional array and an array of pointers, ...
     
Ah, a gift indeed.
     
  Given the declarations
     
    int a[10][10];
    int *b[10];
     
  the usage of a and b may be similar, in that a[5][5] and b[5][5]
  are both legal references to a single int.  But a is a true array:
  all 100 storage cells ahve been allocated, and the conventional
  rectangular subscript calculation is done to find any given
  element.  For b, however, the declaration only allocates 10
  pointers; each must be set to point to an array of integers.
  Assuming that each does point to a ten-element array, then there
  will be 100 storage cells set aside, plus the ten cells for the
  pointers.  Thus the array of pointers uses slightly more space,
  and may require an explicit initialization step.  But it has two
  advantages:  accessing an element is done by indirection through
  a pointer rather than by a multiplication and addition, and the
  rows of the array may be of different lengths.  That is, each
  element of b need not point to a ten-element vector; some may
  point to two elements, some to twenty, and some to none at all.
     
Now for some even more horrid examples of my own, all type-correct:
     
    /* declare st as array 1 of array 5 of pointer to char */
    char *st[1][5] = { { "fee", "fie", "foo", "fum", "foobar" } };
     
    /* declare x as pointer to array 5 of pointer to char */
    char *(*x)[5] = st;
     
    /* declare y as array 1 of array 3 of array 4 of pointer to
       array 5 of pointer to char */
    char *(*y[1][3][4])[5] = { {
        { st, 0, 0, st },
        { 0, st, st, 0 },
        { 0, 0, st, st }
    } } ;
     
    /* declare p as array 2 of pointer to array 3 of array 4
       of pointer to array 5 of pointer to char */
    char *(*(*p[2])[3][4])[5] = { y, 0 };
     
It does take some trickery to do this.  Given the declaration
     
    char *strings[5] = { ... };
     
the type of `strings' is `array 5 of pointer to char', which, when
used in an expression, becomes `pointer to pointer to char' (by
changing the first `array of' to `pointer to'), but for `x' and
`y' I wanted a type of `pointer to array 5 of pointer to char'.
It might be nice if I could write `&strings' to get this, but I
cannot; however, I can use the declaration above for `st' to get
`array 1 of array 5 of pointer to char'.  Changing the first `array
of' yeilds `pointer to array 5 of pointer to char', which was what
I wanted.
     
Likewise, for `p' I wanted `y' to evaluate to `pointer to array
3 of array 4 of pointer to array 5 of pointer to char'; in order
to get that, I again used a `fake' [1] in the declaration.
     
    `You can hack anything you want,
     with pointers and funny C . . .'
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9477
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 17:33:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003199; 30 Jun 86 16:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010042; 30 Jun 86 15:51 EDT
From: Charley Wingate <mangoe%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2210@umcp-cs.UUCP>
Date: 30 Jun 86 03:59:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Actually, the only real problem in confusing equality with assignment is
when people try to put assignments in expressions to get side effects, at
least in procedural languages.  PL/I solves the problem neatly (when's the
last time you heard THAT about PL/I?) by having a special
assignment-in-an-expression operator.
     
The only language that actually followed the mathematics convention was
BASIC as it existed before micros, when the magic word LET was generally
required.  What we really need is a one-character assignment operator; only
APL has the optimal solution as it stands.  The C convention is unfortunate
for two reasons; first, it's unlike everyone else's, and second, confusing
the operators is not likely to result in a syntax error.
(Chris, I can't imagine why you mentioned Snobol.  In my view, saying that
snobol does something in such and such a way is tantemount to saying that we
should find another way to do it.)
     
C. Wingate

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9601
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:52 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003306; 30 Jun 86 16:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010569; 30 Jun 86 15:59 EDT
From: flaps%utcs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Yet another ALIGN idea.
Message-ID: <1986Jun29.15:39:38.4762@utcs.uucp>
Date: 29 Jun 86 19:39:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
How about an #include <align.h> which contains a single #define which gives the
alignment constant for this machine?
     
This of course would only be useful if put into the standard.
     
Which reminds me, is sizeof(char) always = 1 yet?  I mean, is it guaranteed?
     
ajr

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9725
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:54 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003696; 30 Jun 86 16:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011755; 30 Jun 86 16:31 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: Yet another ALIGN idea.
Message-ID: <1837@brl-smoke.ARPA>
Date: 30 Jun 86 20:30:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1986Jun29.15:39:38.4762@utcs.uucp> flaps@utcs.uucp (Alan J
 Rosenthal) writes:
>Which reminds me, is sizeof(char) always = 1 yet?  I mean, is it guaranteed?
     
sizeof(char) is indeed supposed to be 1 as things now stand.
However, this may need to be reconsidered.  The meaning of
"char" is currently overloaded, which doesn't much matter
until one gets into multi-byte character representations.
I'm hoping to work up a complete discussion and a number
of specific proposals in a paper for X3J11 as soon as I can
find the time.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9796
          for JMS@ARIZMIS; Mon, 30-JUN-1986 20:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004747; 30 Jun 86 18:00 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a012517; 30 Jun 86 17:41 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA07536; Mon, 30 Jun 86 15:35:19 edt
Date: Mon, 30 Jun 86 15:35:19 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8606301935.AA07536@icst-cmr.ARPA>
To: gwyn@BRL.ARPA, tainter%ihlpg.uucp@BRL.ARPA
Subject: Re:  LPow correction
Cc: info-c@BRL-SMOKE.ARPA
     
    >>>    limit of x^x as x->0+ is precisely 1
    > This isn't a truth, it's a consequence of the definition of the system
    > as self consistant.
     
    Fortunately I don't subscribe to the school of thought that says all
    mathematics is simply rearrangement of symbols according to formal rules.
    As a physicist/engineer, the above limit has real meaning for me.
    So there.
     
Which came first the chicken or the egg? (The rooster :-) Would EE's ever
have figured out how complex arithmetic relates to reactance if some
mathematician hadn't wondered `What squared is minus one?'
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Let me do my TRIBUTE to FISHNET STOCKINGS...

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9521
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003253; 30 Jun 86 16:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010141; 30 Jun 86 15:52 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2215@umcp-cs.UUCP>
Date: 30 Jun 86 04:27:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2210@umcp-cs.UUCP> mangoe@umcp-cs.UUCP (Charley Wingate) writes:
>(Chris, I can't imagine why you mentioned Snobol.  In my view, saying that
>snobol does something in such and such a way is tantemount to saying that we
>should find another way to do it.)
     
I was specifically avoiding making any judgement calls.  I happen
to agree that Snobol syntax is exceedingly ugly, and I find it
interesting to note that Griswold used `:=' in Icon, which is sort
of a `Snobol done right'.
     
Personally, it makes no real difference to me what a language uses
for assignment.  It takes a few minutes for me to switch between
`Algol mode' and `C mode', but afterward everything just flows
right on out.  Had C used := for assignment, I think I would be
just as happy with the language.  Ah well.  As they say, `too late
now.'
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9656
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003556; 30 Jun 86 16:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009493; 30 Jun 86 15:41 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a
  bug?
Message-ID: <2204@umcp-cs.UUCP>
Date: 29 Jun 86 14:15:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6152@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes:
>As I understand it, the code produced by some compilers from
>
>    long x(cp)
>    char * cp;
>    {
>        return *((long *) cp);
>    }
>
>will cause core dumps if the value of cp isn't "appropriately aligned".
     
>...  Doesn't the cast in the
>        return *((long *) cp);
>give the compiler all the evidence it needs that it should, *on its own*,
>produce code that's the equivalent of the function call?
     
[\S = section symbol]
     
No.  K&R, Appendix A, \S 14.4, p.~210:
     
  14.4  Explicit pointer conversions
  ...
    A pointer to one type may be converted to a pointer to another
  type.  The resulting pointer may cause addressing exceptions
  upon use if the subject pointer does not refer to an object
  suitably aligned in storage. ...
     
While you are verifying this, take a look at \S 16.  I think it is
amusing that as long ago as 1978, K&R identified most of the major
portability problems that many people are now seeing for the first
time.  (The big one they left out of \S 16 is null-pointer derefer-
encing.)  You were warned, eight years ago!  :-)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9879
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 18:01:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003138; 30 Jun 86 16:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009833; 30 Jun 86 15:48 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a
  bug?
Message-ID: <4614@sun.uucp>
Date: 29 Jun 86 20:53:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Isn't this really a compiler bug?  Doesn't the cast in the
>         return *((long *) cp);
> give the compiler all the evidence it needs that it should, *on its own*,
> produce code that's the equivalent of the function call?
     
A piece of software has a "bug" if it's supposed to do something and it
doesn't; for instance, if it's supposed to generate correct code and it
generates incorrect code instead.  The C compiler isn't *supposed* to do
unaligned copying in circumstances like this, so it can hardly be a "bug" if
it doesn't.
     
> Does the latest version of X3J11 have anything to say on the matter?
     
The August 11, 1985 draft says:
     
    C.3.3.2 Address and indirection operators
     
    ...
     
    Semantics
     
    ...
     
         If an invalid value has been assigned to the pointer, the
    behavior of the unary * operator is undefined.  Such invalid
    values include ... *an address inappropriately aligned for the
    type of the object pointed to*...
     
I *very* sincerely doubt this has been changed in any later drafts.  Such
dereferences are uncommon occurrences, and a programmer can damn well write
their own code to do the unaligned copy.
     
So a C compiler which doesn't generate unaligned copies is perfectly within
its rights to do so, and has no bug.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0208
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 19:11:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006753; 30 Jun 86 20:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013289; 30 Jun 86 19:43 EDT
From: Rob McMahon <cudcv%daisy.warwick.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Additions to C - range checking
Message-ID: <155@daisy.warwick.UUCP>
Date: 29 Jun 86 19:48:17 GMT
Posted: Sun Jun 29 19:48:17 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <523@ccird1.UUCP> rb@ccird1.UUCP (Rex Ballard) writes:
>
>if (5<a<50) do_something(a);
>
...
>
>Is this impossible to parse?
     
This was in BCPL, and was a GOOD IDEA.
--
UUCP:   ...!mcvax!ukc!warwick!cudcv
JANET:  cudcv@uk.ac.warwick.daisy
ARPA:   cudcv@daisy.warwick.ac.uk
PHONE:  +44 204 523037
Rob McMahon, Computer Unit, Warwick University, Coventry CV4 7AL, England

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0274
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:17 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 19:16:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006713; 30 Jun 86 19:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013257; 30 Jun 86 19:42 EDT
From: "Krishnakumar K." <kk%amdcad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: pointers to functions
Message-ID: <12187@amdcad.UUCP>
Date: 30 Jun 86 17:52:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <237@killer.UUCP> toma@killer.UUCP (Tom Armistead) writes:
>Secondly is it possible to have an array of type 'pointer to' function.
>i.e.
>int  (*function)()[SIZE];
>something like the above, I was able to achieve this using this:
>struct    fct {
>            int  (*func)();
>            } f_array[SIZE];
>function()
>{
>    int x;
>    printf("offset: ");
>    scanf("%d",&x);
>    (*f_array[x].func)();
>}
>Is there another way???
>
I'm currently involved in writing an interpreter to process numeric
expressions.  When I encounter a function reference I need to translate
between that string and the 'C' function that will perform it.  The
following seems to work well.  I use a binary search of a function
table to keep it fast even for a large number of possible functions.
     
typedef struct {
    char *funcname;
    double (*func)();
} FUNCELEM;
     
extern double exp(), log(), sin(), cos();
     
FUNCELEM functable[] = {
    { "cos", cos },
    { "exp", exp },
    { "log", log },
    { "sin", sin }
};
     
extern double (*binary_search())();
     
double callfunc(name, arg)
char *name;
double arg;
{
    double (*func)();
     
    func = binary_search(functable, name);
    if (func == NULL)
        return 0.0;
    else
        return (*func)(arg);
}
     
Brad Budlong.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0536
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:28 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 20:06:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007545; 30 Jun 86 20:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013648; 30 Jun 86 20:50 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: LPow correction
Message-ID: <1848@brl-smoke.ARPA>
Date: 1 Jul 86 00:49:47 GMT
Followup-To: net.math
To:       info-c@BRL-SMOKE.ARPA
     
In article <1843@brl-smoke.ARPA> Root Boy Jim <rbj@icst-cmr> writes:
> He could have chosen x^(sin x) as well, but why should he?
     
Of course that has the same limit as x->0+.
     
I bet people are getting tired of this discussion.  Any further
debate about whether 0^0 has a definite value, can harmlessly be
assigned one, etc. should move to net.math instead, so we can
bore the mathematicians too.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0623
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 20:27:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007749; 30 Jun 86 21:07 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a013655; 30 Jun 86 20:50 EDT
Date:     Mon, 30 Jun 86 20:42:50 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Rob McMahon <cudcv%daisy.warwick.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Additions to C - range checking
Message-ID:  <8606302042.aa00668@VGR.BRL.ARPA>
     
Problem is, C already has a meaning for
    5<a<50
and it's not the one you want.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0684
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 20:55:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008344; 30 Jun 86 21:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013988; 30 Jun 86 21:42 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <761@ucbcad.BERKELEY.EDU>
Date: 30 Jun 86 20:05:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1645@brl-smoke.ARPA>, JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
> Why can't C be like everybody else?  Practically every language uses
> the equals sign, "=", to test for equality, not as an assignment operator.
     
This is a useless argument, since it won't change anything... However,
I can't agree that K&R were mistaken -- just because all other
languages use = differently, that doesn't mean that they had to.  I
think their argument in favor of = and == is a good onew, certainly
better than "Pascal uses := for assignment".  If I use C 90% of the time
and other languages 10% of the time, I think it makes more sense to ask
"Why can't the other languages be like C..."
     
> If they had my brains, they would have used Pascal's method.
     
The fact that Pascal uses := is an argument against it, since Pascal is
simply *ugly*...
     
    Wayne

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0730
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 20:59:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008368; 30 Jun 86 21:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014014; 30 Jun 86 21:42 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: cdecl availability
Message-ID: <2218@umcp-cs.UUCP>
Date: 30 Jun 86 23:40:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Many of you seem to be interested in obtaining the `cdecl' program
I have mentioned recently.  First, I should say that I did not
write it; I have forgotten who did (that is twice now!), and the
author's name appears in neither the manual entry nor the source.
However, the code was made freely available, so I can pass it on.
My shar file is just a bit over 14K, so I am even willing to send
it through a reasonable number of UUCP hops, but please ask your
immediate neighbors if they have cdecl before flooding seismo with
mail.
     
For those of you receiving this message via the Info-C mailing
list, if you are on the ARPA Internet, you can retrieve the file
from host mimsy.umd.edu using anonymous FTP.  Those on CSNet or
BITNET can send me mail.  BITNET people should consider using
umd2.umd.edu as a gateway, as it is practically on the same Ethercable
as mimsy.umd.edu.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0452
          for JMS@ARIZMIS; Mon, 30-JUN-1986 21:40 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 06/30/86 at 20:04:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007525; 30 Jun 86 20:55 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a013621; 30 Jun 86 20:46 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA08831; Mon, 30 Jun 86 20:44:26 edt
Date: Mon, 30 Jun 86 20:44:26 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607010044.AA08831@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, umcp-cs!chris@ICST-CMR.ARPA
Subject: Re: Precedent for use of =
     
> In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
> >Why can't C be like everybody else?
     
Why should it?
     
> It is too late for C to be like anything else; it is like C.  Besides,
> if it were exactly like (say) Pascal, it would *be* Pascal.  There is
> room for many languages.
     
> >Practically every language uses the equals sign, "=", to test for
> >equality, not as an assignment operator.
     
> Perhaps you know more languages than I.  Let me list those whose
> syntax I remember, and count `= for assigment' vs. `= for equality'
> (or both).
>
>     Assignment        Equality
>     ----------        --------
>                 Algol
>                 APL
>     awk
>                         BASIC (really both)
>     FORTRAN
>                 Icon
>                         Lisp (neither really)
>                 Mesa
>                 Pascal
>     Snobol
>
> Well, 5 to 3 in favour of `= for equality', though APL and Mesa are
> perhaps special cases: back-arrow is not available for assignment on
> my H19.
     
I am surprised you left out `sh' and `csh'. `Sh' is like FORTRAN in that
`=' is assignment and conditionals are those nasty diphthongs adorned
with punctuation. Of course `csh' is like C. You forgot to mention
the language that most programming is done in Cobol. I suppose in
this case, ignorance is bliss. Bliss? I don't know what it does :-)
Several assemblers use `=' for assignment instead of `equ'. Forth has
a word `=' which tests equality while `!' does a store.
     
Perhaps comparing UNIX derived languages is unfair, as they tend to
be C clones. BC is another one.
     
In the case of FORTRAN, BASIC, possibly COBOL (I forget), while the
`=' does double duty, the context is provided by either the IF or LET
(or absence of any keyword).
     
> >Kernighan and Ritchie, in their infinite wisdom, decide
> >instead to use "=" for assignments and to create a new operator, "==" to
> >test for equality.  Gee, that must have required brains, the brains of
> >a 3 year old.
>
> Both Brian Kernighan and Dennis Ritchie have quite a bit of experience
> designing and using languages.  Rather than spewing insults, it
> might be more productive to do some studies as to whether the
> symbols used for assignment and testing affect programming speed
> and error rates, for both novice and experienced programmers.
> Perhaps they did what they did because of some particular insight
> that others have missed, or perhaps it was a mistake.  As far as
> I can tell, you have not even attempted to determine this
> experimentally.
     
Most of us grew up with FORTRAN, COBOL, or assmbly language. The meaning
of `=' being assignment is deeply rooted in computer pre-science history.
     
Whether `:=' may be a better choice for modern languages, I don't know.
What really matters is that you *can* assign within conditionals.
     
I agree that if `:=' was assignment and `=' was equality one would
almost never make the assignment-instead-of-equality-mistake. I find
I almost never make that mistake anyway, and when I do, the resulting
bugs are fairly obvious.
     
> >If they had my brains, they would have used Pascal's method.  Better yet,
> >they should have let someone else write up C.
> >
> >Edward Jung, Stevens Institute of Technology
> >JUNG_E@SITVXB.BITNET
     
> If C were different, it would be different.  That tells us nothing.
> C as it is now is quite obviously rather popular.  How many languages
> have you designed, and who is using them?
> --
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
> UUCP:    seismo!umcp-cs!chris
> CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
Yow!  Now I get to think about all the BAD THINGS I did to a BOWLING BALL
when I was in JUNIOR HIGH SCHOOL!
     
P.S. I realize I misused the word `diphthongs', as they are restricted
to vowels, but I just couldn't resist! Did you catch that? Yow!
     
P.P.S. Sorry to quote so much, but CT's thoughts deserve repetition.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3013
          for JMS@ARIZMIS; Tue,  1-JUL-1986 01:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/01/86 at 03:29:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014388; 1 Jul 86 4:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015900; 1 Jul 86 4:09 EDT
From: Terry Sejnowski <terry@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <1856@brl-smoke.ARPA>
Date: 1 Jul 86 08:08:33 GMT
Keywords: C, Pascal, =, :=, ==
To:       info-c@BRL-SMOKE.ARPA
     
In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
>...
>Why can't C be like everybody else?  Practically every language uses
>the equals sign, "=", to test for equality, not as an assignment operator.
> ... Kernighan and Ritchie, in their infinite wisdom, decide
>instead to use "=" for assignments and to create a new operator, "==" to
>test for equality.  Gee, that must have required brains, the brains of
>a 3 year old.
>
>If they had my brains, they would have used Pascal's method.  Better yet,
>they should have let someone else write up C.
     
    When I first read the above I was ready to flame away, but
I decided to check my facts and come back to it later.  Well now I'm
ready. :-)
     
    The poster of the message above implies that K&R didn't have
the faintest idea what they were doing and didn't bother to examine
other languages (specifically Pascal) before going on their merry way.
Well this sounded sort of fishy to me and I checked out the dates.
     
Ancestory of C            Ancestory of Pascal
--------------            -------------------
     
Algol 60 - 1960 (Inter. Comm.)    Algol 60 - 1960 (Inter. Comm.)
CPL - 1963 (Cambridge and UL)    Pascal - draft written - 1968 (Wirth)
BCPL - 1967 (Martin Richards)    Pascal - first compiler - 1970
B - 1970 (Ken Thompson)        Pascal - first publication - 1971
C - 1972 (Dennis Ritchie)    Pascal - revised report - 1973
     
    Seems to me that it would be kind of hard to justify using
Pascal as the basis for further work when at best it had been in use
for a year or two.   My impression is that around that time a lot of
languages were being written and picking the winners would have taken a
crystal ball.
     
    As to the symbols used to denote assignment and test for
equality, I couldn't find any information on B, but the book on BCPL
used := for assignment and = to test for equality.  It also used = to
set the value of a named constant.  It took me a minute to realize what
was going on there so I can see re-examining the issue when designing a
new language.
     
Quick Jab:
    If Pascal is so good why did its author (N. Wirth) write
two other languages (Modula & Modula II) before deciding he had one
which could be used for system implementation? (Lilith (sp?))
     
                Bill Bogstad
                bogstad@hopkins-eecs-bravo.arpa
     
Disclaimer: The above is true to the best of my knowledge.  Corrections
    cheerfully accepted.  Flames to /dev/null.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0869
          for JMS@ARIZMIS; Tue,  1-JUL-1986 08:56 MST
Received: from OZ.AI.MIT.EDU by wiscvm.arpa on 07/01/86 at 10:29:00 CDT
Received: from DIAMOND.BBN.COM by MC.LCS.MIT.EDU  1 Jul 86 10:05:59 EDT
Received: by DIAMOND.BBN.COM (1.1/4.7)  id AA11708; Tue, 1 Jul 86 10:02:31 EDT
Date: Tue, 1 Jul 86 10:02:31 EDT
From: Anders Weinstein <aweinste@DIAMOND.BBN.COM>
Message-Id: <8607011402.AA11708@DIAMOND.BBN.COM>
To: metaphilosophers%mit-oz@MC.LCS.MIT.EDU
Subject: Re: an ethical question
     
> From: "Scott W. Layson" <Gyro@AI.AI.MIT.EDU>
>
>> Ok, suppose such an event occurs so often that we decide to coin a word
>> for it: let's say we call it "passivicide" -- the deliberate withholding of
>> life-saving efforts with malicious intent. Now all of a sudden the heir
>> might not seem so passive -- after all, he hasn't just failed to do
>> something, he has positively COMMITTED an act of passivicide.
>
> I believe I've heard of a crime in our legal system by the name of
> "homicidal negligence".
     
No doubt there are such offenses in lots of legal codes. However, I also
wouldn't be surprised if the suspect active/passive distinction is enshrined
througout the common law as well (eg. to determine the severity of
the offenses, "active" is usually worse than "passive").
     
My point was simply that I don't understand what's "passive" and what's
"active" -- I think it all depends on how you phrase the description:
"failing to save a life" sounds passive; "committing a heinous act of
passivicide" sounds active. I wouldn't want to base an ethical philosophy on
such a flimsy distinction.
     
Anders
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1206
          for JMS@ARIZMIS; Tue,  1-JUL-1986 09:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/01/86 at 11:00:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028420; 1 Jul 86 11:47 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa24385; 1 Jul 86 10:51 EDT
Received: from bbn-labs-b.arpa by AOS.BRL.ARPA id a026258; 1 Jul 86 10:49 EDT
To: info-c@BRL.ARPA
cc: prentice@S1-ENTERPRISE.ARPA, rgenter@BBN-LABS-B.ARPA
Subject: ending the debate over = vs. ==
Date: 01 Jul 86 10:46:10 EDT (Tue)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     I'm getting tired of reading about = vs. ==, so I am going to make a
proposal that should end the debate once and for all.
     
     The points which have been outlined so far are:
     
    * == is too easy to mistype as =, and C treats = as an operator, so
      no error gets flagged;
     
    * = is shorter than ==, and since assignment is used more frequently
      than the equality comparison, this is as it should be;
     
    * other languages use := for assignment and = for equality and don't
      seem to have any problem, although some of them don't allow
      assignment embedded within expressions, so this is a moot point;
     
    * various arguments about what mathematicians think.
     
     Notice that this debate never came up in Fortran.  Since I believe in
learning from the past, I propose that
     
    * the assignment operator be changed to .GETS.
    * the equality operator be changed to .IS.EQUAL.TO.
     
The meaning is obvious and doesn't get confused with current mathematical
symbols.  The assignment operator is shorter than the equality operator.
Fortran has used a similar symbology for 30 years now.  It's not likely that
you could mistype one as the other.
     
     As an added bonus, a special preprocessor switch could be added to allow
an alternative form of the equality operator to be recognized, namely .ZEKWAL2,
which involves even less typing, yet retains all of the above properties (with
the possible exception of obvious meaning).  I propose naming this switch -RBJ.
     
     So there.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1399
          for JMS@ARIZMIS; Tue,  1-JUL-1986 09:22 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/01/86 at 11:17:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029177; 1 Jul 86 12:04 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a026557; 1 Jul 86 11:40 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA10230; Tue, 1 Jul 86 11:15:00 edt
Date: Tue, 1 Jul 86 11:15:00 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607011515.AA10230@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, terry@BRL-SMOKE.ARPA
Subject: Re: PRECEDENT FOR USE OF =
     
> Quick Jab:
>     If Pascal is so good why did its author (N. Wirth) write
> two other languages (Modula & Modula II) before deciding he had one
> which could be used for system implementation? (Lilith (sp?))
     
Really! Pascal: The language that could have been C.
Wirth is an idiot. Blaise is rolling over in his grave.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
     
The opinions expressed are my own.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1740
          for JMS@ARIZMIS; Tue,  1-JUL-1986 09:41 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/01/86 at 11:38:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029825; 1 Jul 86 12:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026901; 1 Jul 86 11:49 EDT
From: flaps%utcs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <1986Jun30.203536.6984@utcs.uucp>
Date: 1 Jul 86 00:35:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
>Why can't C be like everybody else?  Practically every language uses
>the equals sign, "=", to test for equality, not as an assignment operator.
>...
>              Kernighan and Ritchie, in their infinite wisdom, decide
>instead to use "=" for assignments and to create a new operator, "==" to
>test for equality.
     
Not only that, they changed "begin" and "end" to { and }, changed "writeln"
to puts, and all sorts of awful things!  They made it into a WHOLE NEW
LANGUAGE!!!!!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1815
          for JMS@ARIZMIS; Tue,  1-JUL-1986 09:47 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/01/86 at 11:37:38 CDT
Received: from cu-arpa.cs.cornell.edu by SRI-KL.ARPA with TCP; Mon 30 Jun 86
  06:25:18-PDT
Received: by cu-arpa.cs.cornell.edu (5.31/4.30)
    id AA00585; Mon, 30 Jun 86 09:23:51 EDT
Date: Sun, 29 Jun 86 20:55:44 EDT
From: garry@tcgould.tn.cornell.edu (Garry Wiegand)
Message-Id: <8606300055.AA18979@tcgould.tn.cornell.edu>
Received: by tcgould.tn.cornell.edu (5.9/4.30)
    id AA18979; Sun, 29 Jun 86 20:55:44 EDT
Newsgroups: net.decus,net.unix,net.usenix,mod.computers.vax
Subject: Re: Favorite operating systems query
Reply-To: garry%cadif-oak@cu-arpa.cs.cornell.edu
Organization: Cornell Engineering && Flying Moose Graphics
Apparently-To: info-vax@sri-kl.arpa
     
By just saying what I *liked* about VMS, and not saying *anything* about
any other operating system, I was trying hard not to get drawn into the
Unix wars. But I can't take the all the nonsense (tho there's been some
sense too) that's been flowing by. Specifically:
     
1) Any message that begins with something of the form of "I prefer Unix but
   I'm a VMS expert too and I know you can't do ..." deserves an immediate
   'n' key. The body of the message can be safely assumed to be wrong.
     
2) The C language and the C run-time library are no longer the same thing as
   "Unix"! I have cheerfully carried C programs full of library calls
   back and forth between my VMS Vax, my Unix Vax, a MS-DOS PC, and a
   MacIntosh. It's easy. When I want to create a file with a specific file
   protection (not that I ever have wanted such a thing :-)) I call 'creat'.
   Yes, on VMS! What we're supposed to be having here is a system war, not
   a language war. Let's keep it pure, people!
     
3) The c-shell and Bourne shell are fine and wonderful in and of themselves,
   and would be a nice amenity on any system. Wollongong's implementation
   of them on VMS side-stepped the process creation problem, but they
   unfortunately lost the DCL commands somewhere else along the way,
   leaving only the Unix syntax. I like my DCL command syntax and I'd
   love to be able to wrap a better control structure around them. (I
   haven't seen Dec/Shell yet; don't know if they did it right.)
   Anyhow, the *shell* isn't "Unix" either!
     
4) What *is* unique to a Unix system are the Unix system service calls,
   like 'stty' and 'fork' (as opposed to 'vfork').  This has made carrying
   system-referencing utilities between vanilla unixae pretty easy, and I
   can't deny it. But see diatribe.
     
*Diatribe begins here*
     
What I see now is Berkeley diverging from Bell Labs, all the micros
out there diverging from both, and many wizards burning the midnight oil
adding whizbangs like sockets, asynchronous I/O, window managers,
semaphores and network file systems -- things that will never be propagated
to the whole unix world. Soon you will have to refer to Unix as "a family
of operating systems", seriously overlapping with other systems like VMS.
     
Which is all to the good. "Cross-fertilization", says I. "Willingness to
listen to other ideas", says I.  When it comes to something as complex as
an operating system and all its support utilities, don't close yourself
out. Standards are for dead people.
     
(Now, can I please have a good Ultrix debugger?)
     
*end diatribe*

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1998
          for JMS@ARIZMIS; Tue,  1-JUL-1986 09:55 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/01/86 at 11:50:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000487; 1 Jul 86 12:35 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a026473; 1 Jul 86 11:39 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA10269; Tue, 1 Jul 86 11:37:27 edt
Date: Tue, 1 Jul 86 11:37:27 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607011537.AA10269@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Re: Additions to C - range checking
     
    >if (5<a<50) do_something(a);
    >
    >Is this impossible to parse?
     
    This was in BCPL, and was a GOOD IDEA.
     
COBOL has this too. It is not impossible to parse, but it is not trivial
either. It requires lookahead to resolve the meaning. Perhaps another syntax?
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
The entire CHINESE WOMEN'S VOLLEYBALL TEAM all share ONE personality --

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6701
          for JMS@ARIZMIS; Tue,  1-JUL-1986 17:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/01/86 at 19:37:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013587; 1 Jul 86 20:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004875; 1 Jul 86 19:07 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re:  LPow correction
Message-ID: <1880@brl-smoke.ARPA>
Date: 1 Jul 86 23:07:04 GMT
Followup-To: net.math
To:       info-c@BRL-SMOKE.ARPA
     
In article <3055@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) shows that
    limit as (x,y)->(0,0) of x^y
is path-dependent, which is quite correct and no news at all to anyone
who has studied complex analysis.  The reason I selected 1 as the return
value for 0^0 rather than my initially-coded 0 is that almost all (in a
technical sense) paths yield that value for the limit of x^y.  Of course,
0^0 really is not well-defined; I just wanted to return the most generally
useful value for that case, since I was explicitly not coding in any error
handling.  0^0 "=" 1 turns out to be much more useful in computation than
0^0 "=" 0; neither one is really "right".
     
My general philosophy about such things as 1/0, 0^0, atan2(0.,0.), etc.
is that the application programmer should never allow such situations to
occur in the first place, since they're obviously illegal, improper, ill-
defined, or whatever.  However, when implementing a general function that
may be used by careless programmers, a decision has to be made about how
to cope with such abuse.  For LPow(), I decided to always do something
sane, quietly, since this was intended as an example of how to obtain
run-time integer exponentiation without embedding it in the language.
Another good solution for math library functions in general is to trigger
matherr() or some similar error handling and recovery scheme.
     
In summary:  When writing code for general use, watch for abuse and
do SOMEthing deliberate (and relatively sensible) when it occurs.
When writing applications, never try to do anything ill-defined.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9624
          for JMS@ARIZMIS; Wed,  2-JUL-1986 00:59 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/02/86 at 02:54:49 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Mon 30 Jun 86 09:22:34-PDT
Date: 30 JUN 1986 12:21:36 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: bzs%bu-cs.bu.edu@csnet-relay.arpa
cc: info-vax@sri-kl
Subject:  Re: main() and entry points in C
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
    >From: LEICHTER-JERRY@YALE.ARPA
      ...an attempt to explain _start(), ld, C, null pointers etc...
     
    There are so many horrendous mistakes in this article it would take
    a month to straighten it out.
     
    Suffice it to say I simply hope no takes it seriously, he tries to
    state things as if he knows what he is talking about, but he doesn't.
     
    Perhaps he could post his article to INFO-C or net.lang.c and
    find out how far off it is on almost everything.
     
    Trust me folks, this is one to ignore.
     
        -Barry Shein, Boston University
     
    [Must I have the energy to go point by point just to warn readers? no.]
I don't know about the energy, you seem to have plenty of that.  Things worth
saying, now, that's another issue.
     
When you've demonstrated any knowledge of anything related to this issue, I
might take you seriously.  But I have yet to see anything from you beyond the
typical "Unix is the solution, everything else is just the problem".
     
Grow up.
                            -- Jerry
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0024
          for JMS@ARIZMIS; Wed,  2-JUL-1986 01:49 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/02/86 at 03:45:06 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Mon 30 Jun 86 09:28:53-PDT
Date: 30 JUN 1986 12:21:44 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: bobp%tektools.tek.csnet@CSNET-RELAY.ARPA
cc: info-vax@sri-kl
Subject:  Re: Potential C problem
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
        Perhaps I missed something in the documentation, but can anyone
    tell me why the VMS C compiler doesn't allow a value of 0 in %x1 as in the
    following example ?
     
    [example omitted]
     
    Robert N. Perry (Bob)
Known bug; I believe it's fixed in VAX C V2.2.
                                -- Jerry
-------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0669
          for JMS@ARIZMIS; Wed,  2-JUL-1986 08:16 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/02/86 at 09:53:02 CDT
Received: from decwrl.DEC.COM by SRI-KL.ARPA with TCP; Mon 30 Jun 86
  18:32:14-PDT
Received: from DEC-RHEA.ARPA (dec-rhea) by decwrl.DEC.COM (4.22.05/4.7.34)
    id AA01386; Mon, 30 Jun 86 18:32:54 pdt
Message-Id: <8607010132.AA01386@decwrl.DEC.COM>
Date: Monday, 30 Jun 1986 18:29:08-PDT
From: kaiser%furilo.DEC@decwrl.DEC.COM  (Systems Consultant)
To: info-vax@sri-kl.ARPA, kaiser%furilo.DEC@decwrl.DEC.COM
Subject: Re: main() and entry points in C
     
>>From: LEICHTER-JERRY@YALE.ARPA
>> ...an attempt to explain _start(), ld, C, null pointers etc...
>
>...
>Trust me folks, this is one to ignore.
>
>    -Barry Shein, Boston University
>
>[Must I have the energy to go point by point just to warn readers? no.]
     
Thank you, Barry, for your extremely factual and informative comment.  I'm
afraid you have the wrong answer for your final question, however, which falls
under the rule of "put up or shut up".    Otherwise it's just libel.
     
---Pete
     
Kaiser%furilo.dec@decwrl.dec.com
decwrl!furilo.dec.com!kaiser
DEC, 2 Iron Way (MRO3-3/G20), Marlboro MA 01752     617-467-4445

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5692
          for JMS@ARIZMIS; Wed,  2-JUL-1986 21:41 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024086; 2 Jul 86 22:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008416; 2 Jul 86 21:48 EDT
From: Peter Fales <psfales%ihlpl.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c,net.wanted.sources
Subject: Re: How do I get a directory in MSC?
Message-ID: <1045@ihlpl.UUCP>
Date: 29 Jun 86 23:58:57 GMT
Posted: Sun Jun 29 19:58:57 1986
To:       info-c@BRL-SMOKE.ARPA
     
> Can anybody out there in net.land tell me how to get a directory on DOS 3.1
> using MS C 3.0?  I would like to write my own ls for DOS, but not knowing
> how to get a directory makes it rather difficult to write such a thing. :-)
>
Are you sure your C library does not have functions for this?  If not,
are there functions for doing DOS system calls?  Check out system calls
0x4E and 0x4F.
     
Peter Fales
ihnp4!ihlpl!psfales

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5764
          for JMS@ARIZMIS; Wed,  2-JUL-1986 21:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/02/86 at 23:39:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024194; 2 Jul 86 22:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008428; 2 Jul 86 21:49 EDT
From: ddrex%gorgo.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Query: C for RT-11
Message-ID: <18300004@gorgo.UUCP>
Date: 26 Jun 86 17:16:00 GMT
Nf-ID: #N:gorgo.UUCP:18300004:000:316
Nf-From: gorgo.UUCP!ddrex    Jun 26 12:16:00 1986
Posted: Thu Jun 26 13:16:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
Do any C compilers exist for RT-11 besides the Whitesmith's?  We got a DECUS
implementation that was supposedly for that os, but turned out not to have any
of the low level functions (like read(), write(), open(), etc).
     
Replies by email will be GREATLY appreciated!
     
David Drexler
{ihnp4,cbosgd}!occrsh!gorgo!ddrex

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6047
          for JMS@ARIZMIS; Wed,  2-JUL-1986 22:26 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/02/86 at 23:52:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024212; 2 Jul 86 22:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008653; 2 Jul 86 21:56 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <2226@umcp-cs.UUCP>
Date: 2 Jul 86 04:51:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1836@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB)
<gwyn>) wrote:
>>It may be amusing and/or instructive to contemplate the fact that
>>there is no way to write a function that exchanges the contents of
>>two variables in a language where parameters are passed "by name".
     
In article <2225@umcp-cs.UUCP> I replied:
>I have here a C program that effects call-by-name and does
>indeed perform a swap:
     
What I failed to consider, of course, is the classic problem with
call by name: arrays.  Watch what happens when I `swap' `i' and
`a[i]', using an expanded form of the swap function (this is
necessary to avoid compiler dependencies in this particular case).
     
Ah well, at least I caught my error myself. . . .
     
swap(f1, f2)
    int *(*f1)(), *(*f2)();
{
    int t1, t2;
     
    t1 = *(*f1)();
    t2 = *(*f2)();
    *(*f1)() = t2;
    *(*f2)() = t1;
}
     
int    a[10], i;
     
int *
addr_asubi()
{
     
    return (&a[i]);
}
     
int *
addr_i()
{
     
    return (&i);
}
     
/*ARGSUSED*/
main(argc, argv)
    int argc;
    char **argv;
{
     
    a[3] = 6;
    a[6] = 1;
    i = 3;
    swap(addr_i, addr_asubi);
     
    /*
     * Want i to become 6 and a[3] to become 3, with a[6] left
     * undisturbed.  That is not what happens.  Figure out what
     * it will in fact do, before you run it.
     */
    printf("`should' be 6, 3, 1: i = %d, a[3], a[6] = %d\n",
        i, a[3], a[6]);
    exit(0);
}
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5901
          for JMS@ARIZMIS; Wed,  2-JUL-1986 22:26 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/02/86 at 23:45:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024204; 2 Jul 86 22:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008438; 2 Jul 86 21:49 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <2225@umcp-cs.UUCP>
Date: 1 Jul 86 19:17:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1836@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn
(VLD/VMB) <gwyn>) writes:
>It may be amusing and/or instructive to contemplate the fact that
>there is no way to write a function that exchanges the contents of
>two variables in a language where parameters are passed "by name".
     
How so?  It seems rather simple.  I have here a C program that effects
call-by-name and does indeed perform a swap:
     
/*
 * Call by name example of swap.
 *
 * Call by name is done by passing `thunks', where a `thunk' is a
 * function that returns the address of an argument.  In this case
 * calling the function provided via `f1' returns the address of
 * the first argument; indirecting through this address produces
 * the argument itself, as an lvalue (i.e., `named').  Similarly,
 * indirection through f2's return value names the second argument.
 */
swap(f1, f2)
    int *(*f1)(), *(*f2)();
    /* `pointer to function returning pointer to int' */
{
    int t;
     
    t = *(*f1)();
    *(*f1)() = *(*f2)();
    *(*f2)() = t;
}
     
/*
 * Here are the variables we will address for swap().
 */
int    a, b;
     
/*
 * Here are the two `thunk' functions.
 */
int *
addr_a()
{
     
    return (&a);
}
     
int *
addr_b()
{
     
    return (&b);
}
     
/*
 * Finally, demonstrate that swap() does indeed work:
 */
/*ARGSUSED*/
main(argc, argv)
    int argc;
    char **argv;
{
     
    a = 3;
    b = 7;
    swap(addr_a, addr_b);
    printf("should be 7, 3: a = %d, b = %d\n", a, b);
    exit(0);
}
     
/*
 * Incidentally, `swap' can be passed a thunk that names an expression;
 * here is what a call-by-name compiler might generate for `a+b':
 *
 * int *
 * addr_aplusb()
 * {
 *    int t = a + b;
 *
 *    return (&t);
 * }
 */
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6198
          for JMS@ARIZMIS; Wed,  2-JUL-1986 22:32 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 00:01:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024214; 2 Jul 86 22:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008706; 2 Jul 86 21:57 EDT
From: Robert C Sanders <sandersr%ecn-pc.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c,net.sources
Subject: Re: How do I get a directory in MSC?
Message-ID: <536@ecn-pc.UUCP>
Date: 1 Jul 86 05:27:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1045@ihlpl.UUCP> psfales@ihlpl.UUCP (Peter Fales) writes:
>> Can anybody out there in net.land tell me how to get a directory on DOS 3.1
>> using MS C 3.0?  I would like to write my own ls for DOS, but not knowing
>> how to get a directory makes it rather difficult to write such a thing. :-)
>>
>Are you sure your C library does not have functions for this?  If not,
>are there functions for doing DOS system calls?  Check out system calls
>0x4E and 0x4F.
>
     
The following is program that I picked off a C Language Fido-Net BBS in the
New Jersey area.  I have easily compiled it under the Computer Innovation's
C86 compiler, but I have friends that have ported it to MS C, Aztec C, and
Latice C, all with little or no problems.  Try several of the options.  The
comments document the program.  It is also good learning in several of the
DOS interupt calls.  My compiled version runs under all versions of PC/MS DOS
2.xx, and 3.xx.  (my binary crosses between them no problem)  Combined with
the switch character change for directory names, and add a few UNIX-like
utilities, and well..... UNIX in PC DOS? :-)
     
            Have fun..    - bob
-----------CUT HERE----------------------------------CUT HERE------------
     
/* ls - a Unix-like directory listing program for MS-DOS 2.x
 *
 * Copyright (c) 1984  R. Edward Nather
 *
 */
     
#include <stdio.h>
#define CIC86
     
/* customizing constants */
     
#define QS       '\\'            /* filename separator character */
#define DQS       "\\"            /* filename separator (string) */
#define ID     1            /* always identify directory if 1 */
#define ALL     1            /* show hidden files by default if 1 */
#define LONG     1            /* long listing by default if 1 */
#define COLM     0            /* 1-column listing by default if 1 */
#define RSORT    0            /* reverse sort by default if 1 */
#define TSORT    0            /* time sort by default if 1 */
#define DU    0            /* include disk use by default if 1 */
/* #define ANSI    */            /* if ansi.sys has been loaded */
     
     
#define NAMESIZ 13            /* 12 character name + NULL */
#define ONECS 512            /* cluster size on one-sided floppy */
#define TWOCS 1024            /* cluster size on two-sided floppy */
#define HARDCS 4096            /* cluster size on hard disk */
#define SCRSIZ 22            /* scrolling size of display screen */
     
struct dta                    /* DOS Disk Transfer Address table */
    {
    char reserved[21];        /* used in "find next" operation */
    char attr;                /* file attribute byte */
    int ftime;                /* time of last modification */
    int fdate;                /* date of last modification */
    long fsize;                /* file size in bytes */
    char fname[NAMESIZ];    /* filename and extension */
    };
     
struct outbuf                /* output buffer -- array of file structs */
    {
    unsigned oattr;
    unsigned odate;
    unsigned otime;
    long osize;
    char oname[NAMESIZ+1];
    } *obuf;
     
char spath[80];                /* holds current pathname string */
     
/* global variables and flags */
     
int allf = ALL;                /* include hidden & system files */
int ll = LONG;                /* long listing */
int colm = COLM;            /* 1-column format */
int rev = RSORT;            /* reverse sort */
int tsrt = TSORT;            /* timesort the listing */
int usage = DU;                /* print disk usage */
int recd;                    /* recursive descent requested */
int sizonly;                /* only print sizes */
     
int np;                        /* number of groups printed */
int nargs;                    /* number of non-option arguments */
int clsize = 0;                /* size of a cluster, in bytes */
int clmask;                    /* clsize-1 for rounding & chopping */
int drive;                    /* code number for drive requested */
int tsc;                    /* 1 if output is to console screen */
long left;                    /* unused space left on disk */
long total;                    /* total of sizes encountered */
     
main(argc, argv)
int argc;
char *argv[];
{
char *s;
int c = 0;
int nt = 0;
     
/* process input options */
while(--argc > 0 && (*++argv)[0] == '-') {
    for(s = argv[0]+1; *s != '\0'; s++) {
        switch(tolower(*s)) {
            case 'a':                    /* -a: list all files */
                allf = (allf == 0);        /* reverse default value */
                break;
            case 'c':                    /* -c: 1-column listing requested */
                colm = (colm == 0);
                break;
            case 'l':                    /* -l: long listing requested */
                ll = (ll == 0);
                break;
            case 'r':                    /* -r: reverse sort direction */
                rev = (rev == 0);
                break;
            case 's':                    /* -s: print sizes only */
                sizonly = 1;
                if(*(s+1) == '1') {
                    clsize = ONECS;        /* diskuse for 1-sided floppy */
                    s++;
                    nt++;
                    }
                else if(*(s+1) == '2') {
                    clsize = TWOCS;            /* or 2-sided */
                    s++;
                    nt++;
                    }
                break;
            case 't':                    /* -t: time sort requested */
                tsrt = (tsrt == 0);
                break;
            case 'u':                    /* -u: print disk usage */
                usage = (usage == 0);
                break;
            case 'R':                    /* -R: recursively list subdirs */
                recd = 1;
                break;
            default:
                fprintf(stderr, "unknown arg %c\n", *s);
                exit(1);
            }
        }
    }
     
nargs = argc;
tsc = toscreen();            /* find out if output is to console screen */
obuf = (struct outbuf *)malloc(sizeof(*obuf));    /* point to free memory */
     
if(argc == 0) {
    argc++;
    curdrv(spath);                    /* default to current drive */
    }
else
    strcpy(spath, *argv);
     
for(;;) {                            /* cycle through args present */
    if(spath[1] == ':' && spath[2] == '\0')        /* if drive only */
        getpath(spath);                            /* get path */
    if(usage || sizonly || ll)
        c = getsize(spath);            /* get use data only if needed */
    if(c == 0)
        search(spath);                /* go do the hard work */
    if(--argc > 0)
        strcpy(spath, *++argv);
    else {
        if(usage || sizonly) {
            if(np > 1) {
                fprintf(stdout, "-------\n%7ld bytes total", total);
                if(!nt)
                    fputs("; ", stdout);
                }
            if(!nt)
                fprintf(stdout, "%7ld bytes left on drive %c\n",
                    left, drive+'a');
            }
        return;
        }
    }
}
     
getsize(path)        /* get file cluster size */
char *path;
{
if(clsize == 0)                            /* if size not already set */
    if((clsize = getcl(path)) == 0) {    /* get cluster size for drive */
        fprintf(stderr,
         "Invalid drive: %c\n", *path);
        return(1);
        }
clmask = clsize-1;
return(0);
}
     
/* toscreen - find out if output is to console screen */
     
toscreen()
{
struct { unsigned int ax, bx, cx, dx, si, di, ds, es;
       } r;
     
r.ax = 0x4400;
r.bx = 1;
sysint(0x21, &r, &r);
return(r.dx & 1);
}
     
/* search - search 'path' for filename or directory */
     
search(path)
char *path;
{
struct dta dta;                    /* DOS file data table */
extern struct outbuf;            /* array of file structs */
extern int nargs;                /* number of files or directories */
int path_len;                    /* length of initial path */
int z;                            /* char counter */
int k = 0;                        /* counts number of entries found */
char work[80];                    /* working path string */
int comp();                        /* string, time comparison routine */
int mask = 0x0010;                /* attribute mask */
long bytes = 0;                    /* count of disk usage this directory */
     
if(allf)
    mask = 0x001F;
strcpy(work,path);
path_len = strlen(work);        /* save original path length */
     
if(!find_first(work, &dta, 0) || work[path_len-1] == QS) {
    if(work[path_len-1] != QS) {
        strcat(work, DQS);                /* if path is to a directory */
        path_len++;
        }
    strcat(work,"*.*");                    /* list everything in it */
    }
     
if(find_first(work, &dta, mask)) {
    do {
        if(dta.attr & 0x08)                    /* ignore volume label */
            continue;
        if(dta.fname[0] == '.' && !allf)    /* unless -a option */
            continue;                        /* ignore "." and ".." */
     
        obuf[k].oattr = dta.attr;            /* stash this entry */
        obuf[k].otime = dta.ftime;
        obuf[k].odate = dta.fdate;
        obuf[k].osize = dta.fsize;
        strcpy(obuf[k].oname, dta.fname);
     
        if(usage || sizonly) {
            if((dta.attr & 0x10) && dta.fname[0] != '.') {
                bytes += clsize;                /* sum up disk usage */
                }
            else if(dta.fsize) {
                obuf[k].osize = ((dta.fsize + clmask) & (long)(~clmask));
                bytes += obuf[k].osize;
                }
            }
     
        k++;
        } while(find_next(&dta));
    }
else {
    work[path_len-1] = NULL;
    fprintf(stderr, "Can't find a file or directory named \"%s\"\n", work);
    return;
    }
     
work[path_len] = NULL;                        /* restore directory pathname */
if(np++ && !sizonly)
    fputc(endlin(),stdout);                            /* separate listing
 blocks */
if(usage || sizonly) {
    total += bytes;                                    /* total bytes to date */
    fprintf(stdout, "%7ld  ", bytes);
    }
if(recd || nargs > 1 || usage || sizonly || ID) {
    fprintf(stdout, "%s", work);                    /* identify the block */
    fputc(endlin(),stdout);
    }
if(!sizonly) {
    qsort(obuf,k,sizeof(obuf[0]),comp);                /* sort the entries */
    if(ll)
        longlist(k);                                /* and print them */
    else
        shortlist(k);
    }
if(!recd)
    return;                                            /* quit if not -R */
strcat(work, "*.*");
if(find_first(work, &dta, mask))                /* else find all sub-dirs */
    do    {
        if(dta.attr & 0x10 && dta.fname[0] != '.') {
            work[path_len] = 0;                        /* discard old name */
            for(z=0; dta.fname[z] != NULL; z++)
                dta.fname[z] = tolower(dta.fname[z]);
            strcat(work, dta.fname);                /* install a new one */
            strcat(work, DQS);
            search(work);                            /* and recurse */
            }
    } while(find_next(&dta));
return;
}
     
/* find_first - find first file in chosen directory */
     
find_first(path, dta, mask)
char *path;
struct dta *dta;
int mask;
{
struct { int ax, bx, cx;
         char *dx;
         int si, di, ds, es;
       } r;
extern int _showds();
     
r.ax = 0x1A00;                            /* DOS interrupt 1A */
r.dx = (char *)dta;
r.ds = _showds();
sysint(0x21, &r, &r);                    /* sets data transfer address */
     
r.ax = 0x4E00;                            /* DOS interrupt 4E */
r.cx = mask;
r.dx = path;
r.ds = _showds();
return(!(sysint(0x21, &r, &r) & 1));    /* fills the structure */
}
     
/* find_next - find the next file in the same directory */
     
find_next(dta)
struct dta *dta;
{
struct { int ax, bx, cx;
         char *dx;
         int si, di, ds, es;
       } r;
extern int _showds();
     
r.ax = 0x1A00;
r.dx = (char *)dta;
r.ds = _showds();
sysint(0x21, &r, &r);                            /* set dta */
     
r.ax = 0x4F00;
return(!(sysint(0x21, &r, &r) & 1));            /* fill the table */
}
     
/* curdrv - get current default drive */
     
curdrv(sp)
char *sp;
{
struct { int ax, bx, cx;
         char *dx, *si, *di, *ds, *es;
       } r;
     
r.ax = 0x1900;                            /* DOS interrupt 19 */
sysint(0x21, &r, &r);                    /* gets current drive number */
*sp++ = r.ax + 'a';                        /* convert to symbolic drive name */
*sp++ = ':';
return;
}
     
/* getpath - get path to directory on indicated drive */
     
getpath(sp)
char *sp;
{
struct { int ax, bx, cx, dx;
         char *si;
         int di, ds, es;
       } r;
extern int _showds();
     
strcat(sp, DQS);            /* append root file symbol to drive name */
     
r.ax = 0x4700;                /* DOS interrupt 47 gets path string */
r.dx = *sp - '`';            /* convert drive name to index */
r.ds = _showds();
r.si = sp + 3;                /* paste string after root symbol */
sysint(0x21, &r, &r);
return;
}
     
/* getcl - get cluster size & space left on requested drive */
     
getcl(pp)
char *pp;
{
struct { int ax, bx, cx, dx, si, di, ds, es;} r;
int cs;
extern long left;
extern int drive;
     
if(*(pp+1) == ':')                    /* use specified drive if any */
    r.ax = *pp - 'a';
else {
    r.ax = 0x1900;                    /* else get code for default drive */
    sysint(0x21, &r, &r);
    }
drive = r.ax & 0x7F;
if(!usage && !sizonly && drive == 2)
    return(HARDCS);
else {
    r.dx = drive + 1;                /* 0 = default, 1 = a, etc */
    r.ax = 0x3600;
    sysint(0x21, &r, &r);            /* DOS interrupt hex 36 */
    if(r.ax == 0xFFFF)                /* gets free disk space */
        return(0);                    /* and other goodies */
    else {
        cs = r.ax * r.cx;            /* r.ax = sectors/cluster */
        left = (long)cs * r.bx;        /* r.bx = # unused clusters */
        return(cs);                    /* r.cx = bytes/sector */
        }                            /* r.dx = drive capacity (clusters) */
    }
}
     
/* comp - compare size of two entries */
     
comp(a,b)
struct outbuf *a, *b;
{
int y;
     
if(tsrt) {
    if(a->odate != b->odate)                    /* if dates differ */
        y = (a->odate < b->odate) ? -1 : 1;        /* that settles it */
    else
        y = (a->otime < b->otime) ? -1 : 1;        /* else compare times */
    return((rev) ? y : -y);
    }
else {
    y = strcmp(a->oname, b->oname);                /* name comparison */
    return((rev) ? -y : y);
    }
}
     
/* shortlist - print a list of names in 5 columns */
     
shortlist(k)
int k;                    /* total number to print */
{
int i, m, n;
     
if(colm)
    n = k;                /* set for 1-column listing */
else
    n = (k + 4)/5;        /* or 5-column */
     
for(i=0; i < n; i++){
    for(m = 0; (i+m) < k; m += n) {
        if(obuf[i+m].oattr & 0x10)
            strcat(obuf[i+m].oname, DQS);        /* mark directories */
        putname(i+m);                            /* print the name */
        fputs("   ", stdout);
        }
    fputc(endlin(),stdout);
    }
return;
}
     
/* putname - convert name to lower case and print */
     
putname(i)
int i;
{
int c, j = 0;
     
while((c = tolower(obuf[i].oname[j])) != 0) {
    fputc(c, stdout);
    j++;
    }
while(j++ < NAMESIZ - 1)                    /* pad to columnarize */
    fputc(' ', stdout);
}
     
/* endlin - end a line and watch for screen overflow */
     
static int lc = 0;                    /* line counter */
     
endlin(fp)
FILE *fp;
{
extern int tsc;                            /* true if output is to screen */
int c;
     
if(tsc && ++lc >= SCRSIZ) {            /* pause if output is to console screen
 */
                /* and we've shown a screenful */
#ifdef ANSI
    fputs("\n\033[30;43m--More--", fp); c = ci();
    fputs("\033[32;40m\b\b\b\b\b\b\b\b        \b\b\b\b\b\b\b", fp);
#else
    fputs("\n--More--", fp); c = ci();
    fputs("\b\b\b\b\b\b\b\b        \b\b\b\b\b\b\b", fp);
#endif
    switch(c) {
        case '\r':                    /* <RETURN> - show 1 more line */
            lc = SCRSIZ - 1;
            break;
        case 'q':                    /* quit with "q" or "ctrl-C" */
        case '\003':
            exit(0);
        default:
            lc = 0;                    /* else show another screenful */
            break;
        }
    return('\b');
    }
else
    return('\n');
}
     
/* longlist - list everything about files in two columns */
     
struct llst {                /* structure to hold file information */
    char *fattr;            /* file attribute pointer */
    long size;                /* file size */
    int day;                /* the day of creation */
    int mnum;                /* month number */
    int yr;
    int hh;                    /* creation times */
    int mm;
    int ap;                    /* am or pm */
    } l;
     
longlist(k)
int k;            /* total number to list */
{
     
int i, m, n, cdate;
char *mon, *mname();
     
cdate = gcdate();                        /* get current date (in months) */
if(colm)
    n = k;                                /* set for 1 column listing */
else
    n = (k + 1)/2;                        /* or for 2 column listing */
for(i=0; i < n; i++){
    for(m = 0; (m+i) < k; m += n) {
        fill(i+m, &l);                            /* fill llst structure */
        mon = mname(l.mnum);                    /* conv month # to name */
        fprintf(stdout, "%s%7ld  %2d %s ",
            l.fattr, l.size, l.day, mon);
        if(cdate >= (l.yr * 12 +l.mnum) + 12)
            fprintf(stdout, " %4d  ", l.yr);    /* print year if too old */
        else {
            fprintf(stdout, "%2d:%02d%c ",
                l.hh, l.mm, l.ap);                /* else print time */
            }
        putname(i+m);
        if(m+n < k)
            fputs("\272 ", stdout);                /* double bar separator */
        }
    fputc(endlin(),stdout);
    }
return;
}
     
/* fill - fill long list structure with file information */
     
fill(i, ll)
int i;
struct llst *ll;
{
int j, k;
static char fbuf[16][4] = {
    "--w",
    "---",
    "-hw",
    "-h-",
    "s-w",
    "s--",
    "shw",
    "sh-",
    "d-w",
    "d--",
    "dhw",
    "dh-",
    "d-w",
    "d--",
    "dhw",
    "dh-"
    };
     
if((obuf[i].oattr & 0x10) && obuf[i].oname[0] != '.') {
    ll->size = clsize;
    j = 8;                                /* if directory, use block size */
    }                                    /* and set dir attr offset */
else {
    ll->size = obuf[i].osize;            /* else use file size */
    j = 0;                                /* and file attr offset */
    }
ll->fattr = fbuf[(obuf[i].oattr & 0x07) + j];    /* point to symbolic attr */
ll->day = obuf[i].odate & 0x1F;
ll->mnum = (obuf[i].odate >> 5) & 0x0F;
ll->yr = (obuf[i].odate >> 9) + 1980;
k = obuf[i].otime >> 5;                            /* this is a mess */
ll->mm = k & 0x3f;
ll->ap = ((ll->hh = k >> 6) >= 12) ? 'p' : 'a';
if(ll->hh > 12)
    ll->hh -= 12;
if(ll->hh == 0)
    ll->hh = 12;
return;
}
     
     
/* gcdate - get current date (in months) for comparison */
     
gcdate()
{
struct { unsigned int ax, bx, cx, dx, si, di, ds, es;} r;
     
    r.ax = 0x2A00;
    sysint(0x21, &r, &r);
    return(r.cx * 12 + (r.dx >> 8));    /* yr * 12 + month */
}
     
/* mname - convert month number to month name */
     
char *mname(n)
int n;
{
static char *name[] = {
    "???",
    "Jan",
    "Feb",
    "Mar",
    "Apr",
    "May",
    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec"
    };
return((n < 1 || n > 12) ? name[0] : name[n]);
}
     
#ifdef CIC86
     
_showds()
{
struct{int cs, ss, ds, es;} r;
     
segread(&r);
return(r.ds);
}
     
ci()
{
return(bdos(7) & 0xFF);
}
     
#endif
     
--
------------
Continuing Engineering Education Telecommunications
Purdue University
     
"Time is a mouse that requires constant feeding..." -- me
     
    ...!ihnp4!pur-ee!pc-ecn!sandersr

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7348
          for JMS@ARIZMIS; Wed,  2-JUL-1986 23:40 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024299; 2 Jul 86 22:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008991; 2 Jul 86 22:07 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: PRECEDENT FOR USE OF =
Message-ID: <482@cbmvax.cbmvax.cbm.UUCP>
Date: 2 Jul 86 17:17:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Quick Jab:
>     If Pascal is so good why did its author (N. Wirth) write
> two other languages (Modula & Modula II) before deciding he had one
> which could be used for system implementation? (Lilith (sp?))
>
>                 Bill Bogstad
>                 bogstad@hopkins-eecs-bravo.arpa
     
Never any question about this one.  Wirth designed Pascal as a teaching
language, not a system implementation language, and as a language that
could be easily compiled by a 1-pass compiler on small computers.  It
was designed specifically to be used by novices, thus the very strong
type-checking, bounds checking, etc., and the very limited power of
the language.  Modula 2 seems like and attempt to create a spin-off of
the Pascal methodology that can actually be used for system implementation
and the like.  Probably just as reasonable as all the incompatibly-expanded
Pascals around today.
     
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
   A quote usually goes here, but its currently being rennovated.
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8353
          for JMS@ARIZMIS; Thu,  3-JUL-1986 01:05 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/03/86 at 02:59:22 CDT
Received: from BRL-SMOKE.ARPA by SRI-KL.ARPA with TCP; Tue 1 Jul 86 01:55:38-PDT
Date:     Tue, 1 Jul 86 1:51:14 EDT
From:     terry@BRL.ARPA
Sender:   terry@BRL.ARPA
To:       info-vax@sri-kl.arpa
     
Newsgroups: mod.computers.vax
Subject: Re: Favorite operating systems query (VMS vs. Unix)
Summary: Harder to do things in VMS
Expires:
References: <8606300055.AA18979@tcgould.tn.cornell.edu>
Sender:
Reply-To: bogstad@hopkins-eecs-bravo.arpa
Followup-To:
Distribution:
Organization: Ballistic Research Lab (BRL), APG, MD.
Keywords:
     
garry%cadif-oak@cu-arpa.cs.cornell.edu writes:
...
>1) Any message that begins with something of the form of "I prefer Unix but
>   I'm a VMS expert too and I know you can't do ..." deserves an immediate
>   'n' key. The body of the message can be safely assumed to be wrong.
I prefer Unix but I have used VMS.  1/2 :-)
     
>2) The C language and the C run-time library are no longer the same thing as
>   "Unix"! I have cheerfully carried C programs full of library calls
>   back and forth between my VMS Vax, my Unix Vax, a MS-DOS PC, and a
>   MacIntosh. It's easy. When I want to create a file with a specific file
>   protection (not that I ever have wanted such a thing :-)) I call 'creat'.
>   Yes, on VMS! What we're supposed to be having here is a system war, not
>   a language war. Let's keep it pure, people!
    You are right.  If you program in C, you have access to all of
the VMS emulations of the Unix system calls and library routines.
However, not everyone programs in C.  Let's talk about the real VMS
system call interface used by the other languages.
     
    I actually had to program in FORTRAN (heaven forbid) on VMS and
had to do the equivalent of a Unix sleep() call.  Sounds reasonable
right?  Hah!  After spending 3-4 hours wading through the VMS manuals I
discover that I have to do a "scheduled wakeup" for my process and then
a "hibernate".  Of course there are optional arguments to both calls
which I have to decipher.  In addition, I have to call a special routine
to generate the correct arguement to the wakeup call.  Now, I realize
that this is somewhat similiar to the internals of the Unix sleep()
function, but isn't it nicely packaged?  You give it a number and your
program pauses for the required number of seconds.  Obviously not
everything is conceptually this easy, but when it is why make it so
hard to do?  Unix has been termed User unfriendly (with some reason),
but I think a point can be made for VMS being programmer unfriendly.
     
    Finally, yes VMS is a reasonable operating system, but it isn't
perfect.  I'm not claiming this for Unix either, just that it is a
little better.
     
                Bill Bogstad
                bogstad@hopkins-eecs-bravo.arpa
     
Please reply to this message by mail to the address above.  This mailing
list and USENET already have enough traffic as it is.  (I should talk.)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2413
          for JMS@ARIZMIS; Thu,  3-JUL-1986 10:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 12:16:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003932; 3 Jul 86 11:02 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa22309; 3 Jul 86 10:00 EDT
Received: from bbn-labs-b.arpa by AOS.BRL.ARPA id a001135; 3 Jul 86 9:59 EDT
To: info-c@BRL.ARPA
cc: chris%ucmp-cs.UUCP@harvard.ARPA
Subject: slight bug in call-by-name expression
Date: 03 Jul 86 09:49:29 EDT (Thu)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
In article <2225@ucmp-cs.UUCP> chris@ucmp-cs.uucp (Chris Torek) writes:
> /*
>  * Incidentally, `swap' can be passed a thunk that names an expression;
>  * here is what a call-by-name compiler might generate for `a+b':
>  *
>  * int *
>  * addr_aplusb()
>  * {
>  *    int t = a + b;
>  *
>  *    return (&t);
>  * }
>  */
     
Uh, not quite.  I think you actually meant something like:
     
    int *
    addr_aplusb ()
    {
                    /* either t is static, or we are
                       in big trouble */
        static    int    t = a + b;
     
        return (& t);
    }
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2880
          for JMS@ARIZMIS; Thu,  3-JUL-1986 11:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 13:01:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007533; 3 Jul 86 13:42 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a028988; 3 Jul 86 13:25 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a006963; 3 Jul 86 13:25 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06399; Thu, 3 Jul 86 13:22:12 edt
Date: Thu, 3 Jul 86 13:22:12 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607031722.AA06399@icst-cmr.ARPA>
To: info-c@BRL.ARPA
Subject: Swap by name
Cc: basili@MARYLAND.ARPA, chris@MARYLAND.ARPA, gwyn@BRL.ARPA
     
    In article <1836@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn
    (VLD/VMB) <gwyn>) writes:
    >It may be amusing and/or instructive to contemplate the fact that
    >there is no way to write a function that exchanges the contents of
    >two variables in a language where parameters are passed "by name".
     
    How so?  It seems rather simple.  I have here a C program that effects
    call-by-name and does indeed perform a swap:
     
    [Example using `thunks' deleted]
     
Yow! Are we talking about the same thing yet? I seem to remember three types
(possibly four) of parameter passing:
     
    1) Call by value    C scalars
    2) Call by reference    C pointers, arrays, Fortran variables
    3) Call by name        Algol call by name (it also does val & ref)
     
Call by reference went something like this: the calling routine would
pass the string representation of the argument and the caller would parse
it to figure out the argument. Thus if we had a declaration and call:
(I forgot Algol so I'm bastardizing C)
     
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int i = 5;
     
    main()
    {    snafu(a[i]);
    }
     
    snafu(bar) call_by_name bar;
    {
        printf("%d\n",bar);        /* prints 5 */
    i = 7;    printf("%d\n",bar);        /* prints 7 */
    }
     
At least that's what Dr. Vic the BASILIsk told me.
     
Now it does seem that Chris's thunktions will provide a similar effect, so
forgive me if this whole article is unnecessary. However, while I could
write a thunktion similar to snafu to return the address of any single
array element, call by name would allow me to pass a multidimensioned
array reference to the same function as well and muck with it.
     
I have never understood the motivation for this technique, or if I ever
did, I probably didn't like it. Can you say interpreter?
     
The fourth method I have heard is `Call by value-result'. It seems to be
a variation on call by reference or value depending on how it is done.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    RHAPSODY in Glue!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3019
          for JMS@ARIZMIS; Thu,  3-JUL-1986 12:08 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 13:31:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010919; 3 Jul 86 14:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029492; 3 Jul 86 13:42 EDT
From: "John Woods, Software" <john%frog.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: simulating data abstraction facilities
Message-ID: <941@frog.UUCP>
Date: 1 Jul 86 17:13:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> What I would like to do is to simulate data abstraction
> facilities as a design guideline. Note, for various
> reasons we HAVE to use C for time being. The draft-proposal
> is to use file scoping and conditional preprocessor
> clauses to stop private members of a class of data/functions/types
> from external linkage.
>
     
I have bad news for you.  This will not simulate data abstraction.
     
This will _be_ data abstraction.
     
Unless, of course, you use the phrase "Data Abstraction (TM)" in the way
that people who do research into it do, where you MUST be wrapped in
compiler provided straight jackets and given a crayon to hold in your teeth
with which to write.  But this approach (discipline added to an existing
language) was what was used when I took "6.170 Software Engineering" at MIT,
from Barbara Liskov (of CLU fame):  we used a garden-variety PL/1 compiler
with some stylistic rigor to provide protected data types, because the CLU
compiler hadn't been finished yet.
     
(And in my opinion, from having to work with the CLU compiler itself a couple
of years later, it was easier to do it in PL/1, because (A) the CLU compiler
still does not prevent programming mistakes, just certain classes of them,
and (B) the CLU compiler prevents certain reasonable programming constructs,
just simply because they didn't occur to the compiler designers.
     
After all, look at fopen() and friends in the standard C library -- when was
the last time you ripped the top off a FILE * to look inside it (that is, if
you aren't a UCB or Bell Labs programmer [*])?
     
* Some notable programs from each of these caused me to have to rewrite a
from-scratch stdio library that otherwise worked perfectly well (even better
than the original in many respects) to use a structure that was similar to
the regular FILE structure, with much anguish being added to preserve the
old (improved) functionality while making sure that the structure fields
were manipulated the same way that these excremential programs expected!).
     
--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc@MIT-XX.ARPA
     
"Imagine if every Thursday your shoes exploded if you tied them the usual way.
This happens to us all the time with computers, and nobody thinks of
complaining."
            Jeff Raskin, interviewed in Doctor Dobb's Journal

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3251
          for JMS@ARIZMIS; Thu,  3-JUL-1986 12:16 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/03/86 at 13:44:13 CDT
Received: from PS2.CS.CMU.EDU by SRI-KL.ARPA with TCP; Tue 1 Jul 86 09:16:16-PDT
Date: 1 Jul 1986 12:12:40 EST
Sender: MOORE@PS2.CS.CMU.EDU
From: Dale.Moore@PS2.CS.CMU.EDU
To: bogstad@hopkins-eecs-bravo.arpa, info-vax@sri-kl.arpa
Subject: sleep()
     
     
Bill Bogstad writes...
>    I actually had to program in FORTRAN (heaven forbid) on VMS and
> had to do the equivalent of a Unix sleep() call.  Sounds reasonable
>right?  Hah!  After spending 3-4 hours wading through the VMS manuals I
>discover that I have to do a "scheduled wakeup" for my process and then
>a "hibernate".  Of course there are optional arguments to both calls
>which I have to decipher.  In addition, I have to call a special routine
>to generate the correct arguement to the wakeup call.  Now, I realize
>that this is somewhat similiar to the internals of the Unix sleep()
>function, but isn't it nicely packaged?  You give it a number and your
>program pauses for the required number of seconds.  Obviously not
>everything is conceptually this easy, but when it is why make it so
>hard to do?
     
Why didn't you use LIB$WAIT (seconds)?  The VMS runtime library
routine LIB$WAIT places the current process into hibernation for the
number of seconds specified in its argument.  It is not really as
hard as you make it out to be.
     
    Dale.Moore@PS2.CS.CMU.EDU

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3409
          for JMS@ARIZMIS; Thu,  3-JUL-1986 12:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 13:49:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011805; 3 Jul 86 14:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029645; 3 Jul 86 13:46 EDT
From: Tom Stockfisch <tps%sdchem.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Pig C
Message-ID: <249@sdchema.sdchem.UUCP>
Date: 3 Jul 86 00:32:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6874@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes:
>[discussion about redefining C with the preprocessor]
>...  If you can read English you can read Pig Latin,
>but nobody would tolerate documentation written in Pig Latin...
     
This is such a great analogy, with Henry's permission I would like to coin
the term
     
    Pig C
     
to refer to C code (like the Bourne shell) which effectively
redefines the language.  Then when someone posts some bit of obfuscutia
you can flame them saying, "This code looks like Pig C to me."
     
--Tom Stockfisch, UCSD Chemistry

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3699
          for JMS@ARIZMIS; Thu,  3-JUL-1986 12:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 14:03:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa13928; 3 Jul 86 14:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000124; 3 Jul 86 13:56 EDT
From: Jim Cathey <jimc%iscuva.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <241@iscuva.UUCP>
Date: 3 Jul 86 01:43:43 GMT
Keywords: Trivia
To:       info-c@BRL-SMOKE.ARPA
     
     
Why did Algol use := in the first place?  Why not some other symbol?
Was it just because it was easy to type on the keypunch?  (I think it
was a quick roll off the F to the V key with the shift down or
somesuch).  This makes no sense to me as I recall that Algol was
invented in much the same way as APL was -- as a language for humans to
express computer operations.  It was only implemented later.  Who knows
(who cares?).
     
If it was because of the keypunch, I wish that its demise would have
followed the Model 60.  := is a beach to type on every ASCII 'board
I've ever used.  Some other easy combo should have been chosen...  ;-)
     
--
     
+----------------+
! II      CCCCCC !  Jim Cathey
! II  SSSSCC     !  ISC Systems Corp.
! II      CC     !  Spokane, WA
! IISSSS  CC     !  UUCP: ihnp4!tektronix!reed!iscuva!jimc
! II      CCCCCC !  (509)927-5757
+----------------+
            "With excitement like this, who is needing enemas?"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3310
          for JMS@ARIZMIS; Thu,  3-JUL-1986 12:40 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 13:46:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010292; 3 Jul 86 14:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029485; 3 Jul 86 13:42 EDT
From: "John Woods, Software" <john%frog.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a
  bug?
Message-ID: <940@frog.UUCP>
Date: 1 Jul 86 16:57:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     long x(cp)
>     char * cp;
>     {return *((long *) cp); }
> will cause core dumps if the value of cp isn't "appropriately aligned".
> When dealing with such compilers, you get to do something like
>     long x(cp)
>     char * cp;
>     {    long l;
>         function_to_do_arbitrary_copying((char *) &l, cp, sizeof l)
>         return l;
>     }
> to avoid core dumps.
> Isn't this really a compiler bug?
     
No, I'd say not.  The compiler is doing just exactly what you said in the
first case.  What you said was something stupid, ergo it does something
stupid.  Lint will complain about the construction, declaring there to be
a "possible pointer alignment problem" (you bet!).
     
(by the way, an in-line copy would be faster than the function call (except
perhaps on machines where function calls take negative time :-) )).
     
     
--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc@MIT-XX.ARPA
     
"Imagine if every Thursday your shoes exploded if you tied them the usual way.
This happens to us all the time with computers, and nobody thinks of
complaining."
            Jeff Raskin, interviewed in Doctor Dobb's Journal

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4312
          for JMS@ARIZMIS; Thu,  3-JUL-1986 13:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 15:27:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018195; 3 Jul 86 15:49 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002887; 3 Jul 86 15:36 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06741; Thu, 3 Jul 86 15:34:59 edt
Date: Thu, 3 Jul 86 15:34:59 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607031934.AA06741@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, umcp-cs!chris@ICST-CMR.ARPA
Subject: Re: swap() macro
     
    In article <2225@umcp-cs.UUCP> I replied:
    >I have here a C program that effects call-by-name and does
    >indeed perform a swap:
     
    What I failed to consider, of course, is the classic problem with
    call by name: arrays.  Watch what happens when I `swap' `i' and
    `a[i]', using an expanded form of the swap function (this is
    necessary to avoid compiler dependencies in this particular case).
     
Okay, so at least Chris and I are talking about the same thing.
     
    Ah well, at least I caught my error myself. . . .
     
Ah, but why not fix it too? Who says you have to evaluate f1 & f2 each
time you reference them?
     
    swap(f1, f2)            swap(f1, f2)
    int *(*f1)(), *(*f2)();        int *(*f1)(), *(*f2)();
    {                {
        int t1, t2;        int t1, t2, *a1, *a2;
     
        t1 = *(*f1)();        t1 = *(a1 = (*f1)());
        t2 = *(*f2)();        t2 = *(a2 = (*f2)());
        *(*f1)() = t2;        *a1 = t2;
        *(*f2)() = t1;        *a2 = t1;
    }                }
     
By definition you say? Whaddya want, swapping or call by name? To the
outside world, swap is atomic, so who cares what happens inside?
This way, t2 is unneeded as well.
     
    --
    In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
    UUCP:    seismo!umcp-cs!chris
    CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
     
Now recite with me the Hacker's Prayer:
     
    Our father, UART in heaven, Hallowed Call by Name ...
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
OMNIVERSAL AWARENESS?? Oh, YEH!! First you need 4 GALLONS of JELL-O
and a BIG WRENCH!!... I think you drop th'WRENCH in the JELL-O as if
it was a FLAVOR, or an INGREDIENT...  ...or...I...um...WHERE'S the
WASHING MACHINES?
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5292
          for JMS@ARIZMIS; Thu,  3-JUL-1986 15:12 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018493; 3 Jul 86 16:55 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a003796; 3 Jul 86 16:42 EDT
Date:     Thu, 3 Jul 86 16:15:58 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Mike Hickey <MHICKEY%UDCVM.BITNET@wiscvm.ARPA>
cc:       INFO-VAX@SRI-KL.ARPA, INFO-C@BRL-SMOKE.ARPA
Subject:  Re:  VAX C problem (?)
Message-ID:  <8607031615.aa02732@VGR.BRL.ARPA>
     
Any implementation of getchar() that does not require an entire
line to be typed before returning data from the terminal in the
default case is broken.  This behavior is permitted only in raw
(non-canonicalizing) mode, which is not supposed to be enabled by
default.  Sounds like VAX-C ver 2.2 is doing this right.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5374
          for JMS@ARIZMIS; Thu,  3-JUL-1986 15:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018612; 3 Jul 86 17:07 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa03871; 3 Jul 86 16:52 EDT
Date:     Thu, 3 Jul 86 16:50:55 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  swap() macro
Message-ID:  <8607031650.aa02932@VGR.BRL.ARPA>
     
No, you just implemented an elaborate form of "call by reference".
"Call by name" is quite something else, and if you think about it
you'll realize that swapping "by name" would mean that the names
have to be reassociated with different objects, which is contrary
to the meaning of names in this context.  I haven't seen call-by-
name included in any language since Algol.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6769
          for JMS@ARIZMIS; Thu,  3-JUL-1986 17:24 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/03/86 at 19:18:43 CDT
Received: from mitre-bedford.ARPA by SRI-KL.ARPA with TCP; Tue 1 Jul 86
  22:05:43-PDT
Organization: The MITRE Corp., Bedford, MA
Received: by linus.MENET (1.1/4.7)
    id AA11775; Wed, 2 Jul 86 01:06:07 EDT
Posted-Date: Tue, 1 Jul 86 14:25:11 edt
Message-Id: <8607011825.AA28178@rayssd.UUCP>
Date: Tue, 1 Jul 86 14:25:11 edt
From: raybed2!rayssd!m1b.UUCP@seismo.css.gov (M. Joseph Barone)
Subject: Re: Potential C problem
Newsgroups: mod.computers.vax
To: info-vax@sri-kl.ARPA
References: <8606261652.AA25082@tektools.TEK>
     
     
In article <8606261652.AA25082@tektools.TEK>, bobp@tektools.tek.CSNET
(Robert Perry) writes:
>     Perhaps I missed something in the documentation, but can anyone
> tell me why the VMS C compiler doesn't allow a value of 0 in %x1 as in the
> following example ?
> [example follows using sscanf]
     
This is a real problem and has been SPRed (SPR NO. 11-CS01837).
The response DEC sent us follows:
     
    A change is made in VAX C RTL fscanf function (V2.1) to support
    "0x" input string and therefore incidentally ignores leading
    zeros if fscanf function is reading with a "%x" input format
    specifier.
     
    This problem will be fixed in a future release of VAX C RTL that
    will be shipped with a future version of VAX/VMS after VAX/VMS
    V4.2.  The change made for supporting "0x" input string will also
    be documented in the next edition of "Programming in VAX C".
     
    The workaround is to enter either a leading "0x" or a leading "0"
    to get the value 0 matched as you have indicated in your SPR.
     
We're still at V4.2 and when I looked through the V4.3 kit, I didn't find
any patches to VAXCRTL.OLB.  I don't know if this has truly been corrected
in V4.4.
     
Joe Barone
{allegra, cci632, gatech, ihnp4, linus, mirror, raybed2}!rayssd!m1b
Raytheon Co, Submarine Signal Div., 1847 West Main Rd, Portsmouth, RI 02871
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7792
          for JMS@ARIZMIS; Thu,  3-JUL-1986 18:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 20:48:25 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019366; 3 Jul 86 21:36 EDT
Received: from radc-tops20.arpa by SMOKE.BRL.ARPA id a009289; 3 Jul 86 21:15 EDT
Date: Thu 3 Jul 86 21:15:08-EDT
From: MEYER@RADC-TOPS20.ARPA
Subject: Re: Precedent for use of =
To: rbj@ICST-CMR.ARPA
cc: info-c@BRL-SMOKE.ARPA, umcp-cs!chris@ICST-CMR.ARPA
In-Reply-To: <8607010044.AA08831@icst-cmr.ARPA>
Message-ID: <12219856237.5.MEYER@RADC-TOPS20.ARPA>
     
     I know this is going to cause a bit more of a stir here, here goes.
     
Everybody keeps guessing at the reasons for the use of = for asignment
and == for equality tests.  How about a different angle: how many times
in a program do you assign something versus how many times you compare things?
     
I seems to me that if it comes down to keystrokes (which by the way is why
a lot of UNIX commands are two or three letters long) I'll take = for
assignment any day.  When I was writing PASCAL programs, Mmy most
common error was typing '=' when I meant ':='.  Also, if you think about it,
the use of == is not so bad 'cuz it is the same character typed twice as
opposed to two keys in entirely different places on the keyboard in which
one of them has to be shifted and the other not.  I prefer not to have to
perform keyboard acrobatics to type in a program.
     
Maybe Mssrs. Kernighan and/or Ritchie would like to give some input on
their reasons of choice.
-------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8211
          for JMS@ARIZMIS; Thu,  3-JUL-1986 19:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 21:40:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019464; 3 Jul 86 22:26 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a009622; 3 Jul 86 22:11 EDT
Received: from maryland.arpa by AOS.BRL.ARPA id a019450; 3 Jul 86 22:11 EDT
Received: by mimsy.umd.edu (5.9/4.7) id AA10033; Thu, 3 Jul 86 00:00:24 EDT
Date: Thu, 3 Jul 86 00:00:24 EDT
From: Chris Torek <chris@maryland.ARPA>
Message-Id: <8607030400.AA10033@mimsy.umd.edu>
To: info-c@BRL.ARPA, rbj@ICST-CMR.ARPA
Subject: Re:  Swap by name
Cc: basili@maryland.ARPA, gwyn@BRL.ARPA
     
    From: Root Boy Jim <rbj@icst-cmr.arpa>
     
    I seem to remember three types (possibly four) of parameter passing:
     
    1) Call by value    C scalars
    2) Call by reference    C pointers, arrays, Fortran variables
    3) Call by name        Algol call by name (it also does val & ref)
     
The fourth method (as you mention later) is call by value-result.
     
    Call by reference went something like this: the calling
    routine would pass the string representation of the argument
    and the caller would parse it to figure out the argument.
     
This much work is not necessary.  You simply build static links or
a display and use conventional non-local references in the thunk
procedures.  Each thunk procedure returns a pointer to the variable
that represents the evaluation of the appropriate argument, as
performed in the context of the caller.  (If a compiler-generated
thunk requires a temporary variable---all expression-thunks do---that
temporary is unnamed, so the fact that a Pascal-ish thunk would be
nested one level greater than the caller is irrelevant.  To put it
another way, a compiler can do whatever it wants. :-) )
     
    From: Doug Gwyn (VLD/VMB) <seismo!BRL.ARPA!gwyn>
     
[Giving equal time to UUCP domains . . . :-)]
     
    No, you just implemented an elaborate form of "call by reference".
     
I merely chose a poor example.  Call by reference and call by name
often have identical effects.  See my followup for a better example.
(Incidentally, my expression `example', contained in a comment,
has a different problem: it returns the address of a stack variable
that is no longer active by the time the caller uses it.  `t' should
have been declared `static'.  This is what comes of dashing off an
article just before bed . . . .)
     
It is possible to implement full call by name in C, but it is
difficult, for nonlocal reference is difficult; and no one ever
used call by name after Algol anyway---most likely because everyone
thinks it is terrible.  Nonlocal reference *is* possible, but
probably best left to a compiler.  Kludges are not too hard to
write, but are error-prone: the programmer must keep track of the
lexical level of each routine, and know how many levels up to look,
and at what offset, for each nonlocal variable.
     
The other three of Root Boy's methods of parameter passing are also
available to C programmers.  Call by value is of course trivial.
Call by reference is easy to achieve using pointers (though in fact
the call is still `by value': the value of the pointer expression).
Call by value-result is also easy enough in C, though as with call
by reference, it requires cooperation of both caller and callee:
     
    /* Call by value-result */
    f()
    {
        int i, j;
     
        i = 1;
        j = 2;
        call_by_value_result(&i, &j);
    }
     
    call_by_value_result(addr1, addr2)
        int *addr1, *addr2;
    {
        /* perform the entry protocol: obtain the arguments */
        int arg1 = *addr1, arg2 = *addr2;
     
        /*
         * code dealing with `arg1' and `arg2' as though
         * those were the arguments; no `return's; then:
         */
     
        /* perform the exit protocol: modify the arguments */
        *addr1 = arg1;
        *addr2 = arg2;
    }
     
The entry protocol is the `value' part; the exit protocol supplies
the `result'.  Incidentally, call by value-result is a legal
implementation in at least one of the many FORTRAN standards.  It
tends to surprise those who alias a variable and depend on call by
reference to modify two parameters at once:
     
    PROGRAM CALLBY
    INTEGER ARG
C Translate the following two PRINTs as appropriate for whatever
C compiler restrictions you have.
    PRINT *, ' If it says "3 3" then "7 7", you have call by reference;'
    PRINT *, ' if it says "3 3" then "7 3", you have call by value-result.'
    ARG = 3
    CALL TESTIT (ARG, ARG)
C N.B.: If value-result, ARG could be either 3 or 7 now!
    STOP
    END
     
    SUBROUTINE TESTIT (I, J)
    INTEGER I, J
    PRINT *, I, J
    I = 7
    PRINT *, I, J
    RETURN
    END

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8951
          for JMS@ARIZMIS; Thu,  3-JUL-1986 21:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 23:10:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023035; 3 Jul 86 23:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011222; 3 Jul 86 23:43 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang
Subject: Re: What to do with lots of registers
Message-ID: <437@opus.nbires.UUCP>
Date: 3 Jul 86 06:42:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1409@pucc-k>, acz@pucc-k (John R. Jackson) writes:
> I do maintenance and development on the C compiler for the CDC Cyber
> 205 supercomputer.
>
> Among other oddities about the hardware are a very large set of general
> purpose registers (256 of them!).  All (non-vector) operations are
> performed register to register, so it is best to have as many variables
> declared register as possible...
>...
> A second use of the register file could be to hold global variables.
     
See a very interesting paper presented at the SIGPLAN Compiler Construction
Conference, Palo Alto, 27 June 1986, appearing in the July SIGPLAN Notices
(the conference proceedings).
     
The paper is "Global Register Allocation at Link Time", by David Wall of
DEC Western Research Lab.  The idea is to use either data flow analysis or
execution profile information to make decisions about what (scalar)
variables should be allocated to registers, and to include enough
information with the compiled code that the register-allocation decisions
can be deferred to link time so that you can take into account global
considerations.  It was applied to a machine with 64 registers, but results
are also indicated as applicable to machines with a small number of
registers.
     
I'm not associated with the work in any way; I heard the talk (which was
realistic and well-presented) and it sounded like an interesting idea.
--
Dick Dunn    {hao,ucbvax,allegra}!nbires!rcd        (303)444-5710 x3086
   ...Simpler is better.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9104
          for JMS@ARIZMIS; Thu,  3-JUL-1986 21:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 23:29:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023225; 4 Jul 86 0:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011342; 3 Jul 86 23:47 EDT
From: Ben Cranston <zben%umd5.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: cdecl availability
Message-ID: <1056@umd5.UUCP>
Date: 2 Jul 86 22:37:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2218@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
     
> ....  BITNET people should consider using
> umd2.umd.edu as a gateway, as it is practically on the same Ethercable
> as mimsy.umd.edu.
     
Well, Chris, this is close (and we hope will be closer in the near feature).
As I understand it UMD1 is on the Ethercable.  UMD1 has a 40KB sync link to
UMD2, which then has a 64KB HASP link to UMDD.  So far, not too terribly bad.
But the kicker is that UMDD's link to the rest of BitNet is all of 9600 baud
and is going to be the bottleneck.
     
We have the hardware for UMD2 to talk directly to the Ethercable and have
bounced commands off it, so all we really need to do is cobble together a
device driver and low level communications handler for it.
     
If there is a huge demand for cdecl on BitNet maybe we can get one of the
BitNic servers to carry it.  Then BitNet people would say (something like):
     
     tell bitnic sendme cdecl
     
and a card deck would automagically appear in their (virtual) card reader.
     
Chris, I hope there aren't any lines in CDECL longer than 80 characters...
     
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9205
          for JMS@ARIZMIS; Thu,  3-JUL-1986 21:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/03/86 at 23:31:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023227; 4 Jul 86 0:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011363; 3 Jul 86 23:48 EDT
From: Pete Zakel <pete%valid.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: SWAP macro (utter insanity+interesting question)
Message-ID: <409@valid.UUCP>
Date: 3 Jul 86 22:11:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> IT still doesn't work for REGISTER variables!
>
> Mark Biggar
     
Doesn't that depend on the C compiler?  I've heard of compilers that ignore
the "register" declaration if the address of the variable is taken.  Of
course I would HOPE that you would at least get a warning.
--
-Pete Zakel (..!{hplabs,amd,pyramid,ihnp4}!pesnta!valid!pete)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0767
          for JMS@ARIZMIS; Thu,  3-JUL-1986 23:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 01:28:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023522; 4 Jul 86 0:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011477; 3 Jul 86 23:52 EDT
From: Andy Kashyap <aka%cbrma.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Fun with & and *
Message-ID: <4699@cbrma.UUCP>
Date: 30 Jun 86 17:58:57 GMT
Posted: Mon Jun 30 13:58:57 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <3082@jhunix.UUCP> ecf_bdw@jhunix.UUCP (Dwight Wilson) writes:
>
>In a previous article I wrote that one could use the macro:
>
>     #define pointer_to(X)  X *
>
>in order to allow declarations of the form
>
>     pointer_to(float)  x;
>
     
[ ...]
     
>                                                          -Dwight
     
Someday someone will try this declaration:
     
    pointer_to(int) pa, pb, pc ;
     
and be in for a surprise.
     
                            - Andy Kashyap
                            - ..!cbosgd!cbrma!aka

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1687
          for JMS@ARIZMIS; Fri,  4-JUL-1986 01:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 03:10:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024575; 4 Jul 86 3:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012372; 4 Jul 86 3:42 EDT
From: Georges Benzimra <georges%axis.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: RE: TOOLS / LIBRARIES FOR C UNDER MS-DOS, PC-DOS
Message-ID: <720@axis.UUCP>
Date: 3 Jul 86 23:50:52 GMT
Posted: Thu Jul  3 23:50:52 1986
To:       info-c@BRL-SMOKE.ARPA
     
I'm looking for proffesional libraries or tools to help software develop-
pement with C under MS DOS / PC DOS. Any information about wellcome.
Thanks in advance to spider's web.
     
Georges. UUCP ..mcvax!inria!axis!georges    ..mcvax!vmucnam!axis!georges

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1732
          for JMS@ARIZMIS; Fri,  4-JUL-1986 01:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 03:11:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024570; 4 Jul 86 3:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012333; 4 Jul 86 3:41 EDT
From: Paul Condie <pjc%ptsfa.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: pointers to functions
Message-ID: <1435@ptsfa.UUCP>
Date: 3 Jul 86 21:22:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Example of pointers to functtions:
     
#include <stdio.h>
typedef int FCH();
typedef FCH *pFCH;
     
main()
{
   int       Function1(), Function2(), Function3();
   static pFCH    Farray[]= { Function1, Function2, Function3 };
     
   (*Farray[0])();
   (*Farray[1])();
   (*Farray[2])();
}
     
Function1()
{   printf ("\nExecuting function 1"); }
     
Function2()
{   printf ("\nExecuting function 2"); }
     
Function3()
{   printf ("\nExecuting Function 3"); }
     
/*
** Paul J. Condie
** 415/545-8371
** {ihnp4,qantel}!ptsfa!pbbahd!pbpjc!pjc
*/

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1851
          for JMS@ARIZMIS; Fri,  4-JUL-1986 01:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 03:18:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024591; 4 Jul 86 4:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012384; 4 Jul 86 3:43 EDT
From: Kent Black <kab%reed.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a
  bug?
Message-ID: <3783@reed.UUCP>
Date: 3 Jul 86 18:24:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6152@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes:
>As I understand it, the code produced by some compilers from
>
>    long x(cp)
>    char * cp;
>    {
>        return *((long *) cp);
>    }
>
>will cause core dumps if the value of cp isn't "appropriately aligned".
>
>Isn't this really a compiler bug?  Doesn't the cast in the
>        return *((long *) cp);
>give the compiler all the evidence it needs that it should, *on its own*,
>produce code that's the equivalent of the function call?
     
Oh, am I in over my head. . .
     
If a (char *) can reference any `byte' of memory, and a (long *) can
can only reference, as example, even number word addresses, then to have
the compiler correctly cast a char * to a long * would mean it rearranged
your data for you.  In particular, an array of characters would have to
be remade into an array of longs with the apropriate (high or low) byte
holding the character.  Is this all wrong?
     
But do you *really want* to cast a char pointer to a long pointer just
to dereference and return the value?  The example seems to instead call
for dereferencing the char * and casting the value as a long, e.g.,
        return (long) *cp;
     
I only respond because I'm not certain myself and would like some further
discussion.
     
Kent Black

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2690
          for JMS@ARIZMIS; Fri,  4-JUL-1986 02:49 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/04/86 at 04:40:09 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Wed 2 Jul 86 08:43:31-PDT
Date:  2 JUL 1986 11:44:48 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: BOB%BCVAX3.BITNET@WISCVM.ARPA
cc: info-vax@sri-kl.arpa
Subject:  Re: vaxtpu programming
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
    ...
      I was wondering if anyone knew of a way to access a globally defined
    symbol while in VAXTPU?....
There is no direct way to do this; i.e., there is neither a TPU primitive
to access the values of DCL symbols, nor any general call-out interface that
would let you call LIB$GET_SYMBOL (or whatever it's called).
     
HOWEVER, there IS a primitive named CALL_USER that allows you to call out to
a user-provided program written in some other language (such as BASIC).  The
user program has to be built into a shareable image, which TPU will find
using LIB$FIND_IMAGE_SYMBOL.
     
CALL_USER takes one integer and one string argument, which are passed on the
the user program, and returns a single string value, passed back from the user
program.  This should be sufficient for the purpose you have in mind.
     
Another approach is to use the callable TPU interface.  You can use it to
build a single image with your CALL_USER routine already in it, and do various
fancy things.
                            -- Jerry
-------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2893
          for JMS@ARIZMIS; Fri,  4-JUL-1986 03:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 05:02:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024871; 4 Jul 86 5:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013378; 4 Jul 86 5:41 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <2140@ihlpg.UUCP>
Date: 3 Jul 86 01:20:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <1836@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn
> (VLD/VMB) <gwyn>) writes:
> >It may be amusing and/or instructive to contemplate the fact that
> >there is no way to write a function that exchanges the contents of
> >two variables in a language where parameters are passed "by name".
>
> How so?  It seems rather simple.  I have here a C program that effects
> call-by-name and does indeed perform a swap:
>
[Original program deleted for brevity]
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
> UUCP:    seismo!umcp-cs!chris
> CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
Now lets show that it doesn't work:
     
swap(f1, f2)
    int *(*f1)(), *(*f2)();
{
    int t;
     
    t = *(*f1)();
    *(*f1)() = *(*f2)();
    *(*f2)() = t;
}
     
int    c[4], d;
     
int *
addr_c_sub_d()
{
       return(&c[d]);
}
     
int *
addr_d()
{
     return (&d);
}
     
/*ARGSUSED*/
main(argc, argv)
    int argc;
    char **argv;
{
    d = 2;
    c[0] = 3;
    c[1] = 3;
    c[2] = 1;
    c[3] = 3;
    swap(addr_d,addr_c_sub_d);
    printf("should be 1, 2: d = %d, c[2] = %d\n", d, c[2]);
    exit(0);
}
     
--j.a.tainter

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2991
          for JMS@ARIZMIS; Fri,  4-JUL-1986 03:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 05:07:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024873; 4 Jul 86 5:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013422; 4 Jul 86 5:42 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: {register int i, *p; p = &i;}
Message-ID: <430@dg_rtp.UUCP>
Date: 3 Jul 86 20:53:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> markb@sdcrdcf.UUCP (Mark Biggar)
> IT still doesn't work for REGISTER variables!
     
True, true.  Both K&R and the draft standard explicitly deem this
illegal.  But it is worth noting what Harbison and Steele have to say
about it:
     
    7.4.6 Address Operator
     
        [blah, blah, blah, blah, and then the interesting part]
     
    The original description of C specified that it was illegal to apply
    the unary address operator '&' to a register variable, and some
    compilers still enforce this restriction.  However, since register
    is treated only as a hint to the compiler and not a mandatory
    requirement, it seems appropriate to allow such usage, inasmuch as
    on some computers the registers really are addressable as if they
    were memory locations.  On the other hand, when the target computer
    does not have addressable registers, applying '&' to a register
    variable may simply defeat the declaration of the variable as
    register, forcing it to be of class auto instead.  We recommend that
    new compilers take this latter approach and perhaps also issue a
    warning message.  In any case, such usage should be regarded as
    nonportable.
     
This makes three points:
     
  - 'register' is "only" a hint to the compiler, and the declaration of
    a variable as register does not ensure that the variable *will* be
    in a register
  - therefore, '&' of register variables "ought" to be allowed, and
    simply be one of those cases where the compiler might be compelled
    to ignore the register hint
  - (despite this "ought", it is certainly non-portable, given current
     compilers and draft standards)
     
And to conclude, remember that the original posting in this series was a
request to make a macro "swap" such that
     
        swap( *a++, *b++ );
     
would work, and the posted examples would work even if a and b were
declared register.
     
--
"Eschew obfuscation."
"Giesundheit!"
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3041
          for JMS@ARIZMIS; Fri,  4-JUL-1986 03:19 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 05:09:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024875; 4 Jul 86 5:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013426; 4 Jul 86 5:42 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: swap by name
Message-ID: <431@dg_rtp.UUCP>
Date: 3 Jul 86 20:55:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> gwyn@brl-smoke.UUCP (Doug Gwyn (VLD/VMB) <gwyn>)
> It may be amusing and/or instructive to contemplate the fact that
> there is no way to write a function that exchanges the contents of
> two variables in a language where parameters are passed "by name".
     
Amusing, instructive.... and wrong.
     
I am assuming that you mean "Given a language which passes arguments to
functions with call-by-name semantics, it is impossible write an
'exchange argument pair' function, no matter what other facilities the
language provides".  This is clearly incorrect.  In fact, the C language
is a counterexample (assuming that the C language includes the
preprocessor).
     
Consider: macros act much like functions with by-name arguments.  The
trick is to utter the swap while mentioning the arguments only once.
Thus, one needs a bind-by-reference operation, which in C is nicely
provided by the '&' operator (with some restrictions, granted).
     
My conclusion: a swap function is easy to implement even with
pass-by-name functions, *provided* there is a bind-by-reference operator
in the language.
     
--
It is a lovely language, but it takes a very long time to say anything
in it, because we do not say anything in it, unless it is worth taking
a long time to say, and to listen to.
                                                ---     J. R. R. Tolkien
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3235
          for JMS@ARIZMIS; Fri,  4-JUL-1986 03:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 05:24:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024942; 4 Jul 86 6:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013435; 4 Jul 86 5:43 EDT
From: Paul Cohen <pec%necntc.uucp@BRL.ARPA>
Newsgroups: net.arch,net.lang.c,net.micro,net.micro.pc,net.wanted
Subject: Benchmarks wanted
Message-ID: <277@necntc.UUCP>
Date: 3 Jul 86 20:16:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
At ISSCC last February, NEC announced 32-bit microprocessors, the
V60 and V70.  One of my jobs over the coming months will be to
evaluate the performance of the V60.  I want to put together a
package of benchmarks for this purpose and would appreciate
suggestions.  I will compile responses and post them to the network
if there is interest.
     
    1. C code benchmarks are my primary interest.  References
       to published studies (or copies of unpublished studies)
       evaluating processors or C compilers will be appreciated.
       Benchmark source code is also needed.
     
    2. In an emulation mode, the V60 will execute 8086 code.
       For this reason, assembly coded benchmarks for the
       8086 are of interest.  Again, I am interested in both
       source code and any related performance studies.
     
    3. The V60 performs floating point arithmetic, so
       I am interested in benchmarks to evaluate floating
       point arithmetic.  I am especially interested in C
       language or assembly language benchmarks of this kind
       since a Fortran compiler is not immediately avalilable.
     
            If you want literature on
            the V60, I would prefer that
            you call
                        1-800-632-3531
     
            rather than send me mail.
     
     
            Thanks in advance for all responses.
     
            Paul Cohen
     
        {  decvax!frog,
           harvard!talcott!encore!necis,
           hplabs!ridge!necam,
           mcvax!kddlab!titcca!necspl!necam
     
                        }!necntc!pec

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8709
          for JMS@ARIZMIS; Fri,  4-JUL-1986 14:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 16:33:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026428; 4 Jul 86 17:22 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a016386; 4 Jul 86 16:47 EDT
Date:     Fri, 4 Jul 86 16:40:10 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  swap by name
Message-ID:  <8607041640.aa05918@VGR.BRL.ARPA>
     
I'm not sure how one would implement a bind-by-reference
operator in a language with call-by-name function interface,
though.  Are the names to be forced through the bind or not?
I think my original statement is correct no matter what else
you add to the language, unless you break call-by-name.
     
In any case, I was just trying to illuminate one aspect of
the problem; you have added some more light to that.  Who
needs a universal swap macro anyway?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9384
          for JMS@ARIZMIS; Fri,  4-JUL-1986 15:47 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/04/86 at 17:43:47 CDT
Received: from WISCVM.ARPA by SRI-KL.ARPA with TCP; Wed 2 Jul 86 12:32:41-PDT
Received: from (MAILER)UDCVM.BITNET by WISCVM.ARPA on 07/02/86 at
  13:48:04 CDT
Return-path: MHICKEY@UDCVM.BITNET
Received: by UDCVM (Mailer X1.23) id 7293; Wed, 02 Jul 86 14:46:50 EST
Date:         Wed, 2 Jul 1986 14:32 EST
From:           Mike Hickey  <MHICKEY%UDCVM.BITNET@WISCVM.ARPA>
Subject:      VAX C problem (?)
To:  <INFO-VAX@SRI-KL.ARPA> ,
    <INFO-C@BRL-SMOKE.ARPA>
     
     
    We recently got VAX-C ver 2.2 and I've been busy porting programs
from UNIX/DOS.  When I was working with the CURSES package, I found that
getch() wasn't breaking on a character.  Instead, it would block until
a RETURN was hit.  I then tried the getchar() function in the standard
library and, lo and behold, it reacted the same way.
     
    On every other system I've worked with, these functions "woke up" on
any character input whereas these act more like incremental gets().  Have
I missed something somewhere?  I borrowed the ttxxxx() functions from
Micro Emacs which perform character-breaking I/O but they won't work with
CURSES.
     
     
                        Thanks in advance,
     
                              Mike Hickey
                              Systems programmer
                              University of DC
     
   "Structured programmers DO it OD"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9758
          for JMS@ARIZMIS; Fri,  4-JUL-1986 16:08 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/04/86 at 18:04:26 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Wed 2 Jul 86
  17:09:23-PDT
Received: from ti-eg by csnet-relay.csnet id al00253; 2 Jul 86 19:58 EDT
Date:     Wed, 2 Jul 86 13:43 ???
From:     "David L. Cathey, DEIS/DCS VAX System Support"
  <DCATHEY%MCRAD2%ti-eg.csnet@CSNET-RELAY.ARPA>
To:       info-vax@SRI-KL.ARPA
Subject:  sleep() on VMS (and other assorted function...)
X-VMS-To:  SKACSL::IN%"info-vax@sri-kl.arpa",DCATHEY
     
     
    You're right, VMS does not have a specific sleep() function.
The VMS system calls are much more general than that.  However, a
quick look in the Run-Time Library Reference Manual and you will see
a routine called LIB$WAIT.  This provides a the same functionality as
sleep() and a little more.  It is also usable from any language (as are
all the RTL routines).
     
    If you *really* want to use sleep(), you can try this:
     
        EXTERNAL    C$SLEEP
        INTEGER*4    seconds
        CALL C$SLEEP(%VAL(seconds))
     
    and link with the VAX C RTL.
     
     
                        David Cathey
                        Texas Instruments
     
[I don't work here, I'm just employed...]
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0488
          for JMS@ARIZMIS; Fri,  4-JUL-1986 17:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 19:10:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026751; 4 Jul 86 20:02 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a017533; 4 Jul 86 19:37 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a026683; 4 Jul 86 19:35 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA09176; Fri, 4 Jul 86 19:31:14 edt
Date: Fri, 4 Jul 86 19:31:14 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607042331.AA09176@icst-cmr.ARPA>
To: chris@maryland.ARPA, info-c@BRL.ARPA, rbj@ICST-CMR.ARPA
Subject: Re:  Swap by name
Cc: basili@maryland.ARPA, gwyn@BRL.ARPA
     
Previously I wrote:
     
    Call by reference went something like this: the calling
    routine would pass the string representation of the argument
    and the caller would parse it to figure out the argument.
     
Oops! I meant Call By Name. I seem to have proven one of Murphy's
Laws, addressing it to my old prof. We all know what call by reference is.
     
The rest of this article is a response to Chris Torek.
     
    From: Doug Gwyn (VLD/VMB) <seismo!BRL.ARPA!gwyn>
     
    No, you just implemented an elaborate form of "call by reference".
     
> I merely chose a poor example.  Call by reference and call by name
> often have identical effects.
     
That doesn't mean they are the same. In fact, call by {value,reference}
have the same effect if one does not modify the arguments.
     
> See my followup for a better example.
> (Incidentally, my expression `example', contained in a comment,
> has a different problem: it returns the address of a stack variable
> that is no longer active by the time the caller uses it.  `t' should
> have been declared `static'.  This is what comes of dashing off an
> article just before bed . . . .)
     
You mean you wrote this at noon? :-)
     
> It is possible to implement full call by name in C, but it is difficult,
     
I was going to say no, but you need one thunk for each argument you pass.
The distinguishing characteristic about call by name is that you evaluate
your argument every time you use it. Thunks seem to qualify.
     
> for nonlocal reference is difficult; and no one ever
> used call by name after Algol anyway---most likely because everyone
> thinks it is terrible.  Nonlocal reference *is* possible, but
> probably best left to a compiler.  Kludges are not too hard to
> write, but are error-prone: the programmer must keep track of the
> lexical level of each routine, and know how many levels up to look,
> and at what offset, for each nonlocal variable.
     
I would dispute that no one uses call by name. Consider that in APL you
can pass a character string and execute it to get the result. I suppose
I am splitting hairs, but the effect is the same. I imagine one could
do the same thing in LISP, or any interpretive language.
     
> Call by value-result is also easy enough in C, though as with call
> by reference, it requires cooperation of both caller and callee:
     
I was thinking of the caller squirrelling away the value in a temporary
location, passing it by reference (thus allowing modification by the
callee) and then copying the result to the real variable.
     
As the fortune program says, "A fifth theory is held by idiots, but it
is doubtful whether they know anything more than the others do". Which
brings me to Univac's PLUS compiler. It stored its arguments directly
into the callee's statically declared variables and grabbed the results
after the callee returned. Ask zben@umd[25] about this if you care.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    I'd like MY data-base JULIENNED and stir-fried!
     
P.S. Zippy whipped up this saying just for Chris :-)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0772
          for JMS@ARIZMIS; Fri,  4-JUL-1986 18:17 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/04/86 at 20:13:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026847; 4 Jul 86 21:06 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a017797; 4 Jul 86 20:47 EDT
Received: from maryland.arpa by AOS.BRL.ARPA id a026802; 4 Jul 86 20:45 EDT
Received: by mimsy.umd.edu (5.9/4.7) id AA17127; Fri, 4 Jul 86 20:43:55 EDT
Date: Fri, 4 Jul 86 20:43:55 EDT
From: Chris Torek <chris@maryland.ARPA>
Message-Id: <8607050043.AA17127@mimsy.umd.edu>
To: gwyn@BRL.ARPA, info-c@BRL.ARPA, rbj@ICST-CMR.ARPA
Subject: Re:  Swap by name
Cc: basili@maryland.ARPA
     
    From: Root Boy Jim <rbj@icst-cmr.arpa>
     
    > I merely chose a poor example.  Call by reference and call
    > by name often have identical effects.  [me]
     
    That doesn't mean they are the same.  [rbj]
     
That was my point.  They are not the same, except in a particular
set of cases.  That is why (and when) it is important to know what
methods of parameter passing are legal in whatever language you
are using.
     
    I would dispute that no one uses call by name. Consider
    that in APL you can pass a character string and execute it
    to get the result. I suppose I am splitting hairs, but the
    effect is the same. I imagine one could do the same thing
    in LISP, or any interpretive language.
     
Actually, this is a good point.  In Lisp, a fexpr is in fact a
sort of call-by-name, though depending on your scope rules it
may do something very unexpected: evaluating `v' in the callee
may provide the callee's `v', rather than the caller's.  This
is a particularly nasty problem in Gosling Emacs MLisp, where
all MLisp `arguments' are in fact fexpr's.
     
However, I stand by my statement, at least with a little modification:
no one wants to be forced to use call by name exclusively.  (Not
that other methods are not available in Algol.)  And I understand
taht Common Lisp does not have fexpr's.
     
    ~> call by value-result
     
    I was thinking of the caller squirrelling away the value
    in a temporary location, passing it by reference (thus
    allowing modification by the callee) and then copying the
    result to the real variable.
     
That works too---which just goes to show that there is more than
one way to skin a function.
     
`A swap, by any call by name, would smell as sweet ....'
`You can call me Ref, or you can call me Val, ....'
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2687
          for JMS@ARIZMIS; Sat,  5-JUL-1986 01:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/05/86 at 03:27:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027712; 5 Jul 86 4:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019130; 5 Jul 86 3:41 EDT
From: Silver <gaynor@topaz.ARPA>
Newsgroups: net.lang.c
Subject: re: '=' vs '<-' vs '.ne' vs '==' vs ':=' vs '.eq.' vs ...
Message-ID: <5282@topaz.RUTGERS.EDU>
Date: 5 Jul 86 06:36:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
[Line-Eater, hear me!  Eat this message, or I'll be flamed for sure!]
     
I've been following this discussion with polite attention, and decided
what the hell, here's my two cents (probably the value of the opinions
anyway, hee-yuk).
     
I give my preferences, and why.
     
ASSIGNMENT  <-
     
It visually seems more consistent with the programming paradigm, 'move
this value there'.  Mathematically, '=' is usually interpreted as 'it
is asserted that these two expressions are equal'.  To illustrate, can
you imagine what errors C or Pascal would generate on a statement like
x * x = 9?  Of course, it's a totally different story with an
assertive, relational language.  In addition, I don't care that it's
two strokes.  If I *really* minded, I would set-key-globally a
rarely-used key like '`' from self-insert to insert-<the-desired-
operator-of-more-than-one-character> (emacs is real nice about things
like this).
     
EQUALITY  =
     
Now, with '=' free, it can be used in a way more like it's
mathematical interpretion ('it is asserted...').
     
INEQUALITY  <>
     
I like it's visual symmetry, giving each side of the expression the
'half-operator''s mirror image of the other side (hard to express, you
know what I'm trying to say - neither side is favored).  Not so with
'!=', '~=', '|=', ...  Another connotation is that it is a 'true'
assertion, rather than a 'false' one.  That is, a <> b is literally
read as 'a is less than or greater than b', whereas a != b is read as
'a is not equal to b'.
     
By the way, do(es) any language(~s) implement these choices?
     
Go ahead then.
postnews re: "...!topaz!gaynor re: '=' vs '<-' vs ..." \
  | much-hellfire-and-brimstone
     
     
                         _   /|
                         \`o_O'
                           ( )   Aachk! Phft!
                            U
     
Disclaimer: The opinions and/or information and/or code expressed
            here were generated by this characature, stolen from
            Dave Rasmussen, to which I have taken the liberty of
            adding ears.  So don't look to me for a disclaimer!
     
Silver  {...!topaz!gaynor}

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3415
          for JMS@ARIZMIS; Sat,  5-JUL-1986 03:03 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/05/86 at 05:00:12 CDT
Received: from BRL-VGR.ARPA by SRI-KL.ARPA with TCP; Thu 3 Jul 86 13:20:56-PDT
Date:     Thu, 3 Jul 86 16:15:58 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Mike Hickey <MHICKEY%UDCVM.BITNET@wiscvm.wisc.EDU>
cc:       INFO-VAX@sri-kl.arpa, INFO-C@brl-smoke.arpa
Subject:  Re:  VAX C problem (?)
Message-ID:  <8607031615.aa02732@VGR.BRL.ARPA>
     
Any implementation of getchar() that does not require an entire
line to be typed before returning data from the terminal in the
default case is broken.  This behavior is permitted only in raw
(non-canonicalizing) mode, which is not supposed to be enabled by
default.  Sounds like VAX-C ver 2.2 is doing this right.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3621
          for JMS@ARIZMIS; Sat,  5-JUL-1986 03:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/05/86 at 05:14:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027909; 5 Jul 86 6:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019975; 5 Jul 86 5:41 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Shift by negative quantity
Message-ID: <894@bu-cs.UUCP>
Date: 5 Jul 86 02:02:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Question: Is shifting by a negative quantity defined (that is,
probably means the other shift.) I could find no mention in K&R.
     
it came up with an expression like:
     
    foo = goo >> 10-PGSHIFT;
     
which was a constant shift value. it didn't work on a SUN3, what's the
poop? (seems hard for most code generators if it's variable, well,
would have to test and branch if the underlying machine's shift
instruction won't take negative values correctly so I wouldn't be
surprised if it's undefined and I could understand not wanting a
separate rule for a constant even though it would be easy to turn it
around.)
     
Therefore, I guess it's just not defined and you have to generate
your own test, but I was wondering what was official.
     
Of course, it accidently works right on a VAX and NS32k, great,
more bugs to worry about...(a test example forcing negative,
I know the above is positive on a VAX, that's the point ultimately.)
     
    -Barry Shein, Boston University
     
P.S. Is this one of those questions that gets asked every 2 months?
If so, I'm glad, maybe I'll get a good answer after all that practice :-)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4694
          for JMS@ARIZMIS; Sat,  5-JUL-1986 09:15 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/05/86 at 09:05:22 CDT
Received: from WPAFB-FDL by SRI-KL.ARPA with TCP; Thu 3 Jul 86 08:30:08-PDT
Date: Thu, 03 Jul 86 11:30:35 EDT
From: daved@WPAFB-FDL
Subject: RE: Favorite O/S (VMS<>UNIX wars)
To: info-vax@sri-kl
Cc: daved@wpafb-fdl
     
Bill Bogstad at Hopkins-eecs-bravo.arpa writes:
> ...
>     I actually had to program in FORTRAN (heaven forbid) on VMS and
> had to do the equivalent of a Unix sleep() call.  Sounds reasonable
> right?  Hah!  After spending 3-4 hours wading through the VMS manuals I
> discover that I have to do a "scheduled wakeup" for my process and then
> a "hibernate".  Of course there are optional arguments to both calls
> which I have to decipher.  In addition, I have to call a special routine
> to generate the correct arguement to the wakeup call.  Now, I realize
> that this is somewhat similiar to the internals of the Unix sleep()
> function, but isn't it nicely packaged?  You give it a number and your
> program pauses for the required number of seconds.  Obviously not
> everything is conceptually this easy, but when it is why make it so
> hard to do?  Unix has been termed User unfriendly (with some reason),
> but I think a point can be made for VMS being programmer unfriendly.
>
>     Finally, yes VMS is a reasonable operating system, but it isn't
> perfect.  I'm not claiming this for Unix either, just that it is a
> little better.
> ...
    I am rather new to INFO-VAX and the community of users who are on
it, so bear with me and any mistakes I might make.
    After reading this previous message from Mr. Bogstad it occurred to
me that he went to a lot of trouble for nothing. It is true that the method
he describes for a function that "You give it a number and your program
pauses for the required number of seconds" works. but after checking things
with the LIB$... routines list, at least as of VMS 4.0, there is a function
called LIB$WAIT that does exactly that. Mind you, LIB$WAIT wants an address
pointing to a long word F_floating value passed to it, in fortran that's
normally a REAL*4, which means if he wants to use a literal value in
fortran it would have to be specified as a real (i.e. 4.0).
    Disclaimer: I make no claims to being an expert of UNIX, or VMS.
But it would seem to me that if everyone who makes a statement like, "I
like 'a' over 'b' because I can do 'c' easier on 'a' then on 'b'.", did a
little more detective work in the o/s' manuals they might not make the same
statement again.
     
David B. Dierker    <DAVED@WPAFB-FDL>
AFWAL/FITC        (Air Force Wright Aero Labs / Flight Dynamics Comp Ser)
WPAFB OH 45433         (Wright Patterson AFB, Dayton OH)
     
<VMS is wordy, and UNIX is terse;
 but the real discussion is which is worse.>
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6744
          for JMS@ARIZMIS; Sat,  5-JUL-1986 14:19 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/05/86 at 16:16:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000529; 5 Jul 86 17:06 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a023105; 5 Jul 86 16:39 EDT
Received: from maryland.arpa by AOS.BRL.ARPA id a000421; 5 Jul 86 16:37 EDT
Received: by mimsy.umd.edu (5.9/4.7) id AA01171; Sat, 5 Jul 86 16:35:18 EDT
Date: Sat, 5 Jul 86 16:35:18 EDT
From: "Victor R. Basili" <basili@maryland.ARPA>
Message-Id: <8607052035.AA01171@mimsy.umd.edu>
To: chris@maryland.ARPA, gwyn@BRL.ARPA, info-c@BRL.ARPA, rbj@ICST-CMR.ARPA
Subject: Re:  Swap by name
Cc: basili@maryland.ARPA
     
Thanks for letting me in on the discussion. I haven't read the interchange
carefully but I am delight that there is cause for an intellictual debate.
     
It only proves that we all continue to learn - Thank God!
     
Vic Basili

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6982
          for JMS@ARIZMIS; Sat,  5-JUL-1986 15:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/05/86 at 17:09:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000718; 5 Jul 86 18:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023349; 5 Jul 86 17:41 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Shift by negative quantity
Message-ID: <5753@alice.uUCp>
Date: 5 Jul 86 15:46:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Question: Is shifting by a negative quantity defined (that is,
> probably means the other shift.) I could find no mention in K&R.
     
You apparently didn't look on page 189, where it says:
     
    "The result is undefined if the right operand is negative,
     or greater than or equal to the length of the object in bits."

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7568
          for JMS@ARIZMIS; Sat,  5-JUL-1986 17:23 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/05/86 at 19:14:20 CDT
Received: from CitHex.Caltech.Edu by SRI-KL.ARPA with TCP; Fri 4 Jul 86
  09:09:31-PDT
Date:     Fri, 4 Jul 86 09:10:59 PDT
From:     carl@CitHex.Caltech.Edu (Carl J Lydick)
Message-Id: <860704091050.004@CitHex.Caltech.Edu>
Subject:  Re: Potential C problem
In-Reply-To: Your message <8607010910.AA06212@csvax.caltech.edu> dated
  30-Jun-1986
To:       LEICHTER-JERRY@YALE.ARPA, info-vax@CitHex.Caltech.Edu
     
Known bug; I believe it's fixed in VAX C V2.2.
The bug involving sscanf's not recognizing a 0 as a hex digit is still in
VAX-C V2.2-015.  It is the result of scanf's strategy for dealing with
integer conversions, in which it "optimizes" by skipping leading zero's.
To merely state that it's a "known bug" is of little help to somebody trying
to work around it.  You need either to list all cases in which the bug
occurs or give a description of what the problem REALLY is.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9558
          for JMS@ARIZMIS; Sat,  5-JUL-1986 20:24 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/05/86 at 22:18:10 CDT
Received: from CitHex.Caltech.Edu by SRI-KL.ARPA with TCP; Fri 4 Jul 86
  08:59:00-PDT
Date:     Fri, 4 Jul 86 08:53:19 PDT
From:     carl@CitHex.Caltech.Edu (Carl J Lydick)
Message-Id: <860704084941.003@CitHex.Caltech.Edu>
Subject:  Re: Potential C problem
In-Reply-To: Your message <8606261652.AA25082@tektools.TEK> dated 26-Jun-1986
To:       bobp%tektools.uucp@CSNET-RELAY.ARPA, info-vax@CitHex.Caltech.Edu
     
The problem is that sscanf is stripping leading zero's. When that's all
you've got, it fails.  By the way, I suspect you wanted to use the string
"%1x" rather than "%x1" in your example, though both have the same problem.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2713
          for JMS@ARIZMIS; Sun,  6-JUL-1986 03:04 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/06/86 at 05:02:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003841; 6 Jul 86 5:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027060; 6 Jul 86 5:44 EDT
From: Barry Shein <bzs%bu-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: re: '=' vs '<-' vs '.ne' vs '==' vs ':=' vs '.eq.' vs ...
Message-ID: <900@bu-cs.UUCP>
Date: 5 Jul 86 18:46:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Seriously folks, how many angels *can* fit on the head of a pin...

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2759
          for JMS@ARIZMIS; Sun,  6-JUL-1986 03:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/06/86 at 05:05:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003845; 6 Jul 86 5:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027073; 6 Jul 86 5:44 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Shift by negative quantity
Message-ID: <2282@umcp-cs.UUCP>
Date: 5 Jul 86 17:24:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <894@bu-cs.UUCP> bzs@bu-cs.UUCP (Barry Shein) writes:
>Question: Is shifting by a negative quantity defined (that is,
>probably means the other shift.) I could find no mention in K&R.
     
It is explicitly undefined.  K&R, Appendix A, \S 7.5, Shift Operators
(p. 189):
     
  The result is undefined if the right operand is negative, or greater
  than or equal to the length of the object in bits.
     
>P.S. Is this one of those questions that gets asked every 2 months?
     
No.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2970
          for JMS@ARIZMIS; Sun,  6-JUL-1986 03:32 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/06/86 at 05:30:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004036; 6 Jul 86 6:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027029; 6 Jul 86 5:43 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Additions to C - range checking
Message-ID: <441@opus.nbires.UUCP>
Date: 5 Jul 86 06:34:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     >if (5<a<50) do_something(a);
>     >
>     >Is this impossible to parse?
>
>     This was in BCPL, and was a GOOD IDEA.
>
> COBOL has this too. It is not impossible to parse, but it is not trivial
> either. It requires lookahead to resolve the meaning. Perhaps another syntax?
     
This suggestion ( 5<a<50 ) seems to come up every few months.  Every few
months someone gets to point out that it exists in Icon and it works.  The
parsing (for Icon, not COBOL) is no different than for any other dyadic
operator; it requires no extra lookahead or magic.  The Icon trick is that
success/failure indications (which drive control structures like "if") are
separate from values.  The operator "<" may either fail (meaning that the
relation does not hold) or succeed.  If it succeeds, it produces its right
operand as result.  The only remaining piece of the puzzle is that "<" is
left-associative (as dyadic operators usually are), so that 5<a<50 means
(5<a)<50.
--
Dick Dunn    {hao,ucbvax,allegra}!nbires!rcd        (303)444-5710 x3086
   ...Simpler is better.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8614
          for JMS@ARIZMIS; Sun,  6-JUL-1986 21:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/06/86 at 23:26:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008377; 7 Jul 86 0:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028866; 6 Jul 86 23:41 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Yet another ALIGN idea.  (some discussion)
Message-ID: <1038@ttrdc.UUCP>
Date: 6 Jul 86 19:54:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article 38.4762@utcs.uucp>, flaps@utcs.UUCP writes:
>How about an #include <align.h> which contains a single #define which gives the
>alignment constant for this machine?
>This of course would only be useful if put into the standard.
>Which reminds me, is sizeof(char) always = 1 yet?  I mean, is it guaranteed?
>ajr
     
Say if ajr's suggestion were implemented and /usr/include/align.h contained
something like
     
#define ALIGNSIZE 4    /* long int */
     
Now, given an arbitrary char* pointer, how do we tell if it is aligned?
Now on a machine with four-byte pointers and unsigned longs, we could do:
     
    char *c;
    ...
    if (((unsigned long)c % ALIGNSIZE) == 0) {
        /* c is aligned */
        ...
    } else {
        /* c is not aligned */
        ...
    }
     
But... what about a machine where alignments are "screwy," for example they
wanted doubles to be located at some fixed offset, say 2, from addresses which
are integral multiples of 4 or 8?  I can think of no such machine (indeed I
believe design of such would be an exercise in masochism) but where is it
engraved in stone what "aligned" really means (which we presume must imply
some guarantee of solid mapping between pointers and some other data type,
usually long... I used unsigned long in my example because it would work
on a machine with one's complement arithmetic and pointers with their
MSB set, whereas a bit-pattern copy to a long would produce a number which
could not be reliably tested for alignment--but again we hope that the
mapping instruction would be smarter than a bit-pattern copy).
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!ttrda!levy

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9444
          for JMS@ARIZMIS; Mon,  7-JUL-1986 18:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/07/86 at 20:27:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027545; 7 Jul 86 21:15 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a007438; 7 Jul 86 20:36 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA00338; Mon, 7 Jul 86 20:34:04 edt
Date: Mon, 7 Jul 86 20:34:04 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607080034.AA00338@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Pascal's Origin's
     
    > Quick Jab:
    >     If Pascal is so good why did its author (N. Wirth) write
    > two other languages (Modula & Modula II) before deciding he had one
    > which could be used for system implementation? (Lilith (sp?))
    >
    >                 Bill Bogstad
    >                 bogstad@hopkins-eecs-bravo.arpa
     
    Never any question about this one.  Wirth designed Pascal as a teaching
     
Wrong! Even Wirth denied that.
     
    language, not a system implementation language, and as a language that
    could be easily compiled by a 1-pass compiler on small computers.  It
    was designed specifically to be used by novices, thus the very strong
    type-checking, bounds checking, etc., and the very limited power of
    the language.
     
Unfortunately it teaches them bad habits as well. I was freaked royally
when my brother told me years ago that there were no provisions for
separate compilation. Everything in one source file, and they make
people write large scale projects in it? Pure insanity.
     
The I/O is inscrutable to a wizard, much less a novice.
     
Arrays of different sizes are incompatible, which discourages general
purpose routines.
     
No `otherwise' or `default' clause on switches makes them almost useless.
     
And the syntax is incredibly verbose and ugly.
     
    Modula 2 seems like and attempt to create a spin-off of the
    Pascal methodology that can actually be used for system
    implementation and the like.  Probably just as reasonable as
    all the incompatibly-expanded Pascals around today.
     
Modula 2 was written to cover Pascal's mistakes. Perhaps Pascal was
written to cover Lilith's mistakes as well.
     
As for Lilith, I once saw a film about a nutcase woman of the same
name. Filmed in part at Chestnut Lodge, Rockville, Md.
     
All in all, the author's name sums up his contribution to computer science.
     
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
       A quote usually goes here, but its currently being rennovated.
     
    These opinions are my own, though for a small fee they be yours too.
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
You should all JUMP UP AND DOWN for TWO HOURS while I decide on a NEW CAREER!!
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9397
          for JMS@ARIZMIS; Mon,  7-JUL-1986 18:43 MST
Received: from SRI-AI.ARPA by wiscvm.arpa on 07/07/86 at 20:26:06 CDT
Date: Mon  7 Jul 1986 10:41-PDT
From: AIList Moderator Kenneth Laws <AIList-REQUEST@SRI-AI>
Reply-to: AIList@SRI-AI
US-Mail: SRI Int., 333 Ravenswood Ave., Menlo Park, CA  94025
Phone: (415) 859-6467
Subject: AIList Digest   V4 #163
To: AIList@SRI-AI
     
     
AIList Digest             Monday, 7 Jul 1986      Volume 4 : Issue 163
     
Today's Topics:
  AI Tools - The Logix System,
  Psychology - Psychnet BBoard,
  Games - Hitech Results,
  Techniques - Hopfield Networks for Traveling Salesman,
  Opinion - Common Sense,
  Philosophy - Creativity and Analogy
     
----------------------------------------------------------------------
     
Date: Thu, 3 Jul 86 17:03:11 -0200
From: Ehud Shapiro  <udi%wisdom.bitnet@WISCVM.ARPA>
Subject: The Logix system
     
     
We are pleased to announce the availability of the Logix system, an
experimental Flat Concurrent Prolog program development environment.
Logix can be used to study and experiment with concurrent logic
programming, and to develop applications that can benefit from
combining the expressive power of concurrency with that of the logical
variable.
     
Logix is not a conventional programming environment; although presently
a single user single processor system, its basic design scales to a
multiprocessor, multiuser system.  With its novel approach to parallel
computation control, its concept of active modules and its
object-oriented design of system hierarchies, it is an interesting
system to study in its own right.  For the same reason it may be
overdeveloped for the casual user in certain respects (e.g. its
multitasking capabilities), and underdeveloped in others (e.g.
interactive help, "friendliness").
     
Logix includes an FCP compiler to an abstract machine instruction set
and a C emulator of the abstract machine.  With the exception of the
emulator and a few kernels, it is written entirely in Flat Concurrent
Prolog.  The system was bootstrapped in Summer 1985, and has seen
extensive use and development since.  It was used to develop
applications (including Logix itself) whose total size is over 20,000
lines of FCP source code.
     
Logix is available on Vax and Sun computers, under the Berkeley Unix
and Ultrix operating systems.  It is expected that applications
developed under Logix would run almost directly on a multiprocessor
implementation of Flat Concurrnt Prolog; the availability of such a
prototype system for the Intel iPSC hypercube is announced separately.
     
The handling fee for a non-commercial license to the Logix system
is $250 U.S.  To obtain a license form and/or a copy of the Logix user
manual write to:
     
        Mr Yossef Dabby
        Department of Computer Science
        The Weizmann Institute of Science
        Rehovot 76100, Israel
     
To obtain an electronic copy of the license write to:
     
        CSnet, Bitnet:  logix-request@wisdom
        ARPAnet: logix-request%wisdom.bitnet@wiscvm.arpa
     
     
References
     
[1] A. Houri and E. Shapiro, "A sequential abstract machine for Flat
        Concurrent Prolog", Weizmann Institute Technical Report CS86-20,
        1986.
[2] W. Silverman, M. Hirsch, A. Houri, and E. Shapiro, "The Logix system
        user manual, Version 1.21", Weizmann Institute Technical Report
        CS86-21.
[3] M. Hirsch, W. Silverman, E. Shapiro, "Layers of protection and
        control in the Logix system", Weizmann Institute Technical Report
        CS86-19, 1986.
     
------------------------------
     
Date: Mon, 30 Jun 86 12:34:27 CDT
From: Robert C. Morecock <EPSYNET@UHUPVM1>
Reply-to: EPSYNET@UHUPVM1
Subject: Announcement of new bboard named psychnet
     
           [Forwarded from Arpanet-BBoards by Laws@SRI-AI.]
     
     
PSYCHNET (tm)     Psychology Newsletter and Mailing List      EPSYNET@UHUPVM1
   The Psychnet mailing list and Newsletter sends out information and
news to those who sign up.  Within Bitnet, Psychnet is also a 24-hour
server machine which mails out files to users who first send the
PSYCHNET HELP command to userid UH-INFO at node UHUPVM1.  OUTSIDE
BITNET Psychnet is a mailing list and Newsletter only.  Once per week
ALL members receive the latest Psychnet Newsletter and Index of files
available on the server machine.  Outside Bitnet, if a file looks
interesting send an E-mail request to userid EPSYNET (NOT uh-info) at
node UHUPVM1 and the file will be shipped out to you.  Persons within
may also sign up for the mail list and will get the Newsletter and
Index along with other news.  Users within Bitnet should get their
files directly from the server machine.  An Exec file is available for
CMS users and COM files are available for VAX users within Bitnet.
   If you have a file or idea you wish distributed to members of the
list you may send it to userid EPSYNET at node UHUPVM1 and it will be
sent out for you, usually with the week's Psychnet Newsletter.  An
initial formal purpose of Psychnet is distribution of academic papers
in advance of this year's (1986) APA convention.  Other purposes will
develop according to the needs and interests of the profession and
Psychnet users.
   All requests to be added to or deleted from the mailing list, or to
have files distributed should be sent to:
   Coordinator:  Robert C. Morecock, Psychnet Editor, EPSYNET@UHUPVM1
     
------------------------------
     
Date: 6 Jul 86 22:37:15 EDT
From: Murray.Campbell@k.cs.cmu.edu
Subject: Hitech results
     
           [Forwarded from the CMU bboard by Laws@SRI-AI.]
     
Hitech had a tough day, but set a new milestone for computer chess.
In round 8, Hitech drew International Master Michael Rohde, rated
2602, for what we believe is the first draw by a computer against
a titled player in regular tournament play.  In round 9 Hitech
lost to Hungarian Grandmaster Guyla Sax, rated 2769.
     
Overall Hitech finished with 5.5/9, a respectable score given the
quality of the competition.  The performance rating was approximately
2440.
     
------------------------------
     
Date: Sat, 5 Jul 86 21:53:36 EDT
From: ambar@EDDIE.MIT.EDU (Jean Marie Diaz)
Reply-to: ambar@mit-eddie.UUCP (Jean Marie Diaz)
Subject: Re: connectionism/complexity theory
     
(an article published in the April 1, 1985 edition of Fortune--posted
w/out permission)
     
WHAT BELL LABORATORIES IS LEARNING FROM SLUGS
     
[...]  Inspired by the discoveries of physicist John Hopfield, a team
of Bell Labs scientists has been using research on slugs' brains to
develop a radically new type of computer.  [...]  The Bell computer
does not always select the single [best traveling salesman] route,
but--much like a human--it comes up with one of the better routes, and
never picks anything obviously loony.
     
New techniques for recording neurological activity in rats and in
three types of slugs--favored because of their large and accessible
nerve cells--are providing Bell's team with reams of information about
how neurons work.  But the conceptual focus of the Bell project is the
model of the new neural-network computer created by Hopfield, 51, who
splits his time between Bell Labs and the California Institute of
Technology.  Neural networks operate in the analog mode--when
information enters the brain, the neurons start firing and their
values, or "charges," rise and fall like electric voltage in analog
computers.  When information is digested, the network settles down
into a so-called steady state, with each of its many neurons resting
close to their highest or lowest values--effectively, then, either on
or off.  A computer designed to mimic a neural network would solve
problems speedily by manipulating data in analog fashion.  but it
would report its findings when each neuron is either in the on or off
state, operating like a digital computer speaking a binary language.
     
The simulated computer designed by Hopfield and his AT&T colleagues
uses microprocessors to do the work of neurons.  Each microprocessor
is connected to all others--as many neurons are interconnected--which
would make the machine costly and complex to build.  Another major
difference between this computer and traditional ones is that memory
is not localized in any one processor or set of processors.  Instead,
memory is in the patterns formed by all the neurons, whether on or
off, when they are in steady states.  As a result, the computer can
deal with fragmentary or imprecise information.  When given a
misspelled name, for example, it can retreive the full name and data
about the person by settling on the closest name in the network.
     
Though analog computation is astonishingly fast, it sacrifices
precision.  Neural-network computers work best on problems that have
more than one reasonable solution.  Examples include airline
scheduling, superfast processing for robots or weapons, and, more in
AT&T's line, routing long-distance telephone traffic.
     
-John Paul Newport
--
     
                                        AMBAR
                "I need something to change your mind...."
     
------------------------------
     
Date: 02 July 86 20:18 EDT
From: KVQJ%CORNELLA.BITNET@ucbvax.Berkeley.EDU
Subject: common sense
     
I have been thinking a lot about the notion of common sense and
its possible implementation into expert systems. Here are my ideas;
I would appreciate your thoughts.
Webster's Dictionary defines common sense as a 'practical knowledge'.
I contend that all knowledge both informal and formal comes from
this 'practical knowledge'.
After all, if one thinks about Physics,Logic,or Chemistry,much of it
makes practical sense in the real world. For example,a truck colliding
with a Honda civic will cause more destruction than 2 Hondas colliding
together. I think that people took this practical knowledge of the world
and developed formal principles.
It is common sense which distiguishes man from machine. If a bum on
the street were to tell you that if you give him $5.00 he will make you
a million dollars in a week, you would generally walk away and ignore him.
If the same man were to input it into a so called intelligent machine,the
machine would not know if he was Rockefeller or an indigent.
My point is this, I think it is intrinically impossible to program
common sense because a computer is not a man. A computer cannot
experience what man can;it can not see or make ubiquitous judgements
that man can. We may be able to program common-sense like rules into
it,but this is not tantamount to real world common sense because real
world common sense is drawn from a 'database' that could never be
matched by a simulated one.
Thank you for listening.
                       sherry marcus kvqj@cornella
     
------------------------------
     
Date: Thu, 3 Jul 86 17:07 EST
From: MUKHOP%RCSJJ%gmr.com@CSNET-RELAY.ARPA
Subject: Creativity and Analogy
     
Jay Weber makes some interesting observations:
     
> Consider the following view of analogy, consistent with its formal
> treatment in many sources.  A particular analogy, e.g. that which
> exists between a battery and a reservoir, is a function that maps
> from one category (set of instances) to another.  Equivalently we
> can view this function as a relation R between categories, in this
> case we have a particular kind of "storage capability".  This relation
> is certainly
>
>  1) reflexive.  "A battery is like a battery"  (under any relation)
>
>  2) symmetric.  "A battery is like a reservoir" implies
>                 "A reservoir is like a battery" under the same relation R
>
>  3) transitive. "A battery is like a reservoir" and
>                 "A reservoir is like a ketchup bottle" imply
>                 "A battery is like a ketchup bottle" WHEN THE SAME
>                 ANALOGY HOLDS BETWEEN THEM (same R).
>
> Then any analogy R is an equivalence relation, partitioning the space
> of categories.  Each analogy corresponds to a node in an abstraction
> hierarchy which relates all of the sub-categories, SO THE SPACE OF
> ANALOGIES MAPS ONTO THE SPACE OF ABSTRACTIONS, and so under these
> definitions analogy and abstraction are equivalent.
     
     
   I agree with your reasoning and the conclusion that analogies map ONTO
abstractions--in fact, I think they map ONTO and ONE-TO-ONE (in other words
there is a one-to-one correspondence).  Also, EACH analogy (and abstraction)
partitions the space of categories into two subspaces.  However, the SPACE
of analogies does not partition the space of categories because the world
can concurrently be modeled by multiple abstraction lattices (not necessarily
hierarchies) in which the transitivity property may not hold. Consider the
following:
     
       a) "A battery is like a reservoir"  (storage capability)
  AND  b) "A reservoir is like a pond"     (body of water)
     
DO NOT IMPLY:
       c) "A battery is like a pond"
     
     
> ...
> no one could agree to a particular formal definition of the term "analogy",
> since we all have individual formal definitions by virtue of the fact that
> we will answer yes or no when given a potential analogy instance, so we
> are formal language acceptors with our senses as input.  This is what I
> mean by a "slippery" term, i.e. one that has drastically different
> meanings depending on its user.   This is why I say a formal definition
> of analogy would satisfy very few people.
     
    I am glad that scientists, by and large, have not let "slipperiness" in
some linguistic sense (as you define it) discourage them from carrying on
their research. Of course, all research issues are "slippery" in a conceptual
sense, by definition. (I would also expect a high degree of correlation
between linguistic and conceptual "slipperiness").
    There has been some discussion now (in AIList) on the relationship
between "creativity" and "making-interesting-analogies".  Is it mere
empirical association or are there stronger causal links?  One extreme
view is that the definition of creativity is "making interesting analogies".
Some recent illuminating discussions in this forum suggest that the ability
to synthesize concepts from partial concepts in other domains is a key
ingredient of a great number of creative activities.
    Is there some creative task that could not be performed by a machine
capable of making complex analogies in an interesting manner--a complex
analogy being defined as a many-to-one transformation between domains (as
opposed to a simple analogy which is a one-to-one mapping)?
     
Uttam Mukhopadhyay
Computer Science Dept.
General Motors Research Labs
     
------------------------------
     
End of AIList Digest
********************

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9726
          for JMS@ARIZMIS; Mon,  7-JUL-1986 19:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/07/86 at 21:00:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027845; 7 Jul 86 21:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008183; 7 Jul 86 21:41 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: variable # of args portability?
Message-ID: <809@ucbcad.BERKELEY.EDU>
Date: 7 Jul 86 22:01:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I want to be able to write a function that will take an unknown number
of arguments and then call another such function with these arguments,
namely something like printf() that calls _doprnt() without processing
its arguments at all.  I know there is no way to write this code portably,
but is it reasonable to assume that I will be able to do it at all in
most common implementations of C?  Also, how safe is it to assume that there
will be something like _doprnt() available?  I know it's not good to depend on
things like this, but I don't want to have to write my own printf()...
     
    Wayne

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9769
          for JMS@ARIZMIS; Mon,  7-JUL-1986 19:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/07/86 at 21:01:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027862; 7 Jul 86 21:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008238; 7 Jul 86 21:42 EDT
From: Alan Curtis <apc%cbuxb.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: pointers to functions
Message-ID: <345@cbuxb.UUCP>
Date: 6 Jul 86 19:10:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>Secondly is it possible to have an array of type 'pointer to' function.
Ok, on my machine this works:
     
hi(a)    {
    return(2*a);
    }
     
by(a)    {
    return(4*a);
    }
     
int (*(func[2]))() = { hi, by };
     
main()
    {
    printf("0x%x, 0x%x, 0x%x, 0x%x.\n",
            func[0], func[1], (*func[0])(1), (*func[1])(1));
    }
     
To produce:
     
0x24, 0x30, 0x2, 0x4.
     
I assume this is what you where looking for??
     
Alan Curtis.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0458
          for JMS@ARIZMIS; Mon,  7-JUL-1986 20:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/07/86 at 22:04:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000290; 7 Jul 86 22:55 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a008462; 7 Jul 86 22:02 EDT
Date:     Mon, 7 Jul 86 21:55:59 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       "Wayne A. Christopher" <faustus@ucbcad.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  variable # of args portability?
Message-ID:  <8607072155.aa00176@VGR.BRL.ARPA>
     
Most UNIX and some other C implementations have a <varargs.h>
header file that defines macros for getting at variably-sized
argument lists; unfortunately this is not sufficient for an
interface to a printf-like routine, where you need to pass
the remaining argument list along.  Many UNIX and some other C
implementations provide v*printf functions that are useful
in such situations.  There is normally some function like
_doprnt in the C library, but it may go by another name and
have slightly different arguments.
     
For the time being, people usually either invoke *printf using
functions with fixed arguments (perhaps several of them to
cover all necessary cases) or provide an interface that must
be adapted by each site.  Other commonly-used approaches tend
to be non-portable.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2052
          for JMS@ARIZMIS; Tue,  8-JUL-1986 01:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 03:02:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003426; 8 Jul 86 3:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009924; 8 Jul 86 3:40 EDT
From: kjm%ut-ngp.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <3615@ut-ngp.UUCP>
Date: 8 Jul 86 02:27:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[]
     
JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU (Edward Jung) posts the following missive:
     
>Although this may be read by all, it is targetted for
>Ken "Smurf Shredder" Montgomery at U Texas, self-acknowledged scum.
     
Member of HASA, you mean.  (BTW, Oleg, do I qualify as a charter member?)
     
>Why can't C be like everybody else?  Practically every language uses
>the equals sign, "=", to test for equality, not as an assignment operator.
     
Why should it be like everybody else?  Are you really advocating conformity
at the expense of innovative improvement?
     
>Everybody who's anybody knows that there is a problem in the use of "="
>for more than one purpose, a la BASIC and FORTRAN.
     
Ah, yes.  Once again, Usenetters, we have a personal attack.  (Not to
mention a confused missive-poster: "=" is only used for assignment in
FORTRAN.)
     
>Pascal resolves this
>problem by continuing to use "=" to testing and creating ":=" for
>assignments.  Kernighan and Ritchie, in their infinite wisdom, decide
>instead to use "=" for assignments and to create a new operator, "==" to
>test for equality.  Gee, that must have required brains, the brains of
>a 3 year old.
     
Oh, boy!  Another personal attack!  You must have been in a maximally
awful mood when you wrote this missive!
     
>If they had my brains, they would have used Pascal's method.  Better yet,
>they should have let someone else write up C.
     
Wow!  Rack up three for that man!  (Give him a cigar?  Maybe an exploding one?)
     
     
One completely reactionary statement.  Three personal attacks.  Statement Fu.
Operator Fu.  Confusion Fu.  Impressive.  Not positively.  Smurf-shredder says,
"Check it out!"
     
>Edward Jung, Stevens Institute of Technology
>JUNG_E@SITVXB.BITNET
>
>PS: Ken, I don't like your cat.
     
This is about as rational an opinion as the rest you've shown so far.
     
--
The above viewpoints are mine.  They are unrelated to
those of anyone else, including my cat and my employer.
     
Ken Montgomery  "Shredder-of-hapless-smurfs"
Member of HASA -- Heathen and Atheistic Scum Alliance
...!{ihnp4,allegra,seismo!ut-sally}!ut-ngp!kjm  [Usenet, when working]
kjm@ngp.{ARPA,UTEXAS.EDU}  [Old/New Internet; depends on nameserver operation]
kjm@ngp.CC.UTEXAS.EDU      [Very New Internet; may require nameserver operation]

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2460
          for JMS@ARIZMIS; Tue,  8-JUL-1986 01:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 03:34:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003523; 8 Jul 86 4:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009955; 8 Jul 86 3:41 EDT
From: rmarti%sun.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <4824@sun.uucp>
Date: 7 Jul 86 17:44:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Everybody keeps guessing at the reasons for the use of = for asignment
> and == for equality tests.  How about a different angle: how many times
> in a program do you assign something versus how many times you compare things?
>
> [ ... ]
>
> Maybe Mssrs. Kernighan and/or Ritchie would like to give some input on
> their reasons of choice.
> -------
     
They already did.  Let me quote K&R, p.17:
     
  The double equals sign == is the C notation for "is equal to" (like
  Fortrans's .EQ.).  This symbol is used to distinguish the equality
  test from the single = used for assignment.  Since assignment is about
  twice as frequent as equality testing in typical C programs, it's
  appropriate that the operator be half as long.
     
Personally, I still prefer := for assignment and = for equality over =
and ==.  I also think that the keystroke argument is ridiculous (flames
to /dev/null).  The problem with = and == is further aggravated by the
fact that in C an assignment is an expression and not a statement, so
that code like
     
  if (i = 0) {
    /* do something */
  }
  else {
    /* do something else */
  }
     
is legal C and usually  /* does something else */   than you expected  :-)
     
Despite that, I would never call Messrs K&R idiots, as Niklaus Wirth has
been labeled in a recent message (not the one I am responding to):
I think both C and Pascal have been reasonable designs of programming
languages and important contributions to the computing community.
--
     
Robert Marti, Sun Microsystems, Inc.
     
UUCP: ...{cbosgd,decvax,decwrl,hplabs,ihnp4,pyramid,seismo,ucbvax}!sun!rmarti
ARPA: rmarti@sun.com

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3518
          for JMS@ARIZMIS; Tue,  8-JUL-1986 05:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 07:06:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005861; 8 Jul 86 8:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012075; 8 Jul 86 7:41 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Swap by name
Message-ID: <2293@umcp-cs.UUCP>
Date: 6 Jul 86 23:10:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <1964@brl-smoke.ARPA> rbj@icst-cmr.ARPA (Root Boy Jim) writes:
>>I was thinking of the caller squirrelling away the value in a temporary
>>location, passing it by reference (thus allowing modification by the
>>callee) and then copying the result to the real variable.
     
In article <1060@umd5.UUCP> zben@umd5.UUCP (Ben Cranston) replies:
>Of course the difference between this and real call-by-name comes when
>the subroutine has an alternate access to the global in question - perhaps
>because of scoping rules, or access to a pointer-to-it or something.
     
Careful, Ben: this was under a section about call by value-result,
and it does accomplish that quite handily.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3793
          for JMS@ARIZMIS; Tue,  8-JUL-1986 05:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 07:21:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006045; 8 Jul 86 8:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012110; 8 Jul 86 7:42 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <432@dg_rtp.UUCP>
Date: 7 Jul 86 18:53:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> chris@umcp-cs.UUCP (Chris Torek)
     
Good article overall.  However, I have a nit to pick with one of the
examples:
     
>         int day_tab[2][13] = { ... };
>
> the following are type-correct calls:
>
>         f2d(p) int (*p)[13]; { ...  }
>
>         f1d(p) int *p; { ...  }
>
>         proc()
>         {
>                                         /* argument types: */
>                 f2d(day_tab);           /* pointer to array 13 of int */
>                 f2d(&day_tab[0]);       /* pointer to array 13 of int */
>
>                 f1d(day_tab[0]);        /* pointer to int */
>                 f1d(&day_tab[0][0]);    /* pointer to int */
>         }
     
There is one problem here.  The expression (&day_tab[0]) is illegal.
Given this simplified example:
     
     1  int aa[2][3];
     2
     3  void f1(pa) int (*pa)[3]; { }
     4
     5  void f2(){
     6      f1(aa);
     7      f1(&aa[0]);
     8  }
     
lint has this to say (among other things):
     
        (7)  warning: & before array or function: ignored
     
Granted, things are very strange here, since the [] operator is always
supposed to yield an lvalue.  However, as Chris pointed out, values of
type ([]) are always coerced to expressions of type (*) in all contexts
except sizeof.  Thus, the subscription yields a (potentially) lvalued
expression of array type, and it is coerced to a non-lvalued pointer
type, and thus the address-of is illegal.  (I think.)
     
Note well: The problem isn't with the type of aa.  Lint is *not*
complaining about the fact that aa follows the "&".  This peculiarity
arises because (aa[0]) has type (int [3]), and is immediately coerced to
an expression of type (int *) in all contexts except sizeof.  Thus,
while (&aa[0]) is illegal, (&aa[0][0]) is quite legal indeed.  Of
course, the latter operation doesn't yield a pointer of the correct type
to be passed to function f1 above.
     
--
>       `You can hack anything you want,
>        with pointers and funny C . . .'
     
Sung to "Alice's Restaurant", I presume?
     
(We'll wait 'til it comes around, then join in...)
(That's what we're doing now... waiting for it to come around...)
(Here it comes...)
     
        You can hack anything you want,
        With pointers and funny C.
        You can hack anything you want,
        With pointers and funny C.
     
        Dive right in, if you feel the need,
        It's a great language but it's gone to seed.
        You can hack anything you want,
        With pointers and funny C (Excepting Ritchie...)
     
(That was pittiful.)
     
--
"I wanna *HACK*!  I wanna *HACK*!!!
 I wanna feel *BITS* between my teeth!"
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3901
          for JMS@ARIZMIS; Tue,  8-JUL-1986 05:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 07:37:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007134; 8 Jul 86 8:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012065; 8 Jul 86 7:41 EDT
From: Ben Cranston <zben%umd5.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Swap by name
Message-ID: <1060@umd5.UUCP>
Date: 6 Jul 86 22:49:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1964@brl-smoke.ARPA> rbj@icst-cmr.ARPA (Root Boy Jim) writes:
...
> I was thinking of the caller squirrelling away the value in a temporary
> location, passing it by reference (thus allowing modification by the
> callee) and then copying the result to the real variable.
     
Of course the difference between this and real call-by-name comes when
the subroutine has an alternate access to the global in question - perhaps
because of scoping rules, or access to a pointer-to-it or something.
     
In real call-by-name the data item would change as soon as the parameter
is modified by the subroutine.  In the proposed scheme the transfer does
not take place until the subroutine returns.
     
> ... Univac's PLUS compiler. It stored its arguments directly
> into the callee's statically declared variables and grabbed the results
> after the callee returned. Ask zben@umd[25] about this if you care.
     
Well, since Plus was to be written in Plus there was the old bootstrap
problem.  The solution taken was to hack beat and fiddle an existing
Jovial [1] compiler to be the Plus compiler.  The stuff-into-callee's
static-data-area scheme Jim refers to was inherited from the old code.
     
He's also been away from things awhile - Plus Plus (the second generation
compiler) has been here for years now, and it uses a slightly more
conventional scheme - the arguments are built on the end of the data stack
and in the process of calling the subroutine the stack pointer is pushed
just enough to make the arguments the first N locals of the called routine.
     
Perhaps my usage of "stack pointer" is unusual here - the 1100 does not
have any builtin stack so stacks must be implemented with index registers.
What I called "stack pointer" here is what many people call "frame pointer".
     
[1] Jules schwartz's Own Version of the International Algebraic Language
    Or some YABA [2] like that...
[2] Yet Another (questioned parentage) ALGOL...
     
Cheers
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4014
          for JMS@ARIZMIS; Tue,  8-JUL-1986 05:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 07:42:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007376; 8 Jul 86 8:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012223; 8 Jul 86 7:45 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pig C
Message-ID: <6901@utzoo.UUCP>
Date: 7 Jul 86 20:05:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> This is such a great analogy, with Henry's permission I would like to coin
> the term
>
>     Pig C
>
> to refer to C code (like the Bourne shell) which effectively
> redefines the language...
     
Sounds good to me!
--
Usenet(n): AT&T scheme to earn
revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5779
          for JMS@ARIZMIS; Tue,  8-JUL-1986 09:27 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 11:06:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015673; 8 Jul 86 11:55 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a022198; 8 Jul 86 11:45 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02031; Tue, 8 Jul 86 11:43:01 edt
Date: Tue, 8 Jul 86 11:43:01 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607081543.AA02031@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, rmarti@sun.ARPA
Subject: Re: Precedent for use of =
     
> They already did.  Let me quote K&R, p.17:
>
>   The double equals sign == is the C notation for "is equal to" (like
>   Fortrans's .EQ.).  This symbol is used to distinguish the equality
>   test from the single = used for assignment.  Since assignment is about
>   twice as frequent as equality testing in typical C programs, it's
>   appropriate that the operator be half as long.
     
And since `if' clauses are twice as frequent as `else' clauses, the
former token should be half the length of the latter :-)
     
> Personally, I still prefer := for assignment and = for equality over = and ==.
     
Then you would mistype `a = b' instead of `a := b'.
     
> I also think that the keystroke argument is ridiculous (flames to /dev/null).
     
Me too. Since most statements are one to a line, requiring `;' is kind of
redundant. Make newline imply `;' unless the statement is incomplete,
such as a control statement or unbalanced parens, or dyadic operators
at the end of line. Use `;' to jam multiple statements on one line.
As always, `\' newline is ignored.
     
> The problem with = and == is further aggravated by the
> fact that in C an assignment is an expression and not a statement, so
> that code like
     
Since this feature is only in C, LISP, APL, (& others I don't know about)
and not in FORTRAN, BASIC, PASCAL, COBOL, PL/I (?), two separate operators
are required in the formers, and only suggested in the latters. One
FORTARN compiler (DEC?) (U Md.'s RALPH?) would even convert
`IF (A = B)' into `IF (A .EQ. B)' for you.
>
>   if (i = 0) {
>     /* do something */
>   }
>   else {
>     /* do something else */
>   }
>
> is legal C and usually  /* does something else */   than you expected  :-)
     
Yes, only one branch (or none), or loop forever (or not at all).
I find these easy to fix.
     
> Despite that, I would never call Messrs K&R idiots, as Niklaus Wirth has
> been labeled in a recent message (not the one I am responding to):
> I think both C and Pascal have been reasonable designs of programming
> languages and important contributions to the computing community.
     
Aw, c'mon, is that all the response my statement generated. Let me try
again. Dennis Ritchie is like Jerry Garcia: subtle and sweet,
while Nickels Worth is like Jimmy Page*: obvious and without any taste.
     
> Robert Marti, Sun Microsystems, Inc.
>
> UUCP: ...{cbosgd,decvax,decwrl,hplabs,ihnp4,pyramid,seismo,ucbvax}!sun!rmarti
> ARPA: rmarti@sun.com
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Is it clean in other dimensions?
     
* if you are a `Led Head', then substitute `Mark Farner' for `Jimmy Page'.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6248
          for JMS@ARIZMIS; Tue,  8-JUL-1986 10:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 11:48:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016667; 8 Jul 86 12:43 EDT
Received: from juliet.caltech.edu by SMOKE.BRL.ARPA id a023254;
          8 Jul 86 12:29 EDT
Date:     Tue, 8 Jul 86 09:29:32 PDT
From:     "Robert S. Logan" <bob@juliet.caltech.edu>
Message-Id: <860708092853.00e@Juliet.Caltech.Edu>
Subject:  re: Pig C
To:       info-c@BRL-SMOKE.ARPA
     
Wait a minute, it's Pig Latin, not Pig English. To keep the analogy
maximally analogous, shouldn't it be Pig B or Pig BCPL?
     
--
Robert S. Logan
Campus Computing Organization, 158-79 Caltech, Pasadena, CA, 91125
818-356-4631
rslogan@caltech.bitnet
bob%juliet@cit-hamlet.arpa
...!ucbvax!bob%juliet@cit-hamlet.arpa
     
The above opinions are licensed (not sold)...

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0789
          for JMS@ARIZMIS; Tue,  8-JUL-1986 18:56 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 19:29:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025812; 8 Jul 86 19:24 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a007585; 8 Jul 86 18:48 EDT
Received: from (JUNG_E)SITVXB.BITNET by WISCVM.ARPA on 07/08/86 at
  13:44:50 CDT
Date: 8 JUL 86 14:40-EST
From:  JUNG_E%SITVXB.BITNET@wiscvm.ARPA
To:  info-c@BRL-SMOKE.ARPA
Cc:  JUNG_E%SITVXB.BITNET@wiscvm.ARPA
Subject: PRECEDENT FOR USE OF =
     
        I must apologize for my rash mailing several weeks ago on this
topic.  As many of you have pointed out to me, I should have done a little
more research before attempting to tear apart K&R.
        Apologies to those of you whose intelligence I must have insulted and
to Stevens Institute of Technology.  Being an UNDERGRADUATE majoring in
Electrical Engineering rather than Computer Science, I am but a mere hacker of
small microcomputers and have no right to mention the Institute as my
affiliation.
        Thanks to those who politely put me in my place.  Really.
     
Edward Jung
JUNG_E@SITVXB.BITNET

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9894
          for JMS@ARIZMIS; Tue,  8-JUL-1986 19:15 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/08/86 at 18:27:04 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Mon 7 Jul 86 08:33:01-PDT
Date:  7 JUL 1986 11:35:05 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: carl@CitHex.Caltech.Edu (Carl J Lydick)
cc: info-vax@sri-kl
Subject:  Re: Potential C problem
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
    > Known bug; I believe it's fixed in VAX C V2.2.
     
    The bug involving sscanf's not recognizing a 0 as a hex digit is still in
    VAX-C V2.2-015.  It is the result of scanf's strategy for dealing with
    integer conversions, in which it "optimizes" by skipping leading zero's.
    To merely state that it's a "known bug" is of little help to somebody
    trying to work around it.  You need either to list all cases in which the
    bug occurs or give a description of what the problem REALLY is.
     
All I knew about the bug was what I said:  That it had been reported before.
I didn't know the origin, nor did I have any direct way to check that it WAS
fixed in 2.2, only that it WASN'T fixed in 2.1, the latest version installed
here.  Because of the timing of the reports, I'm surprised that it wasn't
fixed in VAX C V2.2.  On the other hand, this is a problem in VAXCRTL, which
is no longer shipped with the VAX C kit, but directly with VMS.  So the right
answer might be "fixed in VMS V4.4" (which we don't have installed yet
either....))
     
You are certainly welcome to provide more information if you have it.  I
posted my message to (perhaps) save people unnecessary time staring at their
programs and the documentation, trying to figure out what THEY had done wrong.
     
                            -- Jerry
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0663
          for JMS@ARIZMIS; Tue,  8-JUL-1986 19:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 19:17:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023112; 8 Jul 86 15:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000768; 8 Jul 86 13:41 EDT
From: Ben Cranston <zben%umd5.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Swap by name
Message-ID: <1065@umd5.UUCP>
Date: 7 Jul 86 22:37:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1964@brl-smoke.ARPA> rbj@icst-cmr.ARPA (Root Boy Jim) writes:
> I was thinking of the caller squirrelling away the value in a temporary
> location, passing it by reference (thus allowing modification by the
> callee) and then copying the result to the real variable.
     
In article <1060@umd5.UUCP> zben@umd5.UUCP (Ben Cranston) replies:
> Of course the difference between this and real call-by-name comes when
> the subroutine has an alternate access to the global in question - perhaps
> because of scoping rules, or access to a pointer-to-it or something.
     
In article <2293@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) cautions:
> Careful, Ben: this was under a section about call by value-result,
> and it does accomplish that quite handily.
     
Er, yeah.  Another difference between call-by-name and value-result comes
when the actual is subscripted like a[i] and different array indices can
be selected on each reference to the formal (assuming i modified).  This
would have been a better example than the one I actually gave.
     
No criticism of you or Root Boy was meant, I was only adding information.
Your point that I should have reviewed the entire discussion before posting
is well taken.
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1004
          for JMS@ARIZMIS; Tue,  8-JUL-1986 20:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/08/86 at 19:51:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026288; 8 Jul 86 20:32 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa09125; 8 Jul 86 20:20 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a026230; 8 Jul 86 20:19 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA13653; Mon, 7 Jul 86 12:59:12 edt
Date: Mon, 7 Jul 86 12:59:12 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607071659.AA13653@icst-cmr.ARPA>
To: chris@maryland.ARPA, gwyn@BRL.ARPA, info-c@BRL.ARPA
Subject: Re:  Swap by name
     
    >     ~> call by value-result
    >
    >     I was thinking of the caller squirrelling away the value
    >     in a temporary location, passing it by reference (thus
    >     allowing modification by the callee) and then copying the
    >     result to the real variable. [me]
    >
    > That works too---which just goes to show that there is more than
    > one way to skin a function. [chris@maryland (as in Torek)]
     
Changing the subject a bit here, I am referencing Wayne Throop's article
on taking the address of a register variable, where he quotes H&S (how
about that folks, they're mainstream enuf to be ref'ed like K&R).
     
I have said all along that there is no reason why a compiler can't
perform the following transformation:
     
        LEGAL                DESIRED
    foo()                foo()
    {    register int j;        {    register int j;
        auto     int k;
        k = j;
        bar(&k);            bar(&j);
        j = k;
    }                }
     
Sort of a Call by Value-Result, eh?
     
As H&S notes, some machines have registers that really *are* addressable,
so this does provide something that is missing, and is not just syntactic
sugaring. Even if it were, look at all the language implementation
chatter we have removed. Just let the user say what he means.
     
I agree with H&S that the syntax `ought' not to be illegal, but go the
other way with the fix. They wish to ignore the register declaration
making the variable auto, whereas I wish to simulate register addressibility.
     
Consider a function which uses a register variable heavily in three or
four loops. Now consider modifying the code to include a call to one that
wants the address of a variable. Oops! All too often the fix is to change
the register declaration to auto rather than add the extra variable and
two assignments. Down the drain goes performance.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Yow!  Is my fallout shelter termite proof?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0435
          for JMS@ARIZMIS; Tue,  8-JUL-1986 20:07 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/08/86 at 18:47:50 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Mon 7 Jul 86
  21:09:06-PDT
Received: from virginia by csnet-relay.csnet id ac16298; 8 Jul 86 0:09 EDT
Received: by uvacs.UUCP (4.12/5.1.UVA)
    id AA09858; Mon, 7 Jul 86 13:02:09 edt
Posted-Date: Mon, 7 Jul 86 12:58:16 edt
Received: by edison.UUCP (4.12/5.6.edison)
    id AA15798; Mon, 7 Jul 86 12:58:16 edt
Date: Mon, 7 Jul 86 12:58:16 edt
From: John Owens <edison!jso%virginia.csnet@CSNET-RELAY.ARPA>
Message-Id: <8607071658.AA15798@edison.UUCP>
To: LEICHTER-JERRY@YALE.ARPA
Cc: info-vax@SRI-KL.ARPA
Subject: Re: main() and entry points in C
     
I agree.  Certainly there are many UNIX programs that take advantage
of specific non-portable features!  I wish that more people would use
varargs, but old habits die hard.  varargs being a fairly recent
innovation, many people won't use it just because they're likely to
find more UNIX implementations that'll work the old way than those
with varargs, since everyone wants to stay compatible with existing
programs!
     
I finally went and read the start() routine, and was surprised to find
that it was written partially in C, with a few "asm" directives.  Many
other UNIX implementations, such as the PDP-11 ones, have this written
in assembler, with no public symbol for the first location.  (The name
_start comes from the fact that the C compiler prepends an underscore
to any external symbol.)
     
WRT mixing languages, I've found that just as cc will run as on any
assembler files, then invoke the loader appropriately, f77 will invoke
the c compiler on any .c files and the assembler on any .s files, etc.
The (admittedly ad-hoc) solution has usually been to have the
interface to your "new" langauge handle the linking with C modules,
and any others you know about.  Even without this, you can always do
something like:
     
    cc a.c b.c c.c
    f77 d.f e.f
    mod2 f.m g.m
 -- and then, if your main program is C, with Fortran and Modula-2 routines --
    cc a.o b.o c.o d.o e.o f.o g.o
 -- or if it's Fortran with C and Modula-2 routines --
    f77 a.o b.o c.o d.o e.o f.o g.o
 -- etc, since any interface should just pass .o files on to ld --
     
One of the things I actually liked about VMS (really!  it does have a
few redeeming qualities) was that all the langauge interfaces were
extremely standardized, to the point that the main rtl was common to
all languages.  Of course it didn't have to be so cumbersome an
interface....
     
        In hope of universitality-
            -John
            (edison!jso%virginia@CSNET-RELAY.ARPA)
     
     
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3530
          for JMS@ARIZMIS; Wed,  9-JUL-1986 01:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 03:03:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027966; 9 Jul 86 3:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011960; 9 Jul 86 3:42 EDT
From: Stanley Friesen <friesen%psivax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  swap() macro
Message-ID: <1321@psivax.UUCP>
Date: 7 Jul 86 22:44:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1946@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>  I haven't seen call-by-name included in any language since Algol.
     
    What about LISP? Or is LISP older than Algol?
--
     
                Sarima (Stanley Friesen)
     
UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ??

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3442
          for JMS@ARIZMIS; Wed,  9-JUL-1986 01:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 02:57:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027963; 9 Jul 86 3:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011914; 9 Jul 86 3:41 EDT
From: Mike Beckerman <mikeb%copper.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: SWAP macro
Message-ID: <461@copper.UUCP>
Date: 7 Jul 86 20:34:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I'm a little behind on my news for net.lang.c, but of the articles about the
"SWAP" macro which I've read several have some form of copy involved.  By copy
I mean the use of "memcopy", or a cast to character and copy, etc.  These may
work in many cases, but they could be quite harmful when used on objects
which have the "volatile" storage class.
     
For example, if the objects were ints, and the swap is implemented as swapping
4 characters for each int, then each of the two ints would be accessed in
some part 8 times (4 to read old 4 bytes, 4 to write new 4 bytes).
     
Any comments?
     
     
    Mike

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3795
          for JMS@ARIZMIS; Wed,  9-JUL-1986 01:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 03:29:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028053; 9 Jul 86 4:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012082; 9 Jul 86 3:47 EDT
From: C Waldman <cgw%mruxe.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: decline of net.lang.c
Message-ID: <119@mruxe.UUCP>
Date: 8 Jul 86 13:59:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Well, the time has finally come for me to hit the old 'U' key...
too bad, this newsgroup used to be more interesting- seems like
all I ever see anymore are people asking questions that could
be answered by a quick look at the manual- you call yourselves C
programmers, and you _still_ dont understand pointers? But the last straw
when reading the most recent posting on this = versus == versus
:= issue-  MEYER@RADC-TOPS20.ARPA proposes a 'new angle' on the question-
how many times do tou use each, and how many keystrokes, and wonders what K&R
would think of that... well, it's on page 17:
   Since assignment is about twice as frequent as equality testing in C
programs, it's apporpriate that the operator be half as long.
     
     
   The question about negative bit-shifts was of the same ilk- the answer
is in front of your nose, if you just look-
     
   I just don't have the time to read this group anymore. bye-bye.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3615
          for JMS@ARIZMIS; Wed,  9-JUL-1986 01:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 03:19:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028033; 9 Jul 86 4:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012029; 9 Jul 86 3:45 EDT
From: Tom Stockfisch <tps%sdchem.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Shift by negative quantity
Message-ID: <252@sdchema.sdchem.UUCP>
Date: 8 Jul 86 16:23:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <894@bu-cs.UUCP> bzs@bu-cs.UUCP (Barry Shein) writes:
>Question: Is shifting by a negative quantity defined (that is,
>probably means the other shift.) I could find no mention in K&R.
>...
     
Looking up "shift operators" in the index of K&R, I am referred to p. 189:
     
    "The result [of a shift operator] is undefined if the right operand
    is negative, or greater than or equal to the length of the object
    in bits."
     
I'm sure its done this way so that the operation is closer to every machine's
instruction set and isn't a higher-level operation with additional checks
or conversions.
     
>P.S. Is this one of those questions that gets asked every 2 months?
     
I haven't seen it before.
     
--Tom Stockfisch, UCSD Chemistry

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3695
          for JMS@ARIZMIS; Wed,  9-JUL-1986 01:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 03:22:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028035; 9 Jul 86 4:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012049; 9 Jul 86 3:45 EDT
From: Kenneth Ng <ken%argus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pascals Origins
Message-ID: <311@argus.UUCP>
Date: 9 Jul 86 01:54:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2007@brl-smoke.ARPA>, rbj@icst-cmr (Root Boy Jim) writes:
>
> Unfortunately it teaches them bad habits as well. I was freaked royally
> when my brother told me years ago that there were no provisions for
> separate compilation. Everything in one source file, and they make
> people write large scale projects in it? Pure insanity.
I believe Wirth had said that seperate compilation was a tweak, and
that people should concentrate on faster compilers.  I guess he
changed his mind.
     
> The I/O is inscrutable to a wizard, much less a novice.
From my experiences with Pascal I/O, I've found it easier to use 360
assembler and a real library linker/loader than to use Pascal I/O.
I've even found it easier (although non portable), to call Fortran
reads and writes instead of Pascal's.
     
>
> Modula 2 was written to cover Pascal's mistakes. Perhaps Pascal was
> written to cover Lilith's mistakes as well.
And Ada was written to fix Modula 2's mistakes.
     
--
Kenneth Ng:
Post office: NJIT - CCCC, Newark New Jersey  07102
uucp(unreliable) ihnp4!allegra!bellcore!njitcccc!ken
soon uucp:ken@rigel.cccc.njit.edu
bitnet(prefered) ken@njitcccc.bitnet
soon bitnet: ken@orion.cccc.njit.edu
(Yes, we are slowly moving to RFC 920, kicking and screaming)
     
Vulcan jealousy: "I fail to see the logic in prefering Stonn over me"
Romulan: "Permit me the glory of the kill"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3741
          for JMS@ARIZMIS; Wed,  9-JUL-1986 01:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 03:27:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028037; 9 Jul 86 4:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012055; 9 Jul 86 3:46 EDT
From: AAAARRRRGGGGv <argv@SRI-SPAM.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Precedent for use of =
Message-ID: <6056@sri-spam.ARPA>
Date: 9 Jul 86 02:03:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <499@cbmvax.cbmvax.cbm.UUCP> daveh@cbmvax.cbm.UUCP (Dave Haynie)
 writes:
>>   if (i = 0) {
>>     /* do something */
>>   }
>>   else {
>>     /* do something else */
>>   }
>>
>> is legal C and usually  /* does something else */   than you expected  :-)
>
>As long as you're writing in C, and you REALLY know the language, the above
>construct would be ridiculous.
     
I disagree and I believe you do, too. If you really look for this
construct, it is quite common in C, altho good programmers comment
that they know what they're doing here... for example, my favorite:
     
main(argc, argv)
char **argv;
{
    char *prog_name, *rindex();
     
    if (prog_name = rindex(*argv, '/'))  /* find last '/' in argv[0] */
    prog_name++; /* set prog_name to string following last '/' */
    else prog_name = *argv; /* program was exec-ed from same dir or in PATH */
    /* etc... */
}
     
This sort of thing is also quite common when using other string(3) routines
or basically anything which returns char *
I like that much better than doing the same thing via:
     
    prog_name = rindex(*argv, '/');
    if (!prog_name)
    prog_name = *argv;
    else prog_name++;
     
I don't like this method as well simply because there are more statements
than needed and the previous version isn't that cluttered. Since the
nature of this discussion is the use (or misuse) of the = operator, I
would say that C was designed more robustly simply because you can do
the above whereas PASCAL won't let you. C gives you the choice of doing
it if you prefer to and to do it the other way if you really want to (or
don't know better).
     
>I think that most of the folks that are
>unhappy with the way that C handles = and == are frustrated Pascal hackers
>who can't quite adjust to the power and terseness of C.  Maybe if they'd
>spend a few extra hours LEARNING C instead of trying to write Pascal in C,
>they'd be much better off. [etc..]
     
I quite agree.  When I used to work at my school helping students, I found
that the students who complained about C were those who just wanted to take
the course to get out of the requirement (elective general ed for most).
Other comp sci majors who complained about C (either in favor of PASCAL or
not) were merely pedantic and just wanted their peers to respect them.
I even found that the comp sci faculty that pushed PASCAL knew little about
C.  Although all of the faculty (whether they kenw C or not) agreed that
PASCAL was the correct language to learn for freshmen (I am undecided about
this), most of them agreed that it was too limiting for the upper-division
courses which concentrated on more important issues.
     
dan (argv@sri-spam.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3928
          for JMS@ARIZMIS; Wed,  9-JUL-1986 01:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 03:45:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028089; 9 Jul 86 4:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011897; 9 Jul 86 3:41 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Precedent for use of =
Message-ID: <499@cbmvax.cbmvax.cbm.UUCP>
Date: 8 Jul 86 15:04:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Personally, I still prefer := for assignment and = for equality over =
> and ==.  I also think that the keystroke argument is ridiculous (flames
> to /dev/null).  The problem with = and == is further aggravated by the
> fact that in C an assignment is an expression and not a statement, so
> that code like
>
>   if (i = 0) {
>     /* do something */
>   }
>   else {
>     /* do something else */
>   }
>
> is legal C and usually  /* does something else */   than you expected  :-)
     
As long as you're writing in C, and you REALLY know the language, the above
construct would be ridiculous.  I think that most of the folks that are
unhappy with the way that C handles = and == are frustrated Pascal hackers
who can't quite adjust to the power and terseness of C.  Maybe if they'd
spend a few extra hours LEARNING C instead of trying to write Pascal in C,
they'd be much better off.  I've had no trouble switching to := and = for
Pascal and M2, = and .EQ. for Fortran, = and = for BASIC, = and EQ() for
SNOBOL, MAKE and = for LOGO, (LET ), (SET ), (SETQ ) and (EQ ), (EQUAL )
in LISP, or even MOVE and CMP in Assembler.  My point is instead of
tripping over the language syntax and screaming how it should be changed,
one can learn the language and then not have to worry about tripping over
it.  And then you might even start to realize why a particular method has
its advantages.
     
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
   A quote usually goes here, but its currently being rennovated.
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6243
          for JMS@ARIZMIS; Wed,  9-JUL-1986 08:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 09:34:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005836; 9 Jul 86 10:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019945; 9 Jul 86 9:52 EDT
From: hansen%mips.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: variable # of args portability?
Message-ID: <551@mips.UUCP>
Date: 9 Jul 86 03:15:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I want to be able to write a function that will take an unknown number
> of arguments and then call another such function with these arguments,
> namely something like printf() that calls _doprnt() without processing
> its arguments at all.  I know there is no way to write this code portably,
> but is it reasonable to assume that I will be able to do it at all in
> most common implementations of C?  Also, how safe is it to assume that there
> will be something like _doprnt() available?  I know it's not good to depend on
> things like this, but I don't want to have to write my own printf()...
>
>     Wayne
     
System V defines functions named vprintf, vfprintf, and vsprintf,
that combined with the macros defined in varargs.h, provide a
reasonably portable interface to _doprnt.  The first two
functions are trivial to implement on a machine that has _doprnt,
the third is a little tricker, since you must trick the stdio package
into outputting into a string, and the necessary flag setting
is rather unportable (which is why the v...printf functions should
be defined in the system-provided library).
     
Using varargs.h goes a long way toward making such functions portable.
     
--
     
Craig Hansen            |     "Evahthun' tastes
MIPS Computer Systems        |     bettah when it
...decwrl!mips!hansen        |     sits on a RISC"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6271
          for JMS@ARIZMIS; Wed,  9-JUL-1986 08:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 09:34:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005765; 9 Jul 86 10:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019779; 9 Jul 86 9:48 EDT
From: mwm@eris.ucb-vax.ARPA
Newsgroups: net.micro.amiga,net.lang.c
Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only
Message-ID: <951@jade.BERKELEY.EDU>
Date: 8 Jul 86 19:26:25 GMT
Sender: usenet@jade.ucb-vax.ARPA
Followup-To: net.lang.c
To:       info-c@BRL-SMOKE.ARPA
     
In article <1385@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
>    It never fails to amaze me just how many people do this:
>        if (foo == NULL) { ... }
>    or:
>        if (foo == 0) { ... }
[instead of...]
>        if (!foo) { ... }
     
Well, I wrote it the way you think people ought to for 8 years before
changing to coding the test explicitly. I changed because the (!foo)
notation is less readable than the (foo == 0) notation.
     
Also, if foo is a pointer type, the test (!foo) is wrong. NULL doesn't
have to be zero.
     
>    The reason the compiler is exhibiting the behavior you describe is
>because you told it to.  You are asking the compiler to compare an unsigned
>byte to the literal value of NULL.
     
Uh, what he got was:
     
>>causes var to be first loaded, extended to a word, extended to a long, then
>>compared against 0, EVEN when var is declared as a UBYTE...
     
What's the second extend doing in there? Anything claiming to be a
reasonable compiler should generate ONE extend. Anything claiming to
be not bad (much less good) should realize what's going on, and
generate the CMP.B instruction. Of course, a good compiler will check
to see if the Z condition code is set correctly already (from a move
to/from var, or the evaluation into var), and just generate the
branch. If it's slightly intelligent, it'll be willing to re-arrange
code to make that pre-condition happen.
     
>    If you *really* care about optimized code, compile to an assembly
>source file and bang on it yourself.  That's something Lettuce *definitely*
>won't let you do.
     
Well, I'd rather get the source to the compiler and bang on that so it
generates good code (that way I only have to do it once). But I expect
the compiler to at least generate non-abysmal code.
     
>>Oh, well... I guess someone will make a good 'C' compiler someday...
     
DEC has one for VMS. Convex has one for their box (though it may not
be released yet). Anybody know of any others?
     
    <mike

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6854
          for JMS@ARIZMIS; Wed,  9-JUL-1986 08:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 10:35:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008303; 9 Jul 86 11:17 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a023036; 9 Jul 86 11:04 EDT
Received: from (MAILER)TCSVM.BITNET by WISCVM.ARPA on 07/09/86 at
  10:05:39 CDT
Received: by TCSVM (Mailer X1.22) id 3194; Wed, 09 Jul 86 09:35:53 CVT
Date:         Wed, 9 Jul 1986 08:51:37 CVT
From:           Dan Smith <SYSBDES%TCSVM.BITNET@wiscvm.ARPA>
Subject:      Re: Re: Precedent for use of =
To:  INFO-C@BRL-SMOKE.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
     
     I've watched this discussion now for quite a while and finally cann't
stand it anymore.   I agree with Dave Haynie when he says that most people
who seem to have a problem with '=' are frustrated pascal programmers.  We
should start up some new discussions about C syntax or usage/and/or various
implimentations of C by companies.  I've done fortrash/assembler/pascal/c
in my checkered past and have found C's syntax to be quite clear (after you
read K&R)  Save us all from the 'Structure' freaks out there that cann't
do anything if they don't have a symbol or box to fit the construct.  My
main rule of programming which I always try to follow is "NEVER WRITE A
ROUTINE LARGER THAN ONE SCREEN"  Maybe its just me, but this works for me
and produces clean code which others can understand and work on.
     
    Enough of the soap box.  I'll prob' get a ton of flames for that but
my finger is getting tired of discarding mail about swap macros and '='
vs ':='.   Now lets get on to some new topics such as why several large
software houses have modified the syntax of pointer math on Intel 86
series machines to the point that it no longer fits standard C.  Most of
the C compilers which generate 'BIG' model executibles seem to have a
real problem with pointers.  Lattice put in code which converts to/from
a 'intel' pointer to a 'abstract' pointer to allow math to work OK but
at a performance cost.  Computer Innovations (at least at v2.3) use
'intel' style pointers only for the BIG model.  And pointer math takes on
a whole new outlook on life.  I've found that neither of these designs
works very well.  I've looked at the code generated by Lattice and its
QUITE offensive, it calls a subroutine for every instance of pointer
math to convert the internal pointer into a 'absolute' pointer then
converts it back.  Gross..  It would have been better to emit the code
inline and save a ton of overhead.  I tried my hand at it and came up
with about a 5 instruction convert in each direction which almost beats
the memory overhead of a arguement setup/call/arguement cleanup.  It
definitly beats it as far as speed.  These comments pertain to a Lattice
version about 8 months old and might be fixed now.
     
    I know my comments don't really fit the 'Info C' digest I guess it
should be in Info C Compiler Implimentations but I had to try and change
the course of current discussion.  I couldn't stand it anymore.  I guess
I'll have to put my flame proof shorts on now..  Oh vell...
     
"Std Disclaimer -- This stuff is the result of my own burnt out mind and
NOBODY elses"
     
Dan Smith (aka MadMan)
BITNET:     SYSBDES@TCSVM
ARPA:       SYSBDES%TCSVM.BITNET@WISCVM.WISC.EDU
UUCP:       ...psuvax1!tcsvm.bitnet!sysbdes
            real soon now !tu-pul!ludwig!ds
Ma Bell:    (504) 865-5631
Real Paper: Tulane University
            Tulane Computer Services
            Attn: Dan Smith, Systems Group
            6823 St. Charles Ave.
            New Orleans,  LA 70118-5698

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7180
          for JMS@ARIZMIS; Wed,  9-JUL-1986 09:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 11:07:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009251; 9 Jul 86 11:52 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa24248; 9 Jul 86 11:41 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a009105; 9 Jul 86 11:40 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA04897; Wed, 9 Jul 86 11:36:14 edt
Date: Wed, 9 Jul 86 11:36:14 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607091536.AA04897@icst-cmr.ARPA>
To: sam@ZARATHUSTRA.ARPA
Subject: Register Addresses
Cc: info-c@BRL.ARPA
     
Sam Kendall of Thinking Machines writes:
    In article <2036@brl-smoke.ARPA> you write:
    >I have said all along that there is no reason why a compiler can't
    >perform the following transformation:
    >
    >        LEGAL                DESIRED
    >    foo()                foo()
    >    {    register int j;        {    register int j;
    >        auto     int k;
    >        k = j;
    >        bar(&k);            bar(&j);
    >        j = k;
    >    }                }
    >
    >Sort of a Call by Value-Result, eh?
     
    You mean that the compiler should transform the users's code on the
    right into the code on the left, I assume.
     
Yes.
    How would you handle this:
     
        f(){
            register int j;
     
            j = 0;
            bar(&j);
            j = 1;
            if (*static_p == j)    /* this test wil fail */
                ...
        }
     
        int *static_p;
     
        bar(p)  int *p;
        {
            static_p = p;
        }
     
    Of course, your transformation would work in most cases, but for the
    compiler to verify that would take some pretty sophisticated global
    analysis.  A compiler that could actually do such global analysis could
    convert the register variable to non-register auto when it can't verify
    your transformation is okay.
     
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.
     
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.
     
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.
     
You pays your money and you takes your choice.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    I'm dressing up in an ill-fitting IVY-LEAGUE SUIT!! Too late...
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7996
          for JMS@ARIZMIS; Wed,  9-JUL-1986 10:45 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 12:23:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011672; 9 Jul 86 13:15 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a026542; 9 Jul 86 13:05 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a011226; 9 Jul 86 13:03 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA05191; Wed, 9 Jul 86 12:59:29 edt
Date: Wed, 9 Jul 86 12:59:29 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607091659.AA05191@icst-cmr.ARPA>
To: sam@ZARATHUSTRA.ARPA
Subject: Re:  Register Addresses
Cc: info-c@BRL.ARPA
     
> 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        <rbj@icst-cmr.arpa>
    I just forgot my whole philosophy of life!!!
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8568
          for JMS@ARIZMIS; Wed,  9-JUL-1986 11:04 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 12:52:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012835; 9 Jul 86 13:42 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a027091; 9 Jul 86 13:29 EDT
To: mwm%eris.berkeley.edu@BBN-LABS-B.ARPA
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only
In-reply-to: Your message of 8 Jul 86 19:26:25 GMT.
         <951@jade.BERKELEY.EDU>
Date: 09 Jul 86 13:32:13 EDT (Wed)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     One point about your posting:
     
     You mention that the compiler should generate only one extend
instruction.  The MC68000 does not have an instruction to extend from
byte to long - you have to extend byte to word, then extend word to
long.  Of course, it's much better if it just generates TST.B (if
comparing against zero), or, as you pointed out, uses the condition
codes set from the MOV.B instruction which loaded the value in the
first place.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3220
          for JMS@ARIZMIS; Wed,  9-JUL-1986 18:37 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019149; 9 Jul 86 18:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002202; 9 Jul 86 17:42 EDT
From: Jean Marie Diaz <ambar@mit-eddie.ARPA>
Newsgroups: net.lang.c
Subject: Re:  swap() macro (LISP & Algol)
Message-ID: <2498@mit-eddie.MIT.EDU>
Date: 9 Jul 86 12:25:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1321@psivax.UUCP> friesen@psivax.UUCP (Stanley Friesen) writes:
>In article <1946@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>>
>>  I haven't seen call-by-name included in any language since Algol.
>
>    What about LISP? Or is LISP older than Algol?
     
LISP and Pascal are both descendants of Algol 60.
--
     
                    AMBAR
        "I need something to change your mind...."

Received: From BITNIC(MAILER) by ARIZMIS with RSCS id 7127
          for JMS@ARIZMIS; Wed,  9-JUL-1986 18:37 MST
Received: by BITNIC (Mailer X1.23) id 7039; Wed, 09 Jul 86 20:03:00 EDT
Received: (from MAILER@UCHIMVS1 for MAILER@UCHIMVS1 via NJE)
Comment:      (BITMAIL-1732; 18 LINES); Wed, 09 Jul 86 18:02:59 CDT
Date: Wed 9 Jul 86 18:00:05-CDT
Sender:        List Processor<LISTSERV@BITNIC>
Reply-to:     Distribution List <LIAISON@BITNIC>
X-From: Don Goldhamer <STAFF.DHG@CHIP.UChicago>
From:         STAFF.DHG@CHIP.UCHICAGO
Subject: C compilers on MVS
To:           JOEL M SNYDER <JMS@ARIZMIS> (Distribution: LIAISON)
     
Have other Universities had experience (good or bad) with any of the
"C" language compilers available to run under the MVS operating
system?  We are looking at the Lattice compiler (distributed by SAS),
the Waterloo compiler, and an AT&T compiler -- but would like to know
of any others.
     
In particular, we'd like to know about the run-time libraries and such
-- how adequate and reliable they are, ....
     
  Thanks -- Don Goldhamer  STAFF.DHG@UCHICAGO or XASDHGO@UCHIMVS1
    U of Chicago Computation Center
-------
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3168
          for JMS@ARIZMIS; Wed,  9-JUL-1986 18:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/09/86 at 19:17:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019139; 9 Jul 86 18:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002186; 9 Jul 86 17:41 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Re: Precedent for use of =
Message-ID: <502@cbmvax.cbmvax.cbm.UUCP>
Date: 9 Jul 86 18:24:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
> In article <499@cbmvax.cbmvax.cbm.UUCP> daveh@cbmvax.cbm.UUCP (Dave Haynie)
 writes:
>>>   if (i = 0) {
>>>     /* do something */
>>>   }
>>>   else {
>>>     /* do something else */
>>>   }
>>>
>>> is legal C and usually  /* does something else */   than you expected  :-)
>>
>>As long as you're writing in C, and you REALLY know the language, the above
>>construct would be ridiculous.
>
> I disagree and I believe you do, too. If you really look for this
> construct, it is quite common in C, altho good programmers comment
> that they know what they're doing here... for example, my favorite:
>
> main(argc, argv)
> char **argv;
> {
>     char *prog_name, *rindex();
>
>     if (prog_name = rindex(*argv, '/'))  /* find last '/' in argv[0] */
>     prog_name++; /* set prog_name to string following last '/' */
>     else prog_name = *argv; /* program was exec-ed from same dir or in PATH */
>     /* etc... */
> }
>
> This sort of thing is also quite common when using other string(3) routines
> or basically anything which returns char *
> I like that much better than doing the same thing via:
>
>     prog_name = rindex(*argv, '/');
>     if (!prog_name)
>     prog_name = *argv;
>     else prog_name++;
>
> I don't like this method as well simply because there are more statements
> than needed and the previous version isn't that cluttered. Since the
> nature of this discussion is the use (or misuse) of the = operator, I
> would say that C was designed more robustly simply because you can do
> the above whereas PASCAL won't let you. C gives you the choice of doing
> it if you prefer to and to do it the other way if you really want to (or
> don't know better).
>
     
Whoa, there!  I think we're in agreement here, believe it or not.  I've
commented before on the great advantages of the assignment OPERATOR in C,
which is what you've shown.  The case initially presented above is the
trivial case, which is ridiculous, since the /* do something */ clause will
never be executed.  The example that you show is good C, I use that style
all of the time, and a good compiler will produce code for it that's more
efficient than in the second example.  There's no confusion in the if ()
clause of your first example, since it would be silly to expect an
equality test there, with prog_name being an uninitialized variable (in
fact, the Lattice C compiler I use on the Amiga would generate an
"uninitialized auto variable" warning if I used an == operator there
instead of the assignment operator.
     
>>I think that most of the folks that are
>>unhappy with the way that C handles = and == are frustrated Pascal hackers
>>who can't quite adjust to the power and terseness of C.  Maybe if they'd
>>spend a few extra hours LEARNING C instead of trying to write Pascal in C,
>>they'd be much better off. [etc..]
>
> I quite agree.  When I used to work at my school helping students, I found
> that the students who complained about C were those who just wanted to take
> the course to get out of the requirement (elective general ed for most).
> Other comp sci majors who complained about C (either in favor of PASCAL or
> not) were merely pedantic and just wanted their peers to respect them.
> I even found that the comp sci faculty that pushed PASCAL knew little about
> C.  Although all of the faculty (whether they kenw C or not) agreed that
> PASCAL was the correct language to learn for freshmen (I am undecided about
> this), most of them agreed that it was too limiting for the upper-division
> courses which concentrated on more important issues.
>
> dan (argv@sri-spam.arpa)
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
    "I don't feel safe in this world no more,
     I don't want to die in a nuclear war,
     I want to sail away to a distant shore
     And live like an ape man."
                -The Kinks
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7039
          for JMS@ARIZMIS; Wed,  9-JUL-1986 23:45 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/10/86 at 01:34:50 CDT
Received: from WASHINGTON.ARPA by SRI-KL.ARPA with TCP; Tue 8 Jul 86
  12:40:17-PDT
Date: Tue 8 Jul 86 12:37:17-PDT
From: Joe Kelsey <Joe@WASHINGTON.ARPA>
Subject: Re: Potential C problem
To: LEICHTER-JERRY@YALE.ARPA
cc: carl@CITHEX.CALTECH.EDU, info-vax@SRI-KL.ARPA, Joe@WASHINGTON.ARPA
In-Reply-To: Message from "<LEICHTER-JERRY@YALE.ARPA>" of Mon 7 Jul 86
  11:35:05-PDT
Message-ID: <12221105455.17.JOE@WASHINGTON.ARPA>
     
Starting with VAX C V2.2-015, the CRTL is not shipped with compiler
updates.  This means that installing version 2.2 will not fix any
outstanding runtime library bugs.  These bugs are fixed in VMS releases.
     
To answer another question, VMS V4.4 does fix the sscanf problem in the
C runtime library.  This fix is totally independint of whether you
are running version 2.1 or 2.2 of VAX C (assuming that you don't try
to reinstall version 2.1 after upgrading to VMS 4.4.....)
     
/Joe
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8456
          for JMS@ARIZMIS; Thu, 10-JUL-1986 01:33 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/10/86 at 03:25:07 CDT
Received: from ngp.UTEXAS.EDU by SRI-KL.ARPA with TCP; Tue 8 Jul 86 07:35:00-PDT
Date: Tue, 8 Jul 86 09:32:44 cdt
From: mike@ngp.UTEXAS.EDU (wes birdwell)
Posted-Date: Tue, 8 Jul 86 09:32:44 cdt
Message-Id: <8607081432.AA10312@ngp.UTEXAS.EDU>
Received: by ngp.UTEXAS.EDU (4.22/4.22)
    id AA10312; Tue, 8 Jul 86 09:32:44 cdt
Subject: VAX C .OLB Files missing in MicroVMS 4.4
Newsgroups: mod.computers.vax
To: info-vax@sri-kl.ARPA
     
Recently I installed MicroVMS 4.4 and VAX C 2.2 on our MicroVAX II.
I retained the definitions for LNK$LIBRARY and LNK$LIBRARY_1, etc, so
that the linker could find any unresolved function references in the
VAX C object libraries.  According to the installation guide for VAX C
these object libraries are new shipped with VMS, not VAX C.  However
the object libraries weren't on my system after the 4.4 installation.
I then searched all of the save sets on the release tape and they weren't
there either.  Then I called DEC and inquired about this and they didn't
really commit and say that the files were supposed to be there, only
that we could link our programs with the shareable images.  I am familiar
with the advantages of doing this but what, if any, are the tradeoffs?
Is there any reason that I absolutely need these object libraries?
Has anyone else had a similar response from DEC?  Any any information
will be much appreciated.
     
Mike O'Donnell @ LCRA
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8578
          for JMS@ARIZMIS; Thu, 10-JUL-1986 02:01 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/10/86 at 03:30:19 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Tue 8 Jul 86
  07:56:48-PDT
Received: from pitt by csnet-relay.csnet id af19926; 8 Jul 86 9:54 EDT
Received: by pitt (4.12/4.7)
    id AA06742; Mon, 7 Jul 86 22:02:03 edt
Received: by cisunx (4.12/4.7)
    id AA18409; Mon, 7 Jul 86 13:21:25 edt
Date: Mon, 7 Jul 86 13:21:25 edt
From: elliot m <cisunx!gu044150%pitt@CSNET-RELAY.ARPA>
Message-Id: <8607071721.AA18409@cisunx>
Newsgroups: mod.computers.vax
Subject: Re: VAX C problem (?)
Summary:
Expires:
References: <8607031156.AA07330@ucbvax.Berkeley.EDU>
Sender:
Reply-To: Mike Elliot <gu044150%cisunx.uucp@CSNET-RELAY.ARPA>
Followup-To:
Distribution:
Organization: Univ. of Pittsburgh, Comp & Info Sys
Keywords:
Apparently-To: pitt!info-vax@sri-kl.arpa
     
In article <8607031156.AA07330@ucbvax.Berkeley.EDU> MHICKEY@UDCVM.BITNET writes:
>
>    We recently got VAX-C ver 2.2 and I've been busy porting programs
>from UNIX/DOS.  When I was working with the CURSES package, I found that
>getch() wasn't breaking on a character.  Instead, it would block until
>a RETURN was hit.  I then tried the getchar() function in the standard
>library and, lo and behold, it reacted the same way.
>
     
    I haven't worked with curses that much but it seems to me that even
when you do curses on UNIX you have to throw your terminal into cbreak
mode to get a character without hitting a <RET>. I believe the curses
routine which does this is CRMODE. Unfortunately VMS ignores the CRMODE
routine because VMS doesn't have a cbreak mode.
     
    The only way I have been able to get around this is to use the SMG
routines.
     
                Mike
     
                cadre!pitt!cisunx!gu044150
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8720
          for JMS@ARIZMIS; Thu, 10-JUL-1986 02:02 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/10/86 at 03:37:06 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Tue 8 Jul 86
  07:57:05-PDT
Received: from pitt by csnet-relay.csnet id ag19926; 8 Jul 86 9:55 EDT
Received: by pitt (4.12/4.7)
    id AA06769; Mon, 7 Jul 86 22:02:35 edt
Received: by cisunx (4.12/4.7)
    id AA20095; Mon, 7 Jul 86 13:40:30 edt
Date: Mon, 7 Jul 86 13:40:30 edt
From: elliot m <cisunx!gu044150%pitt@CSNET-RELAY.ARPA>
Message-Id: <8607071740.AA20095@cisunx>
Newsgroups: mod.computers.vax
Subject: Re: (none)
Summary:
Expires:
References: <8607020217.AA10512@ucbvax.Berkeley.EDU>
Sender:
Reply-To: Mike Elliot <gu044150%cisunx.uucp@CSNET-RELAY.ARPA>
Followup-To:
Distribution:
Organization: Univ. of Pittsburgh, Comp & Info Sys
Keywords:
Apparently-To: pitt!info-vax@sri-kl.arpa
     
In article <8607020217.AA10512@ucbvax.Berkeley.EDU> terry@BRL.ARPA writes:
>
>    I actually had to program in FORTRAN (heaven forbid) on VMS and
>had to do the equivalent of a Unix sleep() call.  Sounds reasonable
>right?  Hah!  After spending 3-4 hours wading through the VMS manuals I
>discover that I have to do a "scheduled wakeup" for my process and then
>a "hibernate".  Of course there are optional arguments to both calls
>which I have to decipher.  In addition, I have to call a special routine
>to generate the correct arguement to the wakeup call.  Now, I realize
>that this is somewhat similiar to the internals of the Unix sleep()
>function, but isn't it nicely packaged?
     
Try LIB$WAIT it behaves the same way that sleep does on UNIX.
     
>program pauses for the required number of seconds.  Obviously not
>everything is conceptually this easy, but when it is why make it so
>hard to do?  Unix has been termed User unfriendly (with some reason),
>but I think a point can be made for VMS being programmer unfriendly.
     
Sorry pal, but UNIX never was and never will be a friendly evironment.
It is designed to be a good programming environment and it is just that.
Unfortunately or fortunately UNIX is only good if you are programming in
C, PASCAL, or LISP. It has the world's worst FORTRAN compiler I have ever
seen.
     
This is not to say that I love VMS and hat UNIX. I enjoy programming on both
of them depending on what my needs are at a particular time. Generally I use
UNIX if I want to get into some serious programming or VMS if I want to do
some business related stuff.
     
     
                Mike Elliot
                cadre!pitt!cisunx!guo44150
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9466
          for JMS@ARIZMIS; Thu, 10-JUL-1986 03:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 05:02:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023036; 10 Jul 86 5:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008236; 10 Jul 86 4:59 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: Register Addresses
Message-ID: <2061@brl-smoke.ARPA>
Date: 10 Jul 86 08:58:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2051@brl-smoke.ARPA> Root Boy Jim <rbj@icst-cmr.ARPA> writes:
>But Wait! That's a Mimic! Register variables are really fast auto
>variables, so after `f' returns, your static_p is worthless anyhow.
     
But the objection is still valid.  If the compiler were to fake up
some addressable storage for a copy of a register variable, then
afterward it would need to ensure that the contents of that location
track the contents of the register, since the pointer could then be
legitimately used to refer to the data in the register.  This would
negate the whole point of "register".
     
Dennis knew what he was doing.  The restriction of & applied to a
register variable is deliberate and sensible.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0042
          for JMS@ARIZMIS; Thu, 10-JUL-1986 04:37 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/10/86 at 06:29:16 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Wed 9 Jul 86
  06:44:06-PDT
Received: from waterloo by csnet-relay.csnet id ab01174; 9 Jul 86 9:37 EDT
Received: by watmath; Wed, 9 Jul 86 09:25:09 edt
Date: Wed, 9 Jul 86 09:25:09 edt
From: Eric Gisin <egisin%watmath.waterloo.edu@CSNET-RELAY.ARPA>
Subject: Re: VAX C .OLB Files missing in MicroVMS 4.4
Newsgroups: mod.computers.vax
To: info-vax@SRI-KL.ARPA
References: <8607081432.AA10312@ngp.UTEXAS.EDU>
     
> Recently I installed MicroVMS 4.4 and VAX C 2.2 on our MicroVAX II.
> I retained the definitions for LNK$LIBRARY and LNK$LIBRARY_1, etc, so
> that the linker could find any unresolved function references in the
> VAX C object libraries.  According to the installation guide for VAX C
> these object libraries are new shipped with VMS, not VAX C.  However
> Mike O'Donnell @ LCRA
     
The LNK$LIBRARY names refer to object libraries (.OLB files).
What is distributed with VMS are the sharable image librarys,
SYS$LIBRARY:VAXCRTL.EXE and VAXCRTLG.EXE.  I don't know what you get with micro
 VMS,
but I think the C installation can build the sharable images from the object
 libraries.
     
You can link with either the C object libraries or a C sharable image library.
The latter results in much faster LINKing and smaller image files
(by about 60 blocks). A typical link with the sharable library follows:
$ Link test,sys$input:/opt
sys$library:vaxcrtl/share
     
Does anyone know of any reason to use the C object libraries over
the C sharable library? The C installation says you don't need the
sharable libraries and can therefor save space, but on the other
hand you can delete the object libraries and save just as much space.
(I'm not recommending that anyone actually delete sys$library:vaxc*.olb).
     
    Eric Gisin, egisin@waterloo.{csnet|edu}
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1587
          for JMS@ARIZMIS; Thu, 10-JUL-1986 07:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 09:31:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000305; 10 Jul 86 10:25 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a013162; 10 Jul 86 9:38 EDT
Received: from bbn-labs-b.arpa by AOS.BRL.ARPA id a028417; 10 Jul 86 9:37 EDT
To: info-c@BRL.ARPA
Subject: What a "good" compiler generates.
Date: 10 Jul 86 09:36:25 EDT (Thu)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
In article <502@cbmvax.cbmvax.cbm.UUCP> daveh@cbmvax.cbm.uucp (Dave Haynie)
writes:
> > main(argc, argv)
> > char **argv;
> > {
> >     char *prog_name, *rindex();
> >
> >     if (prog_name = rindex(*argv, '/'))  /* find last '/' in argv[0] */
> >     prog_name++; /* set prog_name to string following last '/' */
> >     else prog_name = *argv; /* program was exec-ed from same dir or in PATH
 */
> >     /* etc... */
> > }
> >
> [ ... ]
> >
> >     prog_name = rindex(*argv, '/');
> >     if (!prog_name)
> >     prog_name = *argv;
> >     else prog_name++;
> >
>
> [ ... ].  The example that you show is good C, I use that style
> all of the time, and a good compiler will produce code for it that's more
> efficient than in the second example.  [ ... ]
     
Wrong.  A bad compiler will produce code for the first example that's more
efficient than in the second example.  A *good* compiler will produce the same
code for both.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2191
          for JMS@ARIZMIS; Thu, 10-JUL-1986 08:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 10:27:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001520; 10 Jul 86 11:11 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a016070; 10 Jul 86 10:53 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA00735; Thu, 10 Jul 86 10:53:03 edt
Date: Thu, 10 Jul 86 10:53:03 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607101453.AA00735@icst-cmr.ARPA>
To: gwyn@BRL-SMOKE.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: Register Addresses
     
RBJ->    >But Wait! That's a Mimic! Register variables are really fast auto
    >variables, so after `f' returns, your static_p is worthless anyhow.
     
Gwyn->    But the objection is still valid.  If the compiler were to fake up
    some addressable storage for a copy of a register variable, then
    afterward it would need to ensure that the contents of that location
    track the contents of the register, since the pointer could then be
    legitimately used to refer to the data in the register.  This would
    negate the whole point of "register".
     
Would it? Okay, so we have to pushmi-pullyu the register anytime we
call any function, or reference any global variable starwise, or
perhaps reference  either the result of the function or even any
arguments originally passed by reference.
     
This is starting to get compilicated! Anyone for a 500k C Compiler?
     
It would probably still be smaller and faster than ADA :-)
     
    Dennis knew what he was doing.  The restriction of & applied to a
    register variable is deliberate and sensible.
     
I agree. I was merely speculating on the tradeoff's involved.
     
So when are they going to start making droids with addressable registers again?
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    He is the MELBA-BEING...the ANGEL CAKE...XEROX him...XEROX him --
     

Received: From BITNIC(MAILER) by ARIZMIS with RSCS id 9668
          for JMS@ARIZMIS; Thu, 10-JUL-1986 09:26 MST
Received: by BITNIC (Mailer X1.23) id 9565; Thu, 10 Jul 86 12:21:06 EDT
Received: from CUVMA(MAILER) by BITNIC (Mailer X1.23) id 9344;
Comment:      Thu, 10 Jul 86 12:18:55 EDT
Received: by CUVMA (Mailer X1.23a) id 8223; Thu, 10 Jul 86 12:20:32 EDT
Date: Thu, 10 Jul 86  12:20 EDT
Sender:       (EACUS@CUVMA) via List Processor <LISTSERV@BITNIC>
Reply-to:     Distribution List <LIAISON@BITNIC>
X-From: EACUS@CUVMA (Alan Crosswell)
From:         EACUS@CUVMA
To:           JOEL M SNYDER <JMS@ARIZMIS> (Distribution: LIAISON)
Subject: Re: C compilers on MVS; STAFF.DHG@CHIP.UCHICAGO
In-Reply-To: Your memo of Wed 9 Jul 86 18:00:05-CDT
     
Forget AT&T's.  It is a dog.  We are happy with Waterloo's under CMS
but have no MVS experience.  Also haven't seen SAS's.
/a
------

Received: From BITNIC(MAILER) by ARIZMIS with RSCS id 3632
          for JMS@ARIZMIS; Thu, 10-JUL-1986 12:51 MST
Received: by BITNIC (Mailer X1.23) id 3527; Thu, 10 Jul 86 15:48:16 EDT
Received: from RICE(MAILER) by BITNIC (Mailer X1.23) id 3338;
Comment:      Thu, 10 Jul 86 15:45:37 EDT
Received: by RICE (Mailer X1.23) id 2417; Thu, 10 Jul 86 14:43:41 CDT
Date:         Thu, 10 Jul 1986 14:23 CDT
Sender:       (NAMAN@RICE) via List Processor <LISTSERV@BITNIC>
Reply-to:     Distribution List <LIAISON@BITNIC>
X-From:         John L. Naman <NAMAN@RICE>
From:         NAMAN@RICE
Subject:      Re: C compilers on MVS
To:           JOEL M SNYDER <JMS@ARIZMIS> (Distribution: LIAISON)
In-Reply-To:  Your message of Wed 9 Jul 86 18:00:05-CDT
     
Don: We have had SAS-LC370 up on both CMS and TSO for a couple of months
and our preliminary use has shown nothing bad and the library appears to
be both adeqaute and reliable. The SAS documentation is VERY GOOD and is
very helpful (particularly in the "matrix" references to various books
and other C's).
     
The LC370 Portability was a very important selling point at Rice and it
has lived up to the claim. We have ported Lattice code to/from PC/XT's,
CMS, and MVS/TSO with NO problems. IF PC users stick to Lattice Portable
functions, there does not seem to be any problems porting source around
(remember to watch out for ASCII vs EBCDIC "assumptions"). All Rice
system and utility code is now being written and debuged on a PC/XT and
final tested and run on the mainframe. Students are being encouraged to
do the same.
     
Lastly, we are impressed by SAS's work toward designing the product for
true systems programming (sans library). We expect more goodies in this
area over the next year or so (speculation).

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6811
          for JMS@ARIZMIS; Thu, 10-JUL-1986 15:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 17:23:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012109; 10 Jul 86 18:09 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a005601; 10 Jul 86 17:58 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a011925; 10 Jul 86 17:55 EDT
Received: from (LINNDR)VUENGVAX.BITNET by WISCVM.ARPA on 07/10/86 at
  16:53:10 CDT
Date: 10 JUL 86 10:58-CST
From:  LINNDR%VUENGVAX.BITNET@WISCVM.ARPA
To:  INFO-C@BRL.ARPA
Subject: Swap Macro (a long time ago at least)
     
In article <2498@mit-eddie.MIT.EDU> ambar@mit-eddie.ARPA (Jean Marie Diaz)
writes:
>In article <1321@psivax.UUCP> friesen@psivax.UUCP (Stanley Friesen) writes:
>>In article <1946@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes:
>>>
>>>  I haven't seen call-by-name included in any language since Algol.
>>
>>    What about LISP? Or is LISP older than Algol?
>
>LISP and Pascal are both descendants of Algol 60.
>--
     
This is a very curious assertion to make considering that LISP was also
described in 1960. I would be interested in hearing why you think LISP is
an ALGOL derivative. (we may be straying a bit from the topic of this newslist)
     
David Linn
----------------------------------------------------------
ARPANET(?):     LINNDR%VUENGVAX.BITNET@WISCVM.WISC.EDU
BITNET:         LINNDR@VUENGVAX.BITNET
CSNET:          drl@vanderbilt.csnet
Ma Bell:        (615)322-7924
USPS:           P.O. 3241-B Vanderbilt
                Nashville, TN   37235
UUCP:           ...psuvax1!vuengvax.bitnet!linndr

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8320
          for JMS@ARIZMIS; Thu, 10-JUL-1986 17:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 19:17:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013164; 10 Jul 86 20:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007607; 10 Jul 86 19:43 EDT
From: mcdaniel@uicsrd.csrd.uiuc.edu
Newsgroups: net.lang.c
Subject: Re: making it easier to use unions
Message-ID: <19600002@uicsrd>
Date: 7 Jul 86 01:14:00 GMT
Nf-ID: #R:brl-smoke.ARPA:1725:uicsrd:19600002:000:833
Nf-From: uicsrd.CSRD.UIUC.EDU!mcdaniel    Jul  6 20:14:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
C++ permits "anonymous unions" like
    struct {
        union {
            int x;
            char * y;
        };
        int z;
    } zap;
so
    zap.z = zap.x;
is legal.  I don't find it confusing.  [I think that anonymous structs
should likewise be permitted in C++ -- which is outside the scope of C.]
     
In such a case, I would say
    struct {        /* or union if appropriate */
        int x;
        char * y;
    };
    int z;
outside another struct/float would likewise define 3 external
variables named x, y, and z.
     
Anonymous structs could thus be described as only for purposes of
grouping (like parentheses) but do not affect scope; all identifiers
declared therein are "exported" to the next scope out, whatever it may
be.
     
Anonymous unions would be for grouping and for storage overlay.
     
As for C:  probably too late to add anonymity.  Anonymous is a lousy
keyword:  too hard to speel.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8517
          for JMS@ARIZMIS; Thu, 10-JUL-1986 17:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 19:33:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013153; 10 Jul 86 20:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007603; 10 Jul 86 19:43 EDT
From: mcdaniel@uicsrd.csrd.uiuc.edu
Newsgroups: net.lang.c
Subject: Re: Additions to C - range checking
Message-ID: <19600001@uicsrd>
Date: 7 Jul 86 01:01:00 GMT
Nf-ID: #R:ccird1.UUCP:523:uicsrd:19600001:000:1341
Nf-From: uicsrd.CSRD.UIUC.EDU!mcdaniel    Jul  6 20:01:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
/* Written  7:42 pm  Jun 30, 1986 by franka@mmintl.UUCP in uicsrd:net.lang.c */
>In article <523@ccird1.UUCP> rb@ccird1.UUCP (Rex Ballard) writes:
>>Is this impossible to parse?
     
>To my knowledge (I don't know
>everything), only COBOL actually does this.
     
As a comparative language note, ICON does it.  "a < b"  returns "b" if
the comparison succeeds; with left-to-right association of "a < b < c",
it works.
     
The tricky part is that I haven't said what happens if the comparison
is false.  In that case, the expression "fails", and the rest of the
statement is skipped; the next statement is executed.  (Actually, ICON
has PROLOG-like goal-directed evaluation:
    2 < find("a", "ababc")
will fail; find will be "resumed" where it left off to find any later
substrings and the expression will return 3.  It would take kilobytes
to explain fully.)  So this model is not applicable to C, alas.
     
To find the max of two variables in C, we can say
    if (a < b) a = b;
In ICON, the idiom is
    a <:= b
Almost any binary operator can augment assignment, like C's "+=".
This is "a := a < b"; if a >= b, the comparison fails and the rest of
the statement is skipped.
     
I think ICON is a truly great, clean language (for its domain).
     
> I, for one, think it's a good
> idea; but for new languages, please -- don't try and change C to accomodate
> it.
Yeah.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8673
          for JMS@ARIZMIS; Thu, 10-JUL-1986 17:58 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 19:45:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013232; 10 Jul 86 20:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007652; 10 Jul 86 19:45 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <2157@ihlpg.UUCP>
Date: 8 Jul 86 17:52:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
> >Why can't C be like everybody else?  Practically every language uses
> >the equals sign, "=", to test for equality, not as an assignment operator.
> >...
> >              Kernighan and Ritchie, in their infinite wisdom, decide
> >instead to use "=" for assignments and to create a new operator, "==" to
> >test for equality.
> Not only that, they changed "begin" and "end" to { and }, changed "writeln"
> to puts, and all sorts of awful things!  They made it into a WHOLE NEW
> LANGUAGE!!!!!
And ignored rationality for a cutesy orthoganal operator construct which they
screwed up anyway.
     
<< should be less than, >> greater than, == equal, >= greater or equal,
<= less or equal, <>  (or >< ) greater than or less than
     
The problems C has are mostly in human readability.  Of which, the most glaring
is the use of = as assignment and == as comparison.
     
NOTE: I don't recall Algol having a writeln so I don't why you say they
    changed it to puts. :-)
     
    Yes, I know he was claiming comparison to Pascal as reason for objection
    to C.  Pascal has a writeln but it is much more like printf than prints.
     
--j.a.tainter

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8864
          for JMS@ARIZMIS; Thu, 10-JUL-1986 18:01 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 19:56:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013309; 10 Jul 86 20:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007564; 10 Jul 86 19:42 EDT
From: "Donald L. Nash" <dlnash%ut-ngp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: decline of net.lang.c
Message-ID: <3624@ut-ngp.UUCP>
Date: 9 Jul 86 16:51:41 GMT
Keywords: Me too!
To:       info-c@BRL-SMOKE.ARPA
     
In article <119@mruxe.UUCP>, cgw@mruxe.UUCP (C Waldman) writes:
> Well, the time has finally come for me to hit the old 'U' key...
> too bad, this newsgroup used to be more interesting- seems like
> all I ever see anymore are people asking questions that could
> be answered by a quick look at the manual- you call yourselves C
> programmers, and you _still_ dont understand pointers? But the last straw
> when reading the most recent posting on this = versus == versus
> := issue-  MEYER@RADC-TOPS20.ARPA proposes a 'new angle' on the question-
> how many times do tou use each, and how many keystrokes, and wonders what K&R
> would think of that... well, it's on page 17:
>    Since assignment is about twice as frequent as equality testing in C
> programs, it's apporpriate that the operator be half as long.
>
>
>    The question about negative bit-shifts was of the same ilk- the answer
> is in front of your nose, if you just look-
>
>    I just don't have the time to read this group anymore. bye-bye.
     
     
Couldn't have said it better myself.  The only thing I have to add is that
net.lang.c has the lowest return of information for my time invested in
reading it and that it contributes about 10 to 15% of the news I have to
wade through because of the high volume of junk posted to it.  How do you
spell relief?  I spell it "u-n-s-u-b-s-c-r-i-b-e".  Flames to net.lang.c,
since I won't be there to read them anyway.
     
                    Don Nash
     
UUCP:    ...!{ihnp4,allegra,seismo!ut-sally}!ut-ngp!dlnash
APRA:    dlnash@ngp.CC.UTEXAS.EDU
BITNET:  cceu001@utadnx
     
     
        Money for nothing and chicks for free?  WHERE?!?!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9038
          for JMS@ARIZMIS; Thu, 10-JUL-1986 18:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 20:09:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013228; 10 Jul 86 20:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007631; 10 Jul 86 19:44 EDT
From: flaps%utcs.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Yet another ALIGN idea.  (some discussion)
Message-ID: <1986Jul9.021022.12329@utcs.uucp>
Date: 9 Jul 86 06:10:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1038@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
>Say if ajr's suggestion were implemented and /usr/include/align.h contained
>something like
>
>#define ALIGNSIZE 4    /* long int */
>
>Now, given an arbitrary char* pointer, how do we tell if it is aligned?
     
[provides the simple case]
     
>But... what about a machine where alignments are "screwy," for example they
>wanted doubles to be located at some fixed offset, say 2, from addresses which
>are integral multiples of 4 or 8?
     
#define OFFSET 2
#define ISALIGNED(p)((p)%4 == 2)
     
     
or of course in the usual case:
     
#define ALIGNSIZE 4
#define OFFSET 0
#define ISALIGNED(p)((p)%4 == 0)
     
Of course this could be expanded for any other information that a user needed
to know about the alignment.  And since it would all be in an include file, it
would not break any existing programs, and is not truly an addition to the
language.  I think it would be good to put it in the standard.
     
ajr

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9094
          for JMS@ARIZMIS; Thu, 10-JUL-1986 18:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 20:11:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013238; 10 Jul 86 20:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007656; 10 Jul 86 19:45 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2158@ihlpg.UUCP>
Date: 8 Jul 86 17:58:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
> It is too late for C to be like anything else; it is like C.  Besides,
> if it were exactly like (say) Pascal, it would *be* Pascal.  There is
> room for many languages.
> >Practically every language uses the equals sign, "=", to test for
> >equality, not as an assignment operator.
> Perhaps you know more languages than I.  Let me list those whose
> syntax I remember, and count `= for assigment' vs. `= for equality'
> (or both).
>     Assignment        Equality
>     ----------        --------
>                 Algol
>                 APL
>     awk
>                         BASIC (really both)
>     FORTRAN
>                 Icon
>                         Lisp (neither really)
>                 Mesa
>                 Pascal
>     Snobol
> Well, 5 to 3 in favour of `= for equality', though APL and Mesa are
> perhaps special cases: back-arrow is not available for assignment on
> my H19.
ADD:
    Assignment        Equality
    ----------        ---------
                mathematics
                logic
> --
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
> UUCP:    seismo!umcp-cs!chris
> CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
     
--j.a.tainter

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0461
          for JMS@ARIZMIS; Thu, 10-JUL-1986 19:56 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 21:35:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013882; 10 Jul 86 22:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010058; 10 Jul 86 21:43 EDT
From: Guido van Rossum <guido%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: #if foo vs #if defined(foo)
Message-ID: <6994@boring.mcvax.UUCP>
Date: 29 Jun 86 18:06:30 GMT
Posted: Sun Jun 29 18:06:30 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <1063@watmath.UUCP> rbutterworth@watmath.UUCP writes:
>A CPP which silently takes undefined symbols to be 0 can be quite
>dangerous.  [lengthy example deleted]
     
While I agree with your reasoning (the example was quite amazing!), the
ANSI C standard declares that undefined identifiers must be made 0.
Probably too many people have used this feature so they can't break that
existing code :-(
     
Guido van Rossum, CWI, Amsterdam <guido@mcvax.uucp>

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0217
          for JMS@ARIZMIS; Thu, 10-JUL-1986 19:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 21:22:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013742; 10 Jul 86 22:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010079; 10 Jul 86 21:43 EDT
From: Jack Jansen <jack%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: 5<a<50 (was:Additions to C - range checking)
Message-ID: <7000@boring.mcvax.UUCP>
Date: 30 Jun 86 13:21:51 GMT
Posted: Mon Jun 30 13:21:51 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <155@daisy.warwick.UUCP> cudcv@daisy.warwick.ac.uk (Rob McMahon)
 writes:
>In article <523@ccird1.UUCP> rb@ccird1.UUCP (Rex Ballard) writes:
>>
>>if (5<a<50) do_something(a);
>>
>...
>>
>>Is this impossible to parse?
>
>This was in BCPL, and was a GOOD IDEA.
     
Yes, it is nice from a users standpoint, but if you want to define
the semantics of this operator in a reasonable way, it becomes
difficult. The only way out I see is to let expressions have *two*
values: an ordinary one, and a success/failure indication. Then you
can let the value of 'a<b' be 'b', and the operator return 'success'
when a is less than b. I remember seeing something about a language that
had such semantics, can't remember which one, however.
--
    Jack Jansen, jack@mcvax.UUCP
    The shell is my oyster.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0341
          for JMS@ARIZMIS; Thu, 10-JUL-1986 19:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 21:29:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013768; 10 Jul 86 22:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010085; 10 Jul 86 21:43 EDT
From: Lambert Meertens <lambert%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pig C
Message-ID: <7005@boring.mcvax.UUCP>
Date: 4 Jul 86 19:36:55 GMT
Posted: Fri Jul  4 19:36:55 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <249@sdchema.sdchem.UUCP> tps@sdchema.UUCP (Tom Stockfisch) writes:
> In article <6874@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes:
>> ...  If you can read English you can read Pig Latin,
>> but nobody would tolerate documentation written in Pig Latin...
> This is such a great analogy, with Henry's permission I would like to coin
> the term
>
>     Pig C
>
> to refer to C code [...] which effectively redefines the language.
     
I like this.  Also, if someone writes pseudo C code, you could call it
     
       Pigskin C
     
since it's only skin-deep (like, Pigskin Algol).
     
--
     
     Lambert Meertens
     ...!{seismo,okstate,garfield,decvax,philabs}!lambert@mcvax.UUCP
     CWI (Centre for Mathematics and Computer Science), Amsterdam

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9894
          for JMS@ARIZMIS; Thu, 10-JUL-1986 19:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 21:13:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013652; 10 Jul 86 21:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009997; 10 Jul 86 21:41 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Precedent for use of =
Message-ID: <2306@umcp-cs.UUCP>
Date: 9 Jul 86 04:50:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6056@sri-spam.ARPA> argv@sri-spam.UUCP (AAAARRRRGGGGv) writes:
>this construct ... [if (lvalue = rvalue) { ...] is quite common in C,
>altho good programmers comment that they know what they're doing here...
>for example, my favorite:
>
>main(argc, argv)
>char **argv;
>{
>    char *prog_name, *rindex();
>
>    if (prog_name = rindex(*argv, '/'))  /* find last '/' in argv[0] */
>    prog_name++; /* set prog_name to string following last '/' */
>    else prog_name = *argv; /* program was exec-ed from same dir or in PATH */
>    /* etc... */
     
I have come to favour
     
    if ((prog_name = rindex(*argv, '/')) != NULL)
        ...
     
One of these years I will get around to installing Arthur Olson's
lint code that gripes about assignments in conditional contexts.
Adding the `!= 0' is not difficult and demonstrates your `true
intention' quite well.
     
>I would say that C was designed more robustly simply because you can
>do the above [if (v = e)] whereas PASCAL won't let you.
     
I think the proper word here is `orthogonal'.  Actually, I have a
feeling there is an even better word (no not *that* word :-) ), but
I cannot recall it now.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0680
          for JMS@ARIZMIS; Thu, 10-JUL-1986 19:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 21:47:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013925; 10 Jul 86 22:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010072; 10 Jul 86 21:43 EDT
From: Lambert Meertens <lambert%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: RRe: What's so good about FORTH?
Message-ID: <6993@boring.mcvax.UUCP>
Date: 29 Jun 86 01:55:29 GMT
Keywords: FORTH, threaded-code
Posted: Sun Jun 29 01:55:29 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <255@myrias.UUCP> mj@myrias.UUCP (Michal Jaegermann) writes:
     
> The fact that Forth is "threaded" is not a part of a language definition but
> side-effect of the most popular implementation method.  [...]  The method
> is far from beeing unique to Forth and there are some Forth implementations
> which are not exactly "threaded".  [...]  An extreme case is to have the
> whole Forth as a huge 'case' statement in C.  (Yes, I have seen something
> like that :-) ).
     
How else can you implement threading if C is used as the implementation
language?  (Or is that what the smiley is for?)  In other languages the
obvious implementation would be to have each code fragment (for interpreting
a "word") switch to the interpretation of the next word by having it end on
     
    goto *(IC++)
     
(or goto *(++IC), depending on your and your machine's taste).  But labels
are not a C type: you can only goto a constant label, not to a label
expression.  So the closest you can get--as far as I can see--is to have
this huge switch
     
    while (1) switch (*(IC++)) {
    case word1: ...; break;
    case word2: ...; break;
    ...;
    }
     
This is almost as efficient, but not quite: you loose a few cycles in the
jump taken at each break.  Also, you had better make sure that the words
are contiguous numbers so that good code is produced for the switch.
(Instead of break you can use continue.  In the assembler output of cc this
is one jump less, but compiled with -O, at least on our cc, the extra jump
is optimized away anyway and the resultant object files are identical.)
     
Are there other ideas on implementing threading in C?
     
--
     
     Lambert Meertens
     ...!{seismo,okstate,garfield,decvax,philabs}!lambert@mcvax.UUCP
     CWI (Centre for Mathematics and Computer Science), Amsterdam

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1730
          for JMS@ARIZMIS; Thu, 10-JUL-1986 21:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 23:23:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014528; 11 Jul 86 0:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011627; 10 Jul 86 23:40 EDT
From: Paul Higginbottom <higgin%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: anyone know of any good C compilers?
Message-ID: <505@cbmvax.cbmvax.cbm.UUCP>
Date: 9 Jul 86 20:05:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <951@jade.BERKELEY.EDU> mwm@eris.UUCP () writes:
>>>Oh, well... I guess someone will make a good 'C' compiler someday...
>
>DEC has one for VMS. Convex has one for their box (though it may not
>be released yet). Anybody know of any others?
>
>    <mike
     
I've (regrettably) had to look at a lot of the assembler output of the Manx
C compiler for the Amiga, and I must say that it generates very good code,
and especially since it (apparently) doesn't have an optimizer in it.
     
    Paul.
     
Disclaimer: I do not work for Commodore and opinions expressed are my own.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1761
          for JMS@ARIZMIS; Thu, 10-JUL-1986 21:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 23:25:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014534; 11 Jul 86 0:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011641; 10 Jul 86 23:41 EDT
From: ed gokhman <esg%mtx5a.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: re:re: simulating data abstraction facilities
Message-ID: <1385@mtx5a.UUCP>
Date: 3 Jul 86 23:30:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
* I understand that this is far from C++, but, again, for
* reasons beyong my control C++ is out of reach for now.
     
Noted degree of flaming over this phrase promptly mailed
to me by Bjarne, pointed to a need for clarification.
The "reasons beyong my control //..." do not have ANY
hidden devaluation of C++. We're talking about limited
and/or cosmetic changes to the existing monsterous
state-of-the-art revolutionary "if (tu5_lL == 3)" C-project over
the "aggressive marketting schedules".
The last phrase has hidden non-C-related devaluation.
Thus, THE TIME IS THE REASON ABOVE IT ALL.
     
Sorry, Bjarne, and thanx for your comments, anyhow.
                    Ed

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2032
          for JMS@ARIZMIS; Thu, 10-JUL-1986 21:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/10/86 at 23:42:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014582; 11 Jul 86 0:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011716; 10 Jul 86 23:43 EDT
From: Pete Zakel <pete%valid.uucp@BRL.ARPA>
Newsgroups: net.micro.amiga,net.lang.c
Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only
Message-ID: <421@valid.UUCP>
Date: 10 Jul 86 00:37:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >>causes var to be first loaded, extended to a word, extended to a long, then
> >>compared against 0, EVEN when var is declared as a UBYTE...
>
> What's the second extend doing in there? Anything claiming to be a
> reasonable compiler should generate ONE extend.
     
Not if the processer is a 68000 or 68010.  There is NO instruction to extend
byte to long.  Fortunately that was fixed in the 68020, but that doesn't help
unless you have a compiler that understands 68020 AND you know all your
target machines have 68020s.
--
-Pete Zakel (..!{hplabs,amd,pyramid,ihnp4}!pesnta!valid!pete)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2267
          for JMS@ARIZMIS; Thu, 10-JUL-1986 22:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 00:04:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014695; 11 Jul 86 0:59 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a012067; 11 Jul 86 0:51 EDT
Received: from (MAILER)UREGINA1.BITNET by WISCVM.ARPA on 07/10/86 at
  23:52:34 CDT
Received: by UREGINA1 (Mailer X1.23b) id 9148; Thu, 10 Jul 86 22:49:14
  CST
Date:         Thu, 10 Jul 1986 22:47 CST
From:           Craig Knelsen <CRAIG%UREGINA1.BITNET@WISCVM.ARPA>
Subject:      Re: decline of net.lang.c
To: "net.lang.c" <INFO-C@BRL-SMOKE.ARPA>
     
        Both cgw@mruxe.uucp and dlnash%ut-ngp.uucp@BRL.ARPA complain that
this newsgroup has rapidly deteriorated due to such things as the never
ending saga of why the equality test operator is == instead of = which I
believe has been the result of some misguided Pascal programmers trying to
get people to believe that the language can actually do something useful.
I thought that this group was for discussing C-related topics only. I don't
want to invest my time in reading it if all this Pascal gibberish is thrown
in as well. It's hard to believe that companies like Apple Computer have
based their Macintosh firmware on Pascal or that this language can be used in
ACM Programming Contests but not C (maybe they know that 10 Pascal to 2 C
Programmers is still no match whatsoever and they want to give these less
fortunate people a fighting chance).
        I am Anti-Pascal? Whatever gave you that idea?
     
     
                                                        Craig Knelsen
                                                        University of Regina
                                                        Regina, Sask.
     
UUCP: {ihnp4 | utcsri | alberta} !sask!regina!cknelsen
     
    "Real Programmers don't write in PASCAL, or BLISS, or ADA, or any of
     those pinko computer science languages. Strong typing is for people
     with weak memories."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3629
          for JMS@ARIZMIS; Fri, 11-JUL-1986 01:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 03:08:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015726; 11 Jul 86 4:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012533; 11 Jul 86 3:41 EDT
From: David Shoat <shoat%glasgow.glasgow.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.cpm
Subject: More BDS help wanted
Message-ID: <628@glasgow.glasgow.UUCP>
Date: 4 Jul 86 10:45:09 GMT
Posted: Fri Jul  4 10:45:09 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
       I have an old copy of the CP/M 80 BDS compiler (minus documentation)
       and am a trifle bamboozled about the file handling procedures, as no
       type FILE is defined for file pointers. Could anybody give me a short
       explanation of the file open procedure?
     
       Thanks.
     
       David B. Shoat
       Dept of Medical Cardiology
       Glasgow Royal Infirmary.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3750
          for JMS@ARIZMIS; Fri, 11-JUL-1986 01:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 03:13:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015746; 11 Jul 86 4:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012603; 11 Jul 86 3:43 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pascals Origins
Message-ID: <446@opus.nbires.UUCP>
Date: 9 Jul 86 05:09:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
OK, are we quite done with stupid, irrelevant insults toward Pascal and
Wirth...or does anyone else need to prove that he's such a C weenie that he
can see neither faults in C nor merits in Pascal?  If you're even a halfway
decent programmer, you can do good work in either C or Pascal without
getting hung up on the little issues that folks are flaming about in this
series of postings...
     
...and if you're at all interested in programming languages, you ought to
know (or be able to find) reasonably accurate information about the
evolution of Pascal, Modula, and Modula 2...
     
Now, do we have to keep on criticizing Wirth (a language designer) for
continuing to design languages?  Or does somebody have something substan-
tive to say about C, which WAS the subject of this newsgroup?
--
Dick Dunn    {hao,ucbvax,allegra}!nbires!rcd        (303)444-5710 x3086
   ...At last it's the real thing...or close enough to pretend.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3806
          for JMS@ARIZMIS; Fri, 11-JUL-1986 01:19 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 03:16:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015751; 11 Jul 86 4:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012609; 11 Jul 86 3:43 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only
Message-ID: <2317@umcp-cs.UUCP>
Date: 9 Jul 86 17:38:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <951@jade.BERKELEY.EDU> mwm@eris.UUCP () writes:
>Also, if foo is a pointer type, the test (!foo) is wrong. NULL doesn't
>have to be zero.
     
(Old ground again. . . .)
     
NULL *does* have to be zero, and the test is not wrong.
     
Any null pointer must compare equal to the integer constant zero.
Any null pointer may contain a non-zero bit pattern.  Do you
understand the difference?  (If so, stop reading now.)
     
The difference is that the integer constant zero is only a zero
before compilation.  There is no conceptual reason that it cannot
mutate in the process of code generation.  For example, consider
a Vax compiler that uses the bit pattern 0xc0000000 as the null
pointer (0xc0000000 is an illegal address on a Vax).  The compiler
might turn this:
     
    register char *p = 0;
     
    ...
    if (!p) ...
     
into this:
     
    movl    $0xc0000000,r11        # p = 0
    ...
    cmpl    $0xc0000000,r11        # if (!p)
    jneq    L70            # branch if p == 0
    ...
     
The same compiler would also generate different code for
     
    long t, time(); t = time(0);
     
and
     
    long t, time(); t = time((long *)0);
     
The former might generate the following:
     
    pushl    $0            # 0
    calls    $1,_time
    movl    r0,-4(fp)
     
and the latter:
     
    pushl    $0xc0000000        # (long *)0
    calls    $1,_time
    movl    r0,-4(fp)
     
Now do you see the difference?
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4128
          for JMS@ARIZMIS; Fri, 11-JUL-1986 02:02 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 03:53:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015918; 11 Jul 86 4:49 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a013216; 11 Jul 86 4:34 EDT
Date:     Fri, 11 Jul 86 4:29:57 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Tainter <tainter%ihlpg.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  PRECEDENT FOR USE OF =
Message-ID:  <8607110429.aa05040@VGR.BRL.ARPA>
     
Re: "C has problems in human readability":
     
Funny, I don't have problems with all these things like = vs. ==.
Last I checked, I was human.  Perhaps you meant that C is not a
language for neophyte programmers?  I've ben saying that for years.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4470
          for JMS@ARIZMIS; Fri, 11-JUL-1986 02:45 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 04:37:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016103; 11 Jul 86 5:33 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a013507; 11 Jul 86 5:15 EDT
Date:     Fri, 11 Jul 86 5:07:55 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Lambert Meertens <lambert%mcvax.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  RRe: What's so good about FORTH?
Message-ID:  <8607110507.aa05190@VGR.BRL.ARPA>
     
The obvious approach in C can be gleaned from the "hoc" implementation
in Kernighan & Pike.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4349
          for JMS@ARIZMIS; Fri, 11-JUL-1986 02:45 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 04:20:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016037; 11 Jul 86 5:11 EDT
Received: from ics.uci.edu by SMOKE.BRL.ARPA id a013373; 11 Jul 86 4:55 EDT
Received: from localhost by ICS.UCI.EDU id a009615; 11 Jul 86 1:54 PDT
To: David Shoat <shoat%glasgow.glasgow.uucp@CSNET-RELAY.ARPA>
cc: info-c@BRL-SMOKE.ARPA
cc: jsweet@uci-icsa.ARPA
Subject: Re: More BDS help wanted
In-reply-to: Your message of 4 Jul 86 10:45:09 GMT.
             <628@glasgow.glasgow.UUCP>
Date: Fri, 11 Jul 86 01:52:33 -0800
Message-ID: <9595.521455953@ics.uci.edu>
From: Jerry Sweet <jsweet@uci-icsa.ARPA>
     
     
Without the documentation, you are going to be in deep trouble,
because not only is BDS C a subset implementation, but most
of the support facilities are Slightly Different.
But, to answer your question...
     
The BDS C v 1.50a manual describes fopen() as:
     
    int fopen(filename, iobuf)
      char *filename;
      struct _buf *iobuf;
     
If you want to fake type FILE in BDS C, I suggest:
    #define FILE struct _buf
(BDS C does not implement typedef).
     
You should probably try to order the manual if you're going to do any
serious programming.  Some addresses you can try:
     
    Leor Zolman
    BD Software
    P.O Box 9
    Brighton, Massachuusetts  02135
    (617) 782-0836
     
    Osborne/McGraw-Hill
    2600 Tenth Street
    Berkeley, California  94710
    (Publishers of "The Programmer's CP/M Handbook")
     
    Johnson-Laird, Inc.
    6441 SW CAnyon Court
    Portland, Oregon  97221
    (503) 292-6330
    (Author of the "The Programmer's CP/M Handbook")
     
I mention the Handbook because it contains lots of examples of
programming in BDS C.
     
Good luck.
     
-jns

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4949
          for JMS@ARIZMIS; Fri, 11-JUL-1986 03:17 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 05:14:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016294; 11 Jul 86 6:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013749; 11 Jul 86 5:44 EDT
From: Michael Meissner <meissner%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: variable # of args portability?
Message-ID: <434@dg_rtp.UUCP>
Date: 9 Jul 86 13:46:55 GMT
Keywords: vprintf, vfprintf, and vsprintf
To:       info-c@BRL-SMOKE.ARPA
     
In article <809@ucbcad.BERKELEY.EDU> faustus@ucbcad.UUCP writes:
>
> I want to be able to write a function that will take an unknown number
> of arguments and then call another such function with these arguments,
> namely something like printf() that calls _doprnt() without processing
> its arguments at all.  I know there is no way to write this code portably,
> but is it reasonable to assume that I will be able to do it at all in
> most common implementations of C?  Also, how safe is it to assume that there
> will be something like _doprnt() available?  I know it's not good to depend on
> things like this, but I don't want to have to write my own printf()...
>
>     Wayne
     
    In the forthcoming ANSI X3J11 standard, as well as System V, are the
functions vprintf, vfprintf, and vsprintf.  Instead of taking the argument
list directly, the take the varargs pointer.  Thus the calling sequence looks
like (in the ANSI declarative style):
     
    int vprintf( const char *fmt, va_list varargs_ptr );
    int vfprintf( FILE *stream, const char *fmt, va_list varargs_ptr );
    int vsprintf( char *buffer, const char *fmt, va_list varargs_ptr );
     
    For systems that do not have vprintf and friends yet, you could write
the vprintf, et. al, in a few lines of code calling _doprnt.  This would
have to be tailored for each system.
     
    Michael Meissner, Data General
    ...{ decvax, ucbvax, ihnp4 }!mcnc!rti-sel!dg_rtp!meissner

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5003
          for JMS@ARIZMIS; Fri, 11-JUL-1986 03:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 05:17:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016300; 11 Jul 86 6:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013793; 11 Jul 86 5:45 EDT
From: AAAARRRRGGGGv <argv@SRI-SPAM.ARPA>
Newsgroups: net.lang.c
Subject: Pwers of C (was: Precedent for use of =)
Message-ID: <6061@sri-spam.ARPA>
Date: 10 Jul 86 06:47:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2306@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>I have come to favour
>
>    if ((prog_name = rindex(*argv, '/')) != NULL)
>        ...
>
The simple fact that C lets you evaluate expressions within if statements
(thus saving extra unneeded and combersome code) is reason enough not to
"overevaluate" expressions or to perform expressions in one statement and
to evalute results in the next.
     
Why do the above, when in my first example:
     
if (prog_name = rindex(*argv, '/'))
     
is all that's needed. Those who understand the language properly know that
"progname" and the return of rindex() (or any function or variable) are
one and the same in value and the if statement is evaluating that value.
     
Given that sometimes there may be "tricky" expressions, it is up to the
programmer to comment code well enough so that quick skims of said code
won't confuse the reader too much.  I strongly believe that code should
NOT be made less efficient for readability issues.  Readability can be
made acceptable to even novice programmers with efficient use of comments
and descriptive variable names -- both of which have no effect on the
speed of code.
     
If people would stop fighting C, but take advantage of what it has to offer
over other langages (like the above example and more -- bit manipulations,
etc..), then they would become better programmers themselves.
     
I believe that most are sick and tired of this discussion, so I'll try
to spice something up myself with the following scenario...
     
I like to use my own error statements and print statments for better
control as described below..
     
/*VARARGS*/
print(fmt, args)
register char *fmt;
char *args;
{
    /* other type of actions done here */
    _doprnt(fmt, &args, stdout);
    fflush(stdout);
}
     
/*VARARGS*/
error(fmt, args)
register char *fmt;
char *args;
{
    /* additional actions done here */
    print(fmt, args);
    print(": %s\n", sys_errlist[errno]);
}
     
as you can see, I'm using "print" like printf, and it works fine.
"args" can be declared as basically anything since I'm passing the
address of it to _doprnt (I can see it now; people are going to tell
me to use int, others will claim *int, and some will agree with my
useage, maybe "caddr_t"?).
     
error() is like "perror" except that it is now (functionally) like
printf(). The problem is that error can only take one additional
argument than "fmt" -- that is:
     
error("can't open %s", filename);
     
will work.. you might get something like:
"can't open foobar: no such file or directory"
     
However, additional args like:
     
char *mode = "w";
...
error("can't open %s for \"%s\"", filename, mode);
     
will produce:
"can't open foobar for "(null)": no such file or directory"
     
The reason is that error is receiving the args right, but since
its address is being passed to print(), only the address of the
first arg can be seen by print, thus, all the rest of the args
that _doprnt finally sees are NULL's.
     
The qustion (at last) is, how can a variable number of args be
`elegantly' passed to error and then passed to print so that
the _doprint in print() sees all the arguments.
     
There are various ways which come to mind; none of which I like:
     
1) declare error as:
     error(fmt, arg1, arg2, arg3, arg4)
     char *fmt, *arg1, *arg2, *arg3, *arg4;
     {
     print(fmt, arg1);
         ...
     }
   This works as long as there are no more than 4 args... not good,
   but feasible if you make sure you don't do it. Also, sloppy, but
   portable.
     
2) format the args first into a string:
     
    error(fmt, args)
    char *fmt, *args;
    {
    static char buf[SIZE];
    static FILE &foo;
    /* proper initialization of foo fields including
     * foo._ptr = buf;
     */
        _doprnt(fmt, &args, &foo);
    print(buf);
    ...
    }
     
   I don't like this because you're limited by "SIZE", and it seems to
   be doing much more work than necessary.
     
3) use varargs to split all the args into a double array of char and then
   pass the address of the buffer to print.  yuk.
     
I don't like these because it seems to me that this is straight forward
enough to be done simply and elegantly -- how, I don't know. I hope that
someone can add some light to this problem.
     
dan  <argv@sri-spam.arpa>
     
"Wouldn't ya like to be a pointer, too...
     (be a pointer, be a double pointer, [repeat and fade])"
-------------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5207
          for JMS@ARIZMIS; Fri, 11-JUL-1986 03:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 05:42:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016445; 11 Jul 86 6:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013709; 11 Jul 86 5:43 EDT
From: Charley Wingate <mangoe%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Precedent for use of =
Message-ID: <2323@umcp-cs.UUCP>
Date: 10 Jul 86 05:20:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Dave Haynie writes:
     
>> Personally, I still prefer := for assignment and = for equality over =
>> and ==.  I also think that the keystroke argument is ridiculous.  The
>> problem with = and == is further aggravated by the fact that in C an
>> assignment is an expression and not a statement, so that code like
     
>>   if (i = 0) {
>>     /* do something */
>>   }
>>   else {
>>     /* do something else */
>>   }
     
>> is legal C and usually  /* does something else */   than you expected  :-)
     
>As long as you're writing in C, and you REALLY know the language, the above
>construct would be ridiculous.  I think that most of the folks that are
>unhappy with the way that C handles = and == are frustrated Pascal hackers
>who can't quite adjust to the power and terseness of C.  Maybe if they'd
>spend a few extra hours LEARNING C instead of trying to write Pascal in C,
>they'd be much better off.[...]  My point is instead of
>tripping over the language syntax and screaming how it should be changed,
>one can learn the language and then not have to worry about tripping over
>it.  And then you might even start to realize why a particular method has
>its advantages.
     
Unfortunately, it's that kind of attitude that leads to the perpetuation of
bad language constructs.
     
C's handling of assignment and equality is a problem: it is error-prone.
What's worse is that one often sees code like "if (a=b)" done on purpose--
yet another example on how the "power and terseness" of C leads to
obfuscation.
     
C. Wingate

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5125
          for JMS@ARIZMIS; Fri, 11-JUL-1986 03:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 05:34:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016441; 11 Jul 86 6:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013686; 11 Jul 86 5:42 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.micro.amiga,net.lang.c
Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only
Message-ID: <4907@sun.uucp>
Date: 9 Jul 86 17:52:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >    It never fails to amaze me just how many people do this:
> >        if (foo == NULL) { ... }
> >    or:
> >        if (foo == 0) { ... }
> [instead of...]
> >        if (!foo) { ... }
>
> Well, I wrote it the way you think people ought to for 8 years before
> changing to coding the test explicitly. I changed because the (!foo)
> notation is less readable than the (foo == 0) notation.
     
Amen.  The three constructs given have exactly the same meaning in C (yes,
wait for the explanation, it's true) and any good compiler will produce
exactly the same code for them.  However, "!foo" is suggestive of testing
for the falsity of a Boolean (yes, I know C doesn't have a formal Boolean
type, but that's the proper way to think of something with values meaning
"true" and "false"), while "foo == NULL" is suggestive of testing whether a
pointer is null or not, and "foo == 0" is suggestive of testing whether an
integral value is zero or not.
     
> Also, if foo is a pointer type, the test (!foo) is wrong. NULL doesn't
> have to be zero.
     
Oh, yes it does.  A null pointer need not have a bit pattern consisting of
all zeroes.  However, the value of a null pointer is constructed in
C by converting the integral constant 0 to a pointer type.  In the construct
"foo == 0", the LHS is a pointer, so the compiler knows enough to convert
the "0" on the RHS to a pointer of the same type, hence a null pointer of
the appropriate type.  (No, I won't cite the K&R/ANSI C draft which says
this; seek and ye shall find.)
     
As such, NULL should be #defined as 0 - NOT "(char *)0", because that
causes the compiler to get annoyed when you compare an "int *" against NULL,
since you're comparing two different kinds of pointers.
     
> >    The reason the compiler is exhibiting the behavior you describe is
> >because you told it to.  You are asking the compiler to compare an unsigned
> >byte to the literal value of NULL.
     
Which should always be 0.  As such, in the example given,
     
    if (var == NULL) ...
     
is identical to
     
    if (var == 0) ...
     
and should generate the same code; as the author of the response to the
above comment points out, there is NO reason to extend a 1-byte variable
"var" to 4 bytes when doing this.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5515
          for JMS@ARIZMIS; Fri, 11-JUL-1986 04:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 06:31:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017045; 11 Jul 86 7:25 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a014318; 11 Jul 86 6:48 EDT
Date:     Fri, 11 Jul 86 6:46:24 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Pascals Origins
Message-ID:  <8607110646.aa05420@VGR.BRL.ARPA>
     
I have to agree with the criticisms being made against the recent
content of the INFO-C/net.lang.c mailing list/newsgroup.  I think
some of this is due to the recent rapid spread of the group to
include people who learned C from folks in the Micro world.  Much
of the rest of the junk I attribute to people thinking that it is
useful to discuss how to CHANGE the language.  This is completely
misguided; the natural follow-on to C is C++, which has its own
newsgroup net.lang.c++, and any alterations that will actually
occur to C will be as the result of the ANSI X3J11 standardization
effort, which is getting close to release of a proposed standard
for public review and comment.  There is a moderated newsgroup
mod.std.c for discussions pertinent to the X3J11 effort; however,
be warned that the committee will turn rather deaf ears on
suggestions for radical change, as one of their operative
priniciples is that there be as little invalidation of existing
code as can be feasibly managed while consolidating the already
divergent minor dialects of the language.  Fortunately, there has
been a single acknowledged de facto standard for C that provided
stability for a large segment of the language (similar to the
revised Pascal report for that language before it was standardized).
A second de facto standard for the C environment occurred because
of the close association of C with UNIX.  X3J11 is codifying all
this, and that will certainly be what C "is" for some time to come.
     
I believe that this particular newsgroup should serve as a forum
for technical aspects of the language (as it happens to be).
Questions about the use of macros to accomplish a general swap
are one recent example of a valid topic; attempts to clarify
the meaning of "array[]" are another.  HOWever, it serves no
useful purpose for people who barely understand C to try to
explain tricky technical points to the group; there are several
well-qualified "regulars" in this group who can do a better job.
(Even they make mistakes, but when they do, the ensuing
discussion is generally enlightening rather than confusing.)
     
I don't know of any way to force this newsgroup to re-acquire
some of its lost value; I don't think moderating it would be
a very good solution.  The only hope I have for it is for there
to be a widespread agreement amongst the group members on the
legitimate purposes of the group (which I just discussed), and
a serious attempt by everyone to cooperate with keeping the
discussions germane.  It would be a real pity if the serious C
users had to invent some other mechanism of communicating,
when this one should be able to serve well.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5675
          for JMS@ARIZMIS; Fri, 11-JUL-1986 05:01 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 06:57:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017900; 11 Jul 86 7:50 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a015073; 11 Jul 86 7:39 EDT
Date:     Fri, 11 Jul 86 7:32:36 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Guy Harris <guy%sun.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  printf() code size using Astartup.obj and AMIGA.LIB only
Message-ID:  <8607110732.aa05648@VGR.BRL.ARPA>
     
In agreement with Guy and others, I do not equate readability of C
code with use of the minimum number of tokens.  Readability pertains
to the human mind, perceptions, cognitive psychology, etc. which
makes it hard to reduce C code readability to a simple set of rules
for construction.  However, there are several known good principles
(data abstraction, modularity, good mnemonics, and so forth).  The
key point is that readability depends on conceptual clarity.  This is
why, as Guy points out, it is proper to maintain a conceptual
distinction between Boolean data and pointers, even though C itself
permits blurring of such distinctions.  The use of NULL to mean
"invalid pointer, no data can be accessed via this pointer" is one
important tool for writing intelligible code.  I probably once
thought that it was neat that C (like B, which I never used) folded
together a lot of apparently separate things; fortunately if I did
think that I have since come to my senses.  Simply combining
entities is a far cry from integrating them into a cohesive
concept.  [loose use of terms here so I can be understood by non-
epistemologists]  The only "concept" served by ignoring data types is
that of the machine storage cell (just like B), which is the wrong way
to go, since leverage is obtained by extending one's focus to higher-
level abstractions, not lower.  Only when there is a real need to
be concerned with low-level details (e.g. when writing device
drivers) should one stoop to working at that level of abstraction.
     
Incidentally, ANSI X3J11 seems to be urging the general adoption of
    (void *)0
as the definition of NULL instead of the
    0
that Guy and I agree is the best definition.  I don't know what
their rationale for that is.  It may be meant to help compensate
for lack of care commonly seen in code such as:
    func( arg1, arg2, NULL, arg4 );
since on lucky machines where all pointers happen to be the same
size, that would work despite the fact that it was coded wrong.
I think that's a bogus reason, if it is indeed the reason.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5911
          for JMS@ARIZMIS; Fri, 11-JUL-1986 05:22 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 07:17:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018576; 11 Jul 86 8:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015256; 11 Jul 86 7:42 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pascals Origins
Message-ID: <6915@utzoo.UUCP>
Date: 9 Jul 86 21:57:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > ... Wirth designed Pascal as a teaching...
> Wrong! Even Wirth denied that.
     
Curious, he said quite explicitly in his early Pascal papers that it
was designed primarily as a teaching language.
     
> ...no provisions for
> separate compilation. Everything in one source file, and they make
> people write large scale projects in it? Pure insanity.
     
Wirth definitely had his head screwed on wrong when he did that.  The
idea behind it was that a fast compiler could recompile stuff more
quickly than a linkage editor could link it in, so why bother with the
extra type-checking hassles?  The compilers he was thinking of were
the early Pascal compilers, which were simple and fast; the linkage
editor he was thinking of was the OS/360 one, a notorious pig.  In more
recent times he has come to his senses.
     
Many of Root-Boy's other complaints about Pascal can be covered with a
single observation:  Pascal is over 15 years old.  It's not surprising
that it has a lot of problems by modern standards.
     
>     (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
> You should all JUMP UP AND DOWN for TWO HOURS while I decide on a NEW CAREER!!
     
Jim, if you're really gonna pick a new career, something that will take you
away from your keyboard forever, and jumping up and down for two hours will
help, a lot of people will do it!
--
Usenet(n): AT&T scheme to earn
revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6094
          for JMS@ARIZMIS; Fri, 11-JUL-1986 05:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 07:34:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019030; 11 Jul 86 8:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015292; 11 Jul 86 7:42 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2324@umcp-cs.UUCP>
Date: 10 Jul 86 06:13:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>>In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
     
Careful with the quotes; the `>>' text is mine, not JUNG_E%SITVXA.BITNET's.
(The >>> text is his.)
     
>>>Practically every language uses the equals sign, "=", to test for
>>>equality, not as an assignment operator.
     
(Here I listed some languages, and tallied:)
>>Well, 5 to 3 in favour of `= for equality', though APL and Mesa are
>>perhaps special cases: back-arrow is not available for assignment on
>>my H19.
     
In article <2158@ihlpg.UUCP> tainter@ihlpg.UUCP (Tainter) replies:
>ADD:
>    Assignment        Equality
>    ----------        ---------
>                mathematics
>                logic
>--j.a.tainter
     
Imprimus, the context is really computer languages.  Secondus, both
mathematics and logic are very broad fields, and saying `mathematics
uses ``='' for equality' is like saying `physics uses ``c'' for
the speed of light': true in many instances but by no means universal.
Tertius, this whole discussion is getting boring.  For those of
you who prefer := for assignment and `=' for equality, just compile
all your C code to .o files with the following `pascalcc' shell
script.  It can be extended, if necessary, to do most everything
that /bin/cc does.
     
: pascalcc - compile C code with Pascal-esque assignment / equality
comp=/lib/ccom
c2=/bin/cat
tf=/tmp/pascalcc.$$
trap "rm -f $tf" 0 1 2 3 15
for i
do
    case "$i" in
    -O)    c2=/lib/c2;;
    -c)    ;;
    *.c)    if cc -E "$i" |
           sed -e 's/\([^:]\)=/\1==/' -e 's/:=/=/' |
           $comp | $c2 > $tf; then
            if as -o `echo "$i" | sed -e 's/\.c$//'`.o $tf; then
                :
            else
                exit $?
            fi
        else
            exit $?
        fi;;
    *)    echo "$0: cannot handle file name \`$i'" 1>&2
        exit 1;;
    esac
done
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6172
          for JMS@ARIZMIS; Fri, 11-JUL-1986 05:40 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 07:37:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019184; 11 Jul 86 8:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015758; 11 Jul 86 7:49 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re:  swap() macro (LISP & Algol)
Message-ID: <510@cbmvax.cbmvax.cbm.UUCP>
Date: 10 Jul 86 15:46:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
>>
>>    What about LISP? Or is LISP older than Algol?
>
> LISP and Pascal are both descendants of Algol 60.
> --
>
>                     AMBAR
     
LISP a descendent of Algol 60?!!?!  The earliest ancestor of LISP I've
heard of is IPL, which was developed by Newell, Shaw, and Simon at
Carnegie-Mellon in the fifties.  IPL stands for Information Processing
Language.  LISP itself was invented by John McCarthy (at MIT, I believe)
and was first formally described in papers presented in 1960 and 1961.  The
first progamming guide on LISP was "LISP 1.5 Programmer's Manual" published
in 1961.  The first AI Language I've heard of being based on Algol at
all is SAIL, which was presented in a paper sometime around 1972.
     
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
    "I don't feel safe in this world no more,
     I don't want to die in a nuclear war,
     I want to sail away to a distant shore
     And live like an ape man."
                -The Kinks
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6244
          for JMS@ARIZMIS; Fri, 11-JUL-1986 05:45 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 07:40:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019265; 11 Jul 86 8:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015831; 11 Jul 86 7:51 EDT
From: Patrick M Juola <ins_apmj%jhunix.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <3147@jhunix.UUCP>
Date: 10 Jul 86 13:40:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2158@ihlpg.UUCP> tainter@ihlpg.UUCP (Tainter) writes:
>> Perhaps you know more languages than I.  Let me list those whose
>> syntax I remember, and count `= for assigment' vs. `= for equality'
>> (or both).
>>     Assignment        Equality
>>     ----------        --------
    [ List deleted ]
>ADD:
>    Assignment        Equality
>    ----------        ---------
>                mathematics
>                logic
>--j.a.tainter
     
                try             mathematics (both)
                            logic (both)
     
    You've never seen the statements at the beginning of proofs, where
they assign properties to variables....  If you want to assign to vector
z the length of 1, you write "|z|=1."  Or at least I do.  How do you do it?
     
--
  seismo!umcp-cs \                          Pat Juola
    ihnp4!whuxcc  > !jhunix!ins_apmj        Hopkins Maths
 allegra!hopkins /
     
 "I'm kind of tired.  I was up all night trying to round off infinity."

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6338
          for JMS@ARIZMIS; Fri, 11-JUL-1986 05:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 07:43:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019328; 11 Jul 86 8:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015882; 11 Jul 86 7:52 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Powers of C
Message-ID: <2333@umcp-cs.UUCP>
Date: 10 Jul 86 20:01:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <2306@umcp-cs.UUCP> I wrote:
>>I have come to favour
>>
>>    if ((prog_name = rindex(*argv, '/')) != NULL)
>>        ...
     
In article <6061@sri-spam.ARPA> argv@sri-spam.arpa (AAAARRRRGGGGv) replies:
>Why do the above, when in my first example:
>
>if (prog_name = rindex(*argv, '/'))
>
>is all that's needed.
     
For clarity, readability.  I used to believe as you seem to do---until
I started looking at my own old code after a few years.
     
>Given that sometimes there may be "tricky" expressions, it is up to the
>programmer to comment code well enough so that quick skims of said code
>won't confuse the reader too much.
     
Comments and code have a strange tendency to `get out of sync'.
     
>I strongly believe that code should NOT be made less efficient for
>readability issues.
     
Surprise!
     
    if (v = e)
     
and
     
    if ((v = e) != 0)
     
generate the same code (at least via the 4.3BSD Vax C compiler).
     
>Readability can be made acceptable to even novice programmers with
>efficient use of comments and descriptive variable names -- both of
>which have no effect on the speed of code.
     
Both do indeed help; I am not certain that they are always sufficient.
     
[and a digression]
     
>I like to use my own error statements and print statments for better
>control as described below..
>
>/*VARARGS*/
>print(fmt, args)
>register char *fmt;
>char *args;
>{
>    /* other type of actions done here */
>    _doprnt(fmt, &args, stdout);
>    fflush(stdout);
>}
>
>/*VARARGS*/
>error(fmt, args)
>register char *fmt;
>char *args;
>{
>    /* additional actions done here */
>    print(fmt, args);
>    print(": %s\n", sys_errlist[errno]);
>}
>
>as you can see, I'm using "print" like printf, and it works fine.
     
Wait until you port your code to a Pyramid.
     
>error() is like "perror" except that it is now (functionally) like
>printf(). The problem is that error can only take one additional
>argument than "fmt" [...]
>
>The reason is that error is receiving the args right, but since
>its address is being passed to print(), only the address of the
>first arg can be seen by print, thus, all the rest of the args
>that _doprnt finally sees are NULL's.
     
Well, no, actually, _doprnt gets `stack junk'.  With enough format
elements, and a bit of luck, you might reach error's arguments.
(But not likely on a Pyramid!)
     
>The qustion (at last) is, how can a variable number of args be
>`elegantly' passed to error and then passed to print so that
>the _doprint in print() sees all the arguments.
     
First, get yourself a vprintf (the one I just posted should do).
Then do this:
     
    #include <varargs.h>
     
    extern int errno;
    extern char *sys_errlist[];
    extern int sys_nerr;
     
    void
    error(va_alist)
        va_dcl    /* note no semicolon */
    {
        register int e = errno;
        char *fmt;
        va_list v;
     
        va_start(v);
        fmt = va_arg(v, char *);
        (void) vprintf(fmt, v);
        va_end(v);
        if (e < 0 || e >= sys_nerr)
            printf(": unknown error code %d\n", e);
        else
            printf(": %s\n", sys_errlist[e]);
    }
     
I prefer a routine more like my own error(), which takes the error
number as an argument (sometimes after the error you should clean
up a bit before printing the message, and the cleanup may disturb
errno; it is ugly to have to `put it back'), and an exit code,
which is passed to exit() iff it is nonzero, else error() returns.
Also, error messages should most likely go to stderr.
     
My real preference would be to have a functional interface, with
sensible defaults, but that is trickier, given stdio's current
internals.
     
[enter ANSI C mode]
     
    static void
    putc_stderr(int c) {
     
        (void) putc(c, stderr);
    }
     
    void
    errf(void (*put)(), int quit, int err, const char *fmt, int args) {
     
        if (put == NULL)
            put = putc_stderr;
        if (err < 0)        /* get system error index */
            err = errno;
        /* somehow do the printing */
        if (quit)
            exit(quit);
    }
     
There are some efficiency issues here too: it might be useful to
buffer the characters being put, and fflush afterward; but there
is no way to tell what to flush.  I suppose the series of functions
errf(), ferrf(), serrf(), verrf(), vferrf(), vserrf() would suffice.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6416
          for JMS@ARIZMIS; Fri, 11-JUL-1986 05:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 07:49:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019401; 11 Jul 86 8:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015965; 11 Jul 86 7:54 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Yet another ALIGN idea.  (some
Message-ID: <2600066@ccvaxa>
Date: 9 Jul 86 14:46:00 GMT
Nf-ID: #R:ttrdc.UUCP:1038:ccvaxa:2600066:000:886
Nf-From: ccvaxa.UUCP!aglew    Jul  9 09:46:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
An alignment constant would not necessarily work, because there are machines
that have unusual alignment restrictions. My favorite is `strictly aligned
power of two sized' - ie. an object of size N must be aligned on a boundary
of 2^ceil(lg(N)), if indexing is to be used to access fields of such an
object.
     
    Note that malloc(nitems*sizeof(obj)) is conservative for such a beast,
assuming sizeof rounds up correctly, but calloc() can be a bit more
intelligent.
     
This scheme is strictly size dependent, but screwier schemes are possible.
     
Since an alignment constant doesn't necessarily work, how about an
alignmentof(object) operator, analagous to sizeof()? At least that'll work
on all architectures that have alignments based on multiples.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6580
          for JMS@ARIZMIS; Fri, 11-JUL-1986 06:10 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 08:06:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019973; 11 Jul 86 8:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016272; 11 Jul 86 8:01 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Re: Precedent for use of =
Message-ID: <4971@sun.uucp>
Date: 10 Jul 86 18:26:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >     if (prog_name = rindex(*argv, '/'))
> >         prog_name++;
> >     else prog_name = *argv;
...
> >
> >     prog_name = rindex(*argv, '/');
> >     if (!prog_name)
> >         prog_name = *argv;
> >     else prog_name++;
     
> The example that you show is good C, I use that style all of the time,
> and a good compiler will produce code for it that's more efficient than
> in the second example.
     
Assuming your machine stores an indication of whether a "move" instruction
moved a zero-or-non-zero value somewhere (which may or may not be the case;
the MIPS chip, for example, has no condition code register), and assuming
that your C implemention represents null pointers as all-zero bit patterns,
a good compiler will realize that in the second example an indication of
whether "prog_name" was assigned a zero value will be found there and will
use it, in exactly the same fashion as it did in the first example, and will
generate equally efficient code for both examples.  If the aforementioned
assumptions are not true, the conclusion that a good compiler will generate
equally efficient code for both examples will almost certainly still be
true.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6655
          for JMS@ARIZMIS; Fri, 11-JUL-1986 06:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 08:08:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020078; 11 Jul 86 8:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016310; 11 Jul 86 8:02 EDT
From: Steve Schlaifer x43171 156/224 <steve%jplgodo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: 5<a<50 (was:Additions to C - range checking)
Message-ID: <819@jplgodo.UUCP>
Date: 10 Jul 86 19:34:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <7000@boring.mcvax.UUCP>, jack@mcvax.uucp (Jack Jansen) writes:
>
> In article <155@daisy.warwick.UUCP> cudcv@daisy.warwick.ac.uk (Rob McMahon)
 writes:
> >In article <523@ccird1.UUCP> rb@ccird1.UUCP (Rex Ballard) writes:
> >>
> >>if (5<a<50) do_something(a);
> >>
> >...
> >>
> >>Is this impossible to parse?
> >
> >This was in BCPL, and was a GOOD IDEA.
>
> Yes, it is nice from a users standpoint, but if you want to define
> the semantics of this operator in a reasonable way, it becomes
> difficult. The only way out I see is to let expressions have *two*
> values: an ordinary one, and a success/failure indication. Then you
> can let the value of 'a<b' be 'b', and the operator return 'success'
> when a is less than b. I remember seeing something about a language that
> had such semantics, can't remember which one, however.
     
Icon does just such a thing.  Expressions have both a success/fail value
and their "normal" value.
--
     
...smeagol\            Steve Schlaifer
......wlbr->!jplgodo!steve    Advance Projects Group, Jet Propulsion Labs
....logico/            4800 Oak Grove Drive, M/S 156/204
                Pasadena, California, 91109
                    +1 818 354 3171

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6899
          for JMS@ARIZMIS; Fri, 11-JUL-1986 06:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 08:28:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021340; 11 Jul 86 9:21 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a018419; 11 Jul 86 8:59 EDT
Received: from Concord.ms by ArpaGateway.ms ; 11 JUL 86 05:59:12 PDT
Sender: Eric_S._Fanwick.STHQ@xerox.ARPA
Date: 11 Jul 86 05:58:49 PDT (Friday)
Subject: Re: Re: Re: Precedent for use of =
From: Eric_S._Fanwick.STHQ@xerox.ARPA
To: daveh%cbmvax.cbm.uucp@BRL.ARPA
cc: Eric_S._Fanwick.STHQ@xerox.ARPA, info-c@BRL-SMOKE.ARPA
In-Reply-to: daveh%cbmvax.cbm.uucp%BRL:ARPA:Xerox's message of
 10-July-86 (Thursday) 3:30:39 EDT
Message-ID: <860711-055912-2007@Xerox>
     
The best way to some up the difference between C and Pascal, (I
personnally see strengths and weeknesses in both) is that
     
    C assumes the programmer knows what he is doing and lets him do it.
Pascal assumes the programmer does not know what he is doing and
prevents him.
     
Given this basic difference makes Pascal a better teaching language
     
Eric Fanwick
     
PS: Strong typed languages are for week minds.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8791
          for JMS@ARIZMIS; Fri, 11-JUL-1986 09:21 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 11:16:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026513; 11 Jul 86 12:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007136; 11 Jul 86 11:42 EDT
From: Mikel Manitius <mikel%codas.att.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <630@codas.ATT.UUCP>
Date: 11 Jul 86 03:08:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1645@brl-smoke.ARPA> JUNG_E%SITVXA.BITNET@WISCVM.WISC.EDU writes:
>Kernighan and Ritchie, in their infinite wisdom, decide
>instead to use "=" for assignments and to create a new operator, "==" to
>test for equality.  Gee, that must have required brains, the brains of
>a 3 year old.
     
Where did this clod come from?
--
    ___
   /   \        Mikel Manitius @ AT&T-IS Altamonte Springs, FL
  | RPI |        ...{seismo!akgua|ihnp4|cbosgd|mcnc}!codas!mikel
  |  .  |
\\-------//

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8735
          for JMS@ARIZMIS; Fri, 11-JUL-1986 09:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 11:15:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026505; 11 Jul 86 12:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007127; 11 Jul 86 11:42 EDT
From: Andy Kashyap <aka%cbrma.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Precedent for use of =
Message-ID: <4738@cbrma.UUCP>
Date: 10 Jul 86 17:02:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6056@sri-spam.ARPA> argv@sri-spam.UUCP (AAAARRRRGGGGv) writes:
>In article <499@cbmvax.cbmvax.cbm.UUCP> daveh@cbmvax.cbm.UUCP (Dave Haynie)
 writes:
>>>   if (i = 0) {
>>>     /* do something */
>>>   }
>>>   else {
>>>     /* do something else */
>>>   }
>>>
>>> is legal C and usually  /* does something else */   than you expected  :-)
>>
>>As long as you're writing in C, and you REALLY know the language, the above
>>construct would be ridiculous.
>
>I disagree and I believe you do, too. If you really look for this
>construct, it is quite common in C, altho good programmers comment
>that they know what they're doing here... for example, my favorite:
>
>main(argc, argv)
>char **argv;
>{
>    char *prog_name, *rindex();
>
>    if (prog_name = rindex(*argv, '/'))  /* find last '/' in argv[0] */
>    prog_name++; /* set prog_name to string following last '/' */
>    else prog_name = *argv; /* program was exec-ed from same dir or in PATH */
>    /* etc... */
>}
>
>dan (argv@sri-spam.arpa)
     
Look again, Dan, at the original posting.
The 'true' branch of the 'if' statement is *NEVER* executed.
--
     
+----------------------------------------------------------------------------+
|                                                       | Andy Kashyap       |
|                                                       | AT&T Bell Labs     |
|                                                       | Columbus OH        |
| Say Goodnight Gracey...Gracey?...Gracey?!!...HEY!!!   | ..!cbosgd!cbrma!aka|
+----------------------------------------------------------------------------+

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9112
          for JMS@ARIZMIS; Fri, 11-JUL-1986 09:41 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 11:37:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027028; 11 Jul 86 12:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007091; 11 Jul 86 11:41 EDT
From: Christopher Caldwell <chris%sol.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: source to format (printf like routines) available in net.sources
Message-ID: <126@sol.UUCP>
Date: 9 Jul 86 21:59:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
*** REPLACE THIS LINE WITH YOUR MESSAGE ***
Awhile back, I posted the existance of these routines.  There was enough
interest in them to warrent posting.  I have done so.
     
Christopher M. Caldwell
...decvax!sii!dmcnh!sol!chris
16 Columbia Drive, VIBRAC Corporation, Amherst, NH 03031, (603)882-6777
13B Bobby's Lane, Milford, NH 03055, (603)673-2249

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9259
          for JMS@ARIZMIS; Fri, 11-JUL-1986 09:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 11:44:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027036; 11 Jul 86 12:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007123; 11 Jul 86 11:42 EDT
From: Andy Kashyap <aka%cbrma.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Precedent for use of =
Message-ID: <4737@cbrma.UUCP>
Date: 10 Jul 86 16:25:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <499@cbmvax.cbmvax.cbm.UUCP> daveh@cbmvax.cbm.UUCP (Dave Haynie)
 writes:
>
>... My point is instead of
>tripping over the language syntax and screaming how it should be changed,
>one can learn the language and then not have to worry about tripping over
>it.  And then you might even start to realize why a particular method has
>its advantages.
>--
     
Amen.
--
     
+----------------------------------------------------------------------------+
|                                                       | Andy Kashyap       |
|                                                       | AT&T Bell Labs     |
|                                                       | Columbus OH        |
| Say Goodnight Gracey...Gracey?...Gracey?!!...HEY!!!   | ..!cbosgd!cbrma!aka|
+----------------------------------------------------------------------------+

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3337
          for JMS@ARIZMIS; Fri, 11-JUL-1986 14:49 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 16:10:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005678; 11 Jul 86 16:58 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id ab16471; 11 Jul 86 15:40 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a003666; 11 Jul 86 15:31 EDT
Received: from (LINNDR)VUENGVAX.BITNET by WISCVM.ARPA on 07/11/86 at
  14:29:35 CDT
Date: 11 JUL 86 14:25-CST
From:  LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
To:  INFO-C@BRL.ARPA
Subject: Another printf-type question
     
        All this stuff about v*printf has brought me back to a problem
I was trying to solve earlier. Having a terminal that supports inverse
video, blinking and underlining, I thought it would be fun to write some
printing functions to take advantage of these features. For example,
     
invprintf(fmt,args)
{
        printf(<string to go into inverse video mode>);
        printf(fmt,args);
        printf(<string to leave inverse mode>);
}
     
This simple solution didn't work. Oh great gurus of such things, what
should I have done?
     
David Linn
----------------------------------------------------------
ARPANET(?):     LINNDR%VUEngVAX.BITNET@WISCVM.WISC.EDU
BITNET:         LINNDR@VUEngVAX.BITNET
CSNET:          drl@vanderbilt.csnet
Ma Bell:        (615)322-7924
USPS:           P.O. 3241-B Vanderbilt
                Nashville, TN   37235
UUCP:           ...psuvax1!vuengvax.bitnet!linndr

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2938
          for JMS@ARIZMIS; Fri, 11-JUL-1986 15:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 15:50:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005590; 11 Jul 86 16:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016667; 11 Jul 86 15:42 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Re: Precedent for use of =
Message-ID: <514@cbmvax.cbmvax.cbm.UUCP>
Date: 11 Jul 86 15:48:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
> Unfortunately, it's that kind of attitude that leads to the perpetuation of
> bad language constructs.
>
> C's handling of assignment and equality is a problem: it is error-prone.
> What's worse is that one often sees code like "if (a=b)" done on purpose--
> yet another example on how the "power and terseness" of C leads to
> obfuscation.
>
> C. Wingate
     
Hey, you can use assignment in C as if it were a statement only when you
write YOUR C code, but in the example that you give its used in its full
power as an operator, which can generate much more efficient code than
the equivalent:
     
a=b
if (b)
     
Personally, I would have coded it
     
if ((a=b) == 0)
     
OR
     
if ((a=b) == NULL)
     
to make my point clear (a good compiler will produce the same code in all
three cases, though a bad one may code more efficiently on the first
example).  But my point is that there's nothing inherently bad about the
constructs available in C, there's no confusion if you know the language
and don't specifically try to write confusing code (which you can do in
languages like APL and LISP much more effectively than in C), and there's
additional power in the language for those who know how to use it.  You
like the verobsity of Pascal, so use Pascal.  I like the power of C,
which is why I write in it, and I'm not confusing MYSELF with C.  Giving
Pascal's rules to a good C programmer is like giving a dull scapel to a
skilled surgeon; he can't cut himself with it.
     
     
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
    "I don't feel safe in this world no more,
     I don't want to die in a nuclear war,
     I want to sail away to a distant shore
     And live like an ape man."
                -The Kinks
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7117
          for JMS@ARIZMIS; Fri, 11-JUL-1986 21:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/11/86 at 23:21:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007543; 11 Jul 86 22:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023067; 11 Jul 86 21:41 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: variable # of args portability?
Message-ID: <2332@umcp-cs.UUCP>
Date: 10 Jul 86 19:25:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <434@dg_rtp.UUCP> meissner@dg_rtp.UUCP (Michael Meissner) writes:
> In the forthcoming ANSI X3J11 standard, as well as System V, are the
>functions vprintf, vfprintf, and vsprintf.  Instead of taking the argument
>list directly, the take the varargs pointer.  Thus the calling sequence looks
>like (in the ANSI declarative style):
>
>    int vprintf( const char *fmt, va_list varargs_ptr );
>    int vfprintf( FILE *stream, const char *fmt, va_list varargs_ptr );
>    int vsprintf( char *buffer, const char *fmt, va_list varargs_ptr );
     
Since none of 4.[123]BSD Vax Unix have these, but they are trivial,
here is an (untested) implementation.  (Unfortunately, implementing
the proper return value is not so trivial, except for vsprintf.)
     
I believe this code will work on a Pyramid as well.
     
#include <stdio.h>
     
int
vprintf(fmt, args)
    char *fmt;
    va_list args;
{
     
    _doprnt(fmt, args, stdout);
    return (ferror(stdout) ? EOF : 0);
}
     
int
vfprintf(f, fmt, args)
    FILE *f;
    char *fmt;
    va_list args;
{
     
    _doprnt(fmt, args, f);
    return (ferror(f) ? EOF : 0);
}
     
int
vsprintf(s, fmt, args)
    char *s, *fmt;
    va_list args;
{
    FILE fakebuf;
     
    fakebuf._flag = _IOSTRG;    /* no _IOWRT: avoid stdio bug */
    fakebuf._ptr = s;
    fakebuf._cnt = 32767;
    _doprnt(fmt, args, &fakebuf);
    return (strlen(s));
}
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9340
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 04:06:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001124; 12 Jul 86 4:59 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a025386; 12 Jul 86 4:47 EDT
Date:     Sat, 12 Jul 86 4:40:29 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Yet another ALIGN idea. (some
Message-ID:  <8607120440.aa15261@VGR.BRL.ARPA>
     
You say that an alignof(type) operator is required in order to
implement the va_arg(ap,type) macro.  Could you please demonstrate
this?  I don't believe it.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9248
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:53:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001064; 12 Jul 86 4:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024552; 12 Jul 86 3:41 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Yet another ALIGN idea.  (some
Message-ID: <1511@watmath.UUCP>
Date: 11 Jul 86 12:34:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Since an alignment constant doesn't necessarily work, how about an
> alignmentof(object) operator, analagous to sizeof()? At least that'll work
> on all architectures that have alignments based on multiples.
     
An "alignof(type)" operator is already required by X3J11 (although
they don't seem to have realized this yet) in order to implement
their va_arg(ap,type) macro.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9200
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:52:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001062; 12 Jul 86 4:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024531; 12 Jul 86 3:40 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: '=' vs '<-' vs '.ne' vs '==' vs ':=' vs '.eq.' vs ...
Message-ID: <1631@mmintl.UUCP>
Date: 8 Jul 86 02:12:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5282@topaz.RUTGERS.EDU> gaynor@topaz.UUCP writes:
>ASSIGNMENT  <-
     
The problem is that "<-" is a legal sequence of operators.  Consider
"if (x<-1) { ...}".
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7604
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 00:04:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000374; 12 Jul 86 0:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023521; 11 Jul 86 23:42 EDT
From: Guido van Rossum <guido%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Taking the address of a register (Re:  Swap by name)
Message-ID: <7009@boring.mcvax.UUCP>
Date: 10 Jul 86 22:01:19 GMT
Posted: Thu Jul 10 22:01:19 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <2036@brl-smoke.ARPA> rbj@icst-cmr.ARPA writes:
~> Suggestion to make the compiler introduce a temporary when the
~> address of a register variable is passed as argument to a function.
     
Rather than cluttering the compiler with more crap than this, write an
optimizing compiler that doesn't need register declarations but can find
out for itself what variables are best put in registers.
     
If you want to make the language's level higher by doing something to
register variables, remove them from the language instead of giving them
'pseudo-auto' status.
     
Or did I mis some implicit `:-)' in your article?
     
    Guido van Rossum, CWI, Amsterdam <guido@mcvax.uucp>

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8744
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:08:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000994; 12 Jul 86 4:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024556; 12 Jul 86 3:41 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Powers of C
Message-ID: <1521@watmath.UUCP>
Date: 11 Jul 86 12:48:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>                                   I suppose the series of functions
> errf(), ferrf(), serrf(), verrf(), vferrf(), vserrf() would suffice.
> --
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
     
Isn't it interesting how every time you write a printf-like function
you also have to write a v-version of it too?  I guess that's one way
of getting free advertising for system V.
     
Our solution at waterloo was to introduce a %v format which takes the
next two arguments as the format string and the argument list pointer.
That way you only have to write one version of each function, the
other version comes for free.  It also means you can have things like
"%s: %v: %s\n" in a single call instead of having to make three calls.
This is like the "%r" format that occasionally pops up in versions
of stdio but it doesn't require that the format be on the stack with
the arguments, and it doesn't act like a goto.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9669
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 05:11:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001281; 12 Jul 86 6:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025694; 12 Jul 86 5:43 EDT
From: "Timothy G. Thompson" <tgt%cbosgd.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Cobol to C ????
Message-ID: <2278@cbosgd.UUCP>
Date: 11 Jul 86 18:06:14 GMT
Keywords: COBOL, C, 3B, TRANSLATOR
To:       info-c@BRL-SMOKE.ARPA
     
I know this request is going to sound real strange, but does anyone out there
know of a COBOL to C translator for the 3B line of computers? There's a
software package written in COBOL that I'd like to port to the UNIX/C
environment, and am looking for any help I can get. I'm pretty sure the port
won't work, because I have a feeling that the package makes extensive use
of IMS, an IBM-style database. But it can't hurt to ask. Please e-mail
replies to me at cbosgd!tgt. Thanks!
     
     
     
--
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Timothy G. Thompson           AT&T Network Systems             Columbus, Ohio
                                    cbosgd!tgt
 DISCLAIMER:  These ramblings are my own. However, a thousand monkeys pounding
    on a thousand typewriters would eventually produce the exact same thing!!
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9143
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:47:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001060; 12 Jul 86 4:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024527; 12 Jul 86 3:40 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pig C
Message-ID: <1630@mmintl.UUCP>
Date: 8 Jul 86 02:10:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <249@sdchema.sdchem.UUCP> tps@sdchema.UUCP (Tom Stockfisch) writes:
>In article <6874@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes:
>>[discussion about redefining C with the preprocessor]
>>...  If you can read English you can read Pig Latin,
>>but nobody would tolerate documentation written in Pig Latin...
>
>This is such a great analogy, with Henry's permission I would like to coin
>the term
>
>    Pig C
>
>to refer to C code (like the Bourne shell) which effectively
>redefines the language.
     
You haven't got the analogy quite right.  Pig Latin, after all, is a variant
of English, not of Latin.  So I would recommend you call such things "Pig
Pascal", not "Pig C".
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8907
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:25:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001006; 12 Jul 86 4:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024585; 12 Jul 86 3:42 EDT
From: jso%edison.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: #if foo vs #if defined(foo)
Message-ID: <819@edison.UUCP>
Date: 7 Jul 86 17:20:58 GMT
Keywords: cpp #if
To:       info-c@BRL-SMOKE.ARPA
     
In article <379@twitch.UUCP>, grt@twitch.UUCP ( G.R.Tomasevich) writes:
> #if squat||foo
>
> if the 'cc' command includes either '-Dsquat' or '-Dfoo', then 'yes' is
> selected, else 'no' is selected.  E.g.: 'cc -Dfoo -E c.c'
>     George Tomasevich, ihnp4!twitch!grt
     
Fine, since -Dfoo is the same as '#define foo 1', but what about
#define    foo
or
#define    foo    something
     
Do either of these work with
#if    squat||foo
?  I doubt it, since the #if is a *numeric* if.
     
    John Owens @ General Electric Company    (+1 804 978 5726)
    edison!jso%virginia@CSNet-Relay.ARPA        [old arpa]
    edison!jso@virginia.EDU                [w/ nameservers]
    jso@edison.UUCP                    [w/ uucp domains]
    {cbosgd allegra ncsu xanth}!uvacs!edison!jso    [roll your own]

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9055
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:33:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001015; 12 Jul 86 4:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024668; 12 Jul 86 3:44 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Yet another ALIGN idea.
Message-ID: <2355@umcp-cs.UUCP>
Date: 12 Jul 86 04:14:04 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2600066@ccvaxa> aglew@ccvaxa.UUCP writes:
>Since an alignment constant doesn't necessarily work, how about an
>alignmentof(object) operator, analagous to sizeof()? At least that'll work
>on all architectures that have alignments based on multiples.
     
I think this can still be implemented with a common header file, e.g.,
     
    #define OFFSET_TO_ALIGN(ptr)    /*something*/
    #define    IS_ALIGNED(ptr)    (OFFSET_TO_ALIGN(ptr) == 0)
     
On a Vax, and purely for efficiency, /*something*/ is
     
    #define    OFFSET_TO_ALIGN(ptr)    ((4 - (int) (ptr)) & 3)
     
On a Pyramid, the same `define' works; on a Sun, it can be reduced to
     
    #define    OFFSET_TO_ALIGN(ptr)    ((int) (ptr) & 1)
     
On your hypothetical machine, /*something*/ may be
     
    #define    OFFSET_TO_ALIGN(ptr)    (_offset_to_align(sizeof *(ptr)))
     
where _offset_to_align is a library function.
     
(N.B.: That it *can* be done this way does not mean that it *must*
be done this way.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8952
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:26:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001011; 12 Jul 86 4:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024605; 12 Jul 86 3:43 EDT
From: Silver <gaynor@topaz.ARPA>
Newsgroups: net.lang.c
Subject: Re: '=' vs '<-' vs '.ne' vs '==' vs ':=' vs '.eq.' vs ...
Message-ID: <5321@topaz.RUTGERS.EDU>
Date: 12 Jul 86 03:16:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[ Viewer discretion is advised.  The following ]
[ material may be found offensive...           ]
     
Frank Adams (franka@mmintl.UUCP) writes:
     
> The problem is that "<-" is a legal sequence of operators.  Consider
> "if (x<-1) { ...}".
     
I never said that I was specifying C operators.  What I posted was a
list of how I PREFER the operators, not necessarily how I have them in
any given language.  I assume that there are textual replacement and
definition mechanisms in C strong enough to allow me to have things
the way I want them.  (I've seen the 'pig' prefix thrown around quit a
bit.)  You see, I know very little C, and, from what I've seen, I
don't like it very much.  However, it IS a powerful algorithmic
language, no doubt.  The operators in question upon which I posted are
are the ones I generally use when writing pseudo.
     
The main reason I read this newsgroup is not because I like the penny-
ante discussions that are raged on the obscure and system-dependant
features (bugs?) of C.  It just happens that some topics which better
belong in net.lang are discussed here.  As far as languages go, I
think K&R left much to be desired in the overall design of C.
     
I don't care to be flamed, by the way, for holding an opinion.  Just
to give an indication of where they'll be routed to.  This does not
mean that I'm closed to discussion - just melee.
     
     
                         _   /|
                         \`o_O'
                           ( )   Aachk! Phft!
                            U
     
Disclaimer: The opinions and/or information and/or code expressed
            here were generated by this characature, stolen from
            Dave Rasmussen, to which I have taken the liberty of
            adding ears.  So don't look to me for a disclaimer!
     
Silver  {...!topaz!gaynor}
     
ps I disclaim all the views above for Dave Rasmussen.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9840
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 05:36:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001417; 12 Jul 86 6:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025641; 12 Jul 86 5:41 EDT
From: Helmut Golde <golde@UW-BEAVER.ARPA>
Newsgroups: net.lang.c
Subject: Compiler Specific Operators
Message-ID: <1825@uw-beaver>
Date: 11 Jul 86 06:18:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
.
    What do people think about allowing compilers to have their own
compiler/machine specific operators, in a standardized format.  I think
it might be very useful to allow a compiler to have a non-portable operator
to do something that might be very efficient in machine code, but is not
provided for by C.
     
I propose that the standardized format $op-name$ be used for these operators.
     
I realize that these would be inherently unportable, but sometimes you
*KNOW* what you are doing will never be ported and you don't want to
switch to assembler or write a vert inefficient function.
     
A couple of examples follow:
     
1.  More bit-manipulation routines, such as:
   a $rol$ b ::= rotate a left b bits
   a $ror$ b ::= rotate a right b bits
   a $bit$ b ::= value of b'th bit of a
     
These would of course be usable as part of an assignment operator such as:
     
a $rol$= 5;    /* rotate a left 5 bits */
     
These instructions are provided by MANY processors and are a pain to
emulate in C.
     
2. Fast string/buffer routines.
     
Some processors provide a very fast instruction(s) for copying data from
one address to another.  Providing built-in ternary operators for this
would be convenient in some cases:
     
   d $copy$ s : n ::= given that s and d are both <type> pointers,
                      copies n <type>s from s to d.
              (produces the value d)
     
   one could then write
#define memcpy(d,s,n) ((d) $copy$ (s) : (n))
   and
#define strcpy(d,s) ((d) $copy$ (s) : strlen(s)+1)
     
etc.
     
3. Built in math functions
     
If the processor has more than the standard +,-,/,* operators (esp. for
floating point), it would be more efficient to have built it operators
that to perform function calls.  Things like:
     
$pow$, $sin$, $exp$, $log$, $atan$, etc.
     
#define's could make these quite portable without sacrificing the speed
advantage.
     
     
Well, what think you?  Worth it or not?
     
-----------------------------
     
Peter Golde
     
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8845
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 03:17:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001002; 12 Jul 86 4:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024567; 12 Jul 86 3:42 EDT
From: kenny@uiucdcsb.ARPA
Newsgroups: net.lang.c
Subject: Re: RRe: What's so good about FORTH
Message-ID: <139200032@uiucdcsb>
Date: 11 Jul 86 01:05:00 GMT
Nf-ID: #R:boring.mcvax.UUCP:6993:uiucdcsb:139200032:000:2431
Nf-From: uiucdcsb.CS.UIUC.EDU!kenny    Jul 10 20:05:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
/* Written 10:55 pm  Jun 28, 1986 by lambert@mcvax.UUCP in uiucdcsb:net.lang.c
 */
/* ---------- "Re: RRe: What's so good about FORTH" ---------- */
In article <255@myrias.UUCP> mj@myrias.UUCP (Michal Jaegermann) writes:
     
> The fact that Forth is "threaded" is not a part of a language definition but
> side-effect of the most popular implementation method.  [...]  The method
> is far from beeing unique to Forth and there are some Forth implementations
> which are not exactly "threaded".  [...]  An extreme case is to have the
> whole Forth as a huge 'case' statement in C.  (Yes, I have seen something
> like that :-) ).
     
How else can you implement threading if C is used as the implementation
language?  (Or is that what the smiley is for?)  In other languages the
obvious implementation would be to have each code fragment (for interpreting
a "word") switch to the interpretation of the next word by having it end on
     
    goto *(IC++)
     
(or goto *(++IC), depending on your and your machine's taste).  But labels
are not a C type: you can only goto a constant label, not to a label
expression.  So the closest you can get--as far as I can see--is to have
this huge switch
     
    while (1) switch (*(IC++)) {
    case word1: ...; break;
    case word2: ...; break;
    ...;
    }
     
This is almost as efficient, but not quite: you loose a few cycles in the
jump taken at each break.  Also, you had better make sure that the words
are contiguous numbers so that good code is produced for the switch.
(Instead of break you can use continue.  In the assembler output of cc this
is one jump less, but compiled with -O, at least on our cc, the extra jump
is optimized away anyway and the resultant object files are identical.)
     
Are there other ideas on implementing threading in C?
     
--
     
     Lambert Meertens
     ...!{seismo,okstate,garfield,decvax,philabs}!lambert@mcvax.UUCP
     CWI (Centre for Mathematics and Computer Science), Amsterdam
/* End of text from uiucdcsb:net.lang.c */
     
Is there something wrong with
     
int ((*foo) ()) [] = {
    ... list of code addresses for threaded primitives ...
    }
     
int IP;
     
...
     
for (;;) (* (foo [IP++])) ();
     
That's how I'd do it.
     
 ()    /\   .-.-.   /\    Kevin Kenny
()()  <  >   \ /   (__)    University of Illinois at Urbana-Champaign
 /\    \/     V     /\    UUCP: {ihnp4,pur-ee,convex}!uiucdcs!kenny
"When in doubt,        CSNET: kenny@UIUC.CSNET
    lead trumps."    ARPA: kenny@B.CS.UIUC.EDU (kenny@UIUC.ARPA)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0002
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 05:42:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001420; 12 Jul 86 6:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025700; 12 Jul 86 5:43 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <2364@umcp-cs.UUCP>
Date: 12 Jul 86 05:58:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1825@uw-beaver> golde@uw-beaver.UUCP (Helmut Golde) writes:
>What do people think about allowing compilers to have their own
>compiler/machine specific operators, in a standardized format.
     
The current ANSI C draft standard (or at least the last one I saw)
allows this in a different way, which I will explain later.
     
>I propose that the standardized format $op-name$ be used for these
>operators.
>
>I realize that these would be inherently unportable, but sometimes you
>*KNOW* what you are doing will never be ported and you don't want to
>switch to assembler or write a vert inefficient function.
>
>A couple of examples follow:
>
>1.  More bit-manipulation routines, such as:
>   a $rol$ b ::= rotate a left b bits
>   a $ror$ b ::= rotate a right b bits
>   a $bit$ b ::= value of b'th bit of a
     
(The last example is perhaps not so good: (a & (1 << b)) is both
equivalent and portable.)
     
>These would of course be usable as part of an assignment operator such as:
>
>a $rol$= 5;    /* rotate a left 5 bits */
     
This is not provided in ANSI C, as we shall soon `C'.  (Sorry)
     
>These instructions are provided by MANY processors and are a pain to
>emulate in C.
>
>2. Fast string/buffer routines.
     
[memory copy, fill, etc.]
     
>3. Built in math functions
     
An ANSI-conforming C compiler can implement memcpy(), log(), sin(),
etc. inline by `tricky' use of `define's.  This could be extended
to functions like `rol(a, b)'.  Here is an example of how this may
be implemented:
     
    /* extract from <math.h> */
    double    sin(double x);        /* declare the real function */
    double    _builtin_sin(double x);    /* and the compiler version */
    #define    sin(x)    _builtin_sin(x)    /* default to the compiler version
 */
     
    /* extract from user file */
    #include <math.h>
    ...
        y = sin(x);
    ...
     
which of course expands to
     
        y = _builtin_sin(x);
     
and the compiler is free to handle this as it wishes.  The draft
standard emphasises that
     
    #undef sin
     
guarantees that a function call, not an inline expansion, will be
used.
     
Note that this has some, er, `interesting' implications:
     
    #include <math.h>
     
    double
    subr(double (*fp)(double arg)) {
     
        return ((fp)(3.1415926535897932384626433832795));/* approx */
    }
     
    strange() {
     
        ... subr(sin) ...    /* NOW what? */
    }
     
This seems to call subr(_builtin_sin).  The draft standard says that
because `sin' appears here without a following `(', it is not macro-
expanded; thus this in fact passes the address of the library function.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0900
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 07:42:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001909; 12 Jul 86 8:32 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a026767; 12 Jul 86 8:18 EDT
Date:     Sat, 12 Jul 86 8:16:02 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Helmut Golde <golde@UW-BEAVER.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Compiler Specific Operators
Message-ID:  <8607120816.aa15675@VGR.BRL.ARPA>
     
What most implementations that support such machine-specific operations
do is have the compiler recognize apparent function names and generate
the appropriate machine-specific code instead of a function call.  E.g.
    _rol( a, b );    /* generates code to rotate a left b bits */
This approach has the advantage of fitting into the existing language
syntax, so that other tools for dealing with C (lint, ctrace, cxref,
cpp, etc.) aren't affected.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0506
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 07:08:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001708; 12 Jul 86 8:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026362; 12 Jul 86 7:42 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <5780@alice.uUCp>
Date: 12 Jul 86 03:56:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>    What do people think about allowing compilers to have their own
> compiler/machine specific operators, in a standardized format.  I think
> it might be very useful to allow a compiler to have a non-portable operator
> to do something that might be very efficient in machine code, but is not
> provided for by C.
     
> I propose that the standardized format $op-name$ be used for these operators.
     
C already has a hook for such things.  It's called the "asm" statement.
Despite its name, there is no law that says that what follows "asm"
must in fact be assembly language.  If you're writing the compiler,
you can implement whatever syntax you like with whatever semantics you like.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1593
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 08:49:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002365; 12 Jul 86 9:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027169; 12 Jul 86 9:24 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2152@brl-smoke.ARPA>
Date: 12 Jul 86 13:24:48 GMT
Followup-To: net.math
To:       info-c@BRL-SMOKE.ARPA
     
In article <3147@jhunix.UUCP> ins_apmj@jhunix.ARPA (Patrick M Juola) writes:
>    You've never seen the statements at the beginning of proofs, where
>they assign properties to variables....  If you want to assign to vector
>z the length of 1, you write "|z|=1."  Or at least I do.  How do you do it?
     
Much as I hate to continue this totally bogus discussion,
I really have to point out that |z|=1 is not any sort of
an assignment.  Usually it is seen in a context such as
"assume |z|=1; then..." which is a Boolean use of = as a
relational operator.
     
But this has nothing to do with C and should move to net.math,
if you really want to discuss meaning of symbols in mathematics.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0635
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 07:19:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001818; 12 Jul 86 8:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026435; 12 Jul 86 7:44 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: <-
Message-ID: <2365@umcp-cs.UUCP>
Date: 12 Jul 86 06:02:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <5282@topaz.RUTGERS.EDU> gaynor@topaz.UUCP writes:
>>ASSIGNMENT  <-
     
In article <1631@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) replies:
>The problem is that "<-" is a legal sequence of operators.  Consider
>"if (x<-1) { ...}".
     
DIVISION    /
INDIRECTION    *
     
The problem is that /* is a legal sequence of operators.  Consider
     
    int r, i, *ip; r = i/*p;
     
As usual, if there is some kind of ambiguity, pick a disambiguator.
     
(This is not intended to imply that I think `<-' is a good assignment
operator.  On the other hand, the preceding sentence is not intended
to imply that I think `<-' is a bad assignment operator.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0756
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 07:28:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001836; 12 Jul 86 8:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026459; 12 Jul 86 7:45 EDT
From: Don Libes <libes%nbs-amrf.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: <- vs =.  Naming atoi().
Message-ID: <360@nbs-amrf.UUCP>
Date: 11 Jul 86 05:53:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Ok, so we blew it by omitting a left arrow from ASCII.  How about
making the following legal:
     
    a <- 3;        /* assignment */
    if (a = 3) ...  /* test for equality */
     
Oh, sorry.  Can't screw with C.  D, maybe.
     
I'd also like to point out that we need a symbol to represent "to".
I really tired of seeing things like:
     
    atoi();
    foo_to_bar();
    foo_2_bar();
    Foo2Bar();
    a2z();
     
and all the permutations of these (all of which I see in code).
Let's make a standard on how to name "x to y" functions.  I'd opt
for something like
     
    a->b()
     
where -> is a single character in the character set.  (Hey, as long
as we're redesigning it for <- (not to mention all those
international characters)...)
     
Any better (god I hope so) suggestions.  This is really a topic of
vital importance (as I had to write one of these stupid functions
this morning and I was in a quandary as how to name it).
     
Please do not mail to me.  (I refuse to waste my time summarizing
responses on such a silly topic.)
     
Don Libes       {seismo,umcp-cs}!nbs-amrf!libes

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0812
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 07:34:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001841; 12 Jul 86 8:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026468; 12 Jul 86 7:45 EDT
From: Stanley Friesen <friesen%psivax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a
  bug?
Message-ID: <1329@psivax.UUCP>
Date: 9 Jul 86 22:47:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3783@reed.UUCP> kab@reed.UUCP (Kent Black) writes:
>
>Oh, am I in over my head. . .
>
>If a (char *) can reference any `byte' of memory, and a (long *) can
>can only reference, as example, even number word addresses, then to have
>the compiler correctly cast a char * to a long * would mean it rearranged
>your data for you.  In particular, an array of characters would have to
>be remade into an array of longs with the apropriate (high or low) byte
>holding the character.  Is this all wrong?
     
    Yes, the  purpose of the cast is to allow you to look at your
array of char(or whatever) *as if* it were an array of longs. It would
defeat the purpose of the cast if the compiler rearranged the memory
for you!
>
>But do you *really want* to cast a char pointer to a long pointer just
>to dereference and return the value?  The example seems to instead call
>for dereferencing the char * and casting the value as a long, e.g.,
>        return (long) *cp;
>
    No, this does something completely different. This reads a
single byte from memory, *extends* it to a long and returns the
result. On the other hand
        return *(long *)cp;
     
reads a long from memory and returns it. That is it sort of acts like
a union and allows you to look at the same piece of memory as having
different types.
--
     
                Sarima (Stanley Friesen)
     
UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ??

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0710
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 07:24:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001832; 12 Jul 86 8:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026439; 12 Jul 86 7:45 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Re: WITH statement
Message-ID: <2366@umcp-cs.UUCP>
Date: 12 Jul 86 06:20:19 GMT
Followup-To: net.lang
To:       info-c@BRL-SMOKE.ARPA
     
In article <1003@zog.cs.cmu.edu> dlc@zog.cs.cmu.edu (Daryl Clevenger) writes:
>   I dislike Pascal as much as the next C hacker, but one feature
>that could be useful to add to C is something akin to the Pascal
>"WITH" statement. ... By using such a construct, one avoids long
>statements when using deeply nested structures/unions or the kludgy
>method of using defines.
     
I never did like `with'.  I would like it a lot more if . . . well,
let me see if I can construct a good bad example first.
     
    type
        x = record ... end;
        y = record ... end;
        z = record ... end;
     
    var
        foo : x;
        zarog : y;
        prullo : z;
     
    { several hundred pages of code }
     
        with foo, zarog, prullo do begin
            ...
            { next three statments use fields }
            snert := 5 * bazzi;
            bibble := 10;
            roj := klewp mod snert;
            ...
        end;
        ...
     
To which variables do those fields refer?
     
If `with' is intended as shorthand, I would like to see it used
in more this way:
     
        with a = foo, b = zarog, c = prullo do begin
            ...
            b.snert = 5 * a.bazzi;
            c.bibble := 10;
            a.roj := c.klewp mod b.snert;
     
Note that this allows member name `collisions' to be disambiguated:
     
            b.snert = 5 * a.bazzi;
            c.bibble := 10;
            a.roj = c.klewp mod a.snert;
     
---if that is in fact what is meant.
     
(I have a feeling that `WITH' originally meant `Listen, compiler,
put a pointer to this here record into a machine register now,
because I am about to use it a whole bunch.')
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1670
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:38 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/12/86 at 08:50:48 CDT
Received: from csvax.caltech.edu by SRI-KL.ARPA with TCP; Thu 10 Jul 86
  23:40:24-PDT
Received: by csvax.caltech.edu (5.31/1.2)
    id AA17594; Thu, 10 Jul 86 23:40:37 PDT
Message-Id: <8607110640.AA17594@csvax.caltech.edu>
Date: Thu, 10 Jul 86 12:45:21 PDT
From: Kevin Carosso <engvax!KVC@csvax.caltech.edu>
Subject: This VMS/FORTRAN flaming
To: cit-vax!info-vax@sri-kl.arpa
     
> At that instant, I began hating my system manager (and DEC) for his
> incredible blindness towards modern programming techniques.  Well,
> he is gone now (although our current system manager also codes
> exclusively in Fortran) but every time I open that book to look at
> examples, I still see Fortran.
     
Oh come on!  Enough of this bullshit please.  Take a look at the C manual
for C examples.  Take a look at the Pascal manual for Pascal examples.
Take a look at the goddamn COBOL manual for Christ's sake if you want
COBOL examples!!!!
     
If your system manager (or anyone else) WANTS to use FORTRAN, then that's
his prerogative.  At least the system gives you a CHOICE of languages.
I find it incredibly offensive that any system or any person should force
me to use any particular language, whether that language be C or BASIC.
     
Give it a rest already...
     
    /Kevin Carosso          engvax!kvc @ csvax.caltech.edu
     Hughes Aircraft Co.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1397
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 08:36:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002303; 12 Jul 86 9:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027094; 12 Jul 86 9:15 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: (Really addressing inside struct)
Message-ID: <2151@brl-smoke.ARPA>
Date: 12 Jul 86 13:14:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <403@anasazi.UUCP> john@anasazi.UUCP (John Moore) writes:
-struct links {
-   struct links *forward;
-   struct links *backward;
-};
-
-struct foo {
-   char bar;
-   struct links snake;
-   struct whocares junk;
-   struct links lizard;
-};
-
-struct links *reptile;
-
-Assume that reptile points to the lizard structure of a "foo" structure.
-What construct allows one to do the following:
-
-struct foo *iwish = (mystery function of reptile);
-
-Example of a wrong solution:
-struct foo *iwish = (struct foo *)((char *)reptile + (char *)0->lizard);
     
This is rather a strange way to do business, but I can answer the question:
There is no guaranteed way to do what you're trying to do, therefore there
should be no way to keep "lint" from complaining.  However, the following
should work for most C implementations:
     
struct foo dummy;
#define    LIZ_OFFSET    ((char *)&dummy.lizard - (char *)&dummy.bar)
struct foo *iwish = (struct foo *)((char *)reptile - LIZ_OFFSET);
     
What I would recommend instead is that you keep a pointer to the whole
(struct foo) rather than to the lizard member, if your application permits.
(You might need to add a (struct foo *) member to (struct links).)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1783
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 09:01:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002438; 12 Jul 86 9:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027337; 12 Jul 86 9:40 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: Another printf-type question
Message-ID: <2153@brl-smoke.ARPA>
Date: 12 Jul 86 13:40:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2138@brl-smoke.ARPA> LINNDR%VUENGVAX.BITNET@WISCVM.ARPA writes:
>invprintf(fmt,args)
>{
>        printf(<string to go into inverse video mode>);
>        printf(fmt,args);
>        printf(<string to leave inverse mode>);
>}
>
>This simple solution didn't work. Oh great gurus of such things, what
>should I have done?
     
Assuming you're using UNIX System V Release 2.0 for sake of concreteness,
     
#include    <stdio.h>
#include    <varargs.h>
     
void
invprintf( va_alist )
    va_dcl
    {
    char    *fmt;            /* printf control string */
    va_list    args;            /* argument pointer */
     
    (void)fputs( "string to enter inverse video mode", stdout );
     
    va_start( args );
     
    fmt = va_arg( args, char * );
     
    (void)vprintf( fmt, args );    /* warning! not printf(va_arg etc. */
     
    va_end( args );
     
    (void)fputs( "string to leave inverse video mode", stdout );
    }
     
The final mechanism of ANSI X3J11 will probably be slightly different.
     
P.S.  You should perhaps also test whether the write to the terminal succeeds.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4948
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 15:19:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004477; 12 Jul 86 16:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029934; 12 Jul 86 15:41 EDT
From: emjej%uokvax.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <3000080@uokvax.UUCP>
Date: 10 Jul 86 14:08:00 GMT
Nf-ID: #R:brl-smoke.ARPA:1645:uokvax.UUCP:3000080:000:1294
Nf-From: uokvax.UUCP!emjej    Jul 10 09:08:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
/* Written  8:15 pm  Jul  3, 1986 by MEYER@RADC-TOPS20.ARPA in net.lang.c */
     I know this is going to cause a bit more of a stir here, here goes.
     
Everybody keeps guessing at the reasons for the use of = for asignment
and == for equality tests.  How about a different angle: how many times
in a program do you assign something versus how many times you compare things?
/* End of text from net.lang.c */
     
If that's a reasonable principle of programming language design, then
let's see if we can't get Huffman-coding for C keywords in the next ANSI
draft standard.
     
= for assignment is one of many flaws in C syntax.  Combined with the
absence of a Boolean type, it is a considerable source of errors in C
code.  Lint should warn the user of every occurrence of "if (a = b)".
     
(I predict that at least one C-worshipper will say "*real* C programmers,
as opposed to quiche-eaters, don't make that mistake."  I think they're
wrong, based on the instances of it I've seen.  Second-order comment
will be "you haven't done a study, so you're not worth bothering with":
I admit that I haven't, but (1) I lack the resources, and (2) it's too
bad the designers of programming languages (and Unix utilities) don't
have to do human factors studies before introducing their products.)
     
                    James Jones

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6123
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 17:39:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005038; 12 Jul 86 18:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000457; 12 Jul 86 17:40 EDT
From: Andrew Hume <andrew%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <5783@alice.uUCp>
Date: 12 Jul 86 14:38:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I don't understand. If you personally have a problem handling the token '=',
don't lay it on everyone else. Getting lint to complain about it is fine by me;
I don't use lint. However, the poor sods who do might (should) object.
There is nothing wrong with this sort of code:
    char *s, *getword();
     
    while(s = getword()){
        ...
    }
The more noise lint puts out, the less use it is.
It seems to me you can solve YOUR problems by a preprocessor sed script.
Modifying the C language to avoid this sed step to solve learning
disabilities for a small set of users seems incorrect.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6180
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 17:40:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005032; 12 Jul 86 18:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000400; 12 Jul 86 17:40 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: #if foo vs #if defined(foo)
Message-ID: <344@brl-sem.ARPA>
Date: 12 Jul 86 19:10:37 GMT
Keywords: Sys 5.2
To:       info-c@BRL-SMOKE.ARPA
     
In article <379@twitch.UUCP>, grt@twitch.UUCP ( G.R.Tomasevich) writes:
> Our compiler does not need a defined(), or at least I did not try whether
> it is even accepted.  The following example works fine:
>
> #if squat||foo
     
Consider an optionally included definition
     
#define    SQUAT    0
     
If your code really wanted to check for this then the proper
test would be
     
#if defined(SQUAT) && (squat == 0)
     
to differentiate between undefined SQUAT and SQUAT defined but
equal to zero.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6796
          for JMS@ARIZMIS; Sat, 12-JUL-1986 17:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 19:27:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005468; 12 Jul 86 20:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001100; 12 Jul 86 19:41 EDT
From: Mark Nagel <u557676751ea%ucdavis.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: WITH statement in C
Message-ID: <423@ucdavis.UUCP>
Date: 12 Jul 86 18:17:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
>      I dislike Pascal as much as the next C hacker, but one feature that could
> be useful to add to C is something akin to the Pascal "WITH" statement.  Since
> I haven't seen or read X3J11, I don't know if any new features are being added
> to the language.  By using  such a construct, one avoids long statements when
> using deeply nested structures/unions or the kludgy method of using defines.
> I would mail this to a committee member, but I don't the address of any and
> I figure one of them will probably read this.  In general, I don't advocate
> adding new features to a language (after all, eventually it just turns into
> creeping featurism :-), but some improvements are O.K.  I know everybody
> seems that they want some pet construct/function/option in the ANSI standard,
> so I'm no better than anyone else.  I'm only curious as to why nobody has
> mentioned the desire for this construct (or bitched about its abscence :-)
>
> Daryl Clevenger
>
> P.S.
>     I am not a frustrated Pascal user either, I detest the language.
>     Also, no complete signature line, since I have no idea what the path
>     to my site is through UUCP or anything but direct ARPA mail.
     
     
How about this?
     
    {
    someptr *foo;
     
        foo = &(incredibly->long->and->complicated->nested->structure);
        foo->bar = 0;
        foo->bar2 = x;
        .
        .
        .
    }
     
     
     
- Mark Nagel
     
ucdavis!u557676751ea@ucbvax.berkeley.edu               (ARPA)
...!{dual|lll-crg|ucbvax}!ucdavis!deneb!u557676751ea   (UUCP)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8591
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 01:23:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006986; 13 Jul 86 2:14 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a002449; 13 Jul 86 2:01 EDT
Received: from nosc.arpa by AOS.BRL.ARPA id a006903; 13 Jul 86 1:59 EDT
Received: by bass.ARPA (5.31/4.7)
    id AA03483; Sat, 12 Jul 86 22:56:44 PDT
Received: by cod.ARPA (5.31/4.7)
    id AA04196; Sat, 12 Jul 86 22:56:42 PDT
Message-Id: <8607130556.AA04196@cod.ARPA>
Date: Sat, 12 Jul 86 22:41:49 PDT
From: Jerry Fountain <crash!pnet01!gof@NOSC.ARPA>
To: crash!noscvax!info-c@BRL.ARPA
Subject: Microsoft MSC 4.0
     
Has anybody heard anything about the new Microsoft 'C' Compiler 4.0?  I am
considering upgrading from 3.0 but I would like to know if its worth it
($150 for an upgrade is a bit steep in my opinion but...).  Does it include
source?  What about the new debugger?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7525
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 21:06:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005856; 12 Jul 86 21:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001516; 12 Jul 86 21:41 EDT
From: "Eugene D. Brooks III" <brooks@LLL-CRG.ARPA>
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <3522@lll-crg.ARpA>
Date: 13 Jul 86 00:11:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>= for assignment is one of many flaws in C syntax.  Combined with the
>absence of a Boolean type, it is a considerable source of errors in C
>code.  Lint should warn the user of every occurrence of "if (a = b)".
Not a bad idea.  I don't write this as a matter of policy and I would
not mind lint giving a warning.  You could even have a flag control it.
>
>(I predict that at least one C-worshipper will say "*real* C programmers,
>as opposed to quiche-eaters, don't make that mistake."  I think they're
It is true that real programmers don't make mistakes and don't eat
quiche either.  It has nothing to do with C.
     
Real programmers don't spend their time complaining about using = for
assignment either.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7654
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 21:35:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005976; 12 Jul 86 22:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001506; 12 Jul 86 21:40 EDT
From: Barry Margolin <barmar@mit-eddie.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <2526@mit-eddie.MIT.EDU>
Date: 12 Jul 86 18:37:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Rather than inventing operators that are known to be unportable, why not
write the operations as function calls, and teach compilers to open-code
calls to certain functions.  You would, of course, need compiler
directives to override this, in case you are planning on linking the
program with a different version of the library function.
     
Fortran, PL/I, and Lisp compilers have been doing this for years.  Just
because something is written as a function call does not mean that it
has to be implemented as one.
--
    Barry Margolin
    ARPA: barmar@MIT-Multics
    UUCP: ..!genrad!mit-eddie!barmar

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0282
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 05:28:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007917; 13 Jul 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003634; 13 Jul 86 5:41 EDT
From: Rick Richardson <gemini%homxb.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: WITH statement in C
Message-ID: <1792@homxb.UUCP>
Date: 12 Jul 86 15:31:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>      I dislike Pascal as much as the next C hacker, but one feature that could
> be useful to add to C is something akin to the Pascal "WITH" statement.
>
> Daryl Clevenger
     
    I like this feature too, if for no other reason than: it reduces the
    possibilities of having to look at someones code which is wider than
    80 columns on a display with only 80 columns.  (There are still a lot
    of 132 column junkies out there who like to carry around those massive
    tomes of output.)
     
    The only serious Pascal program I ever wrote was 3-Demon, which many
    of you may have seen on RBBS's (well serious in size, not in function!).
     
    I recall only two joys in using the language: the opportunity to
    use a WITH statement, and the Microsoft-ism of allowing '[' and ']'
    as synonyms for BEGIN and END.
     
Rick Richardson, PC Research, Inc. (201) 922-1134, (201) 834-1378 @ AT&T-CP
..!ihnp4!castor!{rer,pcrat!rer} <--Replies to here, not to homxb!gemini, please.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9100
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 03:09:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007375; 13 Jul 86 4:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002713; 13 Jul 86 3:41 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Re: Precedent for use of =
Message-ID: <5057@sun.uucp>
Date: 12 Jul 86 19:50:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Hey, you can use assignment in C as if it were a statement only when you
> write YOUR C code, but in the example that you give its used in its full
> power as an operator, which can generate much more efficient code than
> the equivalent:
>
> a=b
> if (b)
     
If your compiler can't generate equally efficient code for
     
    a = b;
    if (a != 0)
     
and
     
    if ((a = b) != 0)
     
on any machine other than an incredibly weird one, then your compiler needs
to be improved.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7479
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 21:04:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005844; 12 Jul 86 21:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001512; 12 Jul 86 21:40 EDT
From: "Eugene D. Brooks III" <brooks@LLL-CRG.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <3519@lll-crg.ARpA>
Date: 13 Jul 86 00:03:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>C already has a hook for such things.  It's called the "asm" statement.
>Despite its name, there is no law that says that what follows "asm"
>must in fact be assembly language.  If you're writing the compiler,
>you can implement whatever syntax you like with whatever semantics you like.
It would be nice if asm was more "printf like" instead of just dumping
a string.  I have made quite a lot of use of asms when writing things like
multitasking packages and other things which need assembler hooks.  Most
of the code can be in C and be reasonably portable.  I have often needed
the ability to stick a stack address in an asm without knowing just what
stack address you want to load...
     
ie
     
suppose you want to change the stack pointer...
     
    char *oldpointer;
    char *newpointer;
     
    asm("store sp,%a", oldpointer);
    asm("load sp,%a", newpointer);
     
The code is machine dependent, but the compiler takes care of the
C name -> AS name  mapping for you.   Of course I guess the compiler
should not encourage such screwing around.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9198
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 03:20:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007395; 13 Jul 86 4:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002757; 13 Jul 86 3:43 EDT
From: Roy Smith <roy%phri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <2386@phri.UUCP>
Date: 12 Jul 86 18:36:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1825@uw-beaver> golde@uw-beaver.UUCP (Helmut Golde) writes:
     
> What do people think about allowing compilers to have their own
> compiler/machine specific operators, in a standardized format. [...]
> a $rol$= 5;    /* rotate a left 5 bits */
     
    If you want to do that sort of stuff (gross, but admitedly sometimes
worth the big efficiency win), what's wrong with the following?
     
# ifdef MY_FAVORITE_CPU
asm ("rol a, #5");    /* Use nifty built-in rotate left instruction */
# elseif
a = rol_func (a);    /* Don't have that instruction? do it in software */
# endif
     
    If you wanted to be cynical, you could always claim that we already
do have exactly what you are talking about :-)
     
    a <<= 5;    /* use nifty pdp-11 shift-left instruction */
    b = *--p;    /* use nifty pdp-11 auto-decrement mode */
--
Roy Smith, {allegra,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9891
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 05:10:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007833; 13 Jul 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003647; 13 Jul 86 5:41 EDT
From: David Shoat <shoat%glasgow.glasgow.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pig C
Message-ID: <644@glasgow.glasgow.UUCP>
Date: 11 Jul 86 16:27:08 GMT
Posted: Fri Jul 11 16:27:08 1986
To:       info-c@BRL-SMOKE.ARPA
     
> In article <249@sdchema.sdchem.UUCP> tps@sdchema.UUCP (Tom Stockfisch) writes:
> > In article <6874@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes:
> >> ...  If you can read English you can read Pig Latin,
> >> but nobody would tolerate documentation written in Pig Latin...
> > This is such a great analogy, with Henry's permission I would like to coin
> > the term
> >
> >     Pig C
> >
> > to refer to C code [...] which effectively redefines the language.
>
> I like this.  Also, if someone writes pseudo C code, you could call it
>
>        Pigskin C
>
> since it's only skin-deep (like, Pigskin Algol).
>
> --
>
>      Lambert Meertens
>      ...!{seismo,okstate,garfield,decvax,philabs}!lambert@mcvax.UUCP
>      CWI (Centre for Mathematics and Computer Science), Amsterdam
     
    This could start a craze. Truly appalling code which offends even
    the hardened C programmer could be called "Pigshit C".

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9747
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/13/86 at 04:34:31 CDT
Received: from ucbvax.Berkeley.EDU by SRI-KL.ARPA with TCP; Sat 12 Jul 86
  14:55:11-PDT
Received: by ucbvax.Berkeley.EDU (5.52/1.14)
    id AA04770; Sat, 12 Jul 86 14:55:09 PDT
Received: by sdcsvax.ucsd.edu (5.31/4.42)
    id AA09467; Sat, 12 Jul 86 13:31:38 PDT hops=0
Received: by caip.rutgers.edu; Fri, 11 Jul 86 19:11:09 edt
Received: from ut-sally.UUCP by seismo.CSS.GOV with UUCP; Fri, 11 Jul 86
  17:29:13 EDT
Posted-Date: Fri, 11 Jul 86 09:50:14 cdt
Received: by sally.UTEXAS.EDU (4.22/4.22)
    id AA02683; Fri, 11 Jul 86 09:53:11 cdt
Received: by oakhill.UUCP (4.12/4.7)
    id AA22244; Fri, 11 Jul 86 09:50:14 cdt
Date: Fri, 11 Jul 86 09:50:14 cdt
From: sdcsvax!caip!seismo!ut-sally!oakhill!tomc@ucbvax.Berkeley.EDU (Tom
  Cunningham)
Message-Id: <8607111450.AA22244@oakhill.UUCP>
To: ucbvax!sri-kl.arpa!info-vax
Subject: VAX C/VMS questions
     
Some questions about VMS and VAX C:
     
1)  Is there an equivalent of /dev/null ("bit bucket") on VMS?
     
2)  Are there any routines available written in C that facilitate
    wildcard filename expansion from within a program running under
    VMS?  I have a case where the C program is invoked from DCL as
    a foreign command; thus no automatic wildcard expansion is done.
     
3)  I have a C program that was developed in a PC-DOS/Unix environment.
    I can "install" it on VMS as a foreign command and get access to
    command line arguments via argv (without DCL wildcard expansion,
    as stated above).  My assumption has been that to install the
    program in a more conventional way, I must use the Command Definition
    Utility to specify command line parameters and attributes, and then
    use RTL CLI$ calls to access the arguments, bypassing argc and argv.
    Is this assumption correct?
     
Thanks for any help/information you can give.
     
Tom Cunningham     "Good, fast, cheap -- select two."
{ihnp4,seismo,ctvax,gatech}!ut-sally!oakhill!tomc

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9145
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 03:12:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007390; 13 Jul 86 4:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002723; 13 Jul 86 3:42 EDT
From: Silver <gaynor@topaz.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <5330@topaz.RUTGERS.EDU>
Date: 13 Jul 86 06:01:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5057@sun.uucp>, guy@sun.uucp (Guy Harris) writes:
> If your compiler can't generate equally efficient code for
>
>     a = b;
>     if (a != 0)
>
> and
>
>     if ((a = b) != 0)
>
> on any machine other than an incredibly weird one, then your compiler needs
> to be improved.
     
Ideally, degrees of optimization should be available, offering
trade-offs between code-speed vs code-space vs compilation-time vs
code-size, and optional code generation, to name the biggies.  For
example, when debugging syntax errors, why waste time generating code
when all you want to do is check the syntax?  When verifying a
program's correctness, your not going to need really good code, just
something done quick-n-dirty (to save on system resources).  For
production, the trade-off of code-size vs code-speed rears its ugly
head (code-size is very important when, say, you try to port gnu-emacs
to a small computer).  I reiterate, this is the ideal situation.
     
     
                         _   /|
                         \`o_O'
                           ( )   Aachk! Phft!
                            U
     
Disclaimer: The opinions and/or information and/or code expressed
            here were generated by this characature, stolen from
            Dave Rasmussen, to which I have taken the liberty of
            adding ears.  So don't look to me for a disclaimer!
     
Silver  {...!topaz!gaynor}

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0155
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 05:19:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007838; 13 Jul 86 6:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003710; 13 Jul 86 5:43 EDT
From: der Mouse <mouse%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: SWAP macro
Message-ID: <454@mcgill-vision.UUCP>
Date: 12 Jul 86 07:10:01 GMT
Posted: Sat Jul 12 03:10:01 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <857@bu-cs.UUCP>, bzs@bu-cs.UUCP (Barry Shein) writes:
> And then again, there's always [...]
>
> #define swap(x,y,t) { \
>             t *p1 = &(x), *p2 = &(y), tmp; \
>  \
[...swap code...]
> Also, pointer types would have to be typedef'd to be useful as
> swap(x,y,char *) would not quite work (but w/ a typedef it works
> fine.)
     
     Because you wrote the declaration carelessly.  Should  work fine if
you write it as
    { \
     t *p1 = &(x);
     t *p2 = &(y);
     t tmp;
(assuming there are no side-effects in the type argument :-).   See, now
*I* always write declarations one declaration per variable, even writing
    int i;
    int j;
instead of
    int i,j;
This sort of thing is where the habit pays off (preen preen :-).
     
Now  you *still*  need  a  typedef  when  the  type involves  arrays  or
functions (such as a pointer to function, a  reasonable thing to want to
exchange).  I  suspect  there  is no  way  around  this, anyone  care to
produce a counterexample?
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     philabs!micomvax!musocs!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
        mcvax!seismo!cmcl2!philabs!micomvax!musocs!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8121
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 23:03:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006405; 12 Jul 86 23:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002136; 12 Jul 86 23:40 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <502@cubsvax.UUCP>
Date: 12 Jul 86 17:59:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <uw-beave.1825> golde@uw-beaver.UUCP (Helmut Golde) writes:
     
>3. Built in math functions
>
>If the processor has more than the standard +,-,/,* operators (esp. for
>floating point), it would be more efficient to have built it operators
>that to perform function calls.  Things like:
>
>$pow$, $sin$, $exp$, $log$, $atan$, etc.
>
>#define's could make these quite portable without sacrificing the speed
>advantage.
     
What does the draft standard say about things that look like function calls
actually being implemented otherwise?  Things a la FORTRAN's intrinsic
functions:  when I write y=SQRT(x) in FORTRAN, this looks just like any
other function call, but even UNIX's f77 doesn't generate a function call
(I believe), though as far as I know there's nothing in the FORTRAN77
standard to preclude this.  (Then again, I don't know much about the F77
standard.)
     
Unless there are good reasons not to do this, a given implementation of C
on some machine could actually implement log(x) without a function call --
by an instruction to a special-purpose processor, or even by software
generated by the compiler that runs on the cpu.  This would preclude the
need for any #defines.
     
Regardless of what the draft standard might say, what do the net guru's feel
about this?
     
Even if it turns out to be a bad idea, there ought to be a more system-
independent way than #defines of specifying things -- like a compile-time
option to perform math library "functions calls" by some other means, if
the other means exist .  This option need only exist on the machines where
the other means exist....   The use of #defines means either that the writer
has to worry about such exigencies when he's developing the code, or else
that the porter (not in the railroad-terminal sense!) has to worry about
going into the code and adding lines.
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0358
          for JMS@ARIZMIS; Sun, 13-JUL-1986 13:55 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/13/86 at 05:29:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007857; 13 Jul 86 6:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003761; 13 Jul 86 5:45 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <1054@ttrdc.UUCP>
Date: 13 Jul 86 00:32:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2364@umcp-cs.UUCP>, chris@umcp-cs.UUCP (Chris Torek) writes:
>    /* math.h */
>    double    _builtin_sin(double x);    /* and the compiler version */
>    #define    sin(x)    _builtin_sin(x)    /* default to the compiler version
 */
>...
>Note that this has some, er, `interesting' implications:
>    #include <math.h>
>    double
>    subr(double (*fp)(double arg)) {
>
>        return ((fp)(3.1415926535897932384626433832795));/* approx */
>    }
>    strange() {
>
>        ... subr(sin) ...    /* NOW what? */
>    }
>This seems to call subr(_builtin_sin).  The draft standard says that
>because `sin' appears here without a following `(', it is not macro-
>expanded; thus this in fact passes the address of the library function.
     
If so, this is a "new" feature at least compared with AT&T SysV (could
someone check out BSD and others?) C compilers, which give an error message
about "argument mismatch" if something like this is tried.
     
Given that this is supposed to be a "standard," I wonder what C compilers
support this now?  I thought standards were supposed to, er, be codifications
of a combination of the best features in existing compilers, not invent
things out of the blue sky...
(isn't this the way the Fortran 66 and 77 standardizations worked, for
example?).  Not that treating macros this way is a bad idea, I just would
like to know who does it now.
     
>In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!ttrda!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1593
          for JMS@ARIZMIS; Sun, 13-JUL-1986 18:18 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 08:49:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002365; 12 Jul 86 9:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027169; 12 Jul 86 9:24 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <2152@brl-smoke.ARPA>
Date: 12 Jul 86 13:24:48 GMT
Followup-To: net.math
To:       info-c@BRL-SMOKE.ARPA
     
In article <3147@jhunix.UUCP> ins_apmj@jhunix.ARPA (Patrick M Juola) writes:
>    You've never seen the statements at the beginning of proofs, where
>they assign properties to variables....  If you want to assign to vector
>z the length of 1, you write "|z|=1."  Or at least I do.  How do you do it?
     
Much as I hate to continue this totally bogus discussion,
I really have to point out that |z|=1 is not any sort of
an assignment.  Usually it is seen in a context such as
"assume |z|=1; then..." which is a Boolean use of = as a
relational operator.
     
But this has nothing to do with C and should move to net.math,
if you really want to discuss meaning of symbols in mathematics.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1397
          for JMS@ARIZMIS; Sun, 13-JUL-1986 18:18 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 08:36:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002303; 12 Jul 86 9:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027094; 12 Jul 86 9:15 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: (Really addressing inside struct)
Message-ID: <2151@brl-smoke.ARPA>
Date: 12 Jul 86 13:14:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <403@anasazi.UUCP> john@anasazi.UUCP (John Moore) writes:
-struct links {
-   struct links *forward;
-   struct links *backward;
-};
-
-struct foo {
-   char bar;
-   struct links snake;
-   struct whocares junk;
-   struct links lizard;
-};
-
-struct links *reptile;
-
-Assume that reptile points to the lizard structure of a "foo" structure.
-What construct allows one to do the following:
-
-struct foo *iwish = (mystery function of reptile);
-
-Example of a wrong solution:
-struct foo *iwish = (struct foo *)((char *)reptile + (char *)0->lizard);
     
This is rather a strange way to do business, but I can answer the question:
There is no guaranteed way to do what you're trying to do, therefore there
should be no way to keep "lint" from complaining.  However, the following
should work for most C implementations:
     
struct foo dummy;
#define    LIZ_OFFSET    ((char *)&dummy.lizard - (char *)&dummy.bar)
struct foo *iwish = (struct foo *)((char *)reptile - LIZ_OFFSET);
     
What I would recommend instead is that you keep a pointer to the whole
(struct foo) rather than to the lizard member, if your application permits.
(You might need to add a (struct foo *) member to (struct links).)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1783
          for JMS@ARIZMIS; Sun, 13-JUL-1986 18:18 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/12/86 at 09:01:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002438; 12 Jul 86 9:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027337; 12 Jul 86 9:40 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: Another printf-type question
Message-ID: <2153@brl-smoke.ARPA>
Date: 12 Jul 86 13:40:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2138@brl-smoke.ARPA> LINNDR%VUENGVAX.BITNET@WISCVM.ARPA writes:
>invprintf(fmt,args)
>{
>        printf(<string to go into inverse video mode>);
>        printf(fmt,args);
>        printf(<string to leave inverse mode>);
>}
>
>This simple solution didn't work. Oh great gurus of such things, what
>should I have done?
     
Assuming you're using UNIX System V Release 2.0 for sake of concreteness,
     
#include    <stdio.h>
#include    <varargs.h>
     
void
invprintf( va_alist )
    va_dcl
    {
    char    *fmt;            /* printf control string */
    va_list    args;            /* argument pointer */
     
    (void)fputs( "string to enter inverse video mode", stdout );
     
    va_start( args );
     
    fmt = va_arg( args, char * );
     
    (void)vprintf( fmt, args );    /* warning! not printf(va_arg etc. */
     
    va_end( args );
     
    (void)fputs( "string to leave inverse video mode", stdout );
    }
     
The final mechanism of ANSI X3J11 will probably be slightly different.
     
P.S.  You should perhaps also test whether the write to the terminal succeeds.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3535
          for JMS@ARIZMIS; Mon, 14-JUL-1986 13:46 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028581; 14 Jul 86 12:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018460; 14 Jul 86 11:42 EDT
From: franka%mntgfx.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Pascals Origins
Message-ID: <376@apollo.mntgfx.UUCP>
Date: 11 Jul 86 23:24:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <311@argus.UUCP> ken@argus.UUCP (Kenneth Ng) writes:
>In article <2007@brl-smoke.ARPA>, rbj@icst-cmr (Root Boy Jim) writes:
>>
>> Modula 2 was written to cover Pascal's mistakes. Perhaps Pascal was
>> written to cover Lilith's mistakes as well.
>And Ada was written to fix Modula 2's mistakes.
>
And, unfortunately, none of the above has gotten it right yet...
                    Frank Adrian

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2197
          for JMS@ARIZMIS; Mon, 14-JUL-1986 13:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014030; 13 Jul 86 21:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007826; 13 Jul 86 21:40 EDT
From: "Ron Natalie <ron>" <ron@BRL-SEM.ARPA>
Newsgroups: net.lang.c
Subject: Re: sizeof "string"?  multi-line macro usage?
Message-ID: <349@brl-sem.ARPA>
Date: 14 Jul 86 00:04:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <343@vu-vlsi.UUCP>, colin@vu-vlsi.UUCP (Colin Kelley) writes:
> Question 1.
>
> Is it (portably) legal for sizeof to operate on a string constant?
Yes, "A string is a sequence of characters surrounded by double quotes
[and] has type 'array of characters.'" and "[Sizeof] when applied
to an array, the result is the total number of bytes in the array."
Hence,
    sizeof "foo"
should return 4.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2458
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016322; 14 Jul 86 4:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009341; 14 Jul 86 3:40 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: sizeof "string"?  multi-line macro usage?
Message-ID: <5787@alice.uUCp>
Date: 14 Jul 86 00:43:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
re: is sizeof("...") legal?
     
> This worked great when
> compiled on Pyramid C, VAX VMS C, and Lattice C on a PC.  Then I ran into the
> Regulus C compiler (Regulus 4.2C) which is truly brain-damaged in many
> respects; as far as I can tell, its sizeof returns a random value when given
> a string.  So is it just Regulus that's screwed up ... ?
     
If you want your code to work on a particular compiler,
then the language definition doesn't matter if that compiler
doesn't accept it.  Thus, although K&R says:
     
    A string has type ``array of characters'' ...  (p. 181)
     
and
     
    When [sizeof is] applied to an array, the result
    is the total number of bytes in the array.
     
and thus one should conclude that sizeof("...") is legal,
that doesn't do you a bit of good if your compiler doesn't like it.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1922
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:06 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008499; 13 Jul 86 8:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004610; 13 Jul 86 7:40 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Sizeof structure members
Message-ID: <148@danews.UUCP>
Date: 13 Jul 86 02:14:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I recently wrote a program that made use of the utmp structure.
I wanted to define a global character array of the same size as
a member (ut_line) of utmp.  Since the size is wired in as 12
and not #defined (which is what I would have done!), I decided to
define the array as:
     
char ftty[sizeof getutent()->ut_line];
     
I didn't want to define a global variable of type 'struct utmp *',
because I didn't need it, and lint would complain because I didn't
use it.  I could declare an external variable of type 'struct utmp *',
that I'd never use, but this seems just as bad as the unused global.
     
Without getutent() (which is what could happen in similar situations)
I believe I am stuck with either of the above 'solutions'.  Does anyone
know if I'm wrong about this ?  I use Sys 5 Rel 2 Unix.
     
Thanks,
--
     
Larry Cipriani        AT&T Network Systems
danews!lvc        "Nothing is worse than an itch you can never scratch."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2299
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014475; 13 Jul 86 23:02 EDT
Received: from mimsy.umd.edu by SMOKE.BRL.ARPA id a008072; 13 Jul 86 22:17 EDT
Received: by mimsy.umd.edu (5.9/4.7) id AA26259; Sun, 13 Jul 86 22:18:59 EDT
Date: Sun, 13 Jul 86 22:18:59 EDT
From: Charley Wingate <mangoe@maryland.ARPA>
Message-Id: <8607140218.AA26259@mimsy.umd.edu>
To: seismo!BRL.ARPA!gwyn@maryland.ARPA, seismo!brl.arpa!mangoe@maryland.ARPA
Subject: Re:  Re: Precedent for use of =
Cc: info-c@BRL-SMOKE.ARPA
     
I don't buy your analogy.  We aren't talking about the presence or absence
of computer languages, after all, we're talking about what they should be
like.  We like to think that we know what cars ought to be like, and we
legislate accordingly.  Commercial airliners and railroads are even stronger
examples of the same thing.
     
The problem I'm having with the equality discussion (besides my feeling that
ASCII's lack of a one-character assignment operator) is that there's this
implicit (and occasionally explicitly stated notion) that terseness and
power are apriori virtues.  I'm not convinced that they are.  Verbosity
cabn quite obviously be taken to excess; restrictions in the name of protecting
the programmer can also be taken to excess.  COBOL illustrates the former;
Pascal the latter.  The problem with C is that the extra power it offers
above other high level languages are all really shortcuts inherited from
assembly languages.  The "=" - "==" similarity plays upon this.  C extends
an opebn invitation to obscure hand optimizations and deliberately tricky
code, to the point where it gives the impression of being written for the
express purpose of allowing this.  The array-pointer ambiguity is another
example; people may rail all they want, but a lot of UNIX source plays upon
this ambiguity.
     
In my opinion, the question is whether or not these idiosyncrasies inherited
from minicomputer assembly languages are really desirable in this day and
age.  Six months of reading UNIX source have convinced me that they aren't.
     
Charley Wingate
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3127
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028551; 14 Jul 86 11:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018389; 14 Jul 86 11:41 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Taking the address of a register (R
Message-ID: <2600068@ccvaxa>
Date: 13 Jul 86 16:56:00 GMT
Nf-ID: #R:boring.mcvax.UUCP:7009:ccvaxa:2600068:000:1367
Nf-From: ccvaxa.UUCP!aglew    Jul 13 11:56:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
>In article <2036@brl-smoke.ARPA> rbj@icst-cmr.ARPA writes:
>~> Suggestion to make the compiler introduce a temporary when the
>~> address of a register variable is passed as argument to a function.
>
>Rather than cluttering the compiler with more crap than this, write an
>optimizing compiler that doesn't need register declarations but can find
>out for itself what variables are best put in registers.
>
>If you want to make the language's level higher by doing something to
>register variables, remove them from the language instead of giving them
>'pseudo-auto' status.
>
>    Guido van Rossum, CWI, Amsterdam <guido@mcvax.uucp>
     
The "~>" summary quote is a good idea, but it has been pointed out that it
messes up Hazeltine terminals that use tilde as an escape. How about "... >"
     
Talking about crap - I'm all for good optimizing compilers that can put
variables in registers - but I still want to be able to have explicit control
when the global optimizer isn't smart enough (frequently).
     
Making a language's level higher does not mean removing low level constructs
like register variables, it means making them unnecessary. Your optimizing
compiler should be able to optimize in the presence of human added
constraints.
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6301
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 15:32:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028952; 14 Jul 86 12:23 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a019090; 14 Jul 86 12:06 EDT
Date:     Mon, 14 Jul 86 12:06:22 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Ray Butterworth <rbutterworth%watmath.waterloo.edu@CSNET-RELAY.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Yet another ALIGN idea. (some
Message-ID:  <8607141206.aa23189@VGR.BRL.ARPA>
     
Who says stack alignment has to be the same as machine-forced
alignment?  It's certainly not on some of the machines I use.
     
Since the parameter stack can have different alignment constraints,
one would actually need a stkalignof operator for <stdarg.h>, but
it would be of use only for this one purpose and therefore should
not be intruded upon the programmer's notice.
     
It's true that it would be easier to implement <stdarg.h> on some
machines if the alignof operator were available, but it's not
required.  Indeed, since the compiler can tell that variable-
parameter functions are involved, it may choose to use what we
old-timers call "dope vectors" to describe the variable args.
     
On some unusual architectures, actual library functions may have
to be used in the implementation of va_arg() (which itself is a
macro).
     
There was a motion last meeting to drop parmN, but it was defeated;
however, we decided to make "register" parmN an undefined situation.
     
Although I can't recall anything that requires all structs to
be aligned as stringently as the worst possible scalar data type,
implementations may elect to do so, or to make special arrangements
so that the size and alignment of very small structs are convenient
for <stdarg.h> (besides having to include padding so that arrays of
structs work out right).
     
The reference in the draft standard to int, unsigned int, and
double was with respect to possible result of parameter widening
promotions; it wasn't meant to rule out other parameter types.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2633
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019938; 14 Jul 86 8:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011296; 14 Jul 86 7:41 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <5065@sun.uucp>
Date: 13 Jul 86 19:49:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > If your compiler can't generate equally efficient code for
> >
> >     a = b;
> >     if (a != 0)
> >
> > and
> >
> >     if ((a = b) != 0)
> >
> > on any machine other than an incredibly weird one, then your compiler
> > needs to be improved.
>
> Ideally, degrees of optimization should be available,
     
Yeah, they should, but so what?  Why is this relevant to the previous
comment?  It doesn't say "if your compiler doesn't always generate", it says
"if your compiler *can't* generate".  The claim that constructs like
     
    if ((a = b) != 0)
     
are necessary because they generate more efficient code than
     
    a = b;
    if (a != 0)
     
is bogus; compilers *can* be made to generate equally efficient code for
both.  The fact that you can write things in the first style should *not* be
used as an excuse for compiler writers not to do optimization "because the
human will do it for you".
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3313
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:17 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028569; 14 Jul 86 11:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018429; 14 Jul 86 11:41 EDT
From: Ray Lubinsky <rwl%uvacs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Export/import for C?
Message-ID: <640@uvacs.UUCP>
Date: 13 Jul 86 14:13:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I think C's usage of 'static', as applied to functions, to mean 'don't export'
> is unfortunate.
:
> I would prefer the use of 'export' and 'import' as in Modula, with 'import'
> replacing 'extern'.
> The same arguments apply to variables as functions.
:
> Ok, it's going to mean more typing during initial coding.  But how much
> debugging time will it save you?   *Anything* which encourages modular
> programming has got to be a good idea.
:
> Jeremy Harris                    ...!mcvax!ukc!hrc63!miduet!jgh
> (I don't speak for my employer)            jgh@gec-mi-at.co.uk
     
I can appreciate the aesthetics of export/import, but I don't think it would
improve my coding.  One of the reasons that I like C is the idea of having a
grab-bag of functions at my disposal with the special exception of those which
have been explicitly hidden from me via ``static''.
     
The language is ``flat'': it provides for a set of functions which I organize
to my liking.  I definitely prefer this programming paradigm to the European
style (a la Pascal, Modula2, Ada) which enforces it's own notion of structure
at my expense.  I suppose my attitude is that modular programming is not a
``good idea'' carved in stone; it should be applied as needed.  No more, no
less.  Unlike some languages, C gives me the freedom to use my discretion.
     
Though I didn't look at your path at first, the thing that crossed my mind
while reading was that munging C in this way was down right un-American. :-)
     
--
     
Ray Lubinsky    University of Virginia, Department of Computer Science
        UUCP:  ...!cbosgd!uvacs!rwl or ...!decvax!mcnc!ncsu!uvacs!rwl
        CSNET: rwl@virginia

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2705
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025704; 14 Jul 86 10:36 EDT
Received: from csnet-relay.arpa by SMOKE.BRL.ARPA id a015192; 14 Jul 86 9:39 EDT
Received: from waterloo by csnet-relay.csnet id ab01651; 14 Jul 86 9:37 EDT
Received: by watmath; Mon, 14 Jul 86 09:16:03 edt
Date: Mon, 14 Jul 86 09:16:03 edt
From: Ray Butterworth <rbutterworth%watmath.waterloo.edu@CSNET-RELAY.ARPA>
To: rbutterworth%watmath.uucp@BRL.ARPA, BRL.ARPA!gwyn%seismo.csnet@BRL.ARPA
Subject: Re:  Yet another ALIGN idea. (some
Cc: info-c@BRL-SMOKE.ARPA
     
>  From seismo!BRL.ARPA!gwyn  Sat Jul 12 05:07:56 1986
>  You say that an alignof(type) operator is required in order to
>  implement the va_arg(ap,type) macro.  Could you please demonstrate
>  this?  I don't believe it.
     
Suppose we have a machine where
sizeof(double)==8,  sizeof(long)=8,  sizeof(int)==4,
alignof(double)==8, alignof(long)=4  alignof(int)==4.
     
What does the macro va_arg(list,long) expand to?
The token "long" can't be concatenated to form a predefined token
such as "align_long" since it could just as easily have been "char *".
So the only information we can really determine about the argument
is by using sizeof(long).  But this is simply 4 in this case.  We
still don't know where on the stack the argument will be.  If it is
a long (which we can't determine) it is at the next 4-byte boundary,
but if it is a double (which it could just as easily be, given only
its size) it is at the next 8-byte boundary.
     
How is va_arg supposed to differentiate between these two cases?
I didn't see anything in the standard restricting how things must
be passed in the stack (e.g. all arguments must be aligned the same
way (as in VAX BSD)).  If there isn't an alignof() operator, some
other built-in would be needed (e.g. newptr=align(oldptr,type)).
     
Another example would be the case of structures.  There is nothing
that says that "struct{char a; char b;}" has to be aligned the same
as "struct{double c;}", and I certainly don't see any way of making
va_arg determine the alignment without a built-in alignof() operator.
     
With a very strict reading of the standard one might decide that
the "..." arguments can only be of type int, unsigned int, or double.
That would certainly make my above examples invalid, but it would
also make <stdarg.h> much less useful.  If so, the standard could
make this much clearer by changing
    The parameter _^Ht_^Hy_^Hp_^He is a type name such that the type
    of a pointer to an object that has the specified type can be
    obtained simply by postfixing a * to the type name.
to
    The parameter _^Ht_^Hy_^Hp_^He must be "int", "unsigned int"
    or "double".
or better yet, by replacing va_arg by three macros, va_int, va_unsigned,
and va_double.  I really don't think this was what was intended though.
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1820
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:28 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 12:11:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008315; 13 Jul 86 7:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004625; 13 Jul 86 7:41 EDT
From: Colin Kelley <colin%vu-vlsi.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: sizeof "string"?  multi-line macro usage?
Message-ID: <343@vu-vlsi.UUCP>
Date: 12 Jul 86 18:44:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Question 1.
     
Is it (portably) legal for sizeof to operate on a string constant?  I
checked K&R, and they seem to have nothing to say about the subject.
Admittedly, string constants are weird because they're the only valid
array constants in the language, right?  That is, they evaluate to pointers
just like other arrays do, but they magically find some memory for themselves,
whereas other arrays are only allocated memory when they're declared.
This came up because I have coded
     
#define PROMPT "prog> "
     
in an include file, and then later used
     
for (i = 0; i < sizeof(PROMPT) - 1; i++)    /* indent to first char of input */
    putchar(' ');
     
to get the proper indentation for error messages.  This worked great when
compiled on Pyramid C, VAX VMS C, and Lattice C on a PC.  Then I ran into the
Regulus C compiler (Regulus 4.2C) which is truly brain-damaged in many
respects; as far as I can tell, its sizeof returns a random value when given
a string.  So is it just Regulus that's screwed up, or do I have to explicitly
declare
     
char prompt[] = PROMPT;
     
and then take sizeof(prompt)?  (The latter _does_ work in Regulus.)
     
     
Question 2.
     
Does ANSI say anything about macro usage spanning more than one line?  Lattice
C has something like
     
#define max(a,b) ((a > b) ? a : b)
     
but then barfs when I use the macro over more than one line, like
     
x = min(very-long-expression-here,
    another-very-long-expression-here);
     
All the other compilers I've used have no trouble with this.  (By not allowing
multi-line macro usage, Lattice is screwing with the usually transparent
interchangeability of functions and macros...)
     
Anyone know the correct answer to these questions?  Thanks...
     
            -Colin Kelley ..{cbmvax,pyrnj,psuvax1}!vu-vlsi!colin

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3711
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:35 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028611; 14 Jul 86 12:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018489; 14 Jul 86 11:43 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: sizeof "string"?  multi-line macro usage?
Message-ID: <3098@utcsri.UUCP>
Date: 13 Jul 86 18:53:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <343@vu-vlsi.UUCP> colin@vu-vlsi.UUCP writes:
>Question 1.
>
>Is it (portably) legal for sizeof to operate on a string constant?  I
>checked K&R, and they seem to have nothing to say about the subject.
..
>This came up because I have coded
>
>#define PROMPT "prog> "
>
>in an include file, and then later used
>
>for (i = 0; i < sizeof(PROMPT) - 1; i++)    /* indent to first char of input */
>    putchar(' ');
>
>to get the proper indentation for error messages.  This worked great when
>compiled on Pyramid C, VAX VMS C, and Lattice C on a PC.  Then I ran into the
>Regulus C compiler (Regulus 4.2C) which is truly brain-damaged in many
>respects; as far as I can tell, its sizeof returns a random value when given
>a string.
     
Regulus is screwed up.
BTW,
    printf( "%*s",sizeof(PROMPT)-1, " ");
will work except that Regulus may not support * in formats.
Or if you want to get really efficient at the expense of weirdness:
     
    printf( "                    "+20-( sizeof(PROMPT)-1 ) );
     
>So is it just Regulus that's screwed up, or do I have to explicitly
>declare
>
>char prompt[] = PROMPT;
>
>and then take sizeof(prompt)?  (The latter _does_ work in Regulus.)
>
Interestingly, using PCC, sizeof("foobar") gives 7 but stuffs the string
"foobar" into memory which will never be used, so you may as well use the
prompt[] solution above. This may depend on the dialect of PCC you are using,
but all of ours do, and so does cc11 (PDP11). Dem bugs, dem bugs....
     
>
>Question 2.
>
>Does ANSI say anything about macro usage spanning more than one line?  Lattice
>C has something like
>
>#define max(a,b) ((a > b) ? a : b)
>
>but then barfs when I use the macro over more than one line, like
>
>x = min(very-long-expression-here,
>    another-very-long-expression-here);
>
>All the other compilers I've used have no trouble with this.  (By not allowing
>multi-line macro usage, Lattice is screwing with the usually transparent
>interchangeability of functions and macros...)
>
This is #definitely a preprocessor bug.
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2894
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:41 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028532; 14 Jul 86 11:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018373; 14 Jul 86 11:41 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Yet another ALIGN idea.  (some
Message-ID: <2600067@ccvaxa>
Date: 13 Jul 86 16:44:00 GMT
Nf-ID: #R:<1986Jul9:21022:ccvaxa:2600067:000:3968
Nf-From: ccvaxa.UUCP!aglew    Jul 13 11:44:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
... > Chris Torek responds to my alignof() proposal (the shorter name is
... > better):
     
>I think this can still be implemented with a common header file, e.g.,
>
>    #define OFFSET_TO_ALIGN(ptr)    /*something*/
>    #define    IS_ALIGNED(ptr)    (OFFSET_TO_ALIGN(ptr) == 0)
>
>On your hypothetical [strictly aligned, power of two sized]
>machine, /*something*/ may be
>
>    #define    OFFSET_TO_ALIGN(ptr)    (_offset_to_align(sizeof *(ptr)))
>
>where _offset_to_align is a library function.
     
He's right - I don't care if something gets stuck in the language or in a
header file - but his macros have some weaknesses. (1) They can only be
used to determine if a pointer is correctly aligned, not to generate a
correctly aligned pointer. Ie. given an arena from which your malloc()
draws stuff, do you run through every hole looking for IS_ALIGNED(p) where
p is what you're allocating now? And what if you have a block beginning on
a misaligned address - do you run through every byte in the block looking
for a place to start?
     
(2) On my hypothetical, strictly aligned, power of two sized, machine using
sizeof as the sole criterion can lead to some inefficiencies. For example,
a character string of length 2n+1 need not be allocated on a 4n boundary,
if you know that indexing is never used into the string, or if you are
willing to have indexing be slow (through explicit pointer calculations)
when it is. So you don't need to waste those 2n-1 bytes. However, since
the fields of a structure of size 2n+1 are very frequently indexed, then you
are willing to waste the memory.
     
---
     
The discussion is useful, though. We can see two needs:
     
[A] a predicate IS_ALIGNED(ptr,type) which returns true or false if
    the ptr is correctly aligned for an object of type.
     
    The predicate can handle any machine's alignment restrictions, including
    multiple plus an offset type constraints (not my idea). On most machines
    it can be implemented by a macro in a header, something like
     
    #define IS_ALIGNED(ptr,type) ( sizeof(type) == 1 ? 1 \
                 : sizeof(type) == 2 ? ptr & 1 \
                 : ... \
                 : !(ptr & ((1<<(ALIGN-1))-1)) )
     
    but Ooops! note that even on a VAX struct {char a,b;} doesn't HAVE
    to be aligned like this.
     
[B] Constants that can be used in writing nearly machine independent
    memory allocators.
     
    For a large class of machines this can most simply be done by providing
    the sizeof() the largest data type that has alignment restrictions, eg.
     
    #define ALIGN sizeof(double)
     
    However, that doesn't cover my favorite architecture, strictly aligned
    power of two sized; but a macro generating the alignment constant can
    handle all architectures with alignment constraints based on multiples
    without offsets
     
    #define ALIGN(type)    (1<<ceil_log(sizeof(type))
     
    where ceil_log would have to be a function executable by the
    preprocessor.
     
Of course, you can say "why bother going that extra little step just for one
of Krazy Glew's hypothetical architectures..." Well (1) Even on conventional
machines that have a single upper bound on alignment restrictions,
ALIGN(type) might permit more efficient memory allocators, particularly if
the upper bound on alignments is large. It may only be a 64 bit double now,
but it is quite reasonable to see it becoming 128 bits extended precision
floating point numbers, or even 256 bits, in the near future.
     
(2) Such an architecture may not be hypothetical much longer... I hope,
and I have reasons for hoping.
     
(3) Such an architecture already exists! Surprised? I've heard of somebody
who modified a 68000 compiler to use shifting and oring instead of mutiplying
and adding to access fields of structures. Hai presto! a strictly aligned
power of two sized system. And it ran faster than conventional code. Since
memory keeps getting cheaper...
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6764
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 16:24:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008795; 14 Jul 86 17:05 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a028286; 14 Jul 86 16:52 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02248; Mon, 14 Jul 86 16:51:51 edt
Date: Mon, 14 Jul 86 16:51:51 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607142051.AA02248@icst-cmr.ARPA>
To: Eric_S._Fanwick.STHQ@xerox.ARPA, daveh%cbmvax.cbm.uucp@BRL.ARPA
Subject: Re: Re: Re: Precedent for use of =
Cc: info-c@BRL-SMOKE.ARPA
     
    The best way to some up the difference between C and Pascal, (I
    personnally see strengths and weeknesses in both) is that
     
        C assumes the programmer knows what he is doing and lets him do it.
    Pascal assumes the programmer does not know what he is doing and
    prevents him.
     
Kind of like Georgia telling you what you can put in your mouth.
     
    Given this basic difference makes Pascal a better teaching language
     
Except that Pascal has such other bad features that make it unusable
and promote bad habits.
     
People, I don't see why you can't deal with subsets of a language.
If you took a first semester FORTRAN class (a rarity these days)
and taught it in C (no pointers, no double operators except ==
(you can even #define _EQ_ ==), no ?:, etc) you would be pretty
much teaching in FORTRAN. Hell, you can even lie a little bit:
"Arguments are passed by value, except for arrays. Tacking `&'
onto the front of a variable `makes an array out of it' (lie, lie).
To reference it you need to call it `variable[0]'".
     
After all, when they taught us FORTRAN, I didn't hear anyone
complaining about the dangers of the EQUIVALENCE statement.
     
When your pups get a little bigger, you can tell them what's
*really* going on. Kind of like reality.
     
But to subject them to the slangs and errors of outrageous fortran,
(I meant pascal, but Willie wrote it the other way :-) because
a few pop psychologists are afraid of seeing stars, is insane.
     
I saw throw `em in the water and let `em sink or swim.
     
    Eric Fanwick
     
    PS: Strong typed languages are for week minds.
     
Really! Eight days a weak.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
Being a BALD HERO is almost as FESTIVE as a TATTOOED KNOCKWURST.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7152
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:49 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 16:43:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008285; 14 Jul 86 16:31 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a026650; 14 Jul 86 15:43 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02010; Mon, 14 Jul 86 15:42:22 edt
Date: Mon, 14 Jul 86 15:42:22 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607141942.AA02010@icst-cmr.ARPA>
To: chris@maryland.ARPA, info-c@BRL-SMOKE.ARPA
Subject: PascalCC
     
    : pascalcc - compile C code with Pascal-esque assignment / equality
     
    In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
    UUCP:    seismo!umcp-cs!chris
    CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
     
Perhaps we might call this PCC :-)
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
Concentrate on th'cute, li'l CARTOON GUYS!  Remember the SERIAL NUMBERS!!
Follow the WHIPPLE AVE. EXIT!!  Have a FREE PEPSI!! Turn LEFT at
th'HOLIDAY INN!!  JOIN the CREDIT WORLD!!  MAKE me an OFFER!!!
     
P.S. Seems Zippy is quite verbose today.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7204
          for JMS@ARIZMIS; Mon, 14-JUL-1986 14:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 16:46:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008936; 14 Jul 86 17:17 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a027019; 14 Jul 86 15:52 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02030; Mon, 14 Jul 86 15:52:07 edt
Date: Mon, 14 Jul 86 15:52:07 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607141952.AA02030@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, uokvax!emjej@ICST-CMR.ARPA
Subject: Re: PRECEDENT FOR USE OF =
     
    If that's a reasonable principle of programming language design, then
    let's see if we can't get Huffman-coding for C keywords in the next ANSI
    draft standard.
     
Great! Replace all the keywords by digraphs!
     
    = for assignment is one of many flaws in C syntax.  Combined with the
    absence of a Boolean type, it is a considerable source of errors in C
    code.  Lint should warn the user of every occurrence of "if (a = b)".
     
0 for three.
     
    (I predict at least one C-worshipper will say "*real* C programmers,
    as opposed to quiche-eaters, don't make that mistake."  I think they're
    wrong, based on the instances of it I've seen.
     
Whatever they eat, the mistake is rare (after getting bit a few times),
and easy to find when made.
     
    Second-order comment
    will be "you haven't done a study, so you're not worth bothering with":
     
Hey, I can relate to this. If the founding fathers had done a study, we'd
never have had the Bill of Rights. Why poll the common man when you have
a genius to lead the way.
     
    I admit that I haven't, but (1) I lack the resources, and (2) it's too
    bad the designers of programming languages (and Unix utilities) don't
    have to do human factors studies before introducing their products.)
     
Human factors are for humans. You are talking to machines. Beep, click, whirr!
     
                        James Jones
No, I *don't* want any Kool-Aid!
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
I'm pretending I'm pulling in a TROUT!  Am I doing it correctly??
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8345
          for JMS@ARIZMIS; Mon, 14-JUL-1986 15:45 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/14/86 at 17:37:38 CDT
Received: from MC.LCS.MIT.EDU by SRI-KL.ARPA with TCP; Sun 13 Jul 86
  14:06:53-PDT
Received: from MX.LCS.MIT.EDU by MC.LCS.MIT.EDU via Chaosnet; 13 JUL 86
  17:07:22 EDT
Date: Sun, 13 Jul 86 17:04:57 EDT
From: "Keith F. Lynch" <KFL%MX.LCS.MIT.EDU@MC.LCS.MIT.EDU>
Subject: Number crunching
To: cetron%utah-cbd@UTAH-CS.ARPA
cc: KFL%MX.LCS.MIT.EDU@MC.LCS.MIT.EDU, Info-VAX@SRI-KL.ARPA
Message-ID: <[MX.LCS.MIT.EDU].932954.860713.KFL>
     
    From: cetron%utah-cbd@utah-cs.arpa (Ed Cetron)
     
        On the other hand, C does this kind of stuff extremely well - but it
    is terrible for large brute force number crunching - and it is ludicrous to
    use it in that fashion....
     
  I have heard this several times, and I still don't understand it.  I
can see why C is better for systems programming than Fortran or Pascal,
but why is C supposedly worse at number crunching than Fortran?  What can
be done easily in Fortran that is difficult or impossible in C?
     
                                ...Keith

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8005
          for JMS@ARIZMIS; Mon, 14-JUL-1986 15:46 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/14/86 at 17:25:43 CDT
Received: from MIT-MULTICS.ARPA by SRI-KL.ARPA with TCP; Sun 13 Jul 86
  10:11:46-PDT
Received: from TE.CC.CMU.EDU by MIT-MULTICS.ARPA TCP; 13-Jul-1986 12:53:23-edt
Date: Sun 13 Jul 86 12:51:47-EDT
From: Marc Shannon <MS5U@TE.CC.CMU.EDU>
Subject: [Marc Shannon <MS5U@TE.CC.CMU.EDU>: Re: VAX C/VMS questions]
To: info-vax%sri-kl.arpa@MIT-MULTICS.ARPA
Office: UCC 175, x6692
Message-ID: <12222386046.21.MS5U@TE.CC.CMU.EDU>
     
In article <?@oakhill.UUCP> tomc@oakhill.UUCP writes:
>1)  Is there an equivalent of /dev/null ("bit bucket") on VMS?
     
Yup...There's good old NLA0:, or NL: for short.  Good for when you run
a program for the hundredth time that asks for an output file and you
just don't care. :-)
     
>2)  Are there any routines available written in C that facilitate
>    wildcard filename expansion from within a program running under
>    VMS?  I have a case where the C program is invoked from DCL as
>    a foreign command; thus no automatic wildcard expansion is done.
     
Written in C?  Not exactly, but you can call LIB$FIND_FILE.  The
format is documented on page RTL-105 in the Run Time Library User's
Guide.  It involves some "Mixed-Language Programming" (see chapter 14
in the Programming in VAX-C manual), but it's all well documented.
     
>3)  I have a C program that was developed in a PC-DOS/Unix environment.
>    I can "install" it on VMS as a foreign command and get access to
>    command line arguments via argv (without DCL wildcard expansion,
>    as stated above).  My assumption has been that to install the
>    program in a more conventional way, I must use the Command Definition
>    Utility to specify command line parameters and attributes, and then
>    use RTL CLI$ calls to access the arguments, bypassing argc and argv.
>    Is this assumption correct?
     
You can use your argc and argv and then just install the program as a
foreign command in the system-wide login command procedure.  For
example, if the program is an echo simulator located in
SYS$USER:[UNIX_FAKES], you would have a line in the login like:
     
    $ echo :== $SYS$USER:[UNIX_FAKES]ECHO
     
(If you want to be able to abbreviate echo down to one letter, change
the left side to e*cho.)
     
Personally, I like VMS.  (That's quite an accomplishment to admit
around here at CMU!)  Anyone got any useful utilities for a uVAX-I
running uVMS V4.3? :-)
     
--
Marc Shannon                                                      |
MS5U@TE.CC.CMU.EDU             (Arpanet)                        \ | /
MS5U@CMUCCVMA                  (Bitnet)                       ___\|/___
pitt!darth!plooba!shannon      (UUCP)                            /|\
SHANNON%DRYCAS@TE.CC.CMU.EDU   (The Computer Club's uVAX-I)     / | \
        ^^^^^^ -- Really DRYCAS.CLUB.CC.CMU.EDU :-)               |
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7585
          for JMS@ARIZMIS; Mon, 14-JUL-1986 15:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 17:11:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009362; 14 Jul 86 17:53 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a028667; 14 Jul 86 17:37 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02327; Mon, 14 Jul 86 17:36:33 edt
Date: Mon, 14 Jul 86 17:36:33 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607142136.AA02327@icst-cmr.ARPA>
To: henry%utzoo.uucp@BRL.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: Pascals Origins
     
    > > ... Wirth designed Pascal as a teaching...
    > Wrong! Even Wirth denied that.
     
    Curious, he said quite explicitly in his early Pascal papers that it
    was designed primarily as a teaching language.
     
Well, I have read that he said it wasn't. Sometime recently he received
a Turing award or something.
     
    > ...no provisions for
    > separate compilation. Everything in one source file, and they make
    > people write large scale projects in it? Pure insanity.
     
    Wirth definitely had his head screwed on wrong when he did that.  The
    idea behind it was that a fast compiler could recompile stuff more
    quickly than a linkage editor could link it in, so why bother with the
    extra type-checking hassles?  The compilers he was thinking of were
    the early Pascal compilers, which were simple and fast; the linkage
    editor he was thinking of was the OS/360 one, a notorious pig.  In more
    recent times he has come to his senses.
     
Okay, a bit of history helps clear this up. Given these conditions, his
decision doesn't seem so bad. However, he could have kept the
implementation separate from the language. There are load and go
fortran compilers as well, but they don't limit everybody else.
     
    Many of Root-Boy's other complaints about Pascal can be covered with a
    single observation:  Pascal is over 15 years old.  It's not surprising
    that it has a lot of problems by modern standards.
     
And C is as old. C has evolved; it wasn't perfect as first issued.
Fortunately, C is more flexible. What I am complaining about is
Pascal's *orientation*, or design philosophy. It even bothered BWK
enough to write a techical report (#100?) `Why PASCAL is not my
favorite language'. Too bad it's not an appendix of K&R.
     
    >     (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    > You should all JUMP UP AND DOWN for TWO HOURS while
    > I decide on a NEW CAREER!!
     
    Jim, if you're really gonna pick a new career, something that
    will take you away from your keyboard forever, and jumping up
    and down for two hours will help, a lot of people will do it!
     
Excellent! I'm glad somebody picked up on Zippy's quotes!
I like your quotes too.
     
    Usenet(n): AT&T scheme to earn
    revenue from otherwise-unused    Henry Spencer @ U of Toronto Zoology
    late-night phone capacity.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    My life is a patio of fun!

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8552
          for JMS@ARIZMIS; Mon, 14-JUL-1986 16:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 17:46:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009858; 14 Jul 86 18:35 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a029021; 14 Jul 86 18:19 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02432; Mon, 14 Jul 86 18:18:30 edt
Date: Mon, 14 Jul 86 18:18:30 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607142218.AA02432@icst-cmr.ARPA>
To: guido%mcvax.uucp@BRL.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re:  Taking the address of a register (Re:  Swap by name)
     
    In article <2036@brl-smoke.ARPA> rbj@icst-cmr.ARPA writes:
    ~> Suggestion to make the compiler introduce a temporary when the
    ~> address of a register variable is passed as argument to a function.
     
    Rather than cluttering the compiler with more crap than this, write an
    optimizing compiler that doesn't need register declarations but can find
    out for itself what variables are best put in registers.
     
    If you want to make the language's level higher by doing something to
    register variables, remove them from the language instead of giving them
    'pseudo-auto' status.
     
    Or did I mis some implicit `:-)' in your article?
     
        Guido van Rossum, CWI, Amsterdam <guido@mcvax.uucp>
     
UNCLE! As for those Hazletine terminals, hook them all up to machines
where sizeof(int) != sizeof(any *0)!!!
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Can you MAIL a BEAN CAKE?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9000
          for JMS@ARIZMIS; Mon, 14-JUL-1986 18:03 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/14/86 at 18:33:48 CDT
Received: from AI.AI.MIT.EDU by SRI-KL.ARPA with TCP; Sat 12 Jul 86 22:00:17-PDT
Date: Sun, 13 Jul 86 01:01:21 EDT
From: "Keith F. Lynch" <KFL@AI.AI.MIT.EDU>
Subject: /dev/null
To: sdcsvax!caip!seismo!ut-sally!oakhill!tomc@UCBVAX.BERKELEY.EDU
cc: KFL@AI.AI.MIT.EDU, Info-VAX@SRI-KL.ARPA
Message-ID: <[AI.AI.MIT.EDU].69183.860713.KFL>
     
    From: sdcsvax!caip!seismo!ut-sally!oakhill!tomc@ucbvax.Berkeley.EDU
    (Tom Cunningham)
     
    1)  Is there an equivalent of /dev/null ("bit bucket") on VMS?
     
Yes, NLA0:
                                ...Keith

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9145
          for JMS@ARIZMIS; Mon, 14-JUL-1986 18:03 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/14/86 at 18:38:41 CDT
Received: from ucbvax.Berkeley.EDU by SRI-KL.ARPA with TCP; Sat 12 Jul 86
  23:25:09-PDT
Received: by ucbvax.Berkeley.EDU (5.52/1.14)
    id AA09526; Sat, 12 Jul 86 23:25:08 PDT
Date: Sat, 12 Jul 86 23:25:08 PDT
From: ihnp4!ttrdc!levy@ucbvax.berkeley.edu
Message-Id: <8607130625.AA09526@ucbvax.Berkeley.EDU>
Received: by ihnp4.ATT.COM id AA28540; 13 Jul 86 00:58:00 CDT (Sun)
To: ucbvax!info-vax
Subject: How can I get "Meadows' file modification utility"?
     
O Gurus of info-vax:
     
How can I get "Meadows' file modification utility"?  I read something in
this group some time ago about such a utility was going to be posted to
mod.computers.vax, then I later see some modifications by Charles
Karney to this utility.  However I never saw the utility itself.
     
Could someone tell me how to get it, or (probably better for me, since
I don't have BASIC, only Fortran and C) how to get an executable with the
latest updates?  (I can speak uuencode and uudecode by mail for those
who could uuencode it under Eunice or other VMS UNIX emulator, or who
can get the executable file over intact to a UNIX system and do the same).
I am not on any ARPA net, only uucp/USENET.  I apologize in advance to
mailing list recipients.
     
Thank you very, very much in advance....
     
Dan Levy
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
                        vax135}!ttrdc!ttrda!levy
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9281
          for JMS@ARIZMIS; Mon, 14-JUL-1986 18:03 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 18:47:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010482; 14 Jul 86 19:34 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a029281; 14 Jul 86 19:07 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02578; Mon, 14 Jul 86 19:07:23 edt
Date: Mon, 14 Jul 86 19:07:23 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607142307.AA02578@icst-cmr.ARPA>
To: gwyn@BRL-SMOKE.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: Another printf-type question
     
> In article <2138@brl-smoke.ARPA> LINNDR%VUENGVAX.BITNET@WISCVM.ARPA writes:
> >invprintf(fmt,args)
> >{
> >        printf(<string to go into inverse video mode>);
> >        printf(fmt,args);
> >        printf(<string to leave inverse mode>);
> >}
> >
> >This simple solution didn't work. Oh great gurus of such things, what
> >should I have done?
     
The solution presented below is probably correct, given the poster. I
find it rather unreadable, and would opt for a more local but readable
solution. Having expressed my opinions, I present my solutions along with
their required constraints.
     
First I present Berkeley's solution:
     
    /* @(#)printf.c    4.1 (Berkeley) 12/21/80 */
    #include    <stdio.h>
     
    printf(fmt, args)
    char *fmt;
    {
ABC:
        _doprnt(fmt, &args, stdout);
        return(ferror(stdout)? EOF: 0);
XYZ:
    }
     
The labels ABC & XYZ are where you put the strings to go into reverse
video and back to normal. You also must fix up the return status to
account for the extra I/O.
     
This only works if all the arguments are pushed on the stack in reverse
order. VAXen, SUNS, most any 68k box, Sequent, most any ns32032 box,
and anyone else attempting to be reasonable.
     
Secondly, if you are willing to limit
     
1) the number of parameters to a reasonable number, say ten
2) the type of parameters to only integers and pointers
3) sizeof(int) = sizeof(int *) = sizeof(char *) = sizeof(any *)
     
then you might like the following solution:
     
invprintf(fmt,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9)
{    printf(<reverse video>);
    printf(fmt,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9);
    printf(<reverse video>);
}
     
> Assuming you're using UNIX System V Release 2.0 for sake of concreteness,
> #include    <stdio.h>
> #include    <varargs.h>
>
> void
> invprintf( va_alist )
>     va_dcl
>     {
>     char    *fmt;            /* printf control string */
>     va_list    args;            /* argument pointer */
>
>     (void)fputs( "string to enter inverse video mode", stdout );
>
>     va_start( args );
>
>     fmt = va_arg( args, char * );
>
>     (void)vprintf( fmt, args );    /* warning! not printf(va_arg etc. */
>
>     va_end( args );
>
>     (void)fputs( "string to leave inverse video mode", stdout );
>     }
>
> The final mechanism of ANSI X3J11 will probably be slightly different.
>
> P.S.  You should perhaps also test whether the write to the terminal succeeds.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Are we live or on tape?
.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9527
          for JMS@ARIZMIS; Mon, 14-JUL-1986 18:04 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 19:20:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010756; 14 Jul 86 20:13 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a029632; 14 Jul 86 20:02 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02737; Mon, 14 Jul 86 20:02:12 edt
Date: Mon, 14 Jul 86 20:02:12 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607150002.AA02737@icst-cmr.ARPA>
To: chris@maryland.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Lethal Sequence of Operators
     
    In article <1631@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) replies:
    >The problem is that "<-" is a legal sequence of operators.  Consider
    >"if (x<-1) { ...}".
     
    DIVISION    /
    INDIRECTION    *
     
    The problem is that /* is a legal sequence of operators.  Consider
     
        int r, i, *ip; r = i/*p;
     
Consider also:
     
ADDITION    +
INCREMENT    ++
     
Now try `a+++b' intending `a+(++b)'. Surprise!
     
    As usual, if there is some kind of ambiguity, pick a disambiguator.
     
What he said.
     
    (This is not intended to imply that I think `<-' is a good assignment
    operator.  On the other hand, the preceding sentence is not intended
    to imply that I think `<-' is a bad assignment operator.)
     
That is implied. Is that what you intended?
     
    In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
    UUCP:    seismo!umcp-cs!chris
    CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
...ich bin in einem dusenjet ins jahr 53 vor chr...ich lande im antiken Rom...
  einige gladiatoren spielen scrabble...ich rieche PIZZA...
     
P.S. Okay, so now I know what the Firesign Theatre said. Now what does it mean?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0176
          for JMS@ARIZMIS; Mon, 14-JUL-1986 18:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 20:06:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011020; 14 Jul 86 20:56 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a029933; 14 Jul 86 20:38 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02858; Mon, 14 Jul 86 20:37:55 edt
Date: Mon, 14 Jul 86 20:37:55 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607150037.AA02858@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA
Subject: Re:  sizeof "string"?  multi-line macro usage?
     
    Question 1.
     
    Is it (portably) legal for sizeof to operate on a string
    constant?  I checked K&R, and they seem to have nothing to say
    about the subject.  Admittedly, string constants are weird
    because they're the only valid array constants in the language,
    right?  That is, they evaluate to pointers just like other
    arrays do, but they magically find some memory for themselves,
    whereas other arrays are only allocated memory when they're
    declared.  This came up because I have coded
     
    #define PROMPT "prog> "
     
    in an include file, and then later used
     
    for (i = 0; i < sizeof(PROMPT) - 1; i++)
                /* indent to first char of input */
        putchar(' ');
     
    to get the proper indentation for error messages.
     
Definitely! I have seen `write(1,"Hello World\n",sizeof "Hello World\n")'.
Of course, if you want indentation, why not use a tab?
     
    Question 2.
     
    Does ANSI say anything about macro usage spanning more than one line?
 Lattice
    C has something like
     
    #define max(a,b) ((a > b) ? a : b)
     
    but then barfs when I use the macro over more than one line, like
     
    x = min(very-long-expression-here,
        another-very-long-expression-here);
     
You could always try a backslash after the comma, or use macros
for the arguments as well. You're right, it does sound brain damaged.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Of course, you UNDERSTAND about the PLAIDS in the SPIN CYCLE --

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0788
          for JMS@ARIZMIS; Mon, 14-JUL-1986 19:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/14/86 at 21:05:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011389; 14 Jul 86 21:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000346; 14 Jul 86 21:41 EDT
From: Bob Marti <rmarti%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <5083@sun.uucp>
Date: 14 Jul 86 16:45:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5783@alice.uUCp> Andrew Hume @ Bell Labs, Murray Hill writes:
> The more noise lint puts out, the less use it is.
     
Good point.  That's precisely why I don't like lint:  I hardly ever get
a program to pass through lint without getting least a dozen lines of
garbage.  (Interestingly enough, I do eventually get Pascal and Modula-2
programs to compile without error messages from the compiler ... )
--
     
Robert Marti, Sun Microsystems, Inc.
     
UUCP: ...{cbosgd,decvax,decwrl,hplabs,ihnp4,pyramid,seismo,ucbvax}!sun!rmarti
ARPA: rmarti@sun.com

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1543
          for JMS@ARIZMIS; Mon, 14-JUL-1986 21:08 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/14/86 at 22:50:26 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Mon 14 Jul 86 05:03:23-PDT
Date: 14 JUL 1986 08:06:29 EST
From: <GROPP-BILL@YALE.ARPA>
To: KFL%MX.LCS.MIT.EDU@MC.LCS.MIT.EDU
cc: info-vax@sri-kl
Subject:  Re: Number crunching
Reply-To: <GROPP-BILL@YALE.ARPA>
     
        From: cetron%utah-cbd@utah-cs.arpa (Ed Cetron)
     
        On the other hand, C does this kind of stuff extremely well -
        but it is terrible for large brute force number crunching - and
        it is ludicrous to use it in that fashion....
     
      I have heard this several times, and I still don't understand it.  I
    can see why C is better for systems programming than Fortran or Pascal,
    but why is C supposedly worse at number crunching than Fortran?  What can
    be done easily in Fortran that is difficult or impossible in C?
     
There are two main reasons, one real, the other historical.  The first
reason is that c does all floating point operations in double (KR p 184,
section 6.2).  This can be a serious problem in applications that
require only float precision.  The historical reason comes from the fact
that most professionally done Fortran compilers for the faster, number
crunching machines generate significantly better object code than c
compilers on the same machine.  This can be traced to the early
development of c (the "register" declaration is of no use/need to
sufficiently sophisticated code generator; note section 8.1 in KR) and
the continuing belief by many that c generates excellent code.  This
belief, where true at all, generally does not apply to floating point
operations and the kinds of expressions that contain them.
     
Also, it is impossible to pass a 2 or higher dimensioned array AS SUCH
where the dimensions are not known at compile time (section 8.3 and 15,
KR).  Instead, you must pass a pointer and do the pointer arithmetic
yourself.  This can be extremely inconvenient in many number-crunching
applications.  For an example, consider a subroutine library to handle
matrices of arbitrary size such as the Fortran LINPACK and EISPACK.
     
Finally, there is the portability question.  Many number-crunching
programs are intended for wide distribution on the large mainframes,
many of which did not (some still do not) have a c compiler.
     
Having said all of that, there are clearly cases, particularly in
fancier numerical codes using adaptivity and needed dynamic memory
allocation and structures, where c is often the best choice.
                                                Bill
-------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2798
          for JMS@ARIZMIS; Mon, 14-JUL-1986 23:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 01:50:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013191; 15 Jul 86 2:44 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a002039; 15 Jul 86 2:06 EDT
Date:     Tue, 15 Jul 86 2:01:34 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Root Boy Jim <rbj@ICST-CMR.ARPA>
cc:       info-c@BRL.ARPA
Subject:  Re:  Another printf-type question
Message-ID:  <8607150201.aa00269@VGR.BRL.ARPA>
     
invprintf(fmt,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9)
     
is not a portable solution.  In some cases an attempt to invoke
it with a small actual parameter count can even lead to abnormal
process termination.
     
The reason <varargs.h> or <stdarg.h> exist is to provide the
hooks necessary for implementation of a portable solution;
the other half of the solution requires something like the
v*printf() functions.
     
The fellow asked the great gurus what he *should* have done.
Why do you feed him that garbage in return?  If it's to show
us that you don't believe in writing portable code, we knew
that already from your ravings about how the VAX is the only
sane architecture.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3292
          for JMS@ARIZMIS; Tue, 15-JUL-1986 01:06 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 03:01:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013658; 15 Jul 86 3:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002521; 15 Jul 86 3:41 EDT
From: C Waldman <cgw%mruxe.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: re: precedent for use of =
Message-ID: <122@mruxe.UUCP>
Date: 14 Jul 86 19:13:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Why not form a new newsgroup, net.lang.equals, for all those tireless
souls who want to drag this issue out ad infinitum.....  :-)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3371
          for JMS@ARIZMIS; Tue, 15-JUL-1986 01:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 03:06:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013676; 15 Jul 86 3:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002535; 15 Jul 86 3:42 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <853@ucbcad.BERKELEY.EDU>
Date: 15 Jul 86 01:38:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I think that most of the people who are keeping this stupid debate going
don't know C well and don't like it.   In order to keep the flaming down
in net.lang.c, PLEASE don't post anything unless you
     
    (1) Have used C for > 5 years, and
     
    (2) Would not change a single thing about it if you were DMR
            15 years ago.
     
This should help the problem a bit... :-)
     
    Wayne

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3504
          for JMS@ARIZMIS; Tue, 15-JUL-1986 01:24 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 03:16:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013693; 15 Jul 86 3:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002554; 15 Jul 86 3:42 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <2424@umcp-cs.UUCP>
Date: 15 Jul 86 03:41:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <mit-eddi.2526> barmar@mit-eddie.UUCP (Barry Margolin) writes:
>>...why not write the operations as function calls, and teach compilers
>>to open-code calls to certain functions.
     
In article <503@cubsvax.UUCP> peters@cubsvax.UUCP (Peter S. Shenkin) replies:
>Yes;  I tried to send off a similar comment on the original posting, but
>it never made it off site.  What I'd like to know is whether the draft
>standard permits this, and what the net guru's think about it.
>
>In Chris Torek's comment on the original posting, he proposes a workaround
>permitted by the draft ANSI, and notes that it is bug-prone.  If this means
>that the draft standard doesn't permit "function calls" to be implemented
>otherwise, I'm curious what the objections are to this practice.
     
Actually, the workaround comes off as being recommended by the
draft standard, at least to me.  I am not certain it is bug-prone,
but it sure does `feel' odd.
     
Apparently the committee (or a large faction thereof) is quite
concerned about ensuring that there is some easy way to ensure a
`real function call'.  They want a standardised way of defeating
in-line expansion, and have, at least for the nonce, settled upon
`#undef funcname'.  A `#pragma' seems to me to be at least as good
an idea; compilers that never open-code a function call can ignore
this, while those that might perform this optimisation could be
required to pay attention to at least this one pragma.  Then instead
of
     
    #include <math.h>
    #undef sin            /* make sure we get a function */
    ...
     
we might have
     
    #include <math.h>
    #pragma disable_inline(sin)    /* get a function */
    ...
    #pragma enable_inline(sin)    /* back to possible inline */
    ...
    #pragma disable_inline(sin)    /* back to function */
     
This has the advantage of being reversible, as well.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3679
          for JMS@ARIZMIS; Tue, 15-JUL-1986 01:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 03:46:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013946; 15 Jul 86 4:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002511; 15 Jul 86 3:41 EDT
From: " G.R.Tomasevich" <grt%twitch.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Threaded code in C - Forth
Message-ID: <389@twitch.UUCP>
Date: 14 Jul 86 14:47:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > which are not exactly "threaded".  [...]  An extreme case is to have the
> > whole Forth as a huge 'case' statement in C.  (Yes, I have seen something
> > like that :-) ).
>
> How else can you implement threading if C is used as the implementation
> language?  (Or is that what the smiley is for?)  In other languages the
     
You do not need to use a switch.  The threaded code is a list of pointers
to words in the vocabulary.  Each word includes a pointer to a function to
be executed.  The virtual machine fetches those pointers and dereferences
to execute the functions.  The dictionary area ought to be defined as
an array of pointers to dictionary word headers, though I have cheated on the
pointer types and used casts.  The function for executing a definition is
     
xqdef(pwd)
struct w_list *pwd;    /* location in dictionary where we are called */
{
    struct w_list *func;    /* working d.p. for this function */
    save_pc_on_a_stack;    /* pc is dictionary pointer */
    pc = (long*)wargs(pwd);    /* get to first pointer in definition */
    /* note that pc was called pointer to long (yeah, gross) */
    do    func = (struct w_list*)(*pc++);
    while ((*func->w_func)(func) != END);
    pop_pc_from_stack;
    return(DEF);
}
     
Here w_list is the dictionary header, pc is the dictionary pointer,
and so func is a pointer to a header.  In the header, w_func is a pointer
to a function.  Note that the function is passed the pointer to the place
in the dictionary where it was called.  This allows access to inline
literal constants, nesting, and so on.  The functions return int values.
This function returns DEF.  The last pointer in the compiled definition points
to a function that returns END, which terminates the loop.  I wrote a different
dialect, but in standard Forth, ':' would cause the word to point to this
function, while ';' would generate the pointer to the function returning END.
All primitives are C functions in the instruction space, while the vocabulary
is headers, pointers, literals, etc in the data space.  I think it is
impossible to do a Forth-like assembler because of the I/D separation; words
must have a pointer to a function rather than being executed directly.
--
    George Tomasevich, ihnp4!twitch!grt
    AT&T Bell Laboratories, Holmdel, NJ

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4502
          for JMS@ARIZMIS; Tue, 15-JUL-1986 04:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 06:53:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015570; 15 Jul 86 7:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003579; 15 Jul 86 5:43 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Draft standard questions
Message-ID: <2396@umcp-cs.UUCP>
Date: 13 Jul 86 21:22:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <2364@umcp-cs.UUCP> I wrote:
>>...  The draft standard says that because `sin' appears here
>>without a following `(', it is not macro-expanded; thus this in
>>fact passes the address of the library function.
     
In article <1054@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) replies:
>If so, this is a "new" feature at least compared with AT&T SysV (could
>someone check out BSD and others?) C compilers, which give an error message
>about "argument mismatch" if something like this is tried.
     
As far as I know, the current preprocessor description in the
standard is unlike any and all available preprocessors.  According
to Jim Williams there is still some argument over just what is to
be `correct' behaviour.  (It is handy, this knowing someone who
actually goes to these meetings.  I hope I have not too badly
mis-paraphrased Jim.)  This is substantiated by the minutes sent
out to `alternate members'; there were, it seems, some four different
formal descriptions proposed.  If there is enough interest I will
borrow Fred's minutes again and post an extract.  (I am not even
an alternate member: `interested bystander' is rather more accurate.)
     
>I thought standards were supposed to, er, be codifications of a
>combination of the best features in existing compilers, not invent
>things out of the blue sky...
     
There are some rather major variances between existing C compilers,
and in each such case the committee must either pick one, or invent
something new.  Most of the `inventive stuff' in the part traditionally
done by /lib/ccom comes from C++, with which, at least, people have
had experience.  I have reservations about how well some of the
other `inventions' will work.
     
By the bye, that reminds me: Jim was going to mention this, but I
have not seen it, so I will do it.  The current draft standard
contains two new preprocessor operators, the `stringiser' `#' and
the token-concatenater `##'.  For example,
     
    #define glorp(a, b) glump("a " #a " string", _##b)
    glorp(strange, thing)
     
turns into
     
    glump("a strange string", _thing)
     
In one of the meetings someone proposed using `#"' and `#&', as
they are at least slightly more suggestive as to what is occurring:
     
    #define    glorp(a, b) glump("a " #"a " string", _#&b)
     
This was quickly followed by another proposal:
     
    #define    glorp(a, b) glump("a " __STR(a) " string", __CAT(_, b))
     
Naturally, this latter proposal caused much stir, and most likely
due to lack of time for consideration, both were rejected.
     
I think the current `#' and `##' are rather unfortunate forms, not
suggestive of anything, and leaving little room for future expansion.
`#"' and `#&' seem better---although I am uncertain of the first,
for it makes discovering what is quoted in unpreprocessed text more
difficult: a little more for programs, and, I think, much more for
programmers.  The final form is better still, but seems to have
rather more impact on the rest of the language (by which I mean I
am not ready to decide about it without first trying it).
     
Now then, if there is great outcry *and* agreement on the part of
the `C community' (as represented by net.lang.c), we may be able
to change this.  I would like to propose a modification of the
third form above:
     
    #define    glorp(a, b) glump("a " #str(a) " string", #cat(_, b))
     
This is somewhat readable (unlike `#' and `##', and `#"'), and
more importantly, expandable: if `#str' and `#cat' turn out to
be bad or insufficient, there are alternatives.  `#' and `##'
leaves `###', `####', `#####' ... or perhaps `###func(args)':
hardly aesthetic.
     
On the other hand, we could try to come up with a formal definition
of Resier-cpp semantics. . . .
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4552
          for JMS@ARIZMIS; Tue, 15-JUL-1986 05:00 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 06:57:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015602; 15 Jul 86 7:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003598; 15 Jul 86 5:44 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: sizeof "string"?  multi-line macro usage?
Message-ID: <2400@umcp-cs.UUCP>
Date: 14 Jul 86 01:04:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <343@vu-vlsi.UUCP> colin@vu-vlsi.UUCP (Colin Kelley) writes:
>Is it (portably) legal for sizeof to operate on a string constant?  I
>checked K&R, and they seem to have nothing to say about the subject.
     
K&R, by the inclusion of an explanatory sentence, made it ambiguous.
Appendix A, \S 7.1, Primary expressions, p. 186:
     
  A string is a primary expression.  Its type is originally ``array
  of char''; but following the same rule given above for identifiers,
  this is modified to ``pointer to char'' and the result is a pointer
  to the first character in the string.  (There is an exception in
  certain initializers; see \S 8.6.)
     
Had they left out the note about conversion to `pointer to char',
or had they mentioned sizeof in that last sentence, it would not
be ambiguous.  The ANSI draft standard simply declares a string
constant to have the type `array of char', making
`sizeof "foo the bar"' definitely equal to 12*sizeof(char).
     
>... This came up because I have coded
>
>#define PROMPT "prog> "
>
>in an include file, and then later used
>
>for (i = 0; i < sizeof(PROMPT) - 1; i++) /* indent to first char of input */
>    putchar(' ');
     
There is another reason to avoid this: each time you mention the
string, most compilers generate another instance of it.  Using
     
>char prompt[] = PROMPT;
     
not only
>... _does_ work in Regulus
but also may keep your data space usage lower.
     
        * * *
     
>Does ANSI say anything about macro usage spanning more than one line?
     
The way I read the draft standard,
     
>#define max(a,b) ((a > b) ? a : b)
>
>x = min(very-long-expression-here,
>    another-very-long-expression-here);
     
is legal; but this is not explicit.  It depends on allowing `a
sequence of tokens' to include a newline.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4817
          for JMS@ARIZMIS; Tue, 15-JUL-1986 05:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 07:24:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016666; 15 Jul 86 8:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000684; 15 Jul 86 7:42 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <503@cubsvax.UUCP>
Date: 14 Jul 86 15:03:53 GMT
Posted: Mon Jul 14 11:03:53 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <mit-eddi.2526> barmar@mit-eddie.UUCP (Barry Margolin) writes:
>                            ...why not
>write the operations as function calls, and teach compilers to open-code
>calls to certain functions.
>
>Fortran, PL/I, and Lisp compilers have been doing this for years.  Just
>because something is written as a function call does not mean that it
>has to be implemented as one.
     
Yes;  I tried to send off a similar comment on the original posting, but
it never made it off site.  What I'd like to know is whether the draft
standard permits this, and what the net guru's think about it.
     
In Chris Torek's comment on the original posting, he proposes a workaround
permitted by the draft ANSI, and notes that it is bug-prone.  If this means that
the draft standard doesn't permit "function calls" to be implemented
otherwise, I'm curious what the objections are to this practice.
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5553
          for JMS@ARIZMIS; Tue, 15-JUL-1986 06:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 08:48:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020052; 15 Jul 86 9:38 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a004000; 15 Jul 86 9:29 EDT
Date:     Tue, 15 Jul 86 9:20:42 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Draft standard questions
Message-ID:  <8607150920.aa01903@VGR.BRL.ARPA>
     
__STR__ and __CAT__ were suggested by Tom Plum in a late-night
working session to resolve the remaining preprocessor issues,
after general committee rejection of Dave Prosser's innovative
proposals for prefix concatenation, stringize, and charize
operators.  These facilities have to be considered in the light
of a total specification of the phases of translation, which
involves such questions as whether the result of macro
substitution can be allowed to result in pasting of stuff on the
left of what was the current working set of tokens and rescan
of the result of that pasting.  Much of the difficulty comes
from an attempt to accommodate macro substitution on #include
lines, which some vendors support and claim their customers
really need for portability reasons (remember that different
OSes have different ideas of file names).
     
The preprocessor experts (I'm not one of them) seemed to think
that __STR__ and __CAT__ built-in macros was the best solution
under the constraints.  However, the committee members had not
had sufficient time to consider this proposal and didn't want
to risk adopting it without sufficient study.
     
The Reiser CPP is definitely out.  It can be modified with some
effort to conform with the current X3J11 proposal, but it has
too many technical problems to insist on everyone duplicating
its behavior.  In particular, many excellent C compilers handle
preprocessing as part of the general lexical analyzer rather
than as a totally separate pass; such tokenizing approaches
have to be accommodated by the standard.
     
I think Donn Seeley intends to upgrade the 4.nBSD CPP to X3J11.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7124
          for JMS@ARIZMIS; Tue, 15-JUL-1986 09:48 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 11:39:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025267; 15 Jul 86 12:26 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a009754; 15 Jul 86 12:17 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a025120; 15 Jul 86 12:10 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA04108; Tue, 15 Jul 86 12:05:54 edt
Date: Tue, 15 Jul 86 12:05:54 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607151605.AA04108@icst-cmr.ARPA>
To: gwyn@BRL.ARPA, rbj@ICST-CMR.ARPA
Subject: Re:  Another printf-type question
Cc: info-c@BRL.ARPA
     
Doug Gwyn chastises me:
    invprintf(fmt,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9)
     
    is not a portable solution.
     
I thought I said that. If not, `taint portable', but just might be useful.
     
    In some cases an attempt to invoke
    it with a small actual parameter count can even lead to abnormal
    process termination.
     
True, such as floats or doubles, weird format pointers, longs on PDP-11's.
Also, if called directly from main, it could run off the end of the stack.
     
    The reason <varargs.h> or <stdarg.h> exist is to provide the
    hooks necessary for implementation of a portable solution;
    the other half of the solution requires something like the
    v*printf() functions.
     
I can relate to the v*printf guys.
     
    The fellow asked the great gurus what he *should* have done.
    Why do you feed him that garbage in return?
     
For educational purposes. At least my `solutions' are understandable.
The guy was obviously a novice, and while your solution is probably
the best one, do you think he can read it?
     
Also, there is no harm in disseminating bad information as well as
good, for comparison purposes, so he can tell the difference. Also,
to understand why yours works, it is useful to know the usual
(or original if you will) calling sequence.
     
Its probably going to be awhile before he ports code all over creation.
     
I wish *I* had known the magic printf trick when I wrote code that had to
run in both hosted and standalone 68k environments. I wrote three sets of
code, the common stuff, the hosted interface, and the standalone interface.
     
We were using only integers (chars, shorts, & ints) & pointers. It would
have been easier and more maintainable if I had rewritten a subset of
printf (no floats, no field widths or left justification, etc)
INSTEAD OF AN ENTIRE INCOMPATIBLE EDITING PACKAGE based on Exec 8!!!
     
    If it's to show us that you don't believe in writing portable
    code, we knew that already from your ravings about how the VAX
    is the only sane architecture.
     
Why do you keep saying VAX only? I also mentioned 68k's, ns32032's,
I forgot the PDP-11, all of which I would take home to mother.
I suppose even IBM qualifies as a rational data structure.
     
Just because a piece of hardware exists doesn't mean it's rational.
     
Just because a piece of hardware is rational doesn't mean the
software model imposed upon it is rational. INTEL's small, medium,
and large models create more problems than they solve. There is
nothing wrong with the 8086 that treating it like a PDP-11 wouldn't cure.
     
I suppose I would rather program in C than anything else on a
dinosaur, but I would realize that the model was strained at best.
     
I will never touch one of those beasts again. As far as I am concerned,
they don't exist. If you want to contort your code to conform to the
lowest common denominator, fine. My code is optimized for sanity.
     
I am from the National Bureau of Standards, and as such, believe
in them. There ain't nothing else but ASCII. My code will never
support EBCDIC. I expect 'I' + 1 to equal 'J'. If it doesn't,
that's your problem. You fix it.
     
You say your car is 6 volts, positive ground? Wreck it!
There comes a time to forego the past and desanction it.
If you make it easy for them, they'll never give it up.
     
Okay, I'm ranting again, let me get back to the subject.
     
It's all a matter of tradeoffs. Portability comes at a price, both
in time and in space (extra characters), which I find detracts
from readability. Yes, I know that one should aim high, and I do.
     
Perhaps I aim higher than you. You abide the past, I demand the future.
     
I added proper cautionary notes. I acknowledged your solution.
     
In any case, yours is not the only opinion. Mine is shared by
others. We are not unaware of the consequences of our actions,
and accept the responsibility for same. We have made our choice.
     
Respect it. Agree to disagree.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
I guess it was all a DREAM.. or an episode of HAWAII FIVE-O...

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7613
          for JMS@ARIZMIS; Tue, 15-JUL-1986 10:37 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 12:11:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026371; 15 Jul 86 13:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009117; 15 Jul 86 11:44 EDT
From: Jim Hutchison <hutch%sdcsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: decline of net.lang.c
Message-ID: <1929@sdcsvax.UUCP>
Date: 15 Jul 86 04:37:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
At the June Usenix there was a gentleman giving a talk
on PCC2,QCC,& RCC.  I am interested in information on
acquiring the product.  Source ofcourse because he does
not have a version for the machine it will run on, and
some sort of license for binary distirbution.
     
Thanks!
--
    Jim Hutchison   UUCP:    {dcdwest,ucbvax}!sdcsvax!hutch
    "I rep. me"     ARPA:    Hutch@sdcsvax.ucsd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8570
          for JMS@ARIZMIS; Tue, 15-JUL-1986 12:03 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 13:56:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029626; 15 Jul 86 14:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013679; 15 Jul 86 13:44 EDT
From: Robert Thau <rst@zarathustra.ARPA>
Newsgroups: net.lang.c
Subject: Poorly terminated header files.
Message-ID: <5722@think.COM>
Date: 1 Jan 87 02:31:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
After reading reams on token concatenation (and the portability of
lack thereof of various means of doing it), the semantics of #define,
#ifdef, defined() and friends, etc., ad libitum ad nauseam, I hesitate
to add yet another phenom to the fray, but here goes:
     
Recently, through no fault of my own (honest, guv'nor!) I wound up
including a header file with no terminating newline.  The setup looked
like this:
     
(main-line)
     
    #include <loser.h>
    #include <victim.h>
    ... stuff which depends on victim.h being included ...
     
(loser.h)
     
    struct foo { type bar; other-type zot; } glorp;
    #define something else<EOF>
     
victim.h:
    ...
    struct bar *somefunction();
    <EOF>
     
The symptom was (if you haven't already guessed) that victim.h was not
actually included in the main-line, resulting in "illegal combination
of pointer and integer" error messages from both lint and cc (this on
4.2bsd) when I tried to use somefunction().  Adding the terminating
newline to loser.h solves the problem.  (Thanks to J. P. Massar for help
in tracking this down).
     
This peculiar behavior arises because the Reiser cpp actually includes
the content of loser.h verbatim, leaving the "#include <victim.h>"
stranded on the middle of the last line of loser.h.  Now, it is
definitely non-standard for cpp (and /lib/ccom) not to complain about
the # in the middle of the line.  (The Reiser cpp treats the '#' in
the middle of a line as a comment character, and deletes text to the
next newline, which is certainly wrong).  My questions are directed
more toward the handling of the missing newline itself:
     
What do other preprocessors do in this kind of situation?
     
What does X3J11 say about these cases, if anything?  The last time I
looked at a draft standard, __LINE__ and __FILE__ were in it; what are
their values on the split line, if such things are allowed?
     
What *should* X3J11 say about these cases, if anything?
     
rst

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9188
          for JMS@ARIZMIS; Tue, 15-JUL-1986 12:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 14:42:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001883; 15 Jul 86 15:26 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a017334; 15 Jul 86 15:15 EDT
Received: from bbn-labs-b.arpa by AOS.BRL.ARPA id a001293; 15 Jul 86 15:07 EDT
To: Robert Thau <rst%zarathustra.zarathustra.arpa@BRL.ARPA>
Cc: info-c@BRL.ARPA
Subject: Re: Poorly terminated header files.
In-reply-to: Your message of 1 Jan 87 02:31:16 GMT.
         <5722@think.COM>
Date: 15 Jul 86 14:57:51 EDT (Tue)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     I can think of one reason why the Reiser CPP treats free standing # as
a comment when not at the beginning of the line: this is was many assemblers
use as comments.  However, /lib/cpp as shipped with vanilla 4.2 BSD just passes
it on through, causing /lib/ccom to barf with the classic:
     
    illegal character 043 (octal)
    cannot recover from earlier errors, I'm stupid! (er...goodbye!)
     
What is worse is when you have a header file that ends with an unterminated
comment, as in:
     
    loser.h:
        #define LAST_LOSER 99    /* the last loser (oops)... /*
     
    main.c:
     
    #include "loser.h"
    #include "victim.h"
     
                    /* and now the code... */
     
Gee, where did victim.h go?
     
P.S.
     Why does zarathustra.think.com think that it's New Year's Day, 1987?
Or has the ARPAnet finally gone translight?
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0195
          for JMS@ARIZMIS; Tue, 15-JUL-1986 14:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 15:56:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003916; 15 Jul 86 16:37 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a019585; 15 Jul 86 16:29 EDT
Received: from bbn-labs-b.arpa by AOS.BRL.ARPA id a003681; 15 Jul 86 16:21 EDT
To: rst%zarathustra.zarathustra.arpa@BRL.ARPA
cc: info-c@BRL.ARPA
In-reply-to: Your message of 15 Jul 86 15:45:22 EDT (Tue).
         <8607151945.AA11736@Godot.Think.COM>
Date: 15 Jul 86 16:10:55 EDT (Tue)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
Futher investiagtion reveals that the vanilla 4.2 BSD CPP exhibits the same
behavior as outlined earlier.  In fact, it's even worse than that.  If a
#included file does not end in a newline, the next line of the file which
contained the #include is ignored.  Period.  Try this:
     
    junk.h:
    #define foobar printf ("Hello world\n");<EOF>
     
    junk.c:
    #include "junk.h"
    eat me eat me eat me
    main ()
    {
        foobar
    }
     
The only complaint you'll get from doing 'cc junk.c' is that "foobar" is
undefined and that there is a missing ;.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2127
          for JMS@ARIZMIS; Tue, 15-JUL-1986 17:56 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 18:55:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005124; 15 Jul 86 19:41 EDT
Received: from csnet-relay.arpa by SMOKE.BRL.ARPA id aa20753;
          15 Jul 86 19:22 EDT
Received: from ti-eg by csnet-relay.csnet id ab14257; 15 Jul 86 19:07 EDT
Date:     Tue, 15 Jul 86 06:12 ???
From:     HARGED%ti-eg.csnet@CSNET-RELAY.ARPA
To:       info-c%brl-smoke.arpa@CSNET-RELAY.ARPA
Subject:  LISP was devised by extra-terrestrials
     
>
> LISP and Pascal are both descendants of Algol 60.
> --
>
     
Hate to say it, but Lisp was being developed at MIT by Mcarthy, et. al.,
at the same time Algol 60 was being developed. Check out
     
        "Recursive Functions of Symbolic Expressions and Their
         Computation by Machine". McCarthy, John. _Communications
         of the ACM_. Vol. 3, #1. January 1960.
     
This is the article in which McCarthy unveiled LISP after working on it
for a few years. The language described in it is not related to Algol.
     
Richard Hargrove
CSNET: harged@ti-eg
ARPA:  harged%ti-eg.arpa@csnet-relay.arpa
-----------------------------------------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2034
          for JMS@ARIZMIS; Tue, 15-JUL-1986 17:56 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/15/86 at 18:51:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005121; 15 Jul 86 19:40 EDT
Received: from csnet-relay.arpa by SMOKE.BRL.ARPA id a020753;
          15 Jul 86 19:21 EDT
Received: from ti-eg by csnet-relay.csnet id aa14257; 15 Jul 86 19:06 EDT
Date:     Tue, 15 Jul 86 06:10 ???
From:     HARGED%ti-eg.csnet@CSNET-RELAY.ARPA
To:       info-c%brl-smoke.arpa@CSNET-RELAY.ARPA
Subject:  (foo == 0)
     
     
>>      It never fails to amaze me just how many people do this:
>>              if (foo == NULL) { ... }
>>      or:
>>              if (foo == 0) { ... }
>       [instead of...]
>>              if (!foo) { ... }
>
>       ... I changed because the (!foo)
>       notation is less readable than the (foo == 0) notation.
>
>       Also, if foo is a pointer type, the test (!foo) is wrong. NULL doesn't
>       have to be zero.
>
     
Like you, I believe the explicit comaprisons are easier to comprehend
when browsing through code than the ubiquitous (!foo) form. In the
explicit comparison cases, generally no performance overhead is incurred
because these are optimizations that are easy to implement. I'm not sure
I'd want to work with a compiler that couldn't perform the necessary
optimizations - if it couldn't, these would cause the least of the
performance penalties you'd pay !
     
However, the (!foo) form is semantically valid for pointer variables. It
may force an unseen conversion in order to work correctly, but it will
work even when NULL is not represented by 0.
     
Richard Hargrove
CSNET: harged@ti-eg
ARPA:  harged%ti-eg.arpa@csnet-relay.arpa
-----------------------------------------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4186
          for JMS@ARIZMIS; Tue, 15-JUL-1986 21:55 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/15/86 at 23:36:29 CDT
Received: from utah-cs.ARPA by SRI-KL.ARPA with TCP; Mon 14 Jul 86 08:46:03-PDT
Received: by utah-cs.ARPA (5.31/4.40.2)
    id AA12407; Mon, 14 Jul 86 09:45:44 MDT
Received: by utah-cbd.ARPA (5.31/4.40.2)
    id AA00567; Mon, 14 Jul 86 09:45:42 MDT
Date: Mon, 14 Jul 86 09:45:42 MDT
From: cetron%utah-cbd@utah-cs.arpa (Ed Cetron)
Message-Id: <8607141545.AA00567@utah-cbd.ARPA>
To: KFL%MX.LCS.MIT.EDU@mc.lcs.mit.edu, cetron%utah-cbd@utah-cs.arpa
Subject: Re:  Number crunching
Cc: Info-VAX@sri-kl.arpa
     
    I have found (totally empirically) that trying to code
large algorithms is C is somewhat confusing since in order to
optimize the calculations one must code it that way.  I have
yet to see a C compiler that optimizes the numerical calculations
(i.e. keeping things in registers to use in chained calculations).
     
    Additionally, C in the 'proper' standard is supposed to do
everything in double precison and simply convert on input/output
(yes i know not all compilers do this....) and for certain operations
(such as integer calculations) this is highly ineffecient.
     
    C is not so much worse that FORTRAN for simply coding a problem
where speed is not critical,  but for large algorithms where speed is
very important, the FORTRAN compilers tend to give smaller and faster
code than do the C compilers....
     
    NOTE WELL: this is a broad generalization and there will always
be several specific cases which will prove something (or anything) else...
     
-ed cetron

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5915
          for JMS@ARIZMIS; Wed, 16-JUL-1986 01:24 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 03:16:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006756; 16 Jul 86 4:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023562; 16 Jul 86 3:44 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pascal Origins
Message-ID: <149@danews.UUCP>
Date: 15 Jul 86 20:44:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Shouldn't this be in net.lang.pascal ?
     
>Unfortunately it teaches them bad habits as well. I was freaked royally
>when my brother told me years ago that there were no provisions for
>separate compilation. Everything in one source file, and they make
>people write large scale projects in it? Pure insanity.
     
>No `otherwise' or `default' clause on switches makes them almost useless.
     
The version of pascal I used in college six years ago allowed both
seperate compilation of source file, and an 'others' clause on switches
(called case in Pascal I thought).
--
     
Larry Cipriani        AT&T Network Systems
danews!lvc        "Nothing is worse than an itch you can never scratch."

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6509
          for JMS@ARIZMIS; Wed, 16-JUL-1986 02:55 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/16/86 at 04:50:42 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Mon 14 Jul 86
  11:26:26-PDT
Received: from mcnc by csnet-relay.csnet id af03895; 14 Jul 86 13:32 EDT
Received: from ecsvax (ecsvax.ecs) by mcnc.mcnc (5.31/4.7)
    id AA25110; Mon, 14 Jul 86 09:43:41 EDT
Received: by ecsvax (4.12/4.7)
    id AA08839; Mon, 14 Jul 86 09:43:43 edt
Date: Mon, 14 Jul 86 09:43:43 edt
From: Gerard Robinson <ecsvax!robinson%mcnc.csnet@CSNET-RELAY.ARPA>
Message-Id: <8607141343.AA08839@ecsvax>
Newsgroups: mod.computers.vax
Subject: Re: VAX C .OLB Files missing in MicroVMS 4.4
Summary: Link with .olb starts faster.
References: <8607081432.AA10312@ngp.UTEXAS.EDU>
  <8607092354.AA08886@ucbvax.Berkeley.EDU>
Reply-To: Gerard Robinson <robinson%ecsvax.uucp@CSNET-RELAY.ARPA>
Organization: North Carolina Educational Computing Service
Apparently-To: info-vax@sri-kl.arpa
     
I find that with a small program at least, that the time to run the image is
less when it is linked with the object library rather than the shareable
run-time library.  There probably is some trade-off with number of users
running the same code but I couldn't say where that limit is.
     
     
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6808
          for JMS@ARIZMIS; Wed, 16-JUL-1986 03:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 05:13:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007029; 16 Jul 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024687; 16 Jul 86 5:41 EDT
From: Roy Smith <roy%phri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <2391@phri.UUCP>
Date: 16 Jul 86 03:02:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <505@cubsvax.UUCP> peters@cubsvax.UUCP (Peter S. Shenkin) writes:
[Regarding compilers replacing calls to library routines with in-line code]
> What the hell difference does it make, from the user's point of view?
> That is, why should he ever be anything other than happy, if some
> alternative invoked by the compiler produces faster-running code?
     
    What if you want to trap and/or trace subroutine calls for
diagnostic or tuning purposes or you want to supply your own version of the
library routine because it's faster, more accurate, or more featureful?
--
Roy Smith, {allegra,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6850
          for JMS@ARIZMIS; Wed, 16-JUL-1986 03:19 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 05:14:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007033; 16 Jul 86 6:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024716; 16 Jul 86 5:42 EDT
From: daveh%cbmvax.uucp@BRL.ARPA
Newsgroups: net.lang.c,net.micro.mac,net.micro.amiga,net.micro.atari16,net.decus
Subject: Re: C compiler survey
Message-ID: <532@cbmvax.cbmvax.cbm.UUCP>
Date: 15 Jul 86 18:54:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Xref: cbmvax net.lang.c:1847 net.micro.mac:1824 net.micro.amiga:1783
 net.micro.atari16:1232 net.decus:136
>
> I'm writing a book about portable C software, and I'd like to make it
> as accurate and complete as possible.  While I'm reasonably familiar
> with several versions of UNIX, and with somewhat familiar with MS DOS,
> I haven't made much use of some other important operating systems where
> C is heavily used, including the Macintosh, Amiga, Atari ST, VMS, IBM
> MVS, and so on.
>
> Thanks in advance,
>
>     Mark Horton
>     mark@cbosgd.ATT.COM
>     mark@Berkeley.EDU
>     cbosgd!mark
     
Well, I've been using Lattice C 3.03 on an Amiga for over half a year (almost
as long as its been available).  I could send you the book on it, though I
hear that the book is basically the same as their PC implementation.  The
Lattice package contains much of the simple UNIX compatibility stuff,
though it is missing some of the more advanced UNIX packages that are
available on most UNIX systems these days.  Lattice had a reputation for
compiling slowly (TRUE) and for being overly large (somewhat TRUE).  The
problem with it, though, is more the way they organized their linker library
than anything else.  All-in-all, things port to the Amiga at least as well
as anything I've tried to port from UNIX to something like VMS, and usually
much better.  The rumor mill says that Lattice is due for a new release
soon, with a linker library more suited to the Amiga's linker and a
compiler capable of producing more efficient code.
     
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
    "I don't feel safe in this world no more,
     I don't want to die in a nuclear war,
     I want to sail away to a distant shore
     And live like an ape man."
                -The Kinks
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8020
          for JMS@ARIZMIS; Wed, 16-JUL-1986 05:10 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 07:05:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008255; 16 Jul 86 7:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025734; 16 Jul 86 7:41 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <505@cubsvax.UUCP>
Date: 15 Jul 86 15:22:05 GMT
Posted: Tue Jul 15 11:22:05 1986
To:       info-c@BRL-SMOKE.ARPA
     
>>In article <mit-eddi.2526> barmar@mit-eddie.UUCP (Barry Margolin) writes:
>>>...why not write the operations as function calls, and teach compilers
>>>to open-code calls to certain functions.
     
>In article <503@cubsvax.UUCP> peters@cubsvax.UUCP (Peter S. Shenkin) replies:
>>                ... What I'd like to know is whether the draft
>>standard permits this, and what the net guru's think about it.
     
In article <umcp-cs.2424> chris@maryland.UUCP (Chris Torek) writes:
>Apparently the committee (or a large faction thereof) is quite
>concerned about ensuring that there is some easy way to ensure a
>`real function call'.
     
Yes, apparently so, but WHY?  What the hell difference does it make, from
the user's point of view?  That is, why should he ever be anything other
than happy, if some alternative invoked by the compiler produces faster-
running code?
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7991
          for JMS@ARIZMIS; Wed, 16-JUL-1986 05:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 07:05:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008321; 16 Jul 86 8:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025741; 16 Jul 86 7:42 EDT
From: Rex Ballard <rb%cci632.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Threading in C (Re: RRe: What's so good about FORTH?
Message-ID: <223@cci632.UUCP>
Date: 15 Jul 86 17:07:27 GMT
Keywords: FORTH, threaded-code
To:       info-c@BRL-SMOKE.ARPA
     
In article <6993@boring.mcvax.UUCP> lambert@boring.uucp (Lambert Meertens)
 writes:
>In article <255@myrias.UUCP> mj@myrias.UUCP (Michal Jaegermann) writes:
>
>> The fact that Forth is "threaded" is not a part of a language definition but
>> side-effect of the most popular implementation method.  [...]  The method
>> is far from beeing unique to Forth and there are some Forth implementations
>> which are not exactly "threaded".  [...]
     
Often this is called subroutine threaded language.  It is considered "legal"
in Forth 83.
     
>How else can you implement threading if C is used as the implementation
>language?
     
>    goto *(IC++)
     
>Are there other ideas on implementing threading in C?
     
There seems to be a little confusion about threading here.  All that is
*really* required for threading is a parameter stack that is separate
from the program/return stack.
     
As far as getting indirect threading (not required, but possible),
all that is required is to have a very large "array of pointers to
funtions returning void or int".  This may be necessary if your
machine insists on keeping code and data areas separate.  This is
the technique used in Kernigan/Pikes "Hoc" language after about
revision 4.  Nice simple threading machinism without too much fuss.
As a matter of fact, Hoc would make a very nice "interpret or compile"
language.
     
int (dict [HUGE])();    /* this defines the dictionary area */
     
dict(IC++)();        /* this defines the "inner loop interpreter" */
     
It is also possible to just use subroutine calls and append parens to
each word.  If the compiler is smart enough to not try to save a lot
of context on each call, this can be very cheap.
     
In either case, a separate parameter stack of ints or longs provides
a nice effective threading.  This technique is even described in the
K&R C programmers manual.
     
You don't have to have forth to get the benifits of threaded code.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8178
          for JMS@ARIZMIS; Wed, 16-JUL-1986 05:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 07:29:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008859; 16 Jul 86 8:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025760; 16 Jul 86 7:42 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <2205@ihlpg.UUCP>
Date: 15 Jul 86 21:01:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >In article <mit-eddi.2526> barmar@mit-eddie.UUCP (Barry Margolin) writes:
> >>...why not write the operations as function calls, and teach compilers
> >>to open-code calls to certain functions.
>
> In article <503@cubsvax.UUCP> peters@cubsvax.UUCP (Peter S. Shenkin) replies:
> >Yes;  I tried to send off a similar comment on the original posting, but
> >it never made it off site.  What I'd like to know is whether the draft
> >standard permits this, and what the net guru's think about it.
> >
> >In Chris Torek's comment on the original posting, he proposes a workaround
> >permitted by the draft ANSI, and notes that it is bug-prone.  If this means
> >that the draft standard doesn't permit "function calls" to be implemented
> >otherwise, I'm curious what the objections are to this practice.
>
> Actually, the workaround comes off as being recommended by the
> draft standard, at least to me.  I am not certain it is bug-prone,
> but it sure does `feel' odd.
>
> Apparently the committee (or a large faction thereof) is quite
> concerned about ensuring that there is some easy way to ensure a
> `real function call'.  They want a standardised way of defeating
> in-line expansion, and have, at least for the nonce, settled upon
> `#undef funcname'.  A `#pragma' seems to me to be at least as good
> an idea; compilers that never open-code a function call can ignore
> this, while those that might perform this optimisation could be
> required to pay attention to at least this one pragma.  Then instead
> of
>
>     #include <math.h>
>     #undef sin            /* make sure we get a function */
>     ...
>
> we might have
>
>     #include <math.h>
>     #pragma disable_inline(sin)    /* get a function */
>     ...
>     #pragma enable_inline(sin)    /* back to possible inline */
>     ...
>     #pragma disable_inline(sin)    /* back to function */
>
> This has the advantage of being reversible, as well.
> --
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
> UUCP:    seismo!umcp-cs!chris
> CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu
     
Has anyoe proposed :
#suspend    alpha
#restore    alpha
to allow temporary suspension of a macro.
#undef
would mean multiple defines to restore the macro, which could be a pain
to maintain, or imposes some odd coding conventions
     
--j.a.tainter

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8357
          for JMS@ARIZMIS; Wed, 16-JUL-1986 05:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 07:49:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009035; 16 Jul 86 8:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025800; 16 Jul 86 7:43 EDT
From: Andy Kashyap <aka%cbrma.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: swap() macro
Message-ID: <4728@cbrma.UUCP>
Date: 7 Jul 86 18:37:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2225@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>In article <1836@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn
>(VLD/VMB) <gwyn>) writes:
>>It may be amusing and/or instructive to contemplate the fact that
>>there is no way to write a function that exchanges the contents of
>>two variables in a language where parameters are passed "by name".
>
>How so?  It seems rather simple.  I have here a C program that effects
>call-by-name and does indeed perform a swap:
     
[ ... fragmen
x    39    T cd018211043435 cbuxd05279     cbuxd    local
40    T cd018211590636 cbuxd06482     cbuxd    local
41    T cd018213050437 cbuxa07806     cbuxa    local
42    T cd018213051338 cbuxb07820     cbuxb    local
43    T cd018213052139 cbuxd07838     cbuxd    local
44    T cd018213052740 cblpe07854     cblpe    local
45    T cd01

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9273
          for JMS@ARIZMIS; Wed, 16-JUL-1986 08:28 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 10:09:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014564; 16 Jul 86 10:59 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002689; 16 Jul 86 10:38 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06452; Wed, 16 Jul 86 10:37:11 edt
Date: Wed, 16 Jul 86 10:37:11 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607161437.AA06452@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, lvc%danews.uucp@BRL.ARPA
Subject: Re: Pascal Origins
     
    Shouldn't this be in net.lang.pascal ?
     
This is in response to a comparison with C.
     
    >Unfortunately it teaches them bad habits as well. I was freaked royally
    >when my brother told me years ago that there were no provisions for
    >separate compilation. Everything in one source file, and they make
    >people write large scale projects in it? Pure insanity.
     
    >No `otherwise' or `default' clause on switches makes them almost useless.
    The version of pascal I used in college six years ago allowed both
    seperate compilation of source file, and an 'others' clause on switches
    (called case in Pascal I thought).
    --
     
That wasn't Pascal. It was someone's *enhancement* of Pascal. I know I'm
splitting hairs, but it still sucks.
     
    Larry Cipriani        AT&T Network Systems     danews!lvc
    "Nothing is worse than an itch you can never scratch."
     
Ah yes. And Marilyn Monroe is dead.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
On the other hand, life can be an endless parade of TRANSSEXUAL QUILTING BEES
aboard a cruise ship to DISNEYWORLD if only we let it!!
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3160
          for JMS@ARIZMIS; Wed, 16-JUL-1986 14:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 16:26:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004523; 16 Jul 86 16:48 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a015273; 16 Jul 86 15:25 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a001840; 16 Jul 86 15:13 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA06855; Wed, 16 Jul 86 15:08:45 edt
Date: Wed, 16 Jul 86 15:08:45 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607161908.AA06855@icst-cmr.ARPA>
To: info-c@BRL.ARPA
Subject: Yow! It's Limerick Time!
     
Last night while reading Dirty Limericks by (get this) Isaac Asimov
I became inspired. This ain't C, but it ain't "=" vs ":=" either.
Here they are from best to worst. The first is somewhat timely.
     
    A BRL expert named Gwyn
    Said "Root Boy pray tell why you sin.
        Your postings so flippy
        Remind me of Zippy
    Who thinks with the head of a pin."
     
    Chris Torek who hangs out on Mimsy
    Hacked all the code he thought flimsy
        But soon he had nought
        Any code that was bought
    So great was the scope of his whimsy.
     
    There once was a Guy out at SUN
    Who said "My idea of fun
        Is X3J11
        I think it pure heaven
    I've resisted temptation to pun."
     
    McKusick@Berkeley.EDU
    Says "TPC don't write code like we do
        They call all their jive
        The Standard -- System V
    While hoarding V8 for de few."
     
    At utzoo one Henry Spencer
    Finds 4.2 somewhat quite denser
        While reviling ADA
        He found some more data
    That Ed Meese felt required to censor.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
WHOA!! Ken and Barbie are having TOO MUCH FUN!!  It must
be the NEGATIVE IONS!!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5107
          for JMS@ARIZMIS; Wed, 16-JUL-1986 18:08 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/16/86 at 20:03:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005730; 16 Jul 86 20:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019789; 16 Jul 86 19:43 EDT
From: FJ Hirsch <fjh%cord.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C question
Message-ID: <306@cord.UUCP>
Date: 16 Jul 86 19:48:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
What is the difference between:
     
extern    char    *A;
     
and
     
extern    char    A[];
     
If you do: printf("A=%s\n",A);
the first causes a core dump, the second works.
     
I thought pointers and arrays were equivalent?
     
-----
Please send me mail, if you understand this.
Thanks!
     
--
     
<*> Fred Hirsch <*> AT&T Bell Laboratories <*> ihnp4!cord!fjh <*>

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8131
          for JMS@ARIZMIS; Thu, 17-JUL-1986 01:22 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/17/86 at 02:47:25 CDT
Received: from seismo.CSS.GOV by SRI-KL.ARPA with TCP; Tue 15 Jul 86
  09:03:42-PDT
Return-Path: <hadron!jsdy>
Received: from hadron.UUCP by seismo.CSS.GOV with UUCP; Tue, 15 Jul 86 11:03:31
  EDT
Received: by hadron.UUCP (4.12/4.7) id AA00312; Tue, 15 Jul 86 01:15:13 edt
Date: Tue, 15 Jul 86 01:15:13 edt
From: hadron!jsdy@seismo.CSS.GOV (Joseph S. D. Yao)
Message-Id: <8607150515.AA00312@hadron.UUCP>
To: info-vax@sri-kl.ARPA, LEICHTER-JERRY@YALE.ARPA
Subject: Re: main() and entry points in C
Newsgroups: mod.computers.vax
In-Reply-To: <870@bu-cs.UUCP>
Organization: Hadron, Inc., Fairfax, VA
     
Newsgroups: net.lang.c
Subject: Re: Request for Comments
Summary: Combatting nonsense!
     
In article <870@bu-cs.UUCP> bzs@bu-cs.UUCP (Barry Shein) writes:
>Any comments? This is taken from INFO-VAX (mod.computers.vax):
>Path: bu-cs!harvard!caip!think!nike!styx!YALE.ARPA!LEICHTER-JERRY
>From: LEICHTER-JERRY@YALE.ARPA
>Subject: Re: main() and entry points in C
>Date: Thu, 26-Jun-86 08:50:52 EDT
>
>        ...  Thus, _start == NULL.  Most users will never see this,
>but an implementer of _start() would.
     
If some implementation of C uses _start instead of start as an
entry point, they are asking for trouble.  I have never seen a
C-accessible symbol as an entry.  The entry point, start, used
to be almost always 0; but it isn't ever 0, now, in the latest
releases of AT&T System V Unix.
     
>    --  still going to bet that the first routine WON'T end up as the entry
>    point?
>    I won't bet on anything if the loader isn't invoked properly....
>That gets to the crux of things:  The "proper" way to invoke the loader is
>undocumented - you must use cc.  How then do you deal with a program written
>in multiple languages?  Basically, you ask a wizard....
     
On many versions of Unix, it is documented that properly written
multiple-language modules can be compiled together by appropriately
calling the compiler:
    cc myc.c myftn.o ...        or
    f77 myftn.f myc.o ...        or even
    f77 myftn.f myc.c ...
     
>        ..  Since the "entry point is the first routine" IS, in fact,
>documented - even if only for wizards! - supporting it couldn't hurt....
     
You claim this is a documented undocumented feature?  It isn't
even true.  Specifically,
    never_called() { printf("Hi.  Joe is wrong.\n"); }
    main() { printf("Hello world.\n"); }
will never call me a liar.  Even if you are talking about
straight link-loaded objects (with no header to call _main()),
several common loaders allow one to specify entry points
other than 0.  These include, but are not! limited to, the
AT&T System V ld (again); the CULC Fortran IV Plus linker;
and the DEC VMS linker.
     
The C header, which cc puts at the head of the compiled objects,
contains the entry point -- which is not at location 0 under all
versions of Unix!  This header moves the argc, argv, and envp to
a location that main() will understand when called as a function;
then calls main() as a function; then calls exit() as a function
whose argument is main()'s return value; and if this doesn't exit,
typically tries to perform an exit system call itself, and then
(in desperation) a halt.
     
I should say it TYPICALLY does all this.  If it ain't documented
(and especially if it's not in the standard), it ain't guaranteed,
so don't bet the lunch money, Mildred.
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1881
          for JMS@ARIZMIS; Thu, 17-JUL-1986 09:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 11:12:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015768; 17 Jul 86 11:49 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a000308; 17 Jul 86 10:55 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a014438; 17 Jul 86 10:54 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA10748; Thu, 17 Jul 86 10:50:06 edt
Date: Thu, 17 Jul 86 10:50:06 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607171450.AA10748@icst-cmr.ARPA>
To: LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
Subject: Vindication
Cc: gwyn@BRL.ARPA, info-c@BRL.ARPA
     
    Jim,
        I find it somewhat amusing that you say I'm obviously a
    novice after I have been using C for 6 years (starting
    on an early Version 6 PDP 11/34). I'm even the resident expert
    at Camp Wondermite on UNIX and C; obviously, we are still in
    the Dark Ages here but at least I recognize that fact.
     
I'm glad you're amused. I would probably be offended. You can't always
tell the level of the questioner by his questions. Sorry about that.
     
    Anyway, this is a thank you note for your responses both to my original
    question and to Doug Gwyn's reply. The info contained therein
    was quite useful and I *DID* appreciate the (explicitly)
    non-portable, quick and dirty solution. Having spent the last 2
    years porting FranzLISP around, I think I can appreiciate both
    portable and non-portable code. Anyway,
     
Well, that's music to my ears.
                    Thanx,
                        David Linn
     
    P.S. I am another of those who enjoys the Pinhead Quotes that accompany
    your postings.
     
They come from `yow', a Zippy fortune-like program packaged with GNU EMACS.
I could send it to you if you like. Do you have COMPRESS? BTOA? UUDECODE?
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
DON'T go!! I'm not HOWARD COSELL!! I know POLISH JOKES...WAIT!! Don't
go!! I AM Howard Cosell! ...And I DON'T know Polish jokes!!
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2874
          for JMS@ARIZMIS; Thu, 17-JUL-1986 11:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 12:02:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016942; 17 Jul 86 12:44 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a001129; 17 Jul 86 11:18 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a014685; 17 Jul 86 11:11 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA10773; Thu, 17 Jul 86 11:07:38 edt
Date: Thu, 17 Jul 86 11:07:38 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607171507.AA10773@icst-cmr.ARPA>
To: INFO-C@BRL.ARPA, LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
Subject: ALGOL begat LISP?
     
    >LISP and Pascal are both descendants of Algol 60.
     
I find this hard to believe, considering that Algol is procedural
(normal) and LISP is expressional (weird (interesting)).
     
Put another way, and abstracting quite a bit, there are really only a
few languages: fortran, cobol, PL/I, pascal, basic, and C ARE ALL
THE SAME LANGUAGE (I know, that thought hurts). The OTHER languages
are LISP, APL, SNOBOL, FORTH, and probably PROLOG and SMALLTALK, altho
I don't know anything about the last two. They may even be `the same'.
     
This is like saying that Spanish, French, and Italian are `all the
same' language and that the others are the Oriental (all the same)
and possibly equating English with German.
     
I'm sure there are others that exist in both analogies.
We need a place for assembly language in there somewhere.
     
Don't take this any too seriously, it's just random thoughts.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    I'm in direct contact with many advanced fun CONCEPTS.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7460
          for JMS@ARIZMIS; Thu, 17-JUL-1986 20:29 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 20:53:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024676; 17 Jul 86 20:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010418; 17 Jul 86 19:41 EDT
From: Mark Purtill <purtill%petrus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Re: Precedent for use of = (Actually NULL & 0)
Message-ID: <223@petrus.UUCP>
Date: 16 Jul 86 15:39:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>I've been looking at 4.3 code, particularly for the Sun.  There are plenty of
>places where pointers are used indifferently as pointers to structures and
>as pointers to arrays.  There is code which relies on ints and pointers being
>the same size.  There is code which relies on successive declarations being
>stored contiguously and in order.
All of these are of course nonportable, but....
>Code which relies on NULL equalling zero
>is omnipresent.
This is perfectly legal.  NULL == 0.  A null pointer may NOT be 0, but
that's the compiler's problem, not yours.  When the CONSTANT 0 is converted
to a pointer, it has to be changed into a null pointer.  This was gone thru
in great detail a few months ago.
     
            mark purtill            (201) 829-5127
^.-.^ Arpa: purtill@bellcore.com    435 south st 2H-307
((")) Uucp: ihnp4!bellcore!purtill  morristown nj 07960

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8699
          for JMS@ARIZMIS; Thu, 17-JUL-1986 20:30 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/17/86 at 21:56:11 CDT
Received: from seismo.CSS.GOV by SRI-KL.ARPA with TCP; Wed 16 Jul 86
  15:06:19-PDT
Return-Path: <allegra!rayssd!bkb>
Received: from allegra.UUCP by seismo.CSS.GOV with UUCP; Wed, 16 Jul 86
  17:44:35 EDT
Message-Id: <8607161743.AA09986@rayssd.UUCP>
Date: Wed, 16 Jul 86 13:43:01 edt
From: allegra!rayssd!bkb@seismo.CSS.GOV (Brian K. Belson)
To: allegra!seismo!info-vax@sri-kl.arpa
Subject: Pascal call tracer needed
     
We have several Pascal routines as part of a Pascal application
that we need to analyze.  What we need to do is generate a call
tree for this application.  Does anyone know of the existance
of a Pascal call tracer?  Please send response via. mail, for I
do not read these lists that often.
     
Thanks in advance.
     
----------
| Brian  | UUCPmail: {allegra, decvax!brunix, linus!raybed2}!rayssd!bkb
| Belson | RAYmail:  rayssd::bkb
---------- ARPAnet:  allegra!rayssd!bkb@SEISMO.CSS.GOV
           USmail:   Raytheon Company, Submarine Signal Division,
                     1847 W Main Road, Portsmouth, RI 02871
                     Attention: Brian Belson, Box 184
           Phone:    401/847-8000 (x2078)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7245
          for JMS@ARIZMIS; Thu, 17-JUL-1986 20:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 20:40:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024563; 17 Jul 86 19:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010422; 17 Jul 86 19:41 EDT
From: Mark Purtill <purtill%petrus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <224@petrus.UUCP>
Date: 16 Jul 86 15:44:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <505@cubsvax.UUCP> cubsvax!peters (Peter S. Shenkin) writes:
> In article <umcp-cs.2424> chris@maryland.UUCP (Chris Torek) writes:
> >Apparently the committee (or a large faction thereof) is quite
> >concerned about ensuring that there is some easy way to ensure a
> >`real function call'.
> Yes, apparently so, but WHY?  What the hell difference does it make, from
> the user's point of view?  That is, why should he ever be anything other
> than happy, if some alternative invoked by the compiler produces faster-
> running code?
>
> Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
> {philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA
     
Ever heard of debugging?  You might well want to set a trap at that
function, or even replace it with a different version that is somehow
useful, such as a version that prints out its arguments.
     
            mark purtill            (201) 829-5127
^.-.^ Arpa: purtill@bellcore.com    435 south st 2H-307
((")) Uucp: ihnp4!bellcore!purtill  morristown nj 07960

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8025
          for JMS@ARIZMIS; Thu, 17-JUL-1986 20:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 21:23:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024994; 17 Jul 86 22:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011456; 17 Jul 86 21:46 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Sizeof structure members
Message-ID: <444@dg_rtp.UUCP>
Date: 16 Jul 86 17:35:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> lvc@danews.UUCP (Larry Cipriani)
     
> [How does one take sizeof a struct member without an instance of it?]
> I didn't want to define a global variable of type 'struct utmp *',
> because I didn't need it, and lint would complain because I didn't
> use it.  I could declare an external variable of type 'struct utmp *',
> that I'd never use, but this seems just as bad as the unused global.
     
This solution is fairly portable, and may even be legal:
     
        struct s {char a[3];};
        void main(){
            printf( "%d\n", sizeof( ((struct s *)0)->a ) );
        }
     
It works on a at least a couple of machines, and lint doesn't complain.
It may be argued that it is not legal, since it is dereferencing the
null pointer.  On the other hand, sizeof is guaranteed not to evaluate
the object being sizeofed, and to only calculate resulting types, not
values.  It's issues like these that give language lawyers headaches,
right?
     
--
A program without a loop and a structured variable isn't worth writing.
                                --- Alan J. Perlis
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7407
          for JMS@ARIZMIS; Thu, 17-JUL-1986 20:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 20:51:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024567; 17 Jul 86 19:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010493; 17 Jul 86 19:44 EDT
From: Ben Cranston <zben@umd5.ARPA>
Newsgroups: net.lang.c
Subject: Re: WITH statement
Message-ID: <1080@umd5.umd.edu>
Date: 17 Jul 86 02:25:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2366@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
> (I have a feeling that `WITH' originally meant `Listen, compiler,
> put a pointer to this here record into a machine register now,
> because I am about to use it a whole bunch.')
     
And well it might, if the subject record be selected from a record array.
The Pascal compiler on the SperrySaur has a limit of something like five
of these "nontrivial WITHs" to be open at any one time.
     
The idea was to avoid repeating the same selector expression over and over
again, and is akin to the C syntax:
     
       maskarray[selector] |= xbit;     /* Set X bit in maskarray */
     
The ambiguous condition scares me too, and I think I could live much better
with being able to take the address of the thing and then using it, like:
     
       recpointer := &recarray[selector];
       ...
       recpointer^.foo := 1;
       recpointer^.bar := 2;
     
While the & operator (find address) is highly non-standard Pascal, you can
do much the same thing in legal C right now.  Why mess with the language?
     
Not only has UMD5 arisen as a MicroVax from its previous incarnation as an
11/44, but I am using a Macintosh Plus and MacKermit to type this in.
Are we having fun yet?
     
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7186
          for JMS@ARIZMIS; Thu, 17-JUL-1986 20:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 20:36:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024390; 17 Jul 86 19:21 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a009949; 17 Jul 86 18:32 EDT
Received: from acc.arpa by AOS.BRL.ARPA id a024143; 17 Jul 86 18:33 EDT
Date: 17 Jul 86 15:17:00 PST
From: art@ACC.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject: Not again!
To: info-c <info-c@BRL.ARPA>
Reply-To: art@ACC.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
     
     
> What is the difference between:
> extern    char    *A;
> and
> extern    char    A[];
>
> If you do: printf("A=%s\n",A);
> the first causes a core dump, the second works.
>
> I thought pointers and arrays were equivalent?
> <*> Fred Hirsch <*> AT&T Bell Laboratories <*> ihnp4!cord!fjh <*>
     
AARRRGGHH!!! Not this AGAIN!
     
1) extern    char *A;
     
    This declares a variable which contains a POINTER which is
    used to reference entities of type CHAR.
     
2) extern    char A[];
     
    This declares a variable which contains an ARRAY of entities
    of type CHAR (of unspecified length).
     
When allocating memory, the first form causes enough memory to be allocated
to hold an address which points to a char sized entity.  The second form causes
enough memory to be allocated to hold a sequence of char sized entities
(the number must be specified by an explicit subscript or an initializer
when storage is being allocated).
     
When an array name is used in an expression, it is EQUIVALENT to a POINTER
to the FIRST ELEMENT of the array.  The transformations:
     
    A[i] <--> *(ptr-to-A + i)
        and
    A <--> ptr-to-A
     
do NOT make arrays and pointers the same thing!
     
                    <Art@ACC.ARPA>
     
------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7336
          for JMS@ARIZMIS; Thu, 17-JUL-1986 20:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/17/86 at 20:45:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024565; 17 Jul 86 19:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010488; 17 Jul 86 19:44 EDT
From: FJ Hirsch <fjh%cord.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: c answer: THANKS
Message-ID: <308@cord.UUCP>
Date: 17 Jul 86 03:34:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I wish to thank everyone that answered my question. The following
is a very clear explanation. The usage of A rather than &A[0] for arrays
had me blinded. Thanks.
     
>    From ulysses!utah-cs!b-davis Wed Jul 16 19:39 EDT 1986
>    Date: Wed, 16 Jul 86 17:36:32 MDT
>    From: ulysses!utah-cs!b-davis (Brad Davis)
>    Subject: Re: C question
>    Message-Id: <8607162336.AA02526@utah-cs.ARPA>
>    Received: by ulysses.UUCP; Wed, 16 Jul 86 19:38:13 edt
>    Received: by utah-cs.ARPA (5.31/4.40.2)
>        id AA02526; Wed, 16 Jul 86 17:36:32 MDT
>    Received: from ulysses.UUCP by lc/garage/cord.DK; 8607162339
>    To: cord!fjh
>    Newsgroups: net.lang.c
>    In-Reply-To: <306@cord.UUCP>
>    Organization: University of Utah VCIS Group
>    Cc:
>    Status: R
>
>    In article <306@cord.UUCP> you write:
>    >What is the difference between:
>    >extern    char    *A;
>    >and
>    >extern    char    A[];
>    >
>    >If you do: printf("A=%s\n",A);
>    >the first causes a core dump, the second works.
>    >
>    >I thought pointers and arrays were equivalent?
>    NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO :-)
>
>    The first says that A is a pointer.  On a VAX that means that the
>    four bytes A+0, A+1, A+2, and A+3 are made into a pointer to a char.
>    The second says that A is an array.  On a VAX that means that some
>    number of bytes after A (A+0, A+1, A+2, and on up to A+whatever)
>    are characters.
>    --
>    Brad Davis    {ihnp4, decvax, seismo}!utah-cs!b-davis
>            b-davis@utah-cs.ARPA
>    One drunk driver can ruin your whole day.
>
--
     
<*> Fred Hirsch <*> AT&T Bell Laboratories <*> ihnp4!cord!fjh <*>

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2661
          for JMS@ARIZMIS; Fri, 18-JUL-1986 01:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 03:37:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026044; 18 Jul 86 4:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013903; 18 Jul 86 3:48 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: icky C code
Message-ID: <2449@umcp-cs.UUCP>
Date: 17 Jul 86 02:25:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2446@umcp-cs.UUCP> I wrote:
>In 1978 (or perhaps earlier, but the documentation says July 1978),
>Steven C. Johnson recognised the need for a type-checker for the
>C language. ...
     
Ai!  Make that `Stephen C. Johnson.'  ---Or perhaps `S. C. Johnson',
as it says in the documentation.  My apologies for misspelling your
name.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2478
          for JMS@ARIZMIS; Fri, 18-JUL-1986 01:48 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 03:30:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026040; 18 Jul 86 4:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013844; 18 Jul 86 3:46 EDT
From: franka%mntgfx.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re:  swap() macro (LISP & Algol)
Message-ID: <377@apollo.mntgfx.UUCP>
Date: 15 Jul 86 20:44:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2498@mit-eddie.MIT.EDU> ambar@mit-eddie.UUCP (Jean Marie Diaz)
 writes:
>LISP and Pascal are both descendants of Algol 60.
>--
     
    Unfortunately, this is not true.  PASCAL IS a descendant of ALGOL 60.
The evolution of LISP has nothing to do with that of ALGOL, FORTRAN, or any
other language of that era.  People who are interested might check out
Wexelblat's "History of Programming Languages" where John McCarthy includes
a paper on the history of LISP (if anybody knows this, he should).  I'm not
sure of the publisher (I have my copy at home), but it's whoever publishes the
ACM Monograph series.
                Frank Adrian
                Mentor Graphics, Inc.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2263
          for JMS@ARIZMIS; Fri, 18-JUL-1986 01:48 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 03:13:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025988; 18 Jul 86 4:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013735; 18 Jul 86 3:43 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <507@cubsvax.UUCP>
Date: 16 Jul 86 13:27:59 GMT
Posted: Wed Jul 16 09:27:59 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <phri.2391> roy@phri.UUCP (Roy Smith) writes:
>[Regarding compilers replacing calls to library routines with in-line code]
     
>    What if you want to trap and/or trace subroutine calls for
>diagnostic or tuning purposes...
Then you're no worse off than tracing or timing portions of your own in-line
code.
     
>            ... or you want to supply your own version of the
>library routine because it's faster, more accurate, or more featureful?
Use a #define to a new name, or code in a new name (one of these is probably
best), or disenable in-line expansion of code by means of a compile-time flag.
(In one of my postings I suggested that such a flag be available, but it's
probably not really necessary.)  Another possibility: if the compiler knew
about things like sin(x), then the -lm flag would not be necessary in programs
that "call" it; thus specifying -lm could over-ride in-line expansion....
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2580
          for JMS@ARIZMIS; Fri, 18-JUL-1986 01:48 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 03:33:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026042; 18 Jul 86 4:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013879; 18 Jul 86 3:47 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: icky C code
Message-ID: <2446@umcp-cs.UUCP>
Date: 17 Jul 86 00:17:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2239@brl-smoke.ARPA> mangoe@mimsy.umd.edu (Charley Wingate) writes:
>... I've been looking at 4.3 code, particularly for the Sun.  There
>are plenty of places where pointers are used indifferently as
>pointers to structures and as pointers to arrays.
     
If you mean `pointers to structures and pointers to arrays of those same
structures', there is nothing wrong with that.  The C memory model demands
that an array be a linear arrangement of its components.  If this is not
true on a machine, that machine does not run C code.
     
>There is code which relies on ints and pointers being the same size.
     
Alas, this seems to creep in everywhere---usually as a result of
programmer laziness.  An imagined programming session:
     
    /* Oops, gotta call getenv, but the declarations are all
       way above.  Enh, I won't bother declaring it. */
    p = (char *) getenv("FOO");
     
First, this is bad coding, like writing unnecessary LOOPHOLEs in Mesa.
Second, lint will complain.  Third, it is not really all that hard to
go put in the declaration.  Leave out the cast and even the compiler
will complain, which will remind you to go clean up!
     
>There is code which relies on successive declarations being stored
>contiguously and in order.
     
Where?
     
>Code which relies on NULL equalling zero is omnipresent.
     
But NULL *must* equal zero.  If you mean `the bit pattern of the
null pointer-to-X equalling the bit pattern of the zero integer',
again, this is bad coding, and again, lint will complain.
     
>All this leads me inescapably to the conclusion that C was designed
>to allow programmers to violate the rules which everyone else is
>busily putting into their languages to protect themselves.
     
In 1978 (or perhaps earlier, but the documentation says July 1978),
Steven C. Johnson recognised the need for a type-checker for the
C language.  He wrote one.  It is called lint.  If you think
type-checking is good, *use it*.  If you just want your program
to work on your Widget-brand computer, do whatever you like---
though you might still find lint useful.
     
There are those who consider `lint' a necessary part of the C
compiler, that the proper compilation command is
     
    lint file.c; cc file.c -o file
     
These people never seem to worry about all the problems you describe.
The C language has a good type-checker.  It is just not built into
the `normal' compiler.  This may be a serious problem to some, but
I have never found it to be so.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2794
          for JMS@ARIZMIS; Fri, 18-JUL-1986 01:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 03:45:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026064; 18 Jul 86 4:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013923; 18 Jul 86 3:49 EDT
From: Sabalaskey <saba%ihlpl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: rotate operators
Message-ID: <1115@ihlpl.UUCP>
Date: 16 Jul 86 14:25:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Since I'm seeing lots of things about compiler specfic operators and
rotate as an example, I'll post some history. C compilers for the
Z80 and MAC-8 (an AT&T 8 bit CPU) used <<< and >>> for rotate.
     
i = x >>> 3;    /* rotate x right by three bits */
i = y <<< n;    /* rotate y left by n bits */
i >>>= 2;    /* rotate i right by two bits */
     
You get the idea. This was great when you had to write firmware
that fiddled with hardware registers and such.
     
     
Bruce Sabalaskey
ihnp4!ihlpl!saba

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2751
          for JMS@ARIZMIS; Fri, 18-JUL-1986 01:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 03:42:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026062; 18 Jul 86 4:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013907; 18 Jul 86 3:48 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C question
Message-ID: <2451@umcp-cs.UUCP>
Date: 17 Jul 86 03:57:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <306@cord.UUCP> fjh@cord.UUCP (FJ Hirsch) writes:
>What is the difference between:
>
>extern    char    *A;
>
>and
>
>extern    char    A[];
     
Quite a bit.  The former tells the compiler that there is a variable
named `A' defined externally, and that its type is `pointer to
char'.  The latter tells it that there is a variable named `A'
defined externally, and that its type is `array of char'.  These
are most certainly *not* equivalent.  A Vax compiler, for example,
treats the former as a four-byte variable, and the latter as a
`link-time constant'.
     
>If you do: printf("A=%s\n",A);
>the first causes a core dump, the second works.
     
In that case, the actual defintion must have been
     
    char A[<constant>];
     
>I thought pointers and arrays were equivalent?
     
No.  This confusion seems to arise from C's convention of treating
the name of an array (in many places, but not all) as a pointer to
the first element of that array.  It is heightened by C's convention
of allowing an `array' declaration as a formal parameter:
     
    f(s)
        char s[];
    {
        ...
     
It might have been better if compilers refused to accept such a
declaration, rather than silently altering it to read
     
        char *s;
     
So when *is* an object of type `array of <stuff>' treated as an
object of type `pointer to <stuff>'?  If I have not forgotten
anything, the answer is `everywhere except in sizeof and in actual
declarations'.  `extern char *A' and `extern char A[]' are actual
(not formal) declarations.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3552
          for JMS@ARIZMIS; Fri, 18-JUL-1986 03:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 05:03:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026246; 18 Jul 86 6:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015114; 18 Jul 86 5:42 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <2600069@ccvaxa>
Date: 16 Jul 86 15:06:00 GMT
Nf-ID: #R:brl-smoke.ARPA:2032:ccvaxa:2600069:000:272
Nf-From: ccvaxa.UUCP!aglew    Jul 16 10:06:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
    C assumes the programmer knows what he is doing and lets him do it.
    Pascal assumes the programmer does not know what he is doing and
    prevents him.
     
    Kind of like Georgia telling you what you can put in your mouth.
     
Does this mean that C is a language for sodomists?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3726
          for JMS@ARIZMIS; Fri, 18-JUL-1986 03:18 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 05:09:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026263; 18 Jul 86 6:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015145; 18 Jul 86 5:42 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: icky C code
Message-ID: <3117@utcsri.UUCP>
Date: 17 Jul 86 19:00:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2446@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes:
>>There is code which relies on ints and pointers being the same size.
>
>Alas, this seems to creep in everywhere---usually as a result of
>programmer laziness.  An imagined programming session:
>
>    /* Oops, gotta call getenv, but the declarations are all
>       way above.  Enh, I won't bother declaring it. */
>    p = (char *) getenv("FOO");
>
>First, this is bad coding, like writing unnecessary LOOPHOLEs in Mesa.
>Second, lint will complain.  Third, it is not really all that hard to
>go put in the declaration.  Leave out the cast and even the compiler
>will complain, which will remind you to go clean up!
>
Fourth, it is not guaranteed to be portable. It will probably be a lot more
portable than it should be, though. Compiler implementors have gone to
surprising lengths to allow this sort of thing. From a code efficiency
standpoint, for example, a 68000 should return int's in D0 and all pointer
types in A0, which would break the above. ( Somebody pointed out that a
certain 68K compiler has an option to return both types in *both* regs ).
Or am I wrong, and there is a non-unwritten ( i.e. official ) rule that
says everything should return in the same reg whenever possible?
     
Imagine a library function ( coded in assembler ) which returns a useful
int value if declared int and a useful, different, pointer value if declared
as a pointer! ( not a serious suggestion, but would be feasible if the
same code were given two names ).
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3844
          for JMS@ARIZMIS; Fri, 18-JUL-1986 03:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 05:16:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026273; 18 Jul 86 6:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015167; 18 Jul 86 5:43 EDT
From: "Peter S. Shenkin" <peters%cubsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <509@cubsvax.UUCP>
Date: 17 Jul 86 14:02:04 GMT
Posted: Thu Jul 17 10:02:04 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <petrus.224> purtill@petrus.UUCP (Mark Purtill) writes:
[re: reasons for not permitting a compiler to expand "function calls" in-line]
     
>Ever heard of debugging?  You might well want to set a trap at that
>function, or even replace it with a different version that is somehow
>useful, such as a version that prints out its arguments.
     
If you want to set a trap, in-line expansion is no worse than having to deal
with anything else in your code that doesn't call a function.
     
If you want to replace the built-in function with a new version, either use a
new name in-line, or else write a #define to a new name.
     
Since most people don't have source code to the math library anyway, both
of your suggestions would seem to be more useful for debugging the compiler or
math library than for debugging user code that invokes them.  Assuming one has
a compiler that works, these features would seem to be of little use to the
USER, as opposed to the compiler-writer.  And I don't care about the compiler-
writer!
     
But I'd still like to hear someone on the committee confirm that this
is disallowed (if, in fact, it is!), and comment on what went into the
committee's decision to disallow it.
     
Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3926
          for JMS@ARIZMIS; Fri, 18-JUL-1986 03:24 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 05:20:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026299; 18 Jul 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015181; 18 Jul 86 5:44 EDT
From: "Ira G. Chayut" <ira%slovax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: 1986 Obscure C Code winners wanted
Message-ID: <167@slovax.UUCP>
Date: 16 Jul 86 17:33:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
It appears as if I missed the posting of the 1986 Obscure C Contest (my
node has been having intermittent troubles with it's news feed).  If
anyone grabbed a copy I would appreciate it if they could mail it to me.
     
Thanks.
    Ira Chayut
    R & D Associates
    3625 Perkins Lane, SW
    Tacoma, WA 98499
    (206) 581-1322
    ....uw-beaver!tikal!slovax!ira

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4308
          for JMS@ARIZMIS; Fri, 18-JUL-1986 03:44 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 05:39:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026366; 18 Jul 86 6:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015259; 18 Jul 86 5:46 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: Re: ALGOL begat LISP?
Message-ID: <881@ucbcad.BERKELEY.EDU>
Date: 18 Jul 86 00:08:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2334@brl-smoke.ARPA>, rbj@icst-cmr.ARPA (Root Boy Jim) writes:
> Put another way, and abstracting quite a bit, there are really only a
> few languages: fortran, cobol, PL/I, pascal, basic, and C ARE ALL
> THE SAME LANGUAGE (I know, that thought hurts). The OTHER languages
> are LISP, APL, SNOBOL, FORTH, and probably PROLOG and SMALLTALK, altho
> I don't know anything about the last two. They may even be `the same'.
     
I'd tend say that all the languages you mention except prolog are one
language, and prolog is the other one -- they're all procedural, while
prolog is declarative.  But when you look closer, the procedural languages
differentiate themselves pretty much as you describe them...
     
    Wayne

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4202
          for JMS@ARIZMIS; Fri, 18-JUL-1986 04:01 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 05:33:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026303; 18 Jul 86 6:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015227; 18 Jul 86 5:45 EDT
From: Bill Jones <billj%zaphod.uucp@BRL.ARPA>
Newsgroups: net.wanted,net.lang.c
Subject: C cross-compiler wanted for Z8000
Message-ID: <622@zaphod.UUCP>
Date: 16 Jul 86 01:11:13 GMT
Followup-To: net.wanted
Keywords: Zilog Z8000 C UNIX compiler
To:       info-c@BRL-SMOKE.ARPA
     
Our company produces real-time networking systems which are written in C to
run on Zilog Z8001 processors.  We presently do the final code development
on a number of Zilog S8000 machines, but their speed limitations and the
fragmentation of our project code are causing significant headaches, and
we're looking for a cross-compiler system to run on our UNIX VAX and
produce segmented Z8000 (i.e. Z8001) code.  Of the ones we've evaluated or
seen advertised, none seem to implement full Version 7 or better C with
decent code generation and without crippling bugs, and we're beginning to
wonder if such a beast exists.  Our preferred criteria are that the
compiler should
     
    - run under UNIX, specifically Ultrix-32 (4.2 BSD).
     
    - implement full Version 7 or better C (enums, and structures
      by value; and preferably voids) with full support of unsigned
      quantities, particularly unsigned char.  We do not need floating
      point.
     
    - produce code which is correct, suitable for ROM execution and, in
      both time and space, at least reasonably close to the level of
      optimization achieved by the S8000 native compiler.  This means
      having a well-tuned code generator, or an optimizer postpass, or
      both.
     
    - produce an image which is in the Zilog s.out format, and therefore
      downloadable to Zilog emulators.
     
    - ideally, have behaviour similar to the scc/cas/sld compiler package
      on ZEUS (Zilog's UNIX), including their formats for object and
      library files and command options, and the ability of the loader
      to pack segments automatically.
     
Although we may be able to deal with incompatibilities in the last two
criteria, the first three are pretty well iron-clad:  we have a large body
of existing software which we're not very eager to rewrite to compensate
for an inadequate compiler.
     
If anyone on the list has knowledge of, or better yet experience with a
cross-compiler system along these lines, we'd be very happy to hear from
them.  I will summarize any positive responses to the net.
--
Bill Jones, Develcon Electronics, 856 51 St E, Saskatoon S7K 5C7 Canada
uucp:  ...ihnp4!sask!zaphod!billj                phone:  (306) 931-1504

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4629
          for JMS@ARIZMIS; Fri, 18-JUL-1986 04:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 06:08:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026301; 18 Jul 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015202; 18 Jul 86 5:44 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pascal Origins
Message-ID: <2216@ihlpg.UUCP>
Date: 17 Jul 86 14:02:54 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     Shouldn't this be in net.lang.pascal ?
>
> This is in response to a comparison with C.
>
>     >Unfortunately it teaches them bad habits as well. I was freaked royally
>     >when my brother told me years ago that there were no provisions for
>     >separate compilation. Everything in one source file, and they make
>     >people write large scale projects in it? Pure insanity.
>
>     >No `otherwise' or `default' clause on switches makes them almost useless.
>     The version of pascal I used in college six years ago allowed both
>     seperate compilation of source file, and an 'others' clause on switches
>     (called case in Pascal I thought).
>     --
>
> That wasn't Pascal. It was someone's *enhancement* of Pascal. I know I'm
> splitting hairs, but it still sucks.
>
>     Larry Cipriani        AT&T Network Systems     danews!lvc
>     "Nothing is worse than an itch you can never scratch."
>
> Ah yes. And Marilyn Monroe is dead.
>
>     (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
> On the other hand, life can be an endless parade of TRANSSEXUAL QUILTING BEES
> aboard a cruise ship to DISNEYWORLD if only we let it!!
>
     
But lets keep in mind that what we call C these days includes a collection
of enhancements.
--j.a.tainter

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3713
          for JMS@ARIZMIS; Fri, 18-JUL-1986 04:17 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 05:11:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026271; 18 Jul 86 6:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015154; 18 Jul 86 5:43 EDT
From: keith gorlen <keith%cecil.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c++,net.lang.c
Subject: Book review: "Object Oriented Programming" by B.J. Cox
Message-ID: <71@cecil.UUCP>
Date: 17 Jul 86 21:34:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Subject: Book review: "Object-Oriented Programming", by B. J. Cox
Newsgroups: net.lang.c++,net.lang,net.lang.c
     
    Cox, Brad J.: Object Oriented Programming
    Addison-Wesley, 1986
    ISBN 0-201-10393-1
     
I highly recommend this book to anyone interested in object-oriented
programming, interactive graphical user interfaces, or in building large
software systems in general.  The author is a lucid and entertaining
writer, and his enthusiasm for the subject matter is contagious.
     
Chapter 1, "System Building", describes the process and problems of
implementing and maintaining large software systems.  Chapter 2, "Why
Object-Oriented Programming", discusses object-oriented programming,
compares it with other methodologies, and offers it as a partial
solution to the problems of system building.  Chapter 3, "What is
Object-Oriented Programming", defines the term in the context of three
programming languages: Smalltalk-80, Ada, and C++.  These three chapters
are easy reading -- if you're into object oriented programming have your
boss read them so he knows what you're doing and why!
     
Chapters 4-8 describe Objective-C, a language invented, implemented, and
marketed by the author, which adds object-oriented programming features
to C.  Of particular interest is a fairly elaborate example which he
has implemented using both object-oriented and conventional techniques
for purposes of comparison.
     
Chapter 9, "Iconic User Interfaces", describes the Model View Controller
(MVC) paradigm used by Smalltalk-80.  Although it is incomplete, it is
the only MVC information in print that I know of.  This chapter by
itself justified the cost of the book for me!
     
The final chapter, "Different Tools for Other Jobs", relates
object-oriented programming to a variety of other topics: garbage
collection, virtual object memories, concurrency, distributed systems,
and coordination systems.
     
My only criticism is that more references would have been nice, but I
get the impression that the author got a lot of this material by word-
of-mouth from researchers at Xerox and Apple.
     
Table 3.1 shown on page 47 is now out of date with respect to the
information on C++.  C++ is now commercially available (without support)
from AT&T, and (plug) I have implemented a Smalltalk-80 -like
"Software-IC library" for it that does "activation/passivation" (but it
is not automatic as is Objective-C).  I've also heard rumors that
garbage collection may be under development for C++. This gets rid of
most of the "no"s in the C++ column of the table.  (As you may have
guessed, I'm a C++ fan.)
     
"Object Oriented Programming" gets my highest rating:  ****
     
--
---
    Keith Gorlen
    Building 12A, Room 2017
    Computer Systems Laboratory
    Division of Computer Research and Technology
    National Institutes of Health
    Bethesda, MD 20892
    phone:    (301) 496-5363
    uucp:    {decvax!}seismo!elsie!cecil!keith

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9883
          for JMS@ARIZMIS; Fri, 18-JUL-1986 13:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 15:36:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005506; 18 Jul 86 12:10 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a022678; 18 Jul 86 11:29 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA13227; Fri, 18 Jul 86 11:28:35 edt
Date: Fri, 18 Jul 86 11:28:35 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607181528.AA13227@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, zben@umd5.ARPA
Subject: Re: WITH statement
     
Re: WITH statement:
    The ambiguous condition scares me too, and I think I could live
    much better with being able to take the address of the thing
    and then using it, like:
     
           recpointer := &recarray[selector];
           ...
           recpointer^.foo := 1;
           recpointer^.bar := 2;
     
The ambiguity is worse than you might think. I happen to think that
all structure members that are logically the same thing ought to
have the same name. This was not allowed in original C because
structures shared the same name space. On the other hand, you could
use any structure member with any structure type.
     
I am glad I learned C after the change. Requiring different names
for the same item is another example where C outgrew Pascal.
     
    Not only has UMD5 arisen as a MicroVax from its previous
    incarnation as an 11/44, but I am using a Macintosh Plus and
    MacKermit to type this in.
     
Congrats.
     
    Are we having fun yet?
     
Yow!
     
    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
    Ben Cranston zben@umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                      umd2.BITNET     "via HASP with RSCS"
     
I still see you don't believe in TABS.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
Hello...  IRON CURTAIN?  Send over a SAUSAGE PIZZA! World War III?  No thanks!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0504
          for JMS@ARIZMIS; Fri, 18-JUL-1986 14:00 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 15:48:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011538; 18 Jul 86 14:54 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a029562; 18 Jul 86 14:42 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA13759; Fri, 18 Jul 86 14:40:48 edt
Date: Fri, 18 Jul 86 14:40:48 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607181840.AA13759@icst-cmr.ARPA>
To: ihlpg!tainter@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re: Pascal Origins
     
> > That wasn't Pascal. It was someone's *enhancement* of Pascal. I know I'm
> > splitting hairs, but it still sucks. [RBJ]
>
> But lets keep in mind that what we call C these days includes a collection
> of enhancements.
> --j.a.tainter
     
Good point. However, there is a big difference. I pretty much use only
the features in K&R, minus bitfields (altho I have found good use for them
to avoid padding in structures) and unions (well, rarely).
     
The extensions include enums, structure passing/returning/assignment,
void, and a few preprocessor goodies. While these are useful, they are
more like power windows on an automobile. The features tht were added
to Pascal were more like a gearbox and electric starter.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    I'm rated PG-32!!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0187
          for JMS@ARIZMIS; Fri, 18-JUL-1986 14:27 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/18/86 at 15:40:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009262; 18 Jul 86 13:53 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a027533; 18 Jul 86 13:38 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA13473; Fri, 18 Jul 86 13:37:20 edt
Date: Fri, 18 Jul 86 13:37:20 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607181737.AA13473@icst-cmr.ARPA>
To: cubsvax!peters@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re: Compiler Specific Operators
     
> In article <phri.2391> roy@phri.UUCP (Roy Smith) writes:
> >[Regarding compilers replacing calls to library routines with in-line code]
> >    What if you want to trap and/or trace subroutine calls for
> >diagnostic or tuning purposes...
>
> Then you're no worse off than tracing or timing portions of your own in-line
> code.
     
It's not that simple. If I want to know when and from where I was called,
it would please me greatly to merely set ONE breakpoint, and not have
to track down every single call, especially if I didn't have source.
     
> >            ... or you want to supply your own version of the
> >library routine because it's faster, more accurate, or more featureful?
>
> Use a #define to a new name, or code in a new name (one of these is probably
> best), or disenable in-line expansion of code by means of a compile-time flag.
     
Again, lack of source may screw you. In addition, you now have to recompile
everything instead of merely relinking to replace a library routine.
While I probably willing to accept inline expansion of say, strcpy, pray
that some of these bozo vendors don't put malloc in the same bag.
     
Inline expansion should be optional and under control of the coder. I don't
even care if the default is expansion, and you have to work to get a real
function call. Evolution, not Revolution (see end quote) please.
     
A compile flag is too broad. I may want some but not all expanded inline.
     
> (In one of my postings I suggested that such a flag be available, but it's
> probably not really necessary.)  Another possibility: if the compiler knew
> about things like sin(x), then the -lm flag would not be necessary in programs
> that "call" it; thus specifying -lm could over-ride in-line expansion....
     
The -lm is a LOADER flag. The COMPILER may never see it, especially if
each source is compiled separately via a makefile. Besides, how does it
equate `sin()' with -lm? Look up every function in the archive? No thanks.
     
> Peter S. Shenkin     Columbia Univ. Biology Dept., NY, NY  10027
> {philabs,rna}!cubsvax!peters        cubsvax!peters@columbia.ARPA
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Don't hit me!!  I'm in the Twilight Zone!!!
     
~"But if you go quoting phrases of Zippy, YOW!
  You ain't gonna make it with anyone anyhow"~

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4339
          for JMS@ARIZMIS; Sat, 19-JUL-1986 12:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017342; 19 Jul 86 12:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014630; 19 Jul 86 11:42 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Another printf-type question
Message-ID: <447@dg_rtp.UUCP>
Date: 17 Jul 86 19:29:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> rbj@icst-cmr (Root Boy Jim)
     
> ...
>                 _doprnt(fmt, &args, stdout);
> ...
     
BEWARE the _doprnt code, my son!
The bits that twitch; the types that clash!
Use the portable varargs stuff,
Avoid the _doprnt's teeth that gnash!
    --- Eric Kiebler (eric@washu.UUCP)
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4610
          for JMS@ARIZMIS; Sat, 19-JUL-1986 12:26 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017348; 19 Jul 86 12:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014890; 19 Jul 86 11:49 EDT
From: Mark Purtill <purtill%petrus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pascal Origins
Message-ID: <228@petrus.UUCP>
Date: 18 Jul 86 16:03:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > >[about someone's not so brain damaged version of Pascal]
> > That wasn't Pascal. It was someone's *enhancement* of Pascal. I know I'm
> > splitting hairs, but it still sucks.
> But lets keep in mind that what we call C these days includes a collection
> of enhancements.
> --j.a.tainter
     
Yes, but they're (mostly) the *same* enhancements.  Furthermore, you can
write reasonable prrograms in C without the enhancements (which are things
like enums and passing structs as opposed to fixing broken things.)  In
Pascal, everyone has their own set of enhancements and they're all different.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4687
          for JMS@ARIZMIS; Sat, 19-JUL-1986 12:27 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017359; 19 Jul 86 12:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014972; 19 Jul 86 11:51 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  sizeof \"string\"?  multi-line macro usage?
Message-ID: <1068@ttrdc.UUCP>
Date: 18 Jul 86 03:55:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2229@brl-smoke.ARPA>, rbj@icst-cmr (Root Boy Jim) writes:
>Definitely! I have seen `write(1,"Hello World\n",sizeof "Hello World\n")'.
     
But that puts out a null character, too!
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4879
          for JMS@ARIZMIS; Sat, 19-JUL-1986 12:30 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017376; 19 Jul 86 12:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015192; 19 Jul 86 11:57 EDT
From: Bjarne Stroustrup <bs%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <5813@alice.uUCp>
Date: 19 Jul 86 00:43:39 GMT
Keywords: address of arrays
To:       info-c@BRL-SMOKE.ARPA
     
for what it is worth: In C++ it is allowed (and encourraged practice) to use the
addressof operator & explicitly for array and function names.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4942
          for JMS@ARIZMIS; Sat, 19-JUL-1986 12:39 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/19/86 at 14:26:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017393; 19 Jul 86 12:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015224; 19 Jul 86 11:58 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <5814@alice.uUCp>
Date: 19 Jul 86 05:11:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>   After five years of teaching C, I have to agree with my students that
> it makes no sense to forbid this construct. To take the address of
> something use the address operator. I have seen this mistake made by
> students from major universities, and graduates of courses taught by
> high priced consultants, so it's not just my students.
     
All right, tell me:  What is the type of the address of an array?
     
That is, suppose I write:
     
    int a[10];
     
What type is &a?  Don't tell me it's "pointer to integer" because
that is the type of &a[0], and a and a[0] are different things.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4997
          for JMS@ARIZMIS; Sat, 19-JUL-1986 12:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017417; 19 Jul 86 12:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015360; 19 Jul 86 12:02 EDT
From: Robert C Sanders <sandersr%ecn-pc.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers for micros
Message-ID: <583@ecn-pc.UUCP>
Date: 18 Jul 86 19:30:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[nibbles and bits...]
     
I am very partial to the Computer Innovations C86 compiler, but I also
like the Microsoft C compiler.  The MS compiler is slower, and not as
UNIX-like.  Both libraries are interchanable -- at least in format.  In
other words, libraries in MS OBJ format are accepted and used by both
compilers -- intended for the PC/MS DOS linker.  Aztec C and Latice C are
less friendly, and require work to port programs to/from them;  CII's C
and MS C easily port programs with UNIX (not requiring the system library),
and are close (if not) to the new ANSI standard C going through.  Third-
party libraries are also compatible with CII C86 and MS C.
     
                    - bob
--
Continuing Engineering Education Telecommunications
Purdue University         ...!ihnp4!pur-ee!pc-ecn!sandersr
     
Let's make like a BSD process, and go FORK-OFF !!    -- bob
(and "make" a few children while we're at it ...)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4814
          for JMS@ARIZMIS; Sat, 19-JUL-1986 13:32 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017364; 19 Jul 86 12:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015042; 19 Jul 86 11:52 EDT
From: ricmtodd%uok.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: printf() code size using Astart
Message-ID: <3400007@uok.UUCP>
Date: 15 Jul 86 21:13:00 GMT
Nf-ID: #R:jade.BERKELEY.EDU:951:uok.UUCP:3400007:000:1248
Nf-From: uok.UUCP!ricmtodd    Jul 15 16:13:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
/* Written  2:26 pm  Jul  8, 1986 by mwm@eris.berkeley.edu in
 uok.UUCP:net.lang.c */
>>        if (foo == NULL) { ... }
>>    or:
>>        if (foo == 0) { ... }
>[...]
>>>Oh, well... I guess someone will make a good 'C' compiler someday...
>
>DEC has one for VMS. Convex has one for their box (though it may not
>be released yet). Anybody know of any others?
>    <mike
/* End of text from uok.UUCP:net.lang.c */
Well the Aztec C compiler on my PC does the above-mentioned test in one
instruction (a compare with zero). Note that this isn't the fancy version
with optimization or long pointers -- the code is probably worse for long
pointers.  In the test, foo was just a simple (small mem model) char pointer.
It also seems to generate reasonably good (i.e. not totally atrocious) code
for other constructs; remember this isn't even the OPTIMIZING compiler.
___________________________________________________________________________
Vila: "I am entitled to my own opinion."
Avon:  "Yes, but it's your constant assumption that everyone else is
        also that's so annoying."
___________________________________________________________________________
Richard Todd
USSnail:820 Annie Court,Norman OK 73069
UUCP: {allegra!cbosgd|ihnp4}!okstate!uokvax!uok!ricmtodd

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4757
          for JMS@ARIZMIS; Sat, 19-JUL-1986 14:04 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017362; 19 Jul 86 12:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015028; 19 Jul 86 11:52 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <3130@utcsri.UUCP>
Date: 18 Jul 86 18:14:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <7014@boring.mcvax.UUCP> jack@boring.uucp (Jack Jansen) writes:
>
>I'm getting sick and tired of all those people picking on pascal,
>and saying "C is better", without giving *any* reason for it.
>
:
>You can say a lot of things about pascal, but not that it wasn't
>well-designed. And, even though you have to do very wierd things
>to get some things to work, it *is* possible to write medium to
     
Challenge: given
     
var    x: array [1..1000] of integer;
     
write a code fragment to find the location of the first 0 in x. The
condition that no zeroes exist must be distinguished.
     
Further rules:
    - Standard Jensen & Wirth Pascal ( no break from loop )
    - *** x[i] must not be evaluated for i<1 or i>1000 ***
    - The search loop must be terminated as soon as a zero is found.
    - 'a or b', 'a and b' always evaluate both a and b ( I think
       this is a rule in Jensen & Wirth )
     
This is the best I can find:
    var i: integer;
    ...
    i :=1 ;
    while i<1000 and x[i] <> 0 do
        i := i+1;
    if x[i] = 0 then writeln('zero at location', i )
    else writeln('not found');
     
weird,huh? Note that the condition 'x[i]=0' is evaluated twice ( once
in the negative sense ), which would be unacceptable if we were searching
an array of records and the test was expensive.
     
Nobody can call this a special case... and I don't think my rules are
unreasonable. The problem is the behaviour of 'and' plus the lack of 'break'.
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4539
          for JMS@ARIZMIS; Sat, 19-JUL-1986 14:24 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017346; 19 Jul 86 12:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014836; 19 Jul 86 11:47 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <839@steinmetz.UUCP>
Date: 17 Jul 86 19:35:10 GMT
Keywords: address of arrays
To:       info-c@BRL-SMOKE.ARPA
     
     
After thinking about the discussions about using the address operator
on an array by name, I come to the reluctant conclusiont that it SHOULD
be allowed in the new ANSI standard. I have read an understood the
arguments against it, I have spent hours teaching the language and
convincing students that they should not do it, but now I have to
reluctantly say that there are some fairly good reasons why it should
be allowed.
     
Reason 1: "codification of existing practice"
  If three ports of SysV, 2 of 4.2BSD and three of the largest selling
C compiler for PCDOS represent current practice, then it is legal. I
admit that a few compiler BITCHED about it, but they compiled it.
     
Reason 2: "modularity and information hiding"
  If I am writing a modular program in which I have the typedefs in an
include file used by the programmers writing the modules, there is no
way to allow them to take the address of an item which is defined by
typedef unless they know that the item is (or isn't) an array.
     
Example:
  typedef int PARTA[10];
  typedef struct { int x,y; float t[40]; } PARTB;
     
in a module...
  PARTA source, dest, *whead, work[2];
  PARTB *head, workb;
     
If PARTA is an array, I must say:
  whead = &dest[0];
while if it's not, I say:
  whead = &dest;
     
This means that the beauty of having the content of types changable at
some time is no longer present, and every programmer who works with
them, even is s/he never uses the contents (passes addresses, etc, like
FILES) must know the type.
     
Reason 3: "common sense"
  After five years of teaching C, I have to agree with my students that
it makes no sense to forbid this construct. To take the address of
something use the address operator. I have seen this mistake made by
students from major universities, and graduates of courses taught by
high priced consultants, so it's not just my students.
     
Moreover, there is already a major peculiarity in the was array names
are handled, as compared to the way pointers work. This is in the
operation of the sizeof operator, which gives the size of a pointer or
sizeof an entire array.
     
Conclusion: I don't find this very desirable, I just think that it
makes more sense to allow it that not allow it. Hopefully the next
language will do away with arrays, and eliminate the whole problem :>
     
--
    -bill davidsen
     
  ihnp4!seismo!rochester!steinmetz!--\
                                       \
                    unirot ------------->---> crdos1!davidsen
                          chinet ------/
         sixhub ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4459
          for JMS@ARIZMIS; Sat, 19-JUL-1986 14:46 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017344; 19 Jul 86 12:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014797; 19 Jul 86 11:46 EDT
From: Brad Templeton <brad%looking.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <613@looking.UUCP>
Date: 18 Jul 86 07:05:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
I have used several C compilers in my projects and here are the summaries:
     
1) Microsoft C
    The winner:
        - It comes from a large firm dedicated to languages
        - The only compiler to take my 30,000 line program and have
          it run essentially right away.
        - Support has been reasonable for me, but I'm a beta tester.
        - One of the two compilers to have compiled a Unix, so you know
          it is fairly compatible with the Unix compilers.
        - If you dare the use it, the hybrid model support is of
          tremendous value.  Our system in hybrid model is about 2/3
          the size of the large model version.  This made the difference
          in running on a 256K PC or not.
        - Ansi C style argument type checking.
        - Runs under Xenix to Cross compile for DOS
2) Lattice C
    This is one of the best selling and it is well supported.
    The original version was unacceptable.   It lacked things like
    "unsigned int" (you just said unsigned) and structure assignment.
    Not much hope of compiling Unix style programs.
     
    They have a new release which supposedly fixes these problems and
    brings it up to a similar level with Microsoft C.  I have not played
    with this one.  Supposedly they also have a Xenix version.
     
    Their compiler is also available for the 68000 but really bad reports
    have come in.
     
3) Mark Williams C
    This compiler is the other to have compiled a Unix like system, in
    this case Coherent.  Fairly good code quality but:
        It can't handle a function over about 800 lines as the
        optimizer runs out of space.
     
        Support was not good in that we found several problems
        (like the above) for which there was no good workaround, and
        we were told to wait months for new releases.
     
    We gave up on this compiler, although we are using it again on the
    68000.  Support is much better now.
     
4) QNX C compiler
    This compiler runs only under QNX, but they now have a dos cross
    compiler option.
     
    QNX is an elegant, very fast OS but it is still young and lacking
    in certain "creature comforts" found under Unix.  Programs here
    are limited to medium model, but this compiler supports an interesting
    convetion that allows fast access to the extra segment of the 8086.
     
    Non portable (we make all references with macros to avoid trouble) but
    can be even more compact (if harder to use) than the Microsoft hybrid
    schemes.
     
5) DeSmet C compiler
    Been a while since I used it, but it is inexpensive and fast.  A good
    toy for playing around with.  Back then it only had small model.
    I hear this has changed.
     
6) Wizard C.
    No personal experience, but friends say it is fairly good.  From too
    small a company if this matters to you, though.
     
     
     
So in the long run, Microsoft C is the winner.  We run it under Xenix which
means that we don't even have to use dos except for testing.  Documentation
of the DOS functions is very poor in the Xenix version, though.
--
Brad Templeton, Looking Glass Software Ltd. - Waterloo, Ontario 519/884-7473

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5142
          for JMS@ARIZMIS; Sat, 19-JUL-1986 15:01 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/19/86 at 14:33:07 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Thu 17 Jul 86 09:28:55-PDT
Date: 17 JUL 1986 12:31:19 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: info-vax@sri-kl.ARPA
cc: hadron!jsdy@seismo.CSS.GOV (Joseph S. D. Yao)
Subject:  Re: main() and entry points in C
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
I received a private copy of Joe Yao's message, with no indication that it had
also been forwarded to info-vax.  The following is the response I sent him,
slightly amended.  For info-vax readers, there is some repetition here; my
apologies.
     
Unless someone brings up startling new facts, this is my last message on this
subject.  I promise. :-)
                            -- Jerry
     
    If some implementation of C uses _start instead of start as an
    entry point, they are asking for trouble.  I have never seen a
    C-accessible symbol as an entry.  The entry point, start, used
    to be almost always 0; but it isn't ever 0, now, in the latest
    releases of AT&T System V Unix.
Try the Celerity 4.2bsd port - their entry point is BOTH start (no "_") and
something like _crt0_start.  The latter IS accessible from C - and has a
value of 0.  I'm told that this is not uncommon, although I can't name any
other examples.  I DO know that the Pyramid port - at least the 4.2bsd
universe version, I didn't try the System V one - uses start (no "_") only.
     
    On many versions of Unix, it is documented that properly written
    multiple-language modules can be compiled together by appropriately
    calling the compiler:
        cc myc.c myftn.o ...        or
        f77 myftn.f myc.o ...        or even
        f77 myftn.f myc.c ...
"Many versions" of Unix?  I thought we were talking about one portable OS
here! :-)
     
    You claim this is a documented undocumented feature?  It isn't
    even true.  Specifically,
        never_called() { printf("Hi.  Joe is wrong.\n"); }
        main() { printf("Hello world.\n"); }
    will never call me a liar.  Even if you are talking about
    straight link-loaded objects (with no header to call _main()),
    several common loaders allow one to specify entry points
    other than 0.  These include, but are not! limited to, the
    AT&T System V ld (again); the CULC Fortran IV Plus linker;
    and the DEC VMS linker.
Mr. Shein forwarded only the last of a series of messages on this topic.  He
did this because he was interested in flames, not facts.  (Mr. Shein sent me a
note saying he would forward my message, "without editorial comment," to "the
C experts" on info-c/net.lang.c.  His interpretation of "without editorial
comment" allowed him to include a "summary line" of "Combating nonsense".  My,
my.  Mr. Yao's response is the first one, after about 2 weeks, that actually
talks about the issues - there were a couple of others pointing out related
bugs in various microprocessor C implementations.  There's been nothing
further from Mr. Shein.)
     
The whole discussion started with a question from a VMS C user as to why, if
he didn't provide a main() routine, his VMS C code started at the first
function seen by the VMS linker.  (Well, that wasn't QUITE his question -
others asked that, the original questions shows up below.)  As my original
response pointed out, the Unix linker does exactly the same thing, if you
invoke it "straight"; it's only because of the way cc chooses to invoke the
linker that stuff works out.  If you do things the "supported" way in VAX C,
you get exactly the same results as if you do them the "supported" way on Unix
C.  But, in fact, even if you go beyond the "supported" approaches, the
results on VMS are a pretty close approximation to what you get on Unix.
     
    The C header, which cc puts at the head of the compiled objects,
    contains the entry point -- which is not at location 0 under all
    versions of Unix!  This header moves the argc, argv, and envp to
    a location that main() will understand when called as a function;
    then calls main() as a function; then calls exit() as a function
    whose argument is main()'s return value; and if this doesn't exit,
    typically tries to perform an exit system call itself, and then
    (in desperation) a halt.
Again, all of these points were brought up in messages that Mr. Shein chose to
omit.
     
Interestingly enough, the original message complained that, with previous
versions of VMS C, a program without a main(), called at its first function,
received its command line arguments - but that in recent versions this didn't
work "unlike Unix".  In fact, this does NOT work in Unix!
     
    I should say it TYPICALLY does all this.  If it ain't documented
    (and especially if it's not in the standard), it ain't guaranteed,
    so don't bet the lunch money, Mildred.
K&R defines the semantics of C programs.  They provide a definition for how
C programs start up (in main()).  They also provide a definition for how
functions get called.  Nowhere is there a definition of the semantics of a
complete program WITHOUT a main() function - implementations are on their own
here.  The VMS implementation tries to emulate what most Unix implementations
seem to do.  It comes pretty close.
     
        Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
                jsdy@hadron.COM (not yet domainised)
     
     
                            -- Jerry
-------

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2003
          for JMS@ARIZMIS; Sat, 19-JUL-1986 16:33 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/19/86 at 12:32:51 CDT
Received: from ucbvax.Berkeley.EDU by SRI-KL.ARPA with TCP; Thu 17 Jul 86
  14:53:25-PDT
Received: by ucbvax.Berkeley.EDU (5.53/1.14)
    id AA07674; Thu, 17 Jul 86 13:21:51 PDT
Received: by cad.berkeley.edu (5.5/5.6)
    id AA04329; Thu, 17 Jul 86 13:21:38 PDT
Received: Thu, 17 Jul 86 10:08:55 PDT by titan.arc.nasa.gov (5.45/1.2)
Received: Thu, 17 Jul 86 10:03:24 pdt by lll-crg.ARPA (4.12/)
    id AA04749; Thu, 17 Jul 86 10:03:24 pdt
Received: from rpics.UUCP by seismo.CSS.GOV with UUCP; Thu, 17 Jul 86 04:55:19
  EDT
Received: by rpics.RPI (4.30/4.7)
    id AA01337; Wed, 16 Jul 86 18:46:27 EDT
Received: by brspyr1.UUCP (4.12/4.7)
    id AA04387; Wed, 16 Jul 86 13:00:39 edt
Date: Wed, 16 Jul 86 13:00:39 edt
From: nike!lll-crg!seismo!rpics!brspyr1!sam@ucbvax.Berkeley.EDU (Samuel C.
  Baxter)
Message-Id: <8607161700.AA04387@brspyr1.UUCP>
Subject: Re: VAX C problem (?)
Newsgroups: mod.computers.vax
To: nike!sri-kl.arpa!info-vax
References: <8607031156.AA07330@ucbvax.Berkeley.EDU>
     
> Mike Hickey writes ...
>
> ... When I was working with the CURSES package, I found that
> getch() wasn't breaking on a character.  Instead, it would block until
> a RETURN was hit...
     
> Doug Gwyn writes ...
>
> ... This behavior is permitted only in raw
> (non-canonicalizing) mode, which is not supposed to be enabled by
> default.  Sounds like VAX-C ver 2.2 is doing this right.
     
Take a look in the VAX-11 C manual.  Hmmm ... CRMODE(): provided for link
compatibility only, no function performed.   Hmmm ... RAW(): same story.
So what is a Unix hack supposed to do?  Grab those dozen orange binders
and ...
     
We discovered that the following reasonably simple routines emulate grabbing
a single character off the VMS terminal, similar to UNIX raw mode.
Efficiency?  No promises here, but they work.  For good measure, I threw
in a VMS "getpass()" (now why doesn't the C RTL have one of these?)
     
/*
**  The  following  code segment is likely copyrighted by my employer, but
**  since I originally wrote it and hacked it before posting  it  and  you
**  WILL hack it more before even THINKING about using it, well ...
**
**  Okay,  okay,  whatever  you  do don't make any money on it, huh?   But
**  then again, what are we  doing  reading  this  net  and  asking  these
**  question  if  we didn't (ultimately) want to make money for someone or
**  something.  Hmmmmm.  What a dilemma.
**
**  Okay,  you  and me, we'll just pretend this should have been published
**  in one of those twenty or so orange  books  DEC  calls  documentation,
**  right?  And anyway, it is all in there if you look long enough.  So it
**  must be _almost_ PD.
**
**  No flames, dammit.  I was only trying to help.
*/
     
#include <stdio.h>
#include <descrip.h>
#include <ssdef.h>
#include <iodef.h>
     
#define    VMS$IOKFLGS    (IO$_READVBLK | IO$M_NOECHO | IO$M_NOFILTR)
#define    VMS$IOPFLGS    (IO$_READVBLK | IO$M_NOECHO )
#define    VMS$INTR    '\003'    /* ^C */
#define VMS$TTYDEV    "TT"
#define MAX$PASSWD    8
     
static int kb_chan;    /* hold keyboard channel here */
     
/*
**  Assigns  'kb_chan'  to  the terminal I/O channel for later use.   The
**  system logical "TT" is used as the terminal device.
*/
void initialize()        /* call me once at program start */
     
{
    static $DESCRIPTOR(name,VMS$TTYDEV);
     
    if (sys$assign(&name,&kb_chan,0,0) != SS$_NORMAL)
        perror("sys$assign(TT) failed");
     
    return;
}
     
/*
**  This  subroutine  performs  the opposite of initialize(): it deassigns
**  the channel.  This should be done before the application is exited.
*/
void de_initialize()        /* call me once at program end */
     
{
    if (sys$dassgn(kb_chan) != SS$_NORMAL)
        perror("sys$dassgn(TT) failed");
     
    return;
}
     
/*
**  This  subroutine  recovers  a  single  byte  from the user's keyboard.
**  This subroutine may not be used unless initialize() has  been  called,
**  but no enforcement of this is made.
**
**  Returns one of:
**    (char)    - byte retrieved
**    NULL    - interrupt encountered
*/
char get_key_stroke()
     
{
    int i;            /* for catching return value */
    char c;            /* place for char */
     
    /* sys$qiow() ignores EOF's and does not modify 'c' if interrupt. */
    /* better handling here is probably more than possible; VMS$IOKFLGS */
    /* (defined at top) has impact on special char handling. */
     
    do {
        c = VMS$INTR;
        i = sys$qiow(0,kb_chan,VMS$IOKFLGS,0,0,0,&c,1,0,0,0,0);
     
    } while (i != SS$_NORMAL);
     
    return(c == VMS$INTR ? NULL : c);
    }
     
/*
**  As  in getpass(3), basically.  Very minimum; probably should check for
**  EOF or INTR.  Dependent on a prior call to initialize().
*/
char *getpass(p)
     
char *p;
{
    static char passwd[MAX$PASSWD+1];
     
    fputs(p,stdout);
    fflush(stdout);
     
    *passwd = NULL;
    sys$qiow(0,kb_chan,VMS$IOPFLGS,0,0,0,passwd,MAX$PASSWD,0,0,0,0);
     
    for (p = passwd; p - passwd < MAX$PASSWD; p++)
        if (*p == '\n' || *p == '\r' || *p == NULL)
            break;
     
    *p = NULL;
     
    return(passwd);
}
     
From postnews Wed Jul 16 01:02:28 1986
Subject: Re: getch for VAX C (was: VAX C problem)
Newsgroups: mod.computers.vax
To: info-vax@sri-kl.arpa
References: <8607031156.AA07330@ucbvax.Berkeley.EDU>
     
> Mike Hickey writes ...
>
> ... When I was working with the CURSES package, I found that
> getch() wasn't breaking on a character.  Instead, it would block until
> a RETURN was hit...
     
> Doug Gwyn writes ...
>
> ... This behavior is permitted only in raw
> (non-canonicalizing) mode, which is not supposed to be enabled by
> default.  Sounds like VAX-C ver 2.2 is doing this right.
     
Take a look in the VAX-11 C manual.  Hmmm ... CRMODE(): provided for link
compatibility only, no function performed.   Hmmm ... RAW(): same story.
So what is a Unix hack supposed to do?  Grab those dozen orange binders
and ...
     
We discovered that the following reasonably simple routines emulate grabbing
a single character off the VMS terminal, similar to UNIX raw mode.
Efficiency?  No promises here, but they work.  For good measure, I threw
in a VMS "getpass()" (now why doesn't the C RTL have one of these?)
     
/*
**  The  following  code segment is likely copyrighted by my employer, but
**  since I originally wrote it and hacked it before posting  it  and  you
**  WILL hack it more before even THINKING about using it, well ...
**
**  Okay,  okay,  whatever  you  do don't make any money on it, huh?   But
**  then again, what are we  doing  reading  this  net  and  asking  these
**  question  if  we didn't (ultimately) want to make money for someone or
**  something.  Hmmmmm.  What a dilemma.
**
**  Okay,  you  and me, we'll just pretend this should have been published
**  in one of those twenty or so orange  books  DEC  calls  documentation,
**  right?  And anyway, it is all in there if you look long enough.  So it
**  must be _almost_ PD.
**
**  No flames, dammit.  I was only trying to help.
*/
     
#include <stdio.h>
#include <descrip.h>
#include <ssdef.h>
#include <iodef.h>
     
#define    VMS$IOKFLGS    (IO$_READVBLK | IO$M_NOECHO | IO$M_NOFILTR)
#define    VMS$IOPFLGS    (IO$_READVBLK | IO$M_NOECHO )
#define    VMS$INTR    '\003'    /* ^C */
#define VMS$TTYDEV    "TT"
#define MAX$PASSWD    8
     
static int kb_chan;    /* hold keyboard channel here */
     
/*
**  Assigns  'kb_chan'  to  the terminal I/O channel for later use.   The
**  system logical "TT" is used as the terminal device.
*/
void initialize()        /* call me once at program start */
     
{
    static $DESCRIPTOR(name,VMS$TTYDEV);
     
    if (sys$assign(&name,&kb_chan,0,0) != SS$_NORMAL)
        perror("sys$assign(TT) failed");
     
    return;
}
     
/*
**  This  subroutine  performs  the opposite of initialize(): it deassigns
**  the channel.  This should be done before the application is exited.
*/
void de_initialize()        /* call me once at program end */
     
{
    if (sys$dassgn(kb_chan) != SS$_NORMAL)
        perror("sys$dassgn(TT) failed");
     
    return;
}
     
/*
**  This  subroutine  recovers  a  single  byte  from the user's keyboard.
**  This subroutine may not be used unless initialize() has  been  called,
**  but no enforcement of this is made.
**
**  Returns one of:
**    (char)    - byte retrieved
**    NULL    - interrupt encountered
*/
char get_key_stroke()
     
{
    int i;            /* for catching return value */
    char c;            /* place for char */
     
    /* sys$qiow() ignores EOF's and does not modify 'c' if interrupt. */
    /* better handling here is probably more than possible; VMS$IOKFLGS */
    /* (defined at top) has impact on special char handling. */
     
    do {
        c = VMS$INTR;
        i = sys$qiow(0,kb_chan,VMS$IOKFLGS,0,0,0,&c,1,0,0,0,0);
     
    } while (i != SS$_NORMAL);
     
    return(c == VMS$INTR ? NULL : c);
    }
     
/*
**  As  in getpass(3), basically.  Very minimum; probably should check for
**  EOF or INTR.  Dependent on a prior call to initialize().
*/
char *getpass(p)
     
char *p;
{
    static char passwd[MAX$PASSWD+1];
     
    fputs(p,stdout);
    fflush(stdout);
     
    *passwd = NULL;
    sys$qiow(0,kb_chan,VMS$IOPFLGS,0,0,0,passwd,MAX$PASSWD,0,0,0,0);
     
    for (p = passwd; p - passwd < MAX$PASSWD; p++)
        if (*p == '\n' || *p == '\r' || *p == NULL)
            break;
     
    *p = NULL;
     
    return(passwd);
}
     
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8539
          for JMS@ARIZMIS; Sat, 19-JUL-1986 19:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/19/86 at 21:29:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019000; 19 Jul 86 22:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020383; 19 Jul 86 21:40 EDT
From: Ed Nather <nather%ut-sally.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers for micros
Message-ID: <5371@ut-sally.UUCP>
Date: 19 Jul 86 22:12:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <583@ecn-pc.UUCP>, sandersr@ecn-pc.UUCP (Robert C Sanders) writes:
> I am very partial to the Computer Innovations C86 compiler, but I also
> like the Microsoft C compiler.  The MS compiler is slower, [ ... ]
     
Not in my experience.  I compiled the same (small model) program on three
compilers, keeping track of time and code sizes.  Here is the summary:
-------------------------------------------------------------------------
     
     
The "ls.c" program was compiled using the CI-C86 compiler v 2.10 (cxls.exe),
the DeSmet compiler v 2.3 (dxls.exe) and the Microsoft C compiler v 3.0
(mxls.exe).  The Microsoft compiler had slightly more source code than the
other two; an #ifdef added a few extra lines of code to speed up screen
printing.
     
Here are the compile times, using RAMdisk for all of the CIC and DeSmet
compilers, and temp storage for Microsoft, which is too big to fit in
RAMdisk.  Source files were read from hard disk.
     
Compile times:                 Ratio
     
cxls.exe    3:37   (217 s)      5.1
dxls.exe    0:42   ( 42 s)      1.0
mxls.exe    2:48   (168 s)      4.0
     
Here are the resulting file sizes:
     
d:/work/?xls.exe
--w  15205  30 Jan  8:28p cxls.exe
--w  17920  30 Jan  5:02p dxls.exe
--w  12816  30 Jan  8:33p mxls.exe
     
Execution times were measured for the command "xls -l d:/bin" which printed
a complete screenful of data; the executable files were in RAMdisk to
minimize loading time.  Output was to screen, and into a file (in RAMdisk).
     
Execution times:
     
            To Screen   To file      Ratios
     
cxls.exe      6.5 s       3.0 s     1.6  1.6
dxls.exe      5.0 s       6.5 s     1.2  3.4
mxls.exe      4.1 s       1.9 s     1.0  1.0
     
     
Summary:
     
DeSmet compiles 4 times faster than Microsoft, 5 times faster than CIC.
Microsoft generates the smallest code with the fastest execution.
CI-C86 has nothing outstanding to recommend it.
--
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.AS.UTEXAS.EDU

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9704
          for JMS@ARIZMIS; Sat, 19-JUL-1986 22:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/20/86 at 00:08:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019286; 20 Jul 86 0:52 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a021108; 20 Jul 86 0:40 EDT
Received: from (3GTLJHW)CALSTATE.BITNET by WISCVM.ARPA on 07/19/86 at
  23:41:46 CDT
Date: Sat, 19 Jul 1986 21:40 PDT
From:   Joerg Hallbauer <3GTLJHW%CALSTATE.BITNET@WISCVM.ARPA>
Subject: Re: Micro C compiler comparisions.
To:  INFO-C@BRL-SMOKE.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
     
     
   I have found that the Aztec C compiler is the better of the Cs
that I have used.  I really supose that what you consider "good"
depends a LOT on what you intend to do with it.  If you want the
"smallest" and "fastest" code, then AZTEC C is definately the way
to go.  If on the other hand you have a lot of rather obscure Unix
code that you want to port over, then perhaps MS C is a better choice
for you.  One final thought, I started programming in Aztec C on a
Z80 CP/M micro several years ago (before there was any such thing as
an IBM PC or MS/PCDOS) and I had quite a bit of code that I wanted
to move. Aztec is the only C with versions for Z80 (8080), 8088/8086
80286, 6502, and 68000 machines.  They also have versions that run
on the VAX and generate code for all the microprocessors mentioned
above.
     
  Like I said which C is best depends on what you need, but if you
need to move code around to a bunch of differant machines, then
Aztec may be the best compiler for you.
+-------------------------------------------------------------------+
| Joerg Hallbauer                 | Technical Support Group         |
| Systems Analyst                 | California State Universities   |
| Professional Services Division  |                                 |
| Control Data Corporation        | Phone: (213) 852-5087           |
+---------------------------------+---------------------------------+
     
BitNet: 3GTLJHW@CALSTATE
ArpaNet: 3GTLJHW%CALSTATE.BITNET@WISCVM.EDU
UUCP: you tell me?
     
     
The usual disclaimers hold, these opinions are my own and not those of
anyone whom I'm associated with in any way. (Why ANYONE would think
anything else is beyond me ... but you never know.)
     
"A horse can be made to drink, but a pencil must ALWAYS be lead."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0985
          for JMS@ARIZMIS; Sun, 20-JUL-1986 03:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/20/86 at 05:10:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019976; 20 Jul 86 5:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022671; 20 Jul 86 5:42 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <1665@mmintl.UUCP>
Date: 17 Jul 86 21:18:17 GMT
Posted: Thu Jul 17 17:18:17 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
As several people have noted, this discussion has gone on long enough.  Part
of the problem may be that no one seems willing to state this without also
giving their own position on the issue.  Let me be the exception.
     
The arguments, both pro and con, have already been given on this issue.
Anyone who has not been convinced by your point of view is not going to be
convinced by a repetition of the same arguments.  So let's drop the topic.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2278
          for JMS@ARIZMIS; Sun, 20-JUL-1986 12:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/20/86 at 10:45:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020750; 20 Jul 86 11:39 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a024679; 20 Jul 86 11:29 EDT
To: Andrew Koenig <ark%alice.uucp@BBN-LABS-B.ARPA>
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: Pointers and Arrays
In-reply-to: Your message of 19 Jul 86 05:11:56 GMT.
         <5814@alice.uUCp>
Date: 20 Jul 86 11:30:13 EDT (Sun)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     If a is declared as:
     
    int    a[10];
     
then &a is of type "pointer to array [10] of int", or
     
    (int (*) [10])
     
in cast terminology.  (Or at least it should be)
     
(Cdecl is wonderful).
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5084
          for JMS@ARIZMIS; Sun, 20-JUL-1986 21:19 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/20/86 at 22:55:35 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Sat 19 Jul 86 19:52:38-PDT
Date: 19 JUL 1986 22:36:22 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: nike!lll-crg!seismo!rpics!brspyr1!sam@ucbvax.Berkeley.EDU (Samuel C. Baxter)
cc: info-vax@sri-kl
Subject:  Re: VAX C problem (?) - reading single characters with VAX C
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
A recent message from Samuel Baxter (brspyr1!sam) provided a simple program
to do single-character terminal I/O on VMS.  Enclosed below is a program that
does the same thing, though often much more efficiently, since it buffers up
typed-ahead stuff.  In addition, it can be do "non-blocking" terminal reads.
The program has a long history and several people have hacked at it - I'm just
the last.  It's been used successfully for quite some time.  It differs form
Mr. Baxter's code in not attempting to trap CTRL/C.  That, and related
changes, can be made easily enough.
     
Mr. Baxter also asks why VAX C provides crmode() only as a dummy function, and
does not provide getpass().  A guess at the answers:  crmode() has some very
specific effects on Unix that would be very difficult to duplicate exactly
on VMS - different purposes of crmode() would probably want to use slightly
different combinations of VMS terminal settings.  For example, should crmode()
disable xon/xoff (CTRL/Q - CTRL/S) handling?  To be exactly like Unix, probab-
ly, but for most purposes, in a VMS environment, the probably not.  The Unix
and VMS terminal drivers are so different that any attempt to provide anything
beyond the usual buffered I/O is going to run into problems.
     
As to getpass(), it's pretty rarely used outside of the kind of system pro-
grams that are unlikely to be moved to VMS - I'll bet at least 90% of Unix
programmers have never heard of it - and it's pretty easy to write anyway.
So, it must have come far down on the list of things to get written.
     
                            -- Jerry
     
------------------------------Cut Here------------------------------------------
/*#define    TESTING
*/
/*
 *                k b i n . c
 *
 * Read tt: one byte at a time without echo, with or without waiting if there
 * is no typeahead.
 *
 * Synopsis
 *
 *    int
 *    _kbin(wait)
 *    int    wait;
 *
 *    int
 *    kbin()
 *
 *    int
 *    kbinr_()
 *
 * Description
 *
 *    Returns the next character.  Returns EOF on error, or if there is no
 *    typeahead and "no wait" was requested.
 *
 *    _kbin(wait) waits if wait is TRUE, returns EOF if there is no
 *    typeahead and wait is FALSE.  kbin() is the same as _kbin(TRUE);
 *    kbinr() is the same as _kbin(FALSE).
 *
 *    Note -- this routine does not prevent CTRL/C or CTRL/Y aborts
 *    from occurring.
 *
 * Revision History
 * 0.0    19-Jun-79 SB    Original version due to Stoney Ballard.
 * 0.1    19-Oct-79 MM    "Munged".
 * 0.2  31-Aug-81 MM    Name changed to kbin().
 * 1.0  ??-???-?? MM    Made part of VAXLIB.
 * 1.1    22-Jul-83 JSL    Old kbin() ==> _kbin() and gets the "wait" argument;
 *            kbin(), kbinr() in terms of _kbin().
 */
     
#include    <stdio.h>
#include    <ssdef>
#include    <iodef>
#include    <descrip>
     
#define    FALSE    0
#define    TRUE    1
#define    EOS    0
     
#define    BUFFLEN    10            /* Size of typeahead buffer    */
     
/*
 * Local static database:
 */
     
static $DESCRIPTOR(inpdev, "TT");    /* Terminal to use for input    */
static long termset[2] = { 0, 0 };    /* No terminator        */
     
/*
 * Local variables
 */
     
static long    ichan;            /* Gets channel number for TT:    */
static char    opened = FALSE;        /* TRUE when opened        */
static char    ibuff[BUFFLEN];        /* Input buffer -- one byte    */
static char    *buffptr = ibuff;    /* For typeahead processing    */
static char    *buffend = ibuff;    /* For typeahead processing    */
     
int
_kbin(wait)
int    wait;
/*
 * Get one byte without echoing, with or without waiting.
 */
{
    register int    errorcode;
    struct IOSTAB {
        short int    status;
        short int    offset_to_terminator;
        short int    terminator;
        short int    terminator_size;
    } iostab;
     
    if (buffptr < buffend)
        return (*buffptr++ & 0377);    /* Empty our typeahead buffer    */
    if (!opened) {
        if ((errorcode = sys$assign(&inpdev, &ichan, 0, 0)) != SS$_NORMAL) {
        fprintf(stderr, "KBIN assign failed.  code = %X\n", errorcode);
        exit(errorcode);
        }
            else opened = TRUE;
    }
    /*
     * See if there's something in the system typeahead buffer
     * Read up to BUFLEN bytes with "zero" timeout.  This will return
     * whatever's in the timeout buffer.  The iostab.offset_to_terminator
     * and iostab.terminator_size will yield the number of bytes read.
     */
    errorcode = sys$qiow(1,        /* Event flag             */
        ichan,            /* Input channel        */
        IO$_READLBLK | IO$M_NOECHO | IO$M_NOFILTR | IO$M_TIMED,
                    /* Timed read with zero wait    */
        &iostab,        /* I/O status block        */
        NULL,            /* AST block (none)        */
        0,            /* AST parameter        */
        &ibuff,            /* P1 - input buffer        */
        BUFFLEN,        /* P2 - buffer length        */
        0,            /* P3 - ignored (timeout)    */
        &termset,        /* P4 - terminator set        */
        NULL,            /* P5 - ignored (prompt buffer)    */
        0);            /* P6 - ignored (prompt size)    */
#ifdef    TESTING
    printf("timed read code = %X, ", errorcode);
    printf("status = %d, offset = %d, terminator = %d, size = %d\n",
        iostab.status, iostab.offset_to_terminator,
        iostab.terminator, iostab.terminator_size);
#endif
    buffend = &ibuff[iostab.offset_to_terminator + iostab.terminator_size];
    if (buffend > ibuff) {
        buffptr = &ibuff[1];    /* Setup typeahead pointer and    */
        return (ibuff[0] & 0377);    /* Return the first character    */
    }
    /*
     * Nothing in typeahead buffer, nothing read.  If the user doesn't
     * want us to wait, just return EOF; else read one character.
     */
    if (!wait)
        return (EOF);
     
    errorcode = sys$qiow(1,        /* Event flag             */
        ichan,            /* Input channel        */
        IO$_READLBLK | IO$M_NOECHO | IO$M_NOFILTR,
                    /* Read, no echo, no translate    */
        &iostab,        /* I/O status block        */
        NULL,            /* AST block (none)        */
        0,            /* AST parameter        */
        &ibuff,            /* P1 - input buffer        */
        1,            /* P2 - buffer length        */
        0,            /* P3 - ignored (timeout)    */
        &termset,        /* P4 - terminator set        */
        NULL,            /* P5 - ignored (prompt buffer)    */
        0);            /* P6 - ignored (prompt size)    */
#ifdef    TESTING
        printf("read one byte, code = %X, ", errorcode);
        printf("status = %d, offset = %d, terminator = %d, size = %d\n",
        iostab.status, iostab.offset_to_terminator,
        iostab.terminator, iostab.terminator_size);
#endif
    if (errorcode == SS$_NORMAL) {
        return (ibuff[0] & 0377);
    }
    else {
        return (EOF);
    }
}
     
int
kbin()
/*
 * Get one byte without echoing, with waiting.
 */
{
    return (_kbin(TRUE));
}
     
int
kbinr()
/*
 * Get one byte without echoing, without waiting.
 */
{
    return (_kbin(FALSE));
}
     
#ifdef    TESTING
     
main() {
    register int    datum;
     
    printf("kbin() testing - CTRL/Z to exit\n");
    while ((datum = kbin()) != EOF) {
        printf("%03o '", datum);
        dumpc(datum);
        printf("'\n");
        if (datum == ('Z' - 0100))
        break;
    }
    printf("EOF\n");
     
    printf("kbinr() testing - CTRL/Z to exit\n");
    while (1) {
        datum = kbinr();
        if (datum == EOF)
        {    printf("EOF - sleeping...");
        sleep(2);
        printf("\n");
        continue;
        }
        printf("%03o '", datum);
        dumpc(datum);
        printf("'\n");
        if (datum == ('Z' - 0100))
        break;
    }
    printf("EOF\n");
}
     
dumpc(datum)
int        datum;
/*
 * Dump a character readably
 */
{
    datum &= 0377;
    if ((datum & 0200) != 0) {
        putchar('~');
        datum &= 0177;
    }
    if (datum < ' ') {
        putchar('^');
        putchar(datum + '@');
    }
    else if (datum > 0176) {
        printf("<RUB>");
    }
    else putchar(datum);
}
#endif
-------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6304
          for JMS@ARIZMIS; Mon, 21-JUL-1986 03:43 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 05:39:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001175; 21 Jul 86 6:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001234; 21 Jul 86 3:45 EDT
From: Martin Resnick <mlr0%bunny.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C Compiler bug
Message-ID: <501@bunny.UUCP>
Date: 19 Jul 86 19:40:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Please try this code on your flavor of C compiler and see if you get the
correct results:
     
main()
{
   int i;
     
   i = 8;
   i = i/2.5;
   printf("i= %d\n", i);
     
   i = 8;
   i /= 2.5;
   printf("i= %d\n", i);
   exit(0);
}
     
The correct answer is 3 in both cases, not 4.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6650
          for JMS@ARIZMIS; Mon, 21-JUL-1986 05:19 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 07:15:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002404; 21 Jul 86 8:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001250; 21 Jul 86 3:47 EDT
From: Joshua Kosman <kos@ucbernie.ARPA>
Newsgroups: net.lang.c
Subject: Question on getopt()
Message-ID: <14935@ucbvax.BERKELEY.EDU>
Date: 21 Jul 86 03:01:49 GMT
Sender: usenet@ucb-vax.ARPA
Keywords: Message suppression
To:       info-c@BRL-SMOKE.ARPA
     
Anybody know an easy way to intercept, suppress or otherwise get rid of the
error message that getopt() issues when user supplies an illegal flag?
It seems uncharacteristically presumptuous -- I'll write my own "Usage:"
messages myself, thanks.
     
     
    Joshua Kosman
    kos@ernie.berkeley.EDU
     
    "Life is like a bowl of soup with hairs floating on it.
    You have to eat it nevertheless."   -- Flaubert

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7375
          for JMS@ARIZMIS; Mon, 21-JUL-1986 07:03 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 08:45:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005014; 21 Jul 86 9:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002395; 21 Jul 86 5:47 EDT
From: "John R. Levine" <johnl%ima.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <169@ima.UUCP>
Date: 21 Jul 86 03:01:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <613@looking.UUCP> brad@looking.UUCP (Brad Templeton) writes:
>6) Wizard C.
>    No personal experience, but friends say it is fairly good.  From too
>    small a company if this matters to you, though.
>So in the long run, Microsoft C is the winner. ...
     
Funny, in my book the problem with MS-C is that it's from too large a
company.  On the infrequent occasions when I have trouble with my Wizard
C compiler, I call up Mr. Wizard, chat with him for a few minutes, and
I can count on my problem being fixed in the next update, usually within
a month.  Good luck getting Microsoft to do that.  I compared Wizard and
MS-C a while ago and found that Wizard won marginally in code size and
substantially in bug-free-ness and diagnostics.  Both MS and Wizard have
new releases of their compilers out and I have yet to try them.
--
John R. Levine, Javelin Software Corp., Cambridge MA +1 617 494 1400
{ ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl, Levine@YALE.EDU
The opinions expressed herein are solely those of a 12-year-old hacker
who has broken into my account and not those of any person or organization.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7483
          for JMS@ARIZMIS; Mon, 21-JUL-1986 07:10 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 09:00:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005353; 21 Jul 86 9:48 EDT
Received: from dione.rice.edu by SMOKE.BRL.ARPA id a006405; 21 Jul 86 9:05 EDT
Received: from proserpina.rice.edu by dione.rice.edu (AA25541); Mon, 21 Jul 86
  02:53:30 CDT
Received: by proserpina.rice.edu (AA09062); Mon, 21 Jul 86 02:25:14 CDT
Date:     Mon, 21 Jul 86 01:19:03 CDT
From: David Chase <rbbb@rice.ARPA>
Subject:  Re: G Smith's comments on Pascal Style
To: info-c@BRL-SMOKE.ARPA
Message-Id: <440.rbbb.proserpina@Rice>
     
> This is the best I can find:
>    var i: integer;
>    ...
>    i :=1 ;
>    while i<1000 and x[i] <> 0 do
>        i := i+1;
>    if x[i] = 0 then writeln('zero at location', i )
>    else writeln('not found');
>
> weird,huh? Note that the condition 'x[i]=0' is evaluated twice ( once
> in the negative sense ), which would be unacceptable if we were searching
> an array of records and the test was expensive.
     
I disagree with "weird,huh?"
     
I find that your example is easy enough to understand (compare it to some
C code in the Unix source, for instance.  Malloc from 4.1 is my favorite
choice), and certainly not inefficient.  ONE test is performed twice: the
last one.  In your example, if you assume a uniform distribution of first
zero (for the sake of easy math) that means that on the average you will
perform the test 500 times in the loop, plus once more in the if.  Assume
also that the test dominates all other loop costs; one more call costs you
on the average of one part in 500, or .2%.  This sort of inefficiency I do
not worry too much about; I can usually find more deserving problems.  If
(perish the thought) I had a good compiler, it would not perform the test
twice anyway.  I think that there are more good compilers for Pascal than
for C.  The one and only gripe I have with that code is that I have to
WRITE the test twice.
     
By the way, have you heard of GO TO?  It IS in Pascal.  You can also write
an ok recursive solution (contrary to myth, the "high cost of recursion"
is not a universal constant.  Existing compilers take care of that, too,
but not for C.)
     
I think it interesting to see comments on Pascal style on a C mailing
list.  Makes about as much sense to me as my opinions on someone's
style in German.
     
Sorry to be so unsympathetic, but I think that much of the community of C
programmers focuses on the trivial at the expense of the significant.  I
just finished improving an implementation of a particular algorithm by a
factor of 10, and you may be sure that I didn't do that by using
assignments as expressions or liberally sprinkling in register
declarations.  In 1480 lines of code it would have bought me perhaps .1%;
in 20 other lines it bought me about 5%.  I ran "prof"; I ran "gprof"; I
thought about what the code was really doing.  I thought about
interactions with the memory allocator.  I was sometimes surprised.  It is
very misleading to present such things as "while (*a++ = *b++) ;" as
optimizations to a novice programmer.  I believe that this is often done;
I believe that I saw that example in K&R.  If it is REALLY that critical,
as some people claim, then you should use an assembler for the crucial
pieces of code (and now some idiot will start to rant and rave about
portability; did I tell you to delete the old code?).
     
By the way, I don't see much point to the  = vs := and == vs = discussion.
(It is still going on in some form; I looked ahead.)  Either you like C's
choice or you don't.  It won't change.  I doubt that anyone who has
commented on it on this list is planning to implement anything better.  I
rather doubt that the discussion on this list has been of the nature that
it would influence anyone who intends to implement anything better.  At
least in the "7 significant characters in external names" hoopla there was
a chance of some influence, and the real issue of breaking code that ran
under the existing "standard" for C.  Isn't there a "net.I'm-pissed-off-
at-the-world-today" newsgroup?  If there was, you could be sure that
that's where I'd send this.
     
David (particular full of venom and contempt tonight) Chase
     
anagram (no fair using Computer Anagram Assistance): Advised charade

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8036
          for JMS@ARIZMIS; Mon, 21-JUL-1986 08:40 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 09:56:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006803; 21 Jul 86 10:38 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a009287; 21 Jul 86 10:23 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a006381; 21 Jul 86 10:21 EDT
Received: from (LINNDR)VUENGVAX.BITNET by WISCVM.ARPA on 07/21/86 at
  09:19:18 CDT
Date:     Mon, 21 Jul 86 09:10 CST
From:        LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject:  C Compiler Bug
To:  info-c@BRL.ARPA
X-Original-To:  mlr0@bunny.uucp,info-c@brl.arpa, LINNDR
     
I tried the i=i/2.5 vs. i/=2.5 program on two different compilers.
The VMS/EUNICE compiler (essentially the BSD4.2 cc) gives 3 & 4; the
VAX C (from DEC for VMS) gives 3 & 3.
     
David Linn
LINNDR@VUENGVAX.BITNET

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9085
          for JMS@ARIZMIS; Mon, 21-JUL-1986 09:44 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 11:37:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa09323; 21 Jul 86 12:29 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a012643; 21 Jul 86 12:18 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA01387; Mon, 21 Jul 86 11:23:43 edt
Date: Mon, 21 Jul 86 11:23:43 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607211523.AA01387@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, ttrdc!levy@seismo.css.gov
Subject: Re:  sizeof \"string\"?  multi-line macro usage?
     
Dan Levy adds a tad more info:
    In article <2229@brl-smoke.ARPA>, rbj@icst-cmr (Root Boy Jim) writes:
    >Definitely! I've seen write(1,"Hello World\n",sizeof "Hello World\n").
     
    But that puts out a null character, too!
     
Good point, but who cares, as long as you're writing to a tty. Now a file
might be a different story.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    I wonder if I could ever get started in the credit world?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0067
          for JMS@ARIZMIS; Mon, 21-JUL-1986 11:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 13:16:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012326; 21 Jul 86 14:03 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a014358; 21 Jul 86 13:10 EDT
Received: from nosc.arpa by AOS.BRL.ARPA id a010410; 21 Jul 86 13:00 EDT
Received: by bass.ARPA (5.31/4.7)
    id AA18197; Mon, 21 Jul 86 09:58:22 PDT
Received: by cod.ARPA (5.31/4.7)
    id AA04350; Mon, 21 Jul 86 09:58:12 PDT
Message-Id: <8607211658.AA04350@cod.ARPA>
Date: Mon, 21 Jul 86 09:41:36 PDT
From: Adams Douglas <crash!pnet01!adamsd@NOSC.ARPA>
To: crash!noscvax!info-c@BRL.ARPA
Subject: Re: Survey of C Compilers for micros
     
FYI, our section at JPL (DSN Data Systems) has adopted the DeSmet compiler for
any C programming that needs to be done (none as yet) after similar testing.
Apparently, their main concern is development (read: compile & go) time.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1738
          for JMS@ARIZMIS; Mon, 21-JUL-1986 13:45 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 15:34:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016422; 21 Jul 86 16:25 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a019810; 21 Jul 86 16:04 EDT
Date:     Mon, 21 Jul 86 15:56:51 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Joshua Kosman <kos@ucbernie.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Question on getopt()
Message-ID:  <8607211556.aa03753@VGR.BRL.ARPA>
     
There should be an extern int variable named "opterr" that determines
whether or not getopt() prints an error message.  I think setting it
to zero (opposite of what the SVR2 manual says) disables the message.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2065
          for JMS@ARIZMIS; Mon, 21-JUL-1986 14:26 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 16:09:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016573; 21 Jul 86 16:39 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa20270; 21 Jul 86 16:21 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a016342; 21 Jul 86 16:17 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA02138; Mon, 21 Jul 86 16:12:50 edt
Date: Mon, 21 Jul 86 16:12:50 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607212012.AA02138@icst-cmr.ARPA>
To: zben@UMD5.ARPA
Subject: Re: WITH statement
Cc: info-c@BRL.ARPA
     
Re: WITH statement:
    The ambiguous condition scares me too, and I think I could live
    much better with being able to take the address of the thing
    and then using it, like:
     
           recpointer := &recarray[selector];
           ...
           recpointer^.foo := 1;
           recpointer^.bar := 2;
     
The ambiguity is worse than you might think. I happen to think that
all structure members that are logically the same thing ought to
have the same name. This was not allowed in original C because
structures shared the same name space. On the other hand, you could
use any structure member with any structure type.
     
I am glad I learned C after the change. Requiring different names
for the same item is another example where C outgrew Pascal.
     
    Not only has UMD5 arisen as a MicroVax from its previous
    incarnation as an 11/44, but I am using a Macintosh Plus and
    MacKermit to type this in.
     
Congrats.
     
    Are we having fun yet?
     
Yow!
     
    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
    Ben Cranston zben@umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                      umd2.BITNET     "via HASP with RSCS"
     
I still see you don't believe in TABS.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
Hello...  IRON CURTAIN?  Send over a SAUSAGE PIZZA! World War III?  No thanks!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2316
          for JMS@ARIZMIS; Mon, 21-JUL-1986 14:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 16:25:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016815; 21 Jul 86 17:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019048; 21 Jul 86 15:41 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <5289@sun.uucp>
Date: 21 Jul 86 10:13:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> All right, tell me:  What is the type of the address of an array?
>
> That is, suppose I write:
>
>     int a[10];
>
> What type is &a?  Don't tell me it's "pointer to integer" because
> that is the type of &a[0], and a and a[0] are different things.
     
No, it's "pointer to array of 10 'int's", a type that is already in C;
consider
     
    int a[10][10];
     
and ask what the type of "&a[5]" is.  PCC, at least, even handles this sort
of type correctly; you can declare such a pointer, assign a value to it
(even though it's only possible to construct such a value by taking the
address of a subarray, at least in C as she currently is spoke), and select
an element from the array that it points to by the obvious method.
     
This brings up an interesting problem.  The ANSI C draft I have (Aug 11, 1985)
says
     
    C.2.2.1 Arrays, functions, and pointers
     
       Except when used as the operand of the "sizeof" operator or
    when a string literal is used to initialize an array of "char"s,
    an expression that has type "array of 'type'" is converted to
    an expression that has type "pointer to 'type'" and that points
    to the initial member of the array object.
     
This is a generalization of what "The C Reference Manual" says, which is:
     
    7.1 Primary expressions
     
    ...
     
    An identifier is a primary expression, provided that it has
    been suitably declared as discussed below.  Its type is specified
    by its declaration.  If the type of the identifier is
    "array of ...", however, then the value of the identifier-expression
    is a pointer to the first object in the array, and the type of
    the expression is "pointer to ...".
     
This is silent about "array-valued expressions", except that it implies that
the name of an array is not an array-valued expression.  It later (in 8.7
Type names) acknowledges the existence of the type "pointer to array of
...", but doesn't indicate what happens if it encounters an expression of
that type.
     
The ANSI C statement seems to be the obvious way of correcting this
omission.  However, it now makes it harder to construct a value of this
type.
     
Neither K&R C nor ANSI C allow you to construct a pointer to an array that
is not a member of another array (if you declare "int a[10]", "&a" is
illegal and "a" is a pointer to the first member of the array, not to the
array itself).  However, K&R C does not explicitly *forbid* putting an "&"
in front of an expression that is a member of an array of arrays.  E.g., if
you declare "int a[10][10]", it doesn't forbid "&a[3]".  (Our PCC, and
probably most, if not all PCCs, *will* complain about this; I don't know if
this is plugging a loophole in the rules, or just an accident of the
implementation.)
     
ANSI C, however, says that *any* expression of type "array of 'type'" is
converted to a pointer to the first element of that array (hence of type
"pointer to 'type'".  This means that the expression "&a[3]" is invalid,
since "a[3]" is an array-valued expression referring to the fourth member of
"a", and this is converted to a pointer to the first member of the fourth
member of "a"; this expression cannot have its address taken.
     
You can get a pointer to the *first* member of "a"; the expression "a" is
converted to such a pointer.  You can then get a pointer to other members
with pointer arithmetic; i.e., "a + 1" is a pointer to the second member of
"a" (which is another 10-element array of "int").  Unfortunately, this means
something that works for arrays of types that are not arrays won't work for
arrays of types that are.  If you have "int a[10]", "&a[5]" is a point to
"a"s sixth element; if you have "int a[10][10]", however, "&a[5]" is illegal.
     
This is a bit of a rough spot in C's type system.  It would be preferable if
the operand of the "&" operator, like the operand of the "sizeof" operator,
were not converted from "array of 'type'" to "pointer to first element of
array of 'type".  If this were the case, "&a" would be legal, regardless of
the type of "a" (except, possibly, if "a" were of type "function returning
'type', and perhaps even that could be allowed).  This would make pointers
to arrays more useful, and would permit a routine that took a pointer to an
array to be written as such, instead of using the subterfuge of declaring
the argument in question to be a pointer to an element of such an array.
     
One would presumably be allowed to declare a pointer of type "pointer to
array of 'type' of unspecified size", thus permitting a function to take
arrays of arbitrary size as arguments.  The Aug 11, 1985 ANSI C draft seems
to forbid this; an array size specifier "must be present, except that the
first size may be omitted when an array is being declared as a formal
parameter of a function, or when the array declaration has storage-class
specifier 'extern' and the definition that actually allocates storage is
given elsewhere."  One is currently allowed to do so by PCC, at least; K&R
doesn't forbid it, although the only contexts in which it discusses such
array specifiers are the two mentioned by the ANSI C draft.
     
If "&" is to be changed to work like "sizeof", the rules for type specifiers
should also be changed in this fashion.  Yes, there will be a problem with
pointer arithmetic involving pointers to arrays of unspecified size"; this
will have to be forbidden.  However, ANSI C already has object like this;
consider a pointer to a structure of unspecified shape.  One can declare
such pointers - this is needed to deal with mutually-recursive structures,
where an object of type "struct a" contains a pointer to an object of type
"struct b", and *vice versa* - and the language must somehow forbid pointer
arithmetic on such pointers, at least until the structure's shape is
declared.
     
If anyone wonders why the type "pointer to array of 'type'" would be useful,
and is not swayed by arguments involving the completeness of type systems or
the relative merits of using "pointer to array of 'type'" to point to
something of type "array of 'type'" rather than using "pointer to 'type'",
consider a program stepping through an array of "vectors", defined as arrays
of three "double"s, computing the norm of each one.  It *could* do so by
stepping an index of integral type, but one reason why C pointers work the
way they do is so you can step through an array by stepping a pointer into
that array!  (These arguments sound somewhat similar to the arguments about
taking the address of a "jmp_buf" using "&", since forbidding "&" to be
applied to an array forces a programmer to know whether "jmp_buf" is
implemented as an array or a structure.  In both cases, one is forced to
treat arrays differently from other sorts of objects, and it seems
unnecessary to require this.)
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2741
          for JMS@ARIZMIS; Mon, 21-JUL-1986 15:34 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/21/86 at 17:13:07 CDT
Received: from ucbvax.Berkeley.EDU by SRI-KL.ARPA with TCP; Sun 20 Jul 86
  20:07:20-PDT
Received: by ucbvax.Berkeley.EDU (5.53/1.14)
    id AA29084; Sun, 20 Jul 86 10:46:23 PDT
Date: Sun, 20 Jul 86 10:46:23 PDT
From: ihnp4!ttrdc!levy@ucbvax.Berkeley.EDU
Message-Id: <8607201746.AA29084@ucbvax.Berkeley.EDU>
Received: by ihnp4.ATT.COM id AA16808; 19 Jul 86 22:58:13 CDT (Sat)
To: ucbvax!info-vax
     
Subject: How does one make the Eunice Bourne shell inherit the environment?
     
I have been continually frustrated by a quirk in a Eunice system that I must
sometimes program under (no flames about get a real Unix, I DO have real Unix
available but for the things which are stuck under VMS, Eunice makes our life
a bit easier there, IF you steer around the bugs...).  The problem is that
Eunice Bourne shell scripts and interactive Bourne shells do not seem to
inherit the environment from which they were spawned.  They do inherit
certain environment variables which come from system logical names (things
like PATH, for instance).  For example the command
     
% printenv
     
results in the output
     
HOME=/udev6/levy
PATH=/udev6/levy/bin:/lbin:/usr/ucb:/bin:/usr/bin:/usr/eun:/cadbin:.:
TERM=5420
AS_IMAGE=/bin/unixas
LD_IMAGE=/bin/unixld
PUB=/usr/spool/uucppublic
     
whereas the command
     
% sh -c printenv
     
results in the output
     
HOME=UD6:[LEVY]
PATH=:/lbin:/usr/ucb:/bin:/usr/bin:/usr/eun:/cadbin  <-- system logical name
PS1=!$
SHELL_START=XENVMAIN
     
Also, Bourne shell scripts will behave as if the environment is the
latter, not the former, which means they do not find commands in my
own $HOME/bin directory, for instance, and that a recursive script
such as
     
#!/bin/sh
if test -z "$DEPTH"
then
    DEPTH=1
    export DEPTH
fi
DEPTH=`expr $DEPTH + 1`
#
#do a step of a recursive procedure here, which
#exits when finished at the correct depth, otherwise
#executes the following:
#
if test $DEPTH -lt 20
then
    $0 $*
else
    echo Nested too deep. >&2
    exit 1
fi
     
will not work as intended at all (DEPTH never gets to the spawned shells).
     
While I can think of workarounds for just about every difficulty which
results from this (pass things as arguments, modify shell scripts to read
some startup temp file when invoked from a C program, etc. etc.) they are
a pain in the **bleep**.
     
Now if someone out there using Eunice DOES have Bourne shells or Bourne
shell scripts which understand the environment they came from, I would
very much like to know how that is made possible if you know, or at the
least see the output of something which might give me a clue such as
"$ SHOW LOGICAL" under DCL, as well as the output of a "printenv" from
csh and a "sh -c printenv" from the same csh.
     
I don't have much info on the version of Eunice except that we are running
it under VMS V4.3 and that it has long-file-name capability (none of that
HSH*.HSH and HSH*.HSN garbage of earlier Eunices), and that it is a BSD 4.1
emulation.
     
Thanks, thanks, thanks, thanks, ADthanksVANCE!
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy
     
     
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3705
          for JMS@ARIZMIS; Mon, 21-JUL-1986 17:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 19:16:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017731; 21 Jul 86 20:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021719; 21 Jul 86 19:40 EDT
From: Kaufer - Lopez - Pratap <steve@endor.harvard.edu>
Newsgroups: net.lang.c
Subject: C programming survey
Message-ID: <56@husc6.HARVARD.EDU>
Date: 21 Jul 86 18:09:40 GMT
Sender: news@husc6.harvard.edu
To:       info-c@BRL-SMOKE.ARPA
     
     
Hello.  A big favor to ask of all of you:
     
I am attempting to get a general idea of who is using C and
for what sorts of projects.  I am also very interested to know
which compilers and debugging tools / programming aids
are being used.
     
If everyone could take just a moment to mail me comments, I will happily
summarize the results to the net.  References to similar studies
would also be greatly appreciated.
     
Specifically, I am very interested to hear about:
     
    What is the purpose of your current project?
    How many programmers are working with you?
    What is the target machine?  target OS ?
    What is the development machine?  development OS ?
    Which compiler do you use ?  Do you like it ?
    What percent of your time is spent debugging?
    Do you have/use/like/dislike any of the following:
        Static program checker (e.g. lint) ?
        Debugger (e.g. sdb/dbx) ?
        Version control (e.g. sccs/rcs) ?
        Automatic program generation (e.g. make) ?
        Other tools (e.g. profiler) ?
     
Thank you very much for your time,
     
        Stephen Kaufer
        steve@harvard.HARVARD.EDU
        {seismo,ihnp4,allegra,ut-sally}!harvard!steve

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3815
          for JMS@ARIZMIS; Mon, 21-JUL-1986 17:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 19:25:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017763; 21 Jul 86 20:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021730; 21 Jul 86 19:41 EDT
From: "Eric A. Raymond" <ear%duke.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <8069@duke.duke.UUCP>
Date: 21 Jul 86 07:36:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3130@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
     
>Challenge: given
>
>var    x: array [1..1000] of integer;
>
>write a code fragment to find the location of the first 0 in x. The
>condition that no zeroes exist must be distinguished.
>
>Further rules:
>    - Standard Jensen & Wirth Pascal ( no break from loop )
>    - *** x[i] must not be evaluated for i<1 or i>1000 ***
>    - The search loop must be terminated as soon as a zero is found.
>    - 'a or b', 'a and b' always evaluate both a and b ( I think
>       this is a rule in Jensen & Wirth )
>
>This is the best I can find:
>    var i: integer;
>    ...
>    i :=1 ;
>    while i<1000 and x[i] <> 0 do
>        i := i+1;
>    if x[i] = 0 then writeln('zero at location', i )
>    else writeln('not found');
     
     
Well assuming that a OR b only evaluates b if a is false, how about:
     
var i: integer;
     
i := 0;
repeat
  i := i + 1; {or use INC(i) if one exists}
until (i > 1000) OR (x[i] = 0);
     
if (i > 1000) then
  writeln('No zero found')
else
  writeln('Zero at location ',i);
     
Note that this takes an extra loop (1001 .vs. 1000) if there is no zero.
Also, the condition that x[i>1000] not be evaluated is dependent upon
the previous assumption of OR evaluation.  Now if you didn't care whether
x[i>1000] was evaluated and if you don't mind x[i] being evaluated twice,
then you could use something like this ...
     
until (i = 1000) OR (x[i] =0);
     
if (x[i] = 0) then ... found
else ... not found
     
     
Your point (however understated it may be) that C's ability to include
assignment in conditional tests is well taken.  An optimizing compiler
should be able to generate code similar to what C allows one to explicitly
encode.  (This would not be so if x[i] were some (expensive) function.)
     
--
Eric A. Raymond                                   UUCP: ...decvax!mcnc!duke!ear

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3932
          for JMS@ARIZMIS; Mon, 21-JUL-1986 17:43 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 19:36:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017768; 21 Jul 86 20:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021738; 21 Jul 86 19:41 EDT
From: Clayton Cramer <cramer%kontron.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <932@kontron.UUCP>
Date: 21 Jul 86 17:08:53 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I'm not really disagreeing with Brad, but I do have a few comments about
our experiences here at Kontron with the Microsoft C compiler.
     
>
> I have used several C compilers in my projects and here are the summaries:
>
> 1) Microsoft C
>     The winner:
>         - It comes from a large firm dedicated to languages
>         - The only compiler to take my 30,000 line program and have
>           it run essentially right away.
     
Early on in our project, we move 12,000 lines of source from Berkeley 4.2
UNIX on a VAX to Microsoft C under PC-DOS.  It only took six hours to find
all the differences between PC-DOS & UNIX, and to find incompatible chunks
of C.  (The incompatibilities were just about all our fault.)
     
>         - Support has been reasonable for me, but I'm a beta tester.
     
Support has been poor to useless for us.  The questions we ask usually get
pretty useless answers, because they are usually telling us to do things
that the manuals warned about.
     
>         - Ansi C style argument type checking.
     
Nice feature, but incompatible with the Berkeley 4.2 C compiler.  (I use
this feature at home a lot, though.)
     
> Brad Templeton, Looking Glass Software Ltd. - Waterloo, Ontario 519/884-7473
     
Additionally, we have run into a few maddening bugs:
     
1. A parameter is declared as a register pointer to a structure -- it
generated spurious code.  (No, I don't consider register declarations for
a 8086 family machine sensible -- the declaration exists for historical
reasons.)
     
2. If you scanf a floating point variable, the linker will not grab the
8087 emulator unless you have AT LEAST one floating point arithmetic
operation in the program.  This is documented (sort of), but I'm a little
disappointed that the compiler doesn't generate the right floating point
emulator library references because of the float declarations without
an float operation.
     
3. Under some ill-defined conditions, the following parameter declarations
are not equivalent:
     
    char    *String;
     
    char    String[];
     
Overall, I'm very pleased with the Microsoft C V3.0 compiler.  The
number and type of bugs are completely acceptable for a compiler.
     
Clayton E. Cramer

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4663
          for JMS@ARIZMIS; Mon, 21-JUL-1986 20:29 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/21/86 at 22:17:04 CDT
Received: from CitHex.Caltech.Edu by SRI-KL.ARPA with TCP; Mon 21 Jul 86
  06:57:21-PDT
Date:     Mon, 21 Jul 86 07:00:15 PDT
From:     carl@CitHex.Caltech.Edu (Carl J Lydick)
Message-Id: <860721065936.00c@CitHex.Caltech.Edu>
Subject:  Re: VAX C problem (?) - reading single characters with VAX C
In-Reply-To: Your message <8607200641.AA22528@csvax.caltech.edu> dated
  19-Jul-1986
To:       LEICHTER-JERRY@YALE.ARPA, info-vax@CitHex.Caltech.Edu
     
/*****************************************************************************\
 *  >   ...a program that does the same thing, though often much more        *
 *  >   efficiently, since it buffers up typed-ahead stuff....               *
 *                                                                           *
 *  Not quite the same thing, Jerry; your "more efficient" implementation    *
 *  has the following rather odd properties:                                 *
 *      1)  An image exit may flush any, all, or none of the type-ahead.     *
 *      2)  The amount of type-ahead flushed when the image exits            *
 *          depends, in principle, on every keystroke typed since the        *
 *          first call to your _kbin().  In fact, the dependence is upon     *
 *          the number of characters typed since the last time the           *
 *          terminal's type-ahead queue was empty.                           *
 *  The reason for this, of course, is that you and the terminal driver are  *
 *  both buffering typeahead, but you neither return whatever you've got     *
 *  left at image exit to the terminal data stream (which is reasonable,     *
 *  since the VMS terminal drivers don't have any provision for this) and    *
 *  you don't do anything to force a flush of the terminal's type-ahead      *
 *  buffer at image exit (which is not reasonable, since you can declare     *
 *  your own exit handler to take care of this problem.  What you want is    *
 *  somthing like:                                                           *
\*****************************************************************************/
/* clean up after single-character I/O software */
void flush_stream(status, chan)
long *status, chan;
{    SYS$QIOW(0, chan, IO$_READVBLK | IO$M_TIMED | IO$M_NOFILTR |
        IO$M_NOECHO | IO$M_PURGE, 0, 0, 0,0, 0, 0, 0, 0, 0);
    SYS$DASSGN(chan);
}
     
/* exit handler descriptor block */
struct EXH$DESBLK {
    long exh$l_flink;
    void (*exh$a_handler)();
    long exh$b_nargs;
    long *exh$a_status;
    long exh$l_chan;
    long exh$l_stat;
} flush = { 0, flush_stream, 2, &(flush.exh$l_stat), 0, 0 };
/*****************************************************************************\
 *   Then add something like:                                                *
 *                                                                           *
 *      flush.exh$l_chan = chan;                                             *
 *      SYS$DCLEXH(&flush);                                                  *
 *                                                                           *
 *   to the code that opens the channel on the first call.  When your image  *
 *   exits, flush will be called, and it will flush all typeahead on the     *
 *   terminal channel and deassign the channel.                              *
\*****************************************************************************/

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5227
          for JMS@ARIZMIS; Mon, 21-JUL-1986 21:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 23:05:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018007; 21 Jul 86 21:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022198; 21 Jul 86 21:40 EDT
From: Guy Riddle <ggr%packard.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Question on getopt()
Message-ID: <489@packard.UUCP>
Date: 21 Jul 86 21:06:13 GMT
Keywords: Message suppression
To:       info-c@BRL-SMOKE.ARPA
     
) Anybody know an easy way to intercept, suppress or otherwise get rid of the
) error message that getopt() issues when user supplies an illegal flag?
) It seems uncharacteristically presumptuous -- I'll write my own "Usage:"
) messages myself, thanks.
     
Yes, use
     
    extern int    opterr;
     
    opterr = 0;
     
        === Guy Riddle == AT&T Bell Laboratories Liberty Corner ===

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5277
          for JMS@ARIZMIS; Mon, 21-JUL-1986 21:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/21/86 at 23:10:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018418; 21 Jul 86 23:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023105; 21 Jul 86 23:40 EDT
From: Brad Davis <b-davis%utah-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <3859@utah-cs.UUCP>
Date: 22 Jul 86 00:28:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <3130@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>    i :=1 ;
>    while i<1000 and x[i] <> 0 do
>        i := i+1;
>    if x[i] = 0 then writeln('zero at location', i )
>    else writeln('not found');
     
I personally like:
     
    for i := 1 to 1000 do
        if x[i] = 0 then goto DONE;
    i := 1001;
DONE:
    if i <= 1000 then writeln('zero at location', i )
    else writeln('not found');
     
If you don't like the 'goto' then flame someplace else.  I think that
goto's can be used in a structured manner.  The statement 'i := 1001;'
is needed since the value of 'i' is undefined after the 'for' statement.
What's nice is that a good compiler can look at the 'for' loop and
determine that bounds checking is not needed on the 'if' statement.
The 'for' loop can also be done as a single machine instruction (on
none RISC machines).  A good optimizing compiler might even be able
to generate better code than a good optimizing C compiler.
     
I like Pascal for some reasons and I like C for other reasons.  The
reasons usually conflict.  I don't claim to be consistant.
     
--
Brad Davis    {ihnp4, decvax, seismo}!utah-cs!b-davis
        b-davis@utah-cs.ARPA
One drunk driver can ruin your whole day.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5959
          for JMS@ARIZMIS; Tue, 22-JUL-1986 00:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 02:38:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019186; 22 Jul 86 3:32 EDT
Received: from mit-multics.arpa by SMOKE.BRL.ARPA id a023795; 22 Jul 86 2:41 EDT
Date:  Tue, 22 Jul 86 02:24 EDT
From:  Paul Schauble <Schauble@MIT-MULTICS.ARPA>
Subject:  Survey of C compilers
To:  Info-C@BRL-SMOKE.ARPA
Message-ID:  <860722062421.734703@MIT-MULTICS.ARPA>
     
Does anyone have experience with High-C?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6116
          for JMS@ARIZMIS; Tue, 22-JUL-1986 01:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 03:27:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019335; 22 Jul 86 4:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024022; 22 Jul 86 3:42 EDT
From: "M. Slaughter x4992 CB 1E117 JAG" <mhs%cbdkc1.uucp@BRL.ARPA>
Newsgroups: net.micro,net.lang.c
Subject: looking for 8031 C compiler
Message-ID: <1481@cbdkc1.UUCP>
Date: 21 Jul 86 21:46:36 GMT
Keywords: 8031, C compiler
To:       info-c@BRL-SMOKE.ARPA
     
     
     
I am interested in finding a C compiler to produce code for the
Intel 8031 microcontroller family.  A subset of C would be fine
also.
     
                    Marc Slaughter
     
                    AT&T Bell Labs
                    Columbus, OH
                    attmail!mslaughter
                    (ihnp4 | cbosgd)!cbdkc1!mhs
                        614-860-4992

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6161
          for JMS@ARIZMIS; Tue, 22-JUL-1986 01:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 03:29:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019338; 22 Jul 86 4:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024037; 22 Jul 86 3:43 EDT
From: Silver <gaynor@topaz.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <5394@topaz.RUTGERS.EDU>
Date: 22 Jul 86 05:35:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
On using flags to simulate breaks, if a flag is not specifically
called for, I'ld rather use a break statement too.  Especially if the
amount of work it takes to do the book-keeping for a flag comes near
that of the unit of work.  In the long run, if I have a choice between
a program that runs 3 times faster than another, and they are both
quality code, not hard to figure which one'll get picked.  I guess the
point inadvertantly obscured in my first response was when you don't
got, make do without (or at least it's possible to do so).
     
On using unconditional branches to simulate breaks, the professors
here at RU have figured out an ingenious method to eliminate them
from student's code.  Microneurosurgery.  We are not physically
capable of typing the required string of characters - g... uh, go...,
um...  You know, a 'g' followed by a 'o', and then a 't', ...
     
> True, except it is quite common for a search test to produce a
> 'no-match' result very quickly most of the time, and to always take
> a long time to come up with match. The 'match' is the repeated test.
> Your point is well taken though.
     
Common indeed, but not the general case.  Your point is well taken
too, as recently I've read a little on Snobol's pattern matching.
     
On controlled evaluation of boolean operands, you can ALWAYS pull the
stunt off with the introduction of temporary booleans or duplicated
code.  Posting the proofs will surely draw fingers to N keys, hence
they're ommitted.  I wouldn't be caught dead coding any of those
transformations, though.
     
On flow of control, in general.  I haven't quite made up my mind on
all the issues, but Pascal is definitely lacking in some areas where C
is not.  This sentiment was lost in my original response.
     
> > Do your homework BEFORE posting.  People are watching you, and
> > paying for it.
>
> Sorry, I don't feel that you have shot me *that* full of holes. I do
> regret the posting, though, because it was essentially a negative
> contribution. Must have been in a bad mood.
     
I apologize for that last, it was definitely uncalled for.  Them's
fighting words...
     
Silver  {...!topaz!gaynor}

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6583
          for JMS@ARIZMIS; Tue, 22-JUL-1986 03:24 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 05:19:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019586; 22 Jul 86 6:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024992; 22 Jul 86 5:41 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: WITH statement
Message-ID: <470@opus.nbires.UUCP>
Date: 21 Jul 86 06:25:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> The ambiguous condition scares me too, and I think I could live
> much better with being able to take the address of the thing
> and then using it, like:
>
>        recpointer := &recarray[selector];
>        ...
>        recpointer^.foo := 1;
>        recpointer^.bar := 2;
     
I don't intend to flame, but there's a funny ring to this sort of view of
the (Pascal) `with' statement.  C programmers roundly criticize Pascal as
being more cumbersome in notation.  I generally agree; Pascal could allow
more terse expression without suffering...but then why is it scary when
Pascal has a construct which allows more terse expression than C?
     
First off, the standard disclaimer:  the `with' statement can be abused, as
can any statement (including the null statement!) in any language.
     
The `with' statement is an interesting construct from a programming
language standpoint; I don't know of too many others in its class.  One way
to think of it is as a procedure:
    with p^, q[i] do...
is like starting a procedure right there with (value) parameters being the
records given.  Within the procedure you have access to these objects which
is more convenient and presumably more efficient.  It's a funny open-code
sort of thing.
     
Opening a with using two records of the same type is possible, but rare
because it's kind of silly.  (It has nowhere near the potential for screwup
of, say, calling a procedure with two pointer parameters pointing to the
same object.)
     
The "scary" part of the `with' statement--the loss of qualifier in front of
field selectors--is no problem at all in practice because `with' statements
tend to be intensive activity on the records being manipulated.  I've
observed that `with' statements tend to be either fairly short (probably
under 10 lines) or the entirety of a procedure where the `with' opens one
or more of the procedure's parameters--for example:
    procedure xxx(p: pwhatzy);
    ...decls
    begin with p^ do begin
    ...work on the object referenced by p
    end end;
     
I've written a lot of Pascal and a lot more C.  Mostly I find C faster to
write, but when I start writing a sequence of code to fill in a structure,
I sure miss the `with' statement.
--
Dick Dunn    {hao,ucbvax,allegra}!nbires!rcd        (303)444-5710 x3086
   ...At last it's the real thing...or close enough to pretend.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6631
          for JMS@ARIZMIS; Tue, 22-JUL-1986 03:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 05:22:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019590; 22 Jul 86 6:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025029; 22 Jul 86 5:44 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <3142@utcsri.UUCP>
Date: 21 Jul 86 19:06:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5378@topaz.RUTGERS.EDU> gaynor@topaz.RUTGERS.EDU (Silver) writes:
[linear array search in Pascal]
>me (greg@utcsri:)
>> weird,huh? Note that the condition 'x[i]=0' is evaluated twice ( once
>> in the negative sense ), which would be unacceptable if we were searching
>> an array of records and the test was expensive.
>
>Your analysis of your own code is misleading.  Assuming an arbitrarily
>large array and the unit of work is array element comparison, your
>code is an optimal solution.  Your gripe about evaluating x[i] twice
>when it is noticed that i is indexing a zero element is NOT valid,
>though, because it is only a constant amount of work (q: what's the
>difference between 6984713 out of 100000000 and 6948714 out of
>10000000? a: practically nothing).
     
True, except it is quite common for a search test to produce a 'no-match'
result very quickly most of the time, and to always take a long time to
come up with match. The 'match' is the repeated test. Your point is well taken
though.
     
>Of course, if the size of the array is constrained to a (small)
>constant, then your gripe about your solution IS valid.  Perhaps a
>better (in terms of array element comparisons) solution, using boolean
>flags...
:omitted:
>> The problem is the behaviour of 'and' plus the lack of 'break'.
>
>Noper.  The effect of the break statement can always be simulated by
>the use of boolean flags.  These will increase the amount of the
>book-keeping, but not change the order of an algorithm as far as the
>fundamental work unit(s) goes.
     
But I don't like them :-). Anyway, the idea of using different workarounds
for the same language flaw depending on the expected number of loops is
a bit rancid.
>
>The evaluation of the operands in boolean expressions can be
>controlled with nested if-thens.  For example, if I wanted to write
>
>    if a and b then ...
>
>but didn't want to bother evaluating b if a was false, I would write
>
>    if a then if b then ...
>
Try that with an 'else' clause, or with 'if a or b'. Try that with
'while a and/or b'. Your example is the only case that works
( DeMorganizing an OR to an AND won't work either ).
     
>These are applications of Boehm and Jacopini's Fundamental Control
>Structure Theorem.
     
The great thing about the C operators is that a code generator can be
made which generates exactly the same code for 'if(a&&b)' as for
if(!(!a||!!!b)). Without any extra work, too; it happens as a side effect
if conditionals are handled properly (i've written one of these). In effect
they allow you to write spaghetti testing code neatly.
     
As for the lack of break, it is a fact of life that loops do not always
exit at the same point in the cycle as they start. Pascal ignores this.
     
>Do your homework BEFORE posting.  People are watching you, and paying
>for it.
     
Sorry, I don't feel that you have shot me *that* full of holes. I do regret
the posting, though, because it was essentially a negative contribution. Must
have been in a bad mood.
     
Someone pointed out that a goto could be used to break the loop. I had
effectively forgotten that. The only big program I have written in Pascal
was a subset Pascal compiler for an undergrad course. Since it was an
undergrad course, the word 'goto' automatically lost you points, and I had
to do lots of array searching of the above type. Eventually steam started
coming out of my ears. Some of it came back last week :-)
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6743
          for JMS@ARIZMIS; Tue, 22-JUL-1986 03:44 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 05:40:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019601; 22 Jul 86 6:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025073; 22 Jul 86 5:47 EDT
From: Ihor Kinal <ijk%mtung.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: pointers to void () vs. ptr to int () with conditional ops
Message-ID: <742@mtung.UUCP>
Date: 21 Jul 86 18:17:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The following code  does not compile with line 21, yet the equivalent
code using if-else is OK, and the conditional works with int
functions.  Is my lint and compiler broken, or am I overlooking something?
     
Thanks,
Ihor Kinal
ihnp4!mtung!ijk
     
     
     
/* sample program using conditionals and pointers to functions */
extern    int func_i();
extern    int func_J();
extern    void func_v();
extern    void func_W();
     
main()
{
    int (*iptr_to_func) ();
    void (*vptr_to_func) ();
     
    int index = 3;
     
    iptr_to_func = (index == 0) ? func_i : func_J;
     
    if (index == 1)
        vptr_to_func = func_v;
    else
        vptr_to_func = func_W;
     
    vptr_to_func = (index == 1) ? func_v : func_W;
     
}
     
/*    following output from lint:
     
     
tst.c
==============
(21)  operands of : have incompatible types
(14)  warning: iptr_to_ set but not used in function main
(21)  warning: vptr_to_ set but not used in function main
warning: illegal combination of pointer and integer:
    (21)  operator =
     
     
==============
name used but not defined
    func_J       tst.c(14)
    func_W       tst.c(21)
    func_i       tst.c(14)
    func_v       tst.c(21)
     
-------    END of lint output ---------------
     
******* following output from cc:
     
"tst.c", line 21: operands of : have incompatible types
"tst.c", line 21: warning: illegal combination of pointer and
integer, op =
     
*/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3072
          for JMS@ARIZMIS; Tue, 22-JUL-1986 15:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 17:14:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006910; 22 Jul 86 18:04 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa10054; 22 Jul 86 17:02 EDT
Received: from ucb-vax.arpa by AOS.BRL.ARPA id a006529; 22 Jul 86 17:01 EDT
Received: by ucbvax.Berkeley.EDU (5.53/1.14)
    id AA09520; Tue, 22 Jul 86 13:57:53 PDT
Received: from ucsch (ucsch.ARPA) by ucscc (4.12/4.7)
    id AA26944; Tue, 22 Jul 86 11:53:20 pdt
Received: by ucsch (4.12/4.7)
    id AA28907; Tue, 22 Jul 86 11:57:18 pdt
Date: Tue, 22 Jul 86 11:57:18 pdt
From: "Peter L. Rosencrantz" <ucscc!ucsch.pravda@ucb-vax.ARPA>
Message-Id: <8607221857.AA28907@ucsch>
To: info-c@BRL.ARPA
Subject: Re: C compiler test
     
     
On our VAX 11/750 running 4.2bsd I got the incorrect 3 and 4
both normal and optimized.
     
Maybe you see something in this (I'm no assembler wiz)?
output from cc -S
     
LL0:
    .data
    .text
    .align    1
    .globl    _main
_main:
    .word    L12
    jbr     L14
L15:
    movl    $8,-4(fp)
    .data
    .align    2
L16:
    .double    0d2.50000000000000000000e+00
    .text
    cvtld    -4(fp),r0
    divd2    L16,r0
    cvtdl    r0,r0
    movl    r0,-4(fp)
    .data    1
L18:
    .ascii    "i= %d\12\0"
    .text
    pushl    -4(fp)
    pushl    $L18
    calls    $2,_printf
    movl    $8,-4(fp)
    .data
    .align    2
L19:
    .double    0d2.50000000000000000000e+00
    .text
    cvtdl    L19,r0
    divl2    r0,-4(fp)
    .data    1
L20:
    .ascii    "i= %d\12\0"
    .text
    pushl    -4(fp)
    pushl    $L20
    calls    $2,_printf
    pushl    $0
    calls    $1,_exit
    ret
    .set    L12,0x0
L14:
    subl2    $4,sp
    jbr     L15
    .data
     
=============
    Peter L. Rosencrantz
    Mathematics Board
    (or Campus Computer Center)
    University of California
    Santa Cruz, CA 95064
     
    pravda%ucsc.csnet@csnet-relay.ARPA
    pravda%ucsc%csnet-relay.arpa@CSNET-RELAY
    pravda@ucscc.BITNET
    {ucbvax,drivax,escher}!ucscc!pravda.UUCP

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3928
          for JMS@ARIZMIS; Tue, 22-JUL-1986 17:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 19:07:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007520; 22 Jul 86 19:52 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a010989; 22 Jul 86 19:08 EDT
Received: from cmu-psy-a.arpa by AOS.BRL.ARPA id a007360; 22 Jul 86 19:08 EDT
Received: from b.psy.cmu.edu by a.psy.cmu.edu with DECNET ; 22 Jul 86 19:04:23
  EDT
Date:    Tue, 22 Jul 1986 18:27:33-EST
From:    Miles Bader <Bader@b.psy.cmu.edu>
Subject: Re: C compiler test
To:      "Peter L. Rosencrantz" <ucscc!ucsch.pravda@ucb-vax.ARPA>
CC:      info-c@BRL.ARPA
Message-ID: <522437257:Bader@b.psy.cmu.edu>
     
In the first case (i=i/2.5), it's converting the i to double, dividing by
2.5 and converting the answer back to integer.  In the second case, it's
converting the 2.5 to integer and doing an integer divide.  The first
method seems like the correct one, although less efficient...

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4051
          for JMS@ARIZMIS; Tue, 22-JUL-1986 17:26 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/22/86 at 19:21:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007547; 22 Jul 86 20:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011253; 22 Jul 86 19:43 EDT
From: Todd Ogasawara <toddo%uhmanoa.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers for micros
Message-ID: <150@uhmanoa.UUCP>
Date: 21 Jul 86 23:12:35 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Microsoft just sent me the Microsoft C Version 4.0 upgrade notice.  Since
it will be "4 to 6 weeks" before I receive the upgrade (according to the
Microsoft order form), could someone please post a review of the new
window oriented symbolic debugger?  There was also a hint in the upgrade
brochure that MS-DOS MAKE has been enhanced.  Does anyone know what the
enhancements are?  thanks...todd
     
--
Todd Ogasawara, University of Hawaii, Dept. of Psychology
     
UUCP:     {ihnp4,dual,vortex}!islenet!
                      \
                                ihnp4!__\__ uhmanoa!toddo
                    /
      {backbone}!sdcsvax!noscvax!humu!/
                       /
                clyde/
     
ARPA: OGASAWARAT%HAW.SDSCNET@LLL-MFE.ARPA
     
** I used to be: ogasawar@nosc.ARPA & ogasawar@noscvax.UUCP

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8403
          for JMS@ARIZMIS; Wed, 23-JUL-1986 03:40 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 05:30:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009745; 23 Jul 86 6:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015240; 23 Jul 86 5:41 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <452@dg_rtp.UUCP>
Date: 21 Jul 86 16:04:56 GMT
Posted: Mon Jul 21 12:04:56 1986
To:       info-c@BRL-SMOKE.ARPA
     
> davidsen@steinmetz.UUCP (Davidsen)
     
> After thinking about the discussions about using the address operator
> on an array by name, I come to the reluctant conclusiont that it SHOULD
> be allowed in the new ANSI standard. [...]
>
> Reason 1: "codification of existing practice"
     
Well, maybe.  However, this argument means that the standard should say
that the compiler ought to warn about it, yet compile it.  An odd thing
for a standard to say.
     
> Reason 2: "modularity and information hiding"
     
Unfortunately this argument doesn't hold up, for two reasons.  First,
&array (when it is allowed) currently most often evaluates to the
address of the first element of the array, not to the address of the
whole array.  Thus, you can't hide the array-ness anyhow, since this is
different than other applications of the & operator.
     
Second, the inability to hide information (in particular, the allowable
operators for a type) is not unique to arrays in any event.  Integers
can be "+"ed, but not structures, structures can be "."ed, but not
pointers, etc etc etc, and none of this can be hidden.  And even if "&"
were allowed, the assignment would not be.  I'll admit that "&" is a
peculiar operator to not be mostly universal, but I'm still not
convinced that C's peculiar treatment of arrays makes taking their
address sensible.  In effect, it adds yet-another-special-case, rather
than regularizing things.
     
> Reason 3: "common sense"
>   After five years of teaching C, I have to agree with my students that
> it makes no sense to forbid this construct. To take the address of
> something use the address operator.
     
I have a great deal of sympathy for this view.  But NOTE WELL, that it
should yield the address of the WHOLE ARRAY, and NOT the address of the
first element of the array.  This is DIFFERENT than current usage.  Note
that it would make
     
        int actual[10];
        void f(formal) int formal[10];{}
        void g(){ f(&actual); }
     
type-incorrect, since the formal is expecting type (int *), and gets
type (int (*)[]) instead.
     
Also note that "to take the address of something, use the address
operator" is overly simplistic, even if arrays could be "&"ed.  There
are many "somethings" that cannot be "&"ed, such as register variables,
bit fields, expressions, and so on.  Arrays happen currently to be one
of these.
     
     
To sum up, I wouldn't be absolutely aghast if ANSI legislated that
&array should work.  But NOTE WELL that it would constitute YASC, and it
would be a crime against reason to make it work as it does in some
compilers now, such that &array gives a conceptually different type than
&non_array.  And, on balance, I'd say it isn't really that good an idea.
     
--
The string is a stark data structure and everywhere it is passed there
is much duplication of process.  It is a perfect vehicle for hiding
information.
                                --- Alan J. Perlis
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8528
          for JMS@ARIZMIS; Wed, 23-JUL-1986 03:43 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 05:37:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009747; 23 Jul 86 6:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015387; 23 Jul 86 5:46 EDT
From: Ben Cranston <zben@umd5.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <1099@umd5.umd.edu>
Date: 22 Jul 86 23:20:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3142@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
     
> As for the lack of break, it is a fact of life that loops do not always
> exit at the same point in the cycle as they start. Pascal ignores this.
     
Over the last ten years I have implemented several (interpretive) languages
with the extended repeat syntax:
     
   repeat
      (block 1)
   until condition
      (block 2)
   endrep
     
The idea was to allow the entry point and exit point of the loop to differ
without breaking the rule that a loop has only one exit point.
     
   repeat
      fooptr := readnextfoo(foofile)
   until (fooptr=0)
      haveyourwaywithfoo(fooptr)
   endrep
     
In C one would write:
     
   while ( 0 != (fooptr = readnextfoo(foofile)) )
      haveyourwaywithfoo(fooptr);
     
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8665
          for JMS@ARIZMIS; Wed, 23-JUL-1986 03:49 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 05:44:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009749; 23 Jul 86 6:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015395; 23 Jul 86 5:47 EDT
From: Roger Rose <rlr%stcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:C compiler bug
Message-ID: <115@stcvax.UUCP>
Date: 22 Jul 86 19:33:53 GMT
Posted: Tue Jul 22 13:33:53 1986
To:       info-c@BRL-SMOKE.ARPA
     
I tried the program for V7 and 4.1 BSD compilers.  On both compilers
   {int i; i=8; i = i/2.5;} gives i=3.
   {int i; i=8; i/=2.5;} gives i=4.
--
     
Roger Rose
   UUCP:    {hao ihnp4 decvax}!stcvax!rlr
   USnail:  Storage Technology Corp. - MD 3T / Louisville, Co.  80028
   phone:   (303) 673-6873

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8823
          for JMS@ARIZMIS; Wed, 23-JUL-1986 03:55 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 05:49:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009752; 23 Jul 86 6:27 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015402; 23 Jul 86 5:47 EDT
From: Marty Smith <marty%ism780c.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <2943@ism780c.UUCP>
Date: 21 Jul 86 16:05:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3130@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>
>Challenge: given
>
>var    x: array [1..1000] of integer;
>
>write a code fragment to find the location of the first 0 in x. The
>condition that no zeroes exist must be distinguished.
>
>Further rules:
>    - Standard Jensen & Wirth Pascal ( no break from loop )
>    - *** x[i] must not be evaluated for i<1 or i>1000 ***
>    - The search loop must be terminated as soon as a zero is found.
>    - 'a or b', 'a and b' always evaluate both a and b ( I think
>       this is a rule in Jensen & Wirth )
>
>This is the best I can find:
>    var i: integer;
>    ...
>    i :=1 ;
>    while i<1000 and x[i] <> 0 do
>        i := i+1;
>    if x[i] = 0 then writeln('zero at location', i )
>    else writeln('not found');
>
>weird,huh? Note that the condition 'x[i]=0' is evaluated twice ( once
>in the negative sense ), which would be unacceptable if we were searching
>an array of records and the test was expensive.
>
What's wrong with this one?
     
    label 1,2;
    var i: integer;
    ...
    i :=1 ;
    while i<=1000 do
        if x[i] = 0 then goto 1
        else i := i+1;
     
    writeln('not found');
    goto 2;
1:      writeln('zero at location', i )
2:      ...
     
     
     
          Martin Smith

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8895
          for JMS@ARIZMIS; Wed, 23-JUL-1986 03:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 05:51:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009755; 23 Jul 86 6:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015419; 23 Jul 86 5:48 EDT
From: Mark Plotnick <mp%allegra.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <6224@allegra.UUCP>
Date: 21 Jul 86 18:35:06 GMT
Posted: Mon Jul 21 14:35:06 1986
To:       info-c@BRL-SMOKE.ARPA
     
The i /= f and i *= f bugs occur in the 4.3bsd-beta and 4.2bsd
compilers (I don't know about pre-4.2).  The bug is that the
computation is done in integer rather than floating point.  The 4.3bsd
and System V VAX compilers do the right thing.
     
We first noticed this bug on a 4.3bsd-beta system, when we saw
"i *= 0.7" compile into "clrl _i".  Incorrect code, but it's sure fast!
     
    Mark Plotnick
    allegra!mp

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8951
          for JMS@ARIZMIS; Wed, 23-JUL-1986 04:01 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 05:56:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009757; 23 Jul 86 6:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015501; 23 Jul 86 5:49 EDT
From: "David J. Fiander" <djfiander%watnot.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <11897@watnot.UUCP>
Date: 22 Jul 86 14:33:23 GMT
Keywords: Microsoft support
To:       info-c@BRL-SMOKE.ARPA
     
>>
>> I have used several C compilers in my projects and here are the summaries:
>>
>>         - Support has been reasonable for me, but I'm a beta tester.
>
>Support has been poor to useless for us.  The questions we ask usually get
>pretty useless answers, because they are usually telling us to do things
>that the manuals warned about.
>
     
Whenever we phoned up about a problem we were generally told that "that problem
doesn't exist" because no-one else had reported it.
     
One big bug that we found was not in the compiler itself but in the library.
In our product, we would try to malloc() most (if not all) of the free memory,
and after enough malloc()'s, we would start getting back pointers that pointed
into space that we already owned.  Eventually we took the malloc() and free()
out of K&R and used that instead of the library routines.
--
     
----------
     
"Butterflies are free.  This means you can have as many as you want"
                -Sally Brown
     
    UUCP  : {allegra,ihnp4,decvax,utzoo,clyde}!watmath!watnot!djfiander
    CSNET : djfiander%watnot@waterloo.CSNET
    ARPA  : djfiander%watnot%waterloo.csnet@csnet-relay.ARPA
    BITNET: djfiande@watdcs

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9078
          for JMS@ARIZMIS; Wed, 23-JUL-1986 04:08 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 06:01:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009778; 23 Jul 86 6:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015628; 23 Jul 86 5:53 EDT
From: Robert Stroud <robert%cheviot.newcastle.ac.uk@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <889@cheviot.newcastle.ac.uk>
Date: 15 Jul 86 14:22:07 GMT
Posted: Tue Jul 15 14:22:07 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <3519@lll-crg.ARpA> brooks@lll-crg.UUCP (Eugene D. Brooks III)
 writes:
>It would be nice if asm was more "printf like" instead of just dumping
>a string.
     
>suppose you want to change the stack pointer...
>
>    char *oldpointer;
>    char *newpointer;
>
>    asm("store sp,%a", oldpointer);
>    asm("load sp,%a", newpointer);
>
>The code is machine dependent, but the compiler takes care of the
>C name -> AS name  mapping for you.   Of course I guess the compiler
>should not encourage such screwing around.
     
A machine called the Orion made by a British company called High Level
Hardware has something similar. It is based on a bit slice architecture
and has been microcoded as a stack based C machine. Consequently, it is
possible to interpret
     
    asm(opcode, expr, ...)
     
as "push all the C expressions onto the stack and then perform opcode".
     
This lets you mix C expressions with special-purpose opcodes (you can
define your own because the microcode is user-extensible). However,
the clean semantics are only possible because it is a stack machine
and all operations are performed in this way.
     
Robert Stroud,
Computing Laboratory,
University of Newcastle upon Tyne.
     
ARPA robert%cheviot.newcastle@ucl-cs.ARPA
UUCP ...!ukc!cheviot!robert
JANET robert@newcastle.cheviot

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9008
          for JMS@ARIZMIS; Wed, 23-JUL-1986 04:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 05:59:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009774; 23 Jul 86 6:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015574; 23 Jul 86 5:52 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Any GOOD reason for C's behaviour in this example?
Message-ID: <1080@ttrdc.UUCP>
Date: 22 Jul 86 05:37:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I recently came across a situation in C which caused me to do a double
take, at least until I dug out my trusty, dogeared K&R:
     
main()
{
    unsigned short a, b;
    int i;
    a=4;
    b=5;
    i = ( (int) a) - ( (int) b);
    (void) printf("%d\n",i);
    return 0;
}
     
Now, silly me, I was half expecting that casting the unsigned short values
to ints would make them be treated as ints in an expression which takes a
difference between two of them.  (The machine being used was a 3B2, which
has two-byte unsigned shorts and four-byte ints.)
     
However, I initially did a double take when I found that code such as
exemplified in this little program produces a result exemplified by:
     
65535
     
Now deep in the bowels of K&R there is a paragraph explaining that
indeed this is what is supposed to happen and so I am not going to
holler about "oh, I have a broken C compiler" or any such nonsense.
(My own company, AT&T, produces the compiler I am working with; ergo it
CAN'T be broken and if you say it is I'll flame-fight you to the death :-).)
     
But what I'd like to ask is, philosophically, WHY does C expression evaluation
behave in this way?  Is there really a good reason of language design or usage
(other than, obviously, being consistent with existing convention) that you
would NOT want casts within a C expression to act as if they converted the
individual variables or expressions to which they referred into the type of
the cast, regardless of whatever else goes on, before including them in the
evaluation of the entire expression?  I mean, I feel it is rather silly to
have to sidestep what, to me, seemed to be a clear intent with something
like this:
     
main()
{
    unsigned short a, b;
    int i, j;
    a=4;
    b=5;
    i = a;
    j = b;
    i -= j;
    (void) printf("%d\n",i);
    return 0;
}
     
Comments, suggestions, even flames (mild ones; my asbestos is still glowing
from my last round :-) ) are welcome.  Post or mail, and thanks in advance.
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9195
          for JMS@ARIZMIS; Wed, 23-JUL-1986 04:24 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 06:20:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009796; 23 Jul 86 6:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015284; 23 Jul 86 5:43 EDT
From: Jim Webb <jrw%hropus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <576@hropus.UUCP>
Date: 21 Jul 86 22:47:34 GMT
Posted: Mon Jul 21 18:47:34 1986
To:       info-c@BRL-SMOKE.ARPA
     
> Please try this code on your flavor of C compiler and see if you get the
> correct results:
    .
    .
    .
> The correct answer is 3 in both cases, not 4.
     
I got 3 in both cases on my vax running System V Release 2.
--
Jim Webb           "Out of phase--get help"         ihnp4!houxm!hropus!jrw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2236
          for JMS@ARIZMIS; Wed, 23-JUL-1986 09:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 11:05:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018333; 23 Jul 86 11:52 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a023104; 23 Jul 86 10:57 EDT
Received: from ardec-ac2.arpa by AOS.BRL.ARPA id a016874; 23 Jul 86 10:56 EDT
Date:     Wed, 23 Jul 86 10:51:53 EDT
From:     "1LT Dennis G. Rears" (FSAC) <drears@ARDEC.ARPA>
To:       info-unix@BRL.ARPA, info-c@BRL.ARPA
Subject:  curses & ultrix
     
     
We are running Ultrix 1.2 on a VAX 8600.  I am trying to compile a
a set of programs using curses.  Unfortunately Ultrix's curses
doesn't conform with SYSV or 4.2 BSD.
  The first problem I had was the defines of BOLD, DIM, etc was
missing from /usr/include/curses.h.  I had to redefine that file.
I also noticed that the structure element of win_attrs was changed to
win_flags (Probabably so DEC could say they made "major" changes to it)
The functions attron & attroff (in curses.h they are macros which are
mapped to wattron & wattroff) are missing.  I attempted to write
these functions but as I do not have source I can only guess at
this.  This is how these functions look:
     
/*  These functions are added on because ULTRIX
is a incomplete package */
     
wattron(win, att)
WINDOW *win;
int    att;
{
    win->_flags |= att;
}
     
     
wattroff(win, att)
WINDOW *win;
int    att;
{
    win->_flags &= ~att;
}
     
The attributes are defined as:
     
#define A_STANDOUT    0000200
#define A_UNDERLINE    0000400
#define A_REVERSE    0001000
#define A_BLINK        0002000
#define A_DIM        0004000
#define A_BOLD        0010000
#define A_NORMAL    0000000
     
    The programs now compile but when I run it It does not turn on
the attributes.  Can anyone provide insight into fixing this ?
     
        Dennis
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2571
          for JMS@ARIZMIS; Wed, 23-JUL-1986 10:02 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 11:53:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019195; 23 Jul 86 12:40 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024425; 23 Jul 86 11:41 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: WITH statement
Message-ID: <551@cbmvax.cbmvax.cbm.UUCP>
Date: 22 Jul 86 17:16:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Summary: no danger--it's like a procedure
>
> The "scary" part of the `with' statement--the loss of qualifier in front of
> field selectors--is no problem at all in practice because `with' statements
> tend to be intensive activity on the records being manipulated.  I've
> observed that `with' statements tend to be either fairly short (probably
> under 10 lines) or the entirety of a procedure where the `with' opens one
> or more of the procedure's parameters--for example:
>       procedure xxx(p: pwhatzy);
>       ...decls
>       begin with p^ do begin
>       ...work on the object referenced by p
>       end end;
>
> I've written a lot of Pascal and a lot more C.  Mostly I find C faster to
> write, but when I start writing a sequence of code to fill in a structure,
> I sure miss the `with' statement.
> --
> Dick Dunn     {hao,ucbvax,allegra}!nbires!rcd         (303)444-5710 x3086
>    ...At last it's the real thing...or close enough to pretend.
     
Ideally.  Though I had a job one time translation large chunks of Pascal
code to C.  This was on a large CAD project, in other words, a big, non
trivial, etc. example of Pascal.  There were sections of the Pascal
code with 5-10 levels of nested WITH statements.  You get identifiers
flying around all over the place, with no concept as to which structures
they belong to (at least, not without referring to about six pages of
RECORD declarations to track them down). Its may be very nice to
have the WITH construct available when writing code, but its main purpose
when maintaining or translating code is to create confusion and obstruct
the real purpose of the code you're examining.  It could lead to more
efficient code when used properly, though I wonder if anyone thinks of
the troubles involved when using it on a large sca be believed!
   The reviewer now moves to the traitorous character who wishes to leave
his beloved homeland. It is so sad that his activities are praised and
held up to be admired by the reader. Why everybody knows that EVERYBODY
has a job, a place to live, and no charge education and medical care. Who
would believe that it's illegal to live in any city, Especially MOSCOW, without
permission. And to get permission to live in any city, you must work there.
But to get a job, you must have permission to live in the city. See? And the
references to the Soviet Submarine forces are despicable. The observation
that all soviet submariners are bald from the radiation is patently false...
they just like to shave their heads after military service as a sign to their
comrades : a badge of honor and self sacrifice.
This book tries to give the impression that Russians are a besotted,
hopeless bunch of victims of their leaders and the Communist Party!
The descriptive scenes of medical care are fabrications

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4155
          for JMS@ARIZMIS; Wed, 23-JUL-1986 12:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 14:02:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022987; 23 Jul 86 14:52 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a029374; 23 Jul 86 14:41 EDT
Received: from logicon.arpa by AOS.BRL.ARPA id a022406; 23 Jul 86 14:33 EDT
Date: 23 Jul 86 11:18 PDT
From: Bill D'Camp <bill@LOGICON.ARPA>
To: info-c@BRL.ARPA
Subject: RE: C Compiler Bug
     
With respect to the C bug reported the other day I've tried it on the
following systems/compilers:
     
hardware    compiler/vendor        results
     
pdp-11/70    pwb v1.0        3 and 4
     
vax-11/780    4.2BSD            3 and 4
     
level-6        honeywell v6        3 and 3
     
amiga        aztec            3 and 4
     
amiga        lattice            3 and 3
     
ibm pc        microsoft 3.0        3 and 3
     
ibm pc        aztec            3 and 4
     
According to K&R in the reference manual (p. 191) :
     
"In the simple assignment with =, the value of the expression replaces that
of the object referred to by the lvalue.  If both operands have arithmetic
type, the right operand is converted to the type of the left PREPARATORY
(emphasis added) to the assignment."
     
It seems that what remains is interpreting whether the conversion takes place
prior to the operation or not.  Obviously, some vendors have interpreted
this as applying to the operation as well as to the assignment, while others
have not.  The statement is ambiguous on this point, although in the preceding
paragraph it says that the two parts of the compound are treated as separate
tokens.
     
It seems to me that while receiving a consistent answer is clearly desired,
those vendors who have taken the other interpretation COULD also be considered
as complying with the reference.
     
                    Bill D'Camp
     
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5587
          for JMS@ARIZMIS; Wed, 23-JUL-1986 16:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 16:17:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026599; 23 Jul 86 17:02 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002651; 23 Jul 86 15:59 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA07575; Wed, 23 Jul 86 15:57:05 edt
Date: Wed, 23 Jul 86 15:57:05 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607231957.AA07575@icst-cmr.ARPA>
To: daveh%cbmvax.cbm.uucp@BRL.ARPA, info-c@BRL-SMOKE.ARPA
Subject: Re: Re: WITH statement
     
    Ideally.  Though I had a job one time translation large chunks
    of Pascal code to C.  This was on a large CAD project, in other
    words, a big, non trivial, etc. example of Pascal.  There were
    sections of the Pascal code with 5-10 levels of nested WITH
    statements.  You get identifiers flying around all over the
    place, with no concept as to which structures they belong to
    (at least, not without referring to about six pages of RECORD
    declarations to track them down). Its may be very nice to have
    the WITH construct available when writing code, but its main
    purpose when maintaining or translating code is to create
    confusion and obstruct the real purpose of the code you're
    examining.  It could lead to more efficient code when used
    properly, though I wonder if anyone thinks of the troubles
    involved when using it on a large sca be believed!
     
While I'm no lover of Pascal, I CAN offer a porting solution. But
first you must answer one question: Would you be happier (I didn't
say `happy', I said `happi-ER') porting the code without the WITH's?
You would? Good! Here's how.
     
First you need the original Pascal compiler. Then you change all the
`WITH p^'s to `WITH xp^'s, that is bogusize the WITH, but preserve
the original name. Then fix all the errors by prepending `p^' where
necessary, and remove the with statement. Yow!
     
Now you are ready for all the other headaches.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
This ASEXUAL PIG really BOILS my BLOOD...He's so..so.....URGENT!!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5649
          for JMS@ARIZMIS; Wed, 23-JUL-1986 16:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 16:20:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026591; 23 Jul 86 17:01 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a002182; 23 Jul 86 15:46 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA07520; Wed, 23 Jul 86 15:44:27 edt
Date: Wed, 23 Jul 86 15:44:27 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607231944.AA07520@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, zben@umd5.ARPA
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Cc: chris@maryland.ARPA
     
    In article <3142@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
     
    >As for the lack of break, it's a fact of life that loops do not always
    >exit at the same point in the cycle as they start. Pascal ignores this.
     
    Over the last ten years I have implemented several (interpretive)
    languages with the extended repeat syntax:
     
       repeat
          (block 1)
       until condition
          (block 2)
       endrep
     
Struc$ rears it's ugly head again. Perhaps, Ben, you would like to explain
the true significance of the form:
     
    repeat [while Condition_1]    while (Condition_1) {
        Block_1                {Block_1}
    [until Condition_2]            if (Condition_2)
        Block_2                {Block_2; goto YOW;}
    [otherwise]                else
        Block_3                {Block_3}
    [atend]                }
        Block_4                {Block_4}
    endrep                YOW:
     
Oh, I just did.
     
Dr. Pat Haggerty (Chief of Tong, not the referee) implemented this in
Univac 1108 Assembley language (pre MASM).
     
This was before those young whippersnappers like Chris Torek came along
and I could look out my dorm window right thru his present office and see
trees, cows, and pigs.
     
(Slowly the attack of (machinus) envy and nostalgia subsides :-).
     
               umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
    Ben Cranston zben @ umd2.UMD.EDU   Kingdom of Merryland Sperrows 1100/92
               umd2.BITNET     "via HASP with RSCS"
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
On the road, ZIPPY is a pinhead without a purpose, but never without a POINT.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6832
          for JMS@ARIZMIS; Wed, 23-JUL-1986 17:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/23/86 at 19:02:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028456; 23 Jul 86 19:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005207; 23 Jul 86 19:42 EDT
From: Stanley Friesen <friesen%psivax.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <1352@psivax.UUCP>
Date: 22 Jul 86 15:39:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <613@looking.UUCP> brad@looking.UUCP (Brad Templeton) writes:
>
>I have used several C compilers in my projects and here are the summaries:
>
>1) Microsoft C
>    The winner:
>        - Ansi C style argument type checking.
>2) Lattice C
>    This is one of the best selling and it is well supported.
>    The original version was unacceptable.   It lacked things like
>    "unsigned int" (you just said unsigned) and structure assignment.
>    Not much hope of compiling Unix style programs.
>
>    They have a new release which supposedly fixes these problems and
>    brings it up to a similar level with Microsoft C.  I have not played
>    with this one.  Supposedly they also have a Xenix version.
>
    Yes, the new release fixes these problems. It also has a pcc
compatible void type(i.e. void functions only) and Ansi C style argument
type checking. Furthermore the delivered library is much larger and
more useful. It now contains most of the important routines from the
Ansi draft standard and the Sys V interface specification, as well as
support for most of the features of MS-Dos up through version 3.1. A
vast improvement.
>
>
>6) Wizard C.
>    No personal experience, but friends say it is fairly good.  From too
>    small a company if this matters to you, though.
>
    Yes, it is fairly good, and support is *mostly* fairly decent.
One nice feature is its extended Large Model(called Huge Model),
unfortunately that model is somewhat buggy. The latest release also
has a significant bug in Large Model floating point arithmetic, for
which we are waiting for a fix.
--
     
                Sarima (Stanley Friesen)
     
UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ??

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6958
          for JMS@ARIZMIS; Wed, 23-JUL-1986 17:23 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028445; 23 Jul 86 19:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005193; 23 Jul 86 19:41 EDT
From: wade blomgren <st94wb%sdcc12.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <626@sdcc12.UUCP>
Date: 22 Jul 86 17:09:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I tried the '/=' bug test on the following:
     
Pyramid 90x running 4.2/5.0 Unix (cc) - both answers == 3 (passed)
     
SUN 2 running Unix 4.2 release 1.4 (cc) - answers == 3,4  (failed)
     
Hmmmm...
     
     
Wade Blomgren
UCSD Academic Computing Svcs
....!sdcsvax!sdcc12!st94wb
....!sdcsvax!net1!wade

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8485
          for JMS@ARIZMIS; Wed, 23-JUL-1986 20:01 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/23/86 at 21:49:50 CDT
Received: from seismo.CSS.GOV by SRI-KL.ARPA with TCP; Tue 22 Jul 86
  14:55:33-PDT
Return-Path: <mcvax!gec-mi-at.co.uk!steve>
Received: from mcvax.UUCP by seismo.CSS.GOV with UUCP; Tue, 22 Jul 86 16:28:51
  EDT
Received: by mcvax.uucp; Tue, 22 Jul 86 22:10:21 +0200 (MET)
Received: from gec-rl-hrc.co.uk by eagle.Ukc.AC.UK   via PSS with NIFTP
           id a000650; 22 Jul 86 18:18 BST
Received: from miduet by ux63.gec-rl-hrc.co.uk id aa04085; 22 Jul 86 18:17 BST
From: Steve Lademann <mcvax!miduet!steve@seismo.CSS.GOV>
Date: Tue, 22 Jul 86 09:05:06 -0100
Message-Id: <10576.8607220805@miduet.gec-mi-at.co.uk>
Subject: VAX/VMS 'C' Compiler
Newsgroups: mod.computers.vax
Distribution: net
To: info-vax@sri-kl.arpa
Sender: mcvax!gec-mi-at.co.uk!steve@seismo.CSS.GOV
     
A colleague of mine who is a VAX/VMS Systems Programmer, wants to experiment
with using 'C' as a Systems Programming language under VMS. His problem is
that he doesn't want to spend too much money until he has convinced himself
that it's the right way to go.
     
So, does anyone know of a Public Domain 'C' compiler for VAX/VMS? Or an
inexpensive one? Please mail me if you can help.
     
"Make the man who turns the light on in the 'fridge redundant.
 Buy some Welsh lamb"
-----------------------------------------------------------------
|Steve Lademann         |Phone: 44 727 59292 x326               |
|Marconi Instruments Ltd|UUCP : ...mcvax!ukc!hrc63!miduet!steve |
|St. Albans    AL4 0JN  |NRS  : steve@uk.co.gec-mi-ate.mifnet   |
|Herts.   UK            |                                       |
---------------------------------------------------------- /\H --
|"The views expressed herein do not necessarily reflect"| /__\  |
|"those of my employer, and may not even reflect my own"| |  |  |
-----------------------------------------------------------------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1024
          for JMS@ARIZMIS; Wed, 23-JUL-1986 23:39 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 07/24/86 at 01:31:37 CDT
Received: from hqafsc-vax.ARPA by SRI-KL.ARPA with TCP; Wed 23 Jul 86
  02:50:44-PDT
Date: 23 Jul 86 05:46:00 EST
From: "MR JAMES L ANDERSON" <janderson@hqafsc-vax.ARPA>
Subject: Public Domain C
To: "info-vax" <info-vax@sri-kl.ARPA>
Reply-To: "MR JAMES L ANDERSON" <janderson@hqafsc-vax.ARPA>
     
The DECUS library has a public domain version of C available. It does run
in compatability mode, but I understand that some revision is being done to
it. If you are a member of a LUG you might have your LUG chairman or Librarian
look into it for you.
------

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2454
          for JMS@ARIZMIS; Thu, 24-JUL-1986 01:48 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/24/86 at 03:43:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001434; 24 Jul 86 4:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007680; 24 Jul 86 3:42 EDT
From: Bjarne Stroustrup <bs%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: foot in mouth (&vector)
Message-ID: <5827@alice.uUCp>
Date: 23 Jul 86 20:25:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I wrote:
     
> for what it is worth: In C++ it is allowed (and encourraged practice) to use
 the
> addressof operator & explicitly for array and function names.
     
Oops, cfront does not consistently accept &v as the address for a vector v.
So back to the drawing board. I was led astray by the fact the &f consistently
works when f is a function.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3181
          for JMS@ARIZMIS; Thu, 24-JUL-1986 03:05 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/24/86 at 04:59:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001789; 24 Jul 86 5:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008724; 24 Jul 86 5:42 EDT
From: Jeff Lee <jeff%gatech.csnet@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C compiler test
Message-ID: <4182@gatech.CSNET>
Date: 23 Jul 86 16:11:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
This bug has been fixed in the 4.3 compiler. It was documented as a
misunderstanding as to what was to be cast.
--
Jeff Lee
CSNet:    Jeff @ GATech        ARPA:    Jeff%GATech.CSNet @ CSNet-Relay.ARPA
uucp:    ...!{akgua,allegra,hplabs,ihnp4,linus,seismo,ulysses}!gatech!jeff

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3330
          for JMS@ARIZMIS; Thu, 24-JUL-1986 03:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/24/86 at 05:15:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001997; 24 Jul 86 6:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008686; 24 Jul 86 5:41 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Any GOOD reason for C's behaviour in this example?
Message-ID: <2566@umcp-cs.UUCP>
Date: 23 Jul 86 10:17:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1080@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
>I recently came across a situation in C which caused me to do a double
>take, at least until I dug out my trusty, dogeared K&R:
>
>main()
>{
>    unsigned short a, b;
>    int i;
>    a=4;
>    b=5;
>    i = ( (int) a) - ( (int) b);
>    (void) printf("%d\n",i);
>    return 0;
>}
>
>... I was half expecting that casting the unsigned short values to
>ints would make them be treated as ints in an expression which takes a
>difference between two of them.  [But] ... this little program produces
>... 65535.
>
>Now deep in the bowels of K&R there is a paragraph explaining that
>indeed this is what is supposed to happen ...
     
Where?
     
K&R, p. 42:
     
  The precise meaning of a cast is in fact as if {\it expression} were
  assigned to a variable of the specified type, which is then used in
  place of the whole construction.
     
Therefore,
     
    unsigned short us1, us2;
    int i1, i2;
    int r1, r2;
     
    us1 = 4; us2 = 5;
    r1 = (int)us1 - (int)us2;
    i1 = us1; i2 = us2; r2 = i1 - i2;
     
should produce the same values in `r1' and `r2'.  Indeed, the 4.3BSD
C compiler produces -1 for both.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4553
          for JMS@ARIZMIS; Thu, 24-JUL-1986 05:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/24/86 at 07:08:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003542; 24 Jul 86 8:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010125; 24 Jul 86 7:45 EDT
From: Rob Brunner X2830 <brunner%sdsioa.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <154@sdsioa.UUCP>
Date: 23 Jul 86 22:13:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Pyramid 90x running 4.2/5.0 Unix (cc) - both answers == 3 (passed)
> SUN 2 running Unix 4.2 release 1.4 (cc) - answers == 3,4  (failed)
     
I ran the test on a Vax 11/750 running 4.2bsd cc and got 3,4
    ... at least the bug isn't consistent across machines 8-).
--
Rob Brunner                              email:
Scripps Institution of Oceanography      brunner@sdsioa.UUCP
Mail Code A-010, UC San Diego            sdsioa!brunner@sdcsvax
San Diego, CA 92093                      {backbone}!sdcsvax!sdsioa!brunner
Phone: (619) 534-2040 (work)             (619) 452-7656 (home)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4498
          for JMS@ARIZMIS; Thu, 24-JUL-1986 05:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/24/86 at 07:07:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003431; 24 Jul 86 7:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010107; 24 Jul 86 7:44 EDT
From: Roberto Salama <rs%mcnc.uucp@BRL.ARPA>
Newsgroups: net.lang,net.lang.c
Subject: Concurrent C language
Message-ID: <1544@alvin.mcnc.UUCP>
Date: 23 Jul 86 18:04:17 GMT
Keywords: Concurrent C
To:       info-c@BRL-SMOKE.ARPA
     
I have started using the Concurrent C package designed by N. H. Gehani
and W. D. Roome. As people who have used this package know, the manual
is helpful only in getting you started. I was wondering if there are
other users of CCC out there that we can share experiences and answer
questions. As I see, there is no newsgroup net.lang.ccc, and nothing
about concurrent C ever gets said in the net.lang.c news group. Also,
I am interested in receiving information about books or publications
that might be helpful. I would be thankful for any information.
     
Roberto Salama
decvax!mcnc!rs

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7801
          for JMS@ARIZMIS; Thu, 24-JUL-1986 09:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/24/86 at 11:04:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013611; 24 Jul 86 11:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017537; 24 Jul 86 11:41 EDT
From: Ed Nather <nather%ut-sally.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Any GOOD reason  ... (apology)
Message-ID: <5399@ut-sally.UUCP>
Date: 24 Jul 86 13:53:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Whoops, whoops, and triple whoops.  I got my accounts confused.
> So much for flames...  **SPLOOSH**  Oy vey.
> SORRY!!!!!!!!!!
     
I think you owed us at LEAST an "Oy gevalt."
     
--
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.AS.UTEXAS.EDU

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7723
          for JMS@ARIZMIS; Thu, 24-JUL-1986 09:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/24/86 at 11:03:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013582; 24 Jul 86 11:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017525; 24 Jul 86 11:41 EDT
From: Steve Summit <stevesu%copper.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <500@copper.UUCP>
Date: 24 Jul 86 06:56:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <501@bunny.UUCP>, mlr0@bunny.UUCP (Martin Resnick) writes:
> Please try this code on your flavor of C compiler...
(followed by code demonstrating essentially
>    i = i/2.5;
vs.
>    i /= 2.5;
     
The answer is absolutely unequivocal on this point.  A compiler
that does not treat i=i/float and i/=float identically is broken,
although many compilers are so broken.  This question was
discussed to death on the net a year or so ago.  The discussion
came to a screeching halt, quite unlike most net discussions,
when the following article appeared from one dmr@research:
     
> From: dmr@research.UUCP
> Newsgroups: net.lang.c
> Subject: bug in type conversion
> Date: Wed, 4-Jan-84 21:32:17 PST
>
> Mike O'Brien points out that in the C compilers he has available, the
> expression
>     i *= d;
> where  i  is int and  d  is double is evaluated in fixed point, and
> wonders why.  The answer: it is a compiler bug.  I fixed it in
> (a post V7 version) of the 11 compiler, and it is fixed in the current
> System V compiler (by "current" I mean the one I tried;
> I don't know what is being shipped at this instant.)
>
> The manual is reasonably clear and unambiguous on the point, but
> it's not surprising that people for search for definition problems when
> the compilers are unanimously wrong.
>
>     Dennis Ritchie
     
What the manual says is (K&R page 191):
     
    "The behavior of an expression of the form E1 op= E2 may
    be inferred by taking it as equivalent to E1 = E1 op (E2);
    however, E1 is evaluated only once."
     
The single evaluation of E1 is the only difference between the
two forms; any type casting, including truncation, should be done
exactly as if E1 = E1 op (E2) had been performed.
     
                                         Steve Summit
                                         tektronix!copper!stevesu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6785
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 03:24:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025739; 24 Jul 86 21:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028737; 24 Jul 86 21:42 EDT
From: "John P. Nelson" <jpn%teddy.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.pc
Subject: Re: Microsoft MSC ver 4.0
Message-ID: <2918@teddy.UUCP>
Date: 24 Jul 86 21:51:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>Has anybody heard anything about the new Microsoft 'C' Compiler version 4.0?
>I would consider upgrading but at $150 for the upgrade I would like a little
>more information.
     
I received my upgrade form a couple of days ago along with their advertising
blurb.  I don't have it in front of me, so your milage may vary.  The new
version is reported to contain the following new features:
     
    1. Screen oriented debugger.  I would have liked to see more real
       information about this, the blurb in the mailing was a bit sketchy.
       Presumably this supercedes SYMDEB.  I hope you can examine stack
       variables with this one!
     
    2. Two new memory models:  Compact (large data, small code) and Huge
       (true 32 bit pointers, objects larger than 64K).  The Huge model
       corresponds to the Lattice Large model without the -s? option.
       Still no .COM model.
     
    3. Startup source code supplied.  Apparently a lot of people complained
       that MS C was a bit hard to customize.  No library source code yet,
       though.
     
    4. New mixed model programming keyword: "Huge" (allows Huge model
       pointers in other memory model programs).
     
    5. "More ANSI extensions" whatever that means.  They now reserve the
       keywords "volatile" and "const" keywords, without implementing them.
       The DID implement "signed".  There may be some of the new ANSI
       preprocesser stuff, I can't remember.
     
    6. A fair number of new library functions.  The ones that caught my eye
       were the vprintf family.  I think they may have implemented all the
       ANSI mandated functions, but I didn't check.
     
    7. I think that the function prototypes still perform a "lint check"
       rather than a type conversion, as mandated by ANSI, but again, I
       can't really recall.
     
All in all, it looks pretty good.  I was pretty happy with version 3.0;
I thought that it was a fairly high-quality product when it first came
out.  I sent my form in the day I received it, but they said to expect a
6 to 8 week delivery time.   :-(    If I get mine first, I'll post a review.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6891
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 03:28:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026384; 25 Jul 86 0:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029351; 24 Jul 86 23:40 EDT
From: David Dyer-Bennet <ddb%starfire.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Precedent for use of =
Message-ID: <257@starfire.UUCP>
Date: 24 Jul 86 04:40:09 GMT
Posted: Wed Jul 23 23:40:09 1986
To:       info-c@BRL-SMOKE.ARPA
     
>            What we really need is a one-character assignment operator; ....
> ..........................................  The C convention is unfortunate
> for two reasons; first, it's unlike everyone else's.......................
> C. Wingate
     
Um, actually an early language called Fortran had a one-character
assignment operator.  Perhaps you've heard of Fortran?  I haven't,
recently.  But anyway, it used the same little ol' character c uses,
namely the single equal sign.  Seems to me funny assignment operators
started with Algol.
     
        -- David Dyer-Bennet
        Usenet:  ...ihnp4!umn-cs!starfire!ddb
        Fido: sysop of fido 14/341, (612) 721-8967
        Telephone: (612) 721-8800
        USmail: 4242 Minnehaha Ave S
            Mpls, MN 55406

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8345
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 05:07:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027203; 25 Jul 86 5:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001549; 25 Jul 86 5:43 EDT
From: robison@uiucdcsb.ARPA
Newsgroups: net.lang.c
Subject: Re: Any GOOD reason for C's behaviour i
Message-ID: <139200033@uiucdcsb>
Date: 24 Jul 86 01:08:00 GMT
Nf-ID: #R:ttrdc.UUCP:1080:uiucdcsb:139200033:000:465
Nf-From: uiucdcsb.CS.UIUC.EDU!robison    Jul 23 20:08:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
Your compiler is broken according to K&R, section 2.7 (page 42):
     
``In the construction
     
    (type-name) expression
     
the expression is converted to the named type by the conversion rules above.
The precise meaning of a cast is in fact as if expression were assigned to a
variable of the specified type, which is then used in place of the whole
construction.''
     
Your two programs should behave identically.
     
Arch D. Robison
University of Illinois at Urbana-Champaign

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8460
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 05:26:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027365; 25 Jul 86 6:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001505; 25 Jul 86 5:40 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Any GOOD reason for C's behaviour in this example?
Message-ID: <1085@ttrdc.UUCP>
Date: 23 Jul 86 22:24:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1080@ttrdc.UUCP>, levy@ttrdc.UUCP (yeah, that's me) writes:
>main()
>{
>    unsigned short a, b;
>    int i;
>    a=4;
>    b=5;
>    i = ( (int) a) - ( (int) b);
>    (void) printf("%d\n",i);
>    return 0;
>}
>
>(The machine being used was a 3B2, which
>has two-byte unsigned shorts and four-byte ints.)
>
>However, I initially did a double take when I found that code such as
>exemplified in this little program produces a result exemplified by:
>
>65535
     
Whoops, whoops, and triple whoops.  I got my accounts confused.  It works
as expected on the 3B2 (outputs a value of -1).  It was a _3B20_ which
tripped up on this one!  (BTW I have received mail from a person on attunix
telling me that the CURRENT 3B20 compiler has this bug fixed.  I guess I
need to get an update.)  So much for flames...  **SPLOOSH**  Oy vey.
SORRY!!!!!!!!!!
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0883
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 07:50:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029683; 25 Jul 86 8:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002763; 25 Jul 86 7:44 EDT
From: Steven Pemberton <steven%mcvax.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <7019@boring.mcvax.UUCP>
Date: 24 Jul 86 14:22:59 GMT
Posted: Thu Jul 24 14:22:59 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <613@looking.UUCP> brad@looking.UUCP (Brad Templeton) writes:
> I have used several C compilers in my projects and here are the summaries:
>
> 1) Microsoft C
>     The winner:
>         - It comes from a large firm dedicated to languages
>         - The only compiler to take my 30,000 line program and have
>           it run essentially right away.
>         - Support has been reasonable for me, but I'm a beta tester.
     
I agree that MS C is the best compiler, but support? I have written to them
several times about support issues, both electronically and on paper, and
have never once had any reply from them whatsoever. Fooey.
     
Steven Pemberton, CWI, Amsterdam; steven@mcvax.uucp

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0540
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 07:19:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028763; 25 Jul 86 8:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002790; 25 Jul 86 7:45 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <2247@ihlpg.UUCP>
Date: 23 Jul 86 22:01:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >   After five years of teaching C, I have to agree with my students that
> > it makes no sense to forbid this construct. To take the address of
> > something use the address operator. I have seen this mistake made by
> > students from major universities, and graduates of courses taught by
> > high priced consultants, so it's not just my students.
>
> All right, tell me:  What is the type of the address of an array?
>
> That is, suppose I write:
>
>     int a[10];
>
> What type is &a?  Don't tell me it's "pointer to integer" because
> that is the type of &a[0], and a and a[0] are different things.
     
The answer is : It doesn't have one.  That isn't valid C.  Compilers will
give you warnings about this and interpret it as &a[0], or will give you
an error message (or are broken!).
--j.a.tainter

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0708
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 07:33:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028882; 25 Jul 86 8:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002814; 25 Jul 86 7:46 EDT
From: Paul R Markowitz <ecf_eprm%jhunix.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Int and Char
Message-ID: <3250@jhunix.UUCP>
Date: 24 Jul 86 13:31:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Don't C programmers know the difference between a char and an int?
I get these great public domain programs off the net and I spend
the next 2 weeks deciding which variables are declared as char
but really mean short.  You see, it's like this.  Short, int, and
long are all SIGNED.  That means they can take on negative values.
Chars are NOT SIGNED, there is no char called -1.  If you want a
variable that takes on negative values, use a short.  It certainly
makes your code easier for others to read as well as making it
more portable.
     
For my next question, why doesn't my C compiler accept declarations
like 'signed char a;' or something like that?  It says 'signed undefined'
and dies.  Is there no way to make up for the errors of others
and artificially make chars come out signed?  I am running sys V rel2
on an att 3b20.
     
Just had to get this off my chest.
     
Paul
--
------------------------------------------------------------------------
Paul Markowitz
     
"A pessimist is someone who won't call on G-d because he is certain he will
get an answering machine."
     
"Do you wonder if I'm really happy?            seismo!umcp-cs!jhunix!ins_aprm
 Am I just the company you keep?               bitnet: ins_aprm@jhuvms
 Which one of us excercises on the old         arpanet:
 ins_aprm%jhunix.BITNET@wiscvm.ARPA
   tread mill?
 Who hides his head pretending to sleep?"
-Ian Anderson (and Robert Burns?)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0655
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 07:29:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028833; 25 Jul 86 8:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002794; 25 Jul 86 7:45 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <2248@ihlpg.UUCP>
Date: 23 Jul 86 22:12:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Challenge: given
> var    x: array [1..1000] of integer;
> write a code fragment to find the location of the first 0 in x. The
> condition that no zeroes exist must be distinguished.
> Further rules:
>     - Standard Jensen & Wirth Pascal ( no break from loop )
>     - *** x[i] must not be evaluated for i<1 or i>1000 ***
>     - The search loop must be terminated as soon as a zero is found.
>     - 'a or b', 'a and b' always evaluate both a and b ( I think
>        this is a rule in Jensen & Wirth )
> This is the best I can find:
>     var i: integer;
>     ...
>     i :=1 ;
>     while i<1000 and x[i] <> 0 do
>         i := i+1;
>     if x[i] = 0 then writeln('zero at location', i )
>     else writeln('not found');
> Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
     
This is a better solution:
     
    var i : integer;
    notfound : boolean;
    x : array [1..1000] of integer;
    .
    .
    .
    i := 1;
    notfound := true;
    while (i<=1000) and notfound do
    if x[i] = 0 then
        notfound := false
    else
        i := i+1;
    if notfound then
    writeln('not found')
    else
    writeln('zero at location', i );
--j.a.tainter

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0927
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 07:51:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029589; 25 Jul 86 8:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002759; 25 Jul 86 7:43 EDT
From: Steven Pemberton <steven%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <7018@boring.mcvax.UUCP>
Date: 24 Jul 86 13:32:41 GMT
Posted: Thu Jul 24 13:32:41 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <3130@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
> Given     var    x: array [1..1000] of integer;
> write a code fragment to find the location of the first 0 in x. The
> condition that no zeroes exist must be distinguished. Further rules:
>     - Standard Jensen & Wirth Pascal ( no break from loop )
>     - *** x[i] must not be evaluated for i<1 or i>1000 ***
>     - The search loop must be terminated as soon as a zero is found.
>     - 'a or b', 'a and b' always evaluate both a and b
     
What I find an elegant solution to this sort of problem is the following:
     
    var state: (searching, found, absent);
        i: 1..1000;
     
    i:=1; state:=searching;
    repeat
       if x[i]=0 then state:=found
       else if i=1000 then state:=absent
       else i:=succ(i)
    until state <> searching;
     
    case state of
    found: writeln('found at ', i);
    absent:writeln('not there')
    end
     
I like it because it is explicit and generalisable for searches with more
states. Note that i only takes values in 1..1000 and x[i] is only evaluated
once for each element.
     
I still think Jack Jansen's main point has been ignored in this discussion:
you run a C program that overruns an array, and it may run to completion, or
at best say "Memory fault - core dumped".
     
Do the same with a Pascal program, and you're quite likely to get something
like "Index out of bounds at line 123, value = -1". (Actually I just tried
it here, and with "x[1234]:=0", I got a compile-time error! The C version
ran without complaint).
     
This difference can make a huge difference to the time needed to get a
program running, and the confidence you have in it at the end. This
advantage far outweighs the minor notational inconveniences that this group
seems obsessed with.
     
Disclaimer: I think that there are programming languages FAR better than
both Pascal and C. However, I try to remain objective about all of them.
     
Steven Pemberton, CWI, Amsterdam; steven@mcvax.uucp

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5456
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 15:57:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014965; 25 Jul 86 16:39 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a013196; 25 Jul 86 15:29 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a013162; 25 Jul 86 15:21 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA03973; Fri, 25 Jul 86 15:16:55 edt
Date: Fri, 25 Jul 86 15:16:55 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607251916.AA03973@icst-cmr.ARPA>
To: rgenter@BBN-LABS-B.ARPA
Subject: Re: format (printf like routines)
Cc: info-c@BRL.ARPA
     
         With respect to 10**38 being inaccurate:
     
        Geoff is correct.  Since 10 is not a power of two, to represent 10**38
    exactly *does* require many many bits of mantissa (89 to be exact).
    *However*, on the VAX, thanks to hardware magic like guard digits,
    a loop of 38 "* 10.0"s *does* yield the exact representation of
    10**38 within the constraints of a (double).
    A subsequent loop of 38 "/ 10.0"s even gives you 1.0.
     
Perhaps I should have made myself clear. IEEE format does not require
that every integer in it's range be represented exactly. I do agree that
10**38 requires something like 89 bits, but 10**38 - 1 requires more,
something on the order of 126 bits. Even with Cray 128 bit doubles,
some of the bits have to go to the exponent, so it can't represent
all the integers in its range either.
     
    Rick Genter             BBN Laboratories Inc.
    (617) 497-3848            10 Moulton St.  6/512
    rgenter@labs-b.bbn.COM      Cambridge, MA   02238
    rgenter@bbn-labs-b.ARPA     linus!rgenter%BBN-LABS-B.ARPA (UUCP)
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
A can of ASPARAGUS, 73 pigeons, some LIVE ammo, and a FROZEN DAQUIRI!! ...
     
... cannot represent it either.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2951
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 12:04:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007211; 25 Jul 86 12:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007956; 25 Jul 86 11:46 EDT
From: Geoff Kuenning <geoff%desint.uucp@BRL.ARPA>
Newsgroups: net.sources.d,net.lang.c
Subject: Re: format (printf like routines)
Message-ID: <235@desint.UUCP>
Date: 23 Jul 86 06:56:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <125@sol.UUCP> chris@sol.UUCP (Christopher Caldwell) writes:
     
> Here are the routines that I talked about in net.lang.c.
>...
> echo "Extracting format.c (13553 characters)."
>...
     
Sigh.  My soapbox is getting awfully rickety, and with every passing year
it becomes more difficult for my feeble limbs to make the climb onto it.
Nevertheless, I feel morally obligated to warn people:
     
DON'T USE THIS SOFTWARE TO CONVERT FLOATING POINT IF YOU WANT ACCURATE RESULTS!
In fact, I wouldn't trust it for anything much beyond 5 significant digits
with floats, 10 with doubles.
     
I've said it before and I guess it needs saying again:  numerical accuracy
is a *very* complicated subject.  There are people at Livermore who spend
100% of their time pursuing the problem.  One of the worst problems is
input/output conversion.  Here are a few of the things the posted routine
gets wrong:
     
    (1) [by far the worst] It makes no attempt to round.  Thus, the sequence
     
        x = 0.99999999999999; format ("{f.1}", x);
     
    will produce "0.9" as the output, fully 10% off from the
    correctly-rounded answer of "1.0".
    (2) By using division to recalculate "pnum" in the primary loop, errors
    are introduced with large exponents.  For example, 10**38 (the
    maximum range of IEEE floating point numbers) has, by definition,
    38 significant digits.  In binary, those translate to well over
    100 bits, way past the width of even a double on all but a Cray
    (which has a much larger floating range).  So the loops
     
        for (i = 0, x = 1.0;  i < 38;  i++, x *= 10.0) ; /* null body */
        while (--i >= 0) x /= 10.0;
     
    will not produce 1.0 in 'x'.
    (3) Possibly worse than (2) is the fact that, after the digit developed has
    been placed in the buffer, it is removed from the original number
    with subtraction, after having the non-identity transformation
    of (2) applied to it.  This may be acceptable (I'm not a numerical
    expert), since the subtraction takes place in the most-significant
    bits of the number being converted.  I just learned a long time
    ago that addition and subtraction are the source of the worst
    errors in floating point, and they should be avoided whenever
    possible.  It makes me very nervous to see subtraction in this loop.
     
So how does one write an accurate output-conversion routine?  Well, you
should start by asking somebody else;  it's not my field.  I think the
best routines might actually separate the mantissa and exponent.  One thing
I'd certainly do is get the powers of 10 out of a table, rather than
calculating them.  Not only is it much faster (and formatted output can
take a *lot* of a program's execution time) but it isn't susceptible
to accumulative errors.  (Oh, and by the way, you should work out any
table values by hand and initialize them in octal or hex.  It's worth a
big time investment to get accurate values there.  And you can't trust
a compiler writer to have accurate input-conversion routines;  compiler
people aren't usually numerical mathematicians either.)
     
    Geoff Kuenning
    {hplabs,ihnp4}!trwrb!desint!geoff
     
For those who care, the relevant code from the posted routine follows.

> X        case 'f':    if( pf_double < 0 )
> X                  then
> X                    {
> X                    buf[bufcnt++] = '-';
> X                    pf_double = -pf_double;
> X                    }
> X                ind = 0;
> X                for(pnum=1.0; pnum<=pf_double; pnum*=pf_base)
> X                    ind--;
> X                pnum /= pf_base;
> X                do  {
> X                    if( ind++ == 0 ) then buf[bufcnt++]='.';
> X                    c = (int)(pf_double/pnum);
> X                    buf[bufcnt++] = bintodig( c );
> X                    pf_double -= (pnum*c);
> X                    pnum /= pf_base;
> X                    } while( ind < pf_dec );
> X                cp = buf;
> X                break;
--
     
    Geoff Kuenning
    {hplabs,ihnp4}!trwrb!desint!geoff

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3386
          for JMS@ARIZMIS; Fri, 25-JUL-1986 16:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 12:58:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009716; 25 Jul 86 13:45 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a009845; 25 Jul 86 13:23 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA26808; Fri, 25 Jul 86 13:18:08 edt
Date: Fri, 25 Jul 86 13:18:08 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607251718.AA26808@icst-cmr.ARPA>
To: desint!geoff@seismo.css.gov, info-c@BRL-SMOKE.ARPA
Subject: Re: format (printf like routines)
     
> In article <125@sol.UUCP> chris@sol.UUCP (Christopher Caldwell) writes:
>
> > Here are the routines that I talked about in net.lang.c.
> >...
> > echo "Extracting format.c (13553 characters)."
> >...
>
> Sigh.  My soapbox is getting awfully rickety, and with every passing year
> it becomes more difficult for my feeble limbs to make the climb onto it.
> Nevertheless, I feel morally obligated to warn people:
>
> DONT USE THIS SOFTWARE TO CONVERT FLOATING POINT IF YOU WANT ACCURATE RESULTS!
> In fact, I wouldn't trust it for anything much beyond 5 significant digits
> with floats, 10 with doubles.
     
Thanks for the warning.
     
> I've said it before and I guess it needs saying again:  numerical accuracy
> is a *very* complicated subject.  There are people at Livermore who spend
> 100% of their time pursuing the problem.  One of the worst problems is
> input/output conversion.  Here are a few of the things the posted routine
> gets wrong:
>
>     (1) [by far the worst] It makes no attempt to round.  Thus, the sequence
>
>         x = 0.99999999999999; format ("{f.1}", x);
>
>     will produce "0.9" as the output, fully 10% off from the
>     correctly-rounded answer of "1.0".
     
Good advice. On the other hand, (1) you asked for the wrong thing (ask for
two digits instead of one), (2) you presented the worst possible case,
(3) even with rounding, the worst possible case (0.94999...) is off by
5%, so rounding merely cuts the error in half.
     
>     (2) By using division to recalculate "pnum" in the primary loop, errors
>     are introduced with large exponents.  For example, 10**38 (the
>     maximum range of IEEE floating point numbers) has, by definition,
>     38 significant digits.
     
I take issue with this. Significance is irrelevant of scale, unless I
don't know something about IEEE floating point. BTW, how many sigdigs
does 10**-38 have?
     
>    In binary, those translate to well over
>     100 bits, way past the width of even a double on all but a Cray
>     (which has a much larger floating range).  So the loops
>
>         for (i = 0, x = 1.0;  i < 38;  i++, x *= 10.0) ; /* null body */
>         while (--i >= 0) x /= 10.0;
>
>     will not produce 1.0 in 'x'.
>     (3) Possibly worse than (2) is the fact that, after the digit developed
>     has been placed in the buffer, it is removed from the original number
>     with subtraction, after having the non-identity transformation
>     of (2) applied to it.  This may be acceptable (I'm not a numerical
>     expert), since the subtraction takes place in the most-significant
>     bits of the number being converted.  I just learned a long time
>     ago that addition and subtraction are the source of the worst
>     errors in floating point, and they should be avoided whenever
>     possible.  It makes me very nervous to see subtraction in this loop.
     
I would say it depends on the comparative ranges. When exponents differ,
mantissas are shifted to make up for the difference. If they are closely
matched, it shouldn't be too bad, but it could accumulate.
     
> So how does one write an accurate output-conversion routine?  Well, you
> should start by asking somebody else;  it's not my field.  I think the
> best routines might actually separate the mantissa and exponent.  One thing
> I'd certainly do is get the powers of 10 out of a table, rather than
> calculating them.  Not only is it much faster (and formatted output can
> take a *lot* of a program's execution time) but it isn't susceptible
> to accumulative errors.  (Oh, and by the way, you should work out any
> table values by hand and initialize them in octal or hex.  It's worth a
> big time investment to get accurate values there.  And you can't trust
> a compiler writer to have accurate input-conversion routines;  compiler
> people aren't usually numerical mathematicians either.)
     
More good advice. On the powers of ten issue, I would tend to disagree.
Any integer that has less bits than the mantissa should be exactly
representable. Their inverses can be obtained at run time by division.
To hard code these in would be nonportable unless surrounded by #ifdefs.
     
>     Geoff Kuenning
>     {hplabs,ihnp4}!trwrb!desint!geoff
     
Not knowing the author, I am only speculating. I think he wrote this
package because of some perceived lack of functionality in printf,
and added the floating point as an afterthought. Perhaps he should
have warned us he was using truncation instaed of rounding.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
HELLO KITTY gang terrorizes town, family STICKERED to death!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8143
          for JMS@ARIZMIS; Fri, 25-JUL-1986 20:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016876; 25 Jul 86 22:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017317; 25 Jul 86 21:44 EDT
From: The Mad Hacker <jdptxt%adiron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <351@adiron.UUCP>
Date: 24 Jul 86 20:31:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The bug that is being discussed to death was in 4.1BSD as well.
Somebody else ran into this problem a few months after I started
programming professionally, and I gave him the solution to try
i = i * 0.5 instead of i *= 0.5.  I was told to never trust
mixed-mode Fortran arithmetic and the Pascal that I worked with
in college did not support float to integer conversions so I have
stayed away from these 'op=' in mixed-mode.  I always use them when
possible otherwise.
     
     
duke!adiron!jdp

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8437
          for JMS@ARIZMIS; Fri, 25-JUL-1986 21:08 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/25/86 at 23:04:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016999; 25 Jul 86 23:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017956; 25 Jul 86 23:42 EDT
From: Hugh Redelmeier <hugh%hcrvx1.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug (a mutant strain)
Message-ID: <1380@hcrvx1.UUCP>
Date: 24 Jul 86 15:34:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6224@allegra.UUCP> mp@allegra.UUCP (Mark Plotnick) writes:
>The i /= f and i *= f bugs occur in the 4.3bsd-beta and 4.2bsd
>compilers...  The 4.3bsd and System V VAX compilers do the right thing.
     
Well, not so fast.  Many System V compilers (I don't know about
4.3BSD -- we haven't gotten it yet!) have a bug in the fix to this
bug!  Try "*p++ /= f;" where p is "int *": the ++ gets done twice.
In fact, any side-effect on the left-hand-side would be done twice.
Allen McIntosh of HCR has fixed this (with some effort) as part of our
optimizer project (we produce a portable optimizer that fits into PCC
and f77).
     
Hugh Redelmeier (416) 922-1937
{utzoo, ihnp4, decvax}!hcr!hugh

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1433
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/26/86 at 03:36:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017797; 26 Jul 86 4:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019548; 26 Jul 86 3:40 EDT
From: Mark Purtill <purtill%petrus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Question on getopt()
Message-ID: <240@petrus.UUCP>
Date: 25 Jul 86 21:55:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1078@ttrdc.UUCP>, levy@ttrdc.UUCP (Daniel R. Levy) writes:
> In article <14935@ucbvax.BERKELEY.EDU>, kos@ernie.Berkeley.EDU (Joshua
 Kosman) writes:
> >Anybody know an easy way to intercept, suppress or otherwise get rid of the
> >error message that getopt() issues when user supplies an illegal flag?
...
>      GETOPT(3C)               UNIX System V            GETOPT(3C)
...
>       included in optstring.  This error message may be disabled
>                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>       by setting opterr to a non-zero value.
>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      ...
> Please, read the man page.
...
     
Not that the man page we have here (seems to be BSB 4.3) does not have the
sentence marked with ^^^^s for a very good reason:  its not true.  Under
4.3 you can't suppress the messages except by rewriting getopt. Why did
you(dan) assume someone from Berkeley was using sys V?
     
            mark purtill            (201) 829-5127
^.-.^ Arpa: purtill@bellcore.com    435 south st 2H-307
((")) Uucp: ihnp4!bellcore!purtill  morristown nj 07960

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1956
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/26/86 at 05:01:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017941; 26 Jul 86 5:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020666; 26 Jul 86 5:43 EDT
From: Arthur David Olson <ado%elsie.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Wanted:  information on compilability of "switch (long)"
Message-ID: <6190@elsie.UUCP>
Date: 25 Jul 86 21:35:24 GMT
Keywords: C switch long
To:       info-c@BRL-SMOKE.ARPA
     
Someone wrote me today about an
     
    illegal operand of "switch()"
     
message that was produced when compiling code of mine of this ilk:
     
    subr(l)
    long    l;
    {
        switch (l) {
            ...
        }
    }
     
I'd like to know how other compilers (and lints) react to switches on longs.
I already know what K&R, H&S, and the tentative conditional draft proposed
ANSI C standard have to say; I'm interested in learning what happens
in the real world.  The information will tell me whether it's wise to have
"lint" check for such code when lint is used in its "portability mode."  If you
have the information I'm after, please mail me a response.  Thanks.
--
Return is part of a LucasFilm trademark.
--
    UUCP: ..decvax!seismo!elsie!ado   ARPA: elsie!ado@seismo.ARPA
    DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2080
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/26/86 at 05:07:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017943; 26 Jul 86 5:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020691; 26 Jul 86 5:45 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Int and Char
Message-ID: <2617@umcp-cs.UUCP>
Date: 26 Jul 86 00:34:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3250@jhunix.UUCP> ecf_eprm@jhunix.UUCP (Paul R Markowitz) writes:
>Chars are NOT SIGNED, there is no char called -1.
     
Whether characters are signed or not is compiler-dependent.  X3J11
says so; and even K&R says so (p. 40).
     
>If you want a variable that takes on negative values, use a short.
     
Or, optionally, a typedef and/or a sign-extension macro:
     
    /*
     * types.h: system dependent types.
     *
     * Turn on the appropriate things for your system.
     */
     
    /* compiler error until installer adjusts this */
    THIS FILE WAS NOT SET UP FOR YOUR SYSTEM YET!
     
    /* a small integer, signed */
    /* typedef char smallint; */
    /* typedef short smallint; */
     
    /* take a number, treat as eight bits, and sign extend */
    /* #define Sign8(c) ((int)(char)(c)) */
     
    /* use this one on Suns to avoid a compiler bug with constants */
    /* this also works on 32 bit machines with sign extending `>>' */
    /* #define Sign8(c) (((c) << 24) >> 24) */
     
    /* #define Sign8(c) ((c) & 0x80 ? (c) - 0x100 : (c)) */
     
Finally, for X3J11 C:
     
    /* typedef signed char smallint; */
     
    /* #define Sign8(c) ((int)(signed char)(c)) */
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3120
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/26/86 at 09:24:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018738; 26 Jul 86 10:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022799; 26 Jul 86 9:41 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <3162@utcsri.UUCP>
Date: 25 Jul 86 16:12:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>> Please try this code on your flavor of C compiler...
>(followed by code demonstrating essentially
>>    i = i/2.5;
>vs.
>>    i /= 2.5;
>
>The answer is absolutely unequivocal on this point.  A compiler
>that does not treat i=i/float and i/=float identically is broken,
>although many compilers are so broken.  This question was
>discussed to death on the net a year or so ago...
     
Well, I am definitely adding "(int) op= (float) and related things
to my list of Things Not To Do If I Want To Make Life Easier.
This can be considered "defensive programming".
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9622
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/27/86 at 03:24:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022453; 27 Jul 86 4:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028115; 27 Jul 86 3:42 EDT
From: guy%sun.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Int and Char
Message-ID: <5529@sun.uucp>
Date: 26 Jul 86 22:15:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> For my next question, why doesn't my C compiler accept declarations
> like 'signed char a;' or something like that?
     
Because it's not an ANSI C compiler.  The ANSI X3J11 draft includes a
"signed char" specification, but AT&T hasn't put one into the 3B20 C
compiler yet (I suspect few, if any, other PCC-based compilers have, either).
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1223
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/27/86 at 09:00:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023269; 27 Jul 86 9:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000802; 27 Jul 86 9:40 EDT
From: Donn Seeley <donn%utah-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <3865@utah-cs.UUCP>
Date: 27 Jul 86 10:13:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The 'i /= f' bug is fixed in 4.3 BSD.  Someone (Hugh Redelmeier) stated
earlier that this bug was fixed in System V but some implementations
caused side effects in the left hand side to be duplicated.  This was
one of the problems that made the fix quite difficult for 4.3; the
solution was fairly ugly but it works.  Essentially what happens is
that the compiler front end notices the special situation and avoids
'type balancing'; special code table entries enable the code generator
to spot these trees and do the right thing.  (This approach is properly
termed 'hacking'.)  I wasn't able to test this bug on our local System V
boxen -- neither of them (SGI Iris, rev 3.4; HP-UX 5.0) have any form
of the '/=' fix...
     
The 4.3 compiler no longer generates an 'incompatible types' message
for void expressions in the ':' part of a '?' expression -- it prints
'value of void expression used'!
     
Will wonders never Cse,
     
Donn Seeley    University of Utah CS Dept    donn@utah-cs.arpa
40 46' 6"N 111 50' 34"W    (801) 581-5668    decvax!utah-cs!donn

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0274
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/27/86 at 05:37:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022692; 27 Jul 86 6:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029145; 27 Jul 86 5:44 EDT
From: Arthur David Olson <ado%elsie.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Compiler bug
Message-ID: <6191@elsie.UUCP>
Date: 26 Jul 86 22:58:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
For those with source code, here's an addition to "lint" to generate warnings
about
    float /= int
and
    int /= float
constructs.  This is an addition to the 4.1BSD version of "lint/lint.c",
in particular to the function "clocal"; your mileage will vary.
As always, the trade secret status of the code involved precludes a clearer
posting.  The addition is conditioned on "OLDVERSION".
     
    ...
    NODE *
    clocal(p) NODE *p; {
    ...
        switch( o = p->in.op ){
    #ifndef OLDVERSION
        case ASG MUL:
            if (pflag && p->in.right->in.op == SCONV)
                werror( "mixed-mode *= may surprise you");
            break;
        case ASG DIV:
            if (pflag && p->in.right->in.op == SCONV)
                werror( "mixed-mode /= may surprise you");
            break;
    #endif /* !OLDVERSION */
    ...
--
Lint is an Oscar Madison trademark.
--
    UUCP: ..decvax!seismo!elsie!ado   ARPA: elsie!ado@seismo.ARPA
    DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0217
          for JMS@ARIZMIS; Sun, 27-JUL-1986 13:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/27/86 at 05:35:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022690; 27 Jul 86 6:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029054; 27 Jul 86 5:40 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <475@dg_rtp.UUCP>
Date: 26 Jul 86 17:36:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> rbj%icst-cmr@smoke.UUCP ((Root Boy) Jim Cottrell)
>> throopw@dg_rtp.UUCP (Wayne Throop)
>>> davidsen@steinmetz.UUCP (Davidsen)
     
>>> [arguments for allowing (&array)]
>>> Reason 2: "modularity and information hiding"
>> [Still have problem, since current practice is type-anomalous]
> Hopefully, the first element is at the same address as the entire array.
     
Yes this is often true, and is necessary in C.  But only if you are
looking at "addresses" as typeless entities.  Which they are not, at
least not in C.
     
>>> Reason 3: "common sense"
>> [Agreed, but make sure that the type is (int (*)[]), not (int *)]
> If you think about it, a pointer to an int can be used (and is) as a pointer
> to an array of ints. Unless you apply ++ to it, they are the same thing.
> (I can already feel the flames approaching).
     
I assume Jim really means "unless you apply ++, --, [], *, +, -, +=, or
-=" (unless I'm overlooking one).  That is, unless you use it in
arithmetic, subscripting, or indirection.  Sort of covers what you can
do with a pointer, doesn't it?
     
Remember, a type is not just an interpretation of a pattern of bits.  It
also has to do with what operations are legal on those bits, and what
their effects are.  Thus, just because a pointer to the first int in an
array has the same bit pattern as a pointer to the whole array does NOT
indicate that they are "the same thing", any more than the fact that an
integer zero and a floating point zero often have the same bit pattern
indicates that these are "the same thing".
     
--
C types require, when pointers pair,
Conversions which are never there.
They aren't there again today,
Please, Dennis, make them go away.
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4390
          for JMS@ARIZMIS; Sun, 27-JUL-1986 21:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/27/86 at 23:30:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025599; 28 Jul 86 0:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005389; 27 Jul 86 23:40 EDT
From: Bill Crews <bc%cyb-eng.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <938@cyb-eng.UUCP>
Date: 28 Jul 86 01:42:35 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     Since I have just seen a couple of recommendations for the MS C compiler
> and having never used it I would like to know how good is its large model.
> Does it produce faster code than Lattice? Speed and correctness are my major
> concern.
>
>  Peter Ashwood-Smith
     
You'd better be more explicit about the memory model you are interested in;
Lattice large is Microsoft huge model.  Best to describe what size (and
format) of data and code pointers you want.
--
bc                Bill Crews @ NetCor Data International
     
..!{seismo,gatech,ihnp4}!ut-sally!cyb-eng!bc  (512) 835-2937

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6159
          for JMS@ARIZMIS; Mon, 28-JUL-1986 02:59 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/28/86 at 04:56:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026235; 28 Jul 86 5:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007262; 28 Jul 86 5:41 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <3183@utcsri.UUCP>
Date: 27 Jul 86 08:48:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5858@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes:
>> So, does anyone have a fix for this bug?
>> I'll trade for a fix for a problem with void functions and the ?: operator.
>>
>> void f3(which)
>> {
>>     extern void f1(),f2();
>>     which?f1():f2();
>> }
>> cc(1) gives an "incompatible types" error.
>
>As it should.  The only thing you're allowed to do with void values
>is throw them away.
     
But it is being thrown away. In e1?e2:e3, the contexts of e2 and e3 are
inherited from the context of the ?: operator itself. In this case,
that is in a 'for effect' or void context, so f1() and f2() should be
treated as 'thrown away' too.
     
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6263
          for JMS@ARIZMIS; Mon, 28-JUL-1986 03:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/28/86 at 05:10:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026252; 28 Jul 86 6:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007335; 28 Jul 86 5:43 EDT
From: Jack Rouse <jjr%sas.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: typedef bug summary
Message-ID: <131@sas.UUCP>
Date: 27 Jul 86 20:22:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The problem described by Tom Stockfisch, where a typedef identifier cannot be
reused as a variable identifier in a nested scope is common to many C compilers
which use a formal grammar for parsing.  In order to handle ambiguities in the
C grammar, it is necessary for these compilers to regard typedef names and
normal identifiers as different lexical types.  Consider the following code:
    int i, bar;
    ...
    i = (foo)&bar;
If foo is an int variable, the last statement performs a bitwise and of foo and
bar.  If foo is a typedef name (as in "typedef int foo;"), however, then the
last statement takes the address of bar and casts it to type foo.
     
To resolve this ambiguity, PCC derived compilers pass information back from the
parser to the lexical scanner when a typedef name is created so that it will
not be treated as a regular identifier.  What PCC has neglected to do, however,
is provide a means to redeclare the name in a inner scope.
--
--
Jack Rouse, SAS Institute Inc., Box 8000, Cary, NC 27511  USA
USENET:  mcnc!rti-sel!sas!jjr          TELCO :  (919) 467-8000

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6320
          for JMS@ARIZMIS; Mon, 28-JUL-1986 03:24 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/28/86 at 05:22:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026306; 28 Jul 86 6:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007270; 28 Jul 86 5:41 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: '=' vs '<-' vs '.ne' vs '==' vs ':=' vs '.eq.' vs ...
Message-ID: <482@hadron.UUCP>
Date: 19 Jul 86 04:09:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5282@topaz.RUTGERS.EDU> gaynor@topaz.RUTGERS.EDU (Silver) writes:
>By the way, do(es) any language(~s) implement these choices?
Yes.
     
>ASSIGNMENT  <-
PPL, ECL, some ASCII-ised APL's, several other languages.
     
>EQUALITY  =
Most ALGOLische languages.  BASIC.  Likely, others.
     
>INEQUALITY  <>
BASIC.  At least one other.
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6533
          for JMS@ARIZMIS; Mon, 28-JUL-1986 03:41 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/28/86 at 05:37:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026392; 28 Jul 86 6:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007322; 28 Jul 86 5:42 EDT
From: der Mouse <mouse%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Another printf-type question
Message-ID: <463@mcgill-vision.UUCP>
Date: 22 Jul 86 02:27:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>> invprintf(fmt,args)
>> {
>>         printf(<string to go into inverse video mode>);
>>         printf(fmt,args);
>>         printf(<string to leave inverse mode>);
>> }
> Assuming you're using UNIX System V Release 2.0 for sake of concreteness,
> [...solution involving....
>     (void)vprintf( fmt, args );    /* warning! not printf(va_arg etc. */
> ]
     
Sounds to me more like assuming SVR2 for the sake of  possibility.  Many
Unices  do not have  vprintf(), much though AT&T may wish it  otherwise.
Absent some indication of  what flavor  of UNIX the  solution is desired
for, an "answer"  using  vprintf() not much of an answer.  I doubt  that
the original poster is prepared to change operating systems just  to get
a portable version of invprintf().
     
By the way, when I need something like this I write it as follows:
     
/* VARARGS 1 */
invprintf(fmt,a1,a2,a3,a4,a5,a6,a7,a8)
char *fmt;
int a1;
int a2;
int a3;
int a4;
int a5;
int a6;
int a7;
int a8;
{
 printf(<inverse-video-string>);
 printf(fmt,a1,a2,a3,a4,a5,a6,a7,a8);
 printf(<exit-inverse-video-string>);
}
     
Anyone out there care to enlighten me as to  all the ways  in which this
can fail (besides wanting to print more than eight arguments)?  It works
on enough  machines that I  don't feel *too* guilty using it.   I  would
guess that  it works on  substantially more  machines than the vprintf()
solution.
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     philabs!micomvax!musocs!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
        mcvax!seismo!cmcl2!philabs!micomvax!musocs!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7309
          for JMS@ARIZMIS; Mon, 28-JUL-1986 05:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/28/86 at 07:51:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa28445; 28 Jul 86 8:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008507; 28 Jul 86 7:40 EDT
From: Roy Smith <roy%phri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: RTFM vs RTFSC (Read The Friggin' Source Code)
Message-ID: <2402@phri.UUCP>
Date: 27 Jul 86 17:12:33 GMT
Original-Subject: Re: Question on getopt()
To:       info-c@BRL-SMOKE.ARPA
     
In article <5530@sun.uucp> guy@sun.UUCP writes:
[Regarding the 4.3 *and* Sys5 getopt(3) man pages being wrong]
> Read the code, not the manual page!
     
    That this should have to be the case is perhaps the strongest
reason why I wouldn't consider buying a system without source (when we
recently had to decide between Sun and Sequent, Sequent lost largely
because they wouldn't release source for a reasonable price).  This is also
on of the strongest reasons why I don't think Unix is really going to make
it as a commercial system (the current rash of commercial ports of Unix
notwithstanding).
--
Roy Smith, {allegra,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0280
          for JMS@ARIZMIS; Mon, 28-JUL-1986 11:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002560; 28 Jul 86 11:13 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a015941; 28 Jul 86 11:00 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA09554; Mon, 28 Jul 86 10:57:50 edt
Date: Mon, 28 Jul 86 10:57:50 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607281457.AA09554@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, phri!roy@seismo.css.gov
Subject: Re:  RTFM vs RTFSC (Read The Friggin' Source Code)
     
        That this should have to be the case is perhaps the
    strongest reason why I wouldn't consider buying a
    system without source (when we recently had to decide between
    Sun and Sequent, Sequent lost largely because they wouldn't
    release source for a reasonable price).
     
So what does SUN charge for their source? What was Sequent asking?
     
    This is also on of the
    strongest reasons why I don't think Unix is really going to
    make it as a commercial system (the current rash of commercial
    ports of Unix notwithstanding).
     
I don't know about this. Other commercial OS's seem to survive on
not releasing source with a lot less functionality.
     
    --
    Roy Smith, {allegra,philabs}!phri!roy
    System Administrator, Public Health Research Institute
    455 First Avenue, New York, NY 10016
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    Yow!  Are you the self-frying president?
     
Gee, is that what they mean by Teflon Man?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0336
          for JMS@ARIZMIS; Mon, 28-JUL-1986 11:27 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003095; 28 Jul 86 11:27 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a016092; 28 Jul 86 11:04 EDT
Received: from logicon.arpa by AOS.BRL.ARPA id a002142; 28 Jul 86 11:00 EDT
Date: 28 Jul 86 07:56 PDT
From: Bill D'Camp <bill@LOGICON.ARPA>
To: info-c@BRL.ARPA
Subject: RE: C compiler bug
     
     
After reading the note which included a quoted message from dmr, and
noting the vintage of the previous discussion, I went looking through
the 4.2 buglist and found a fix.  The fix was posted back in Jan 84,
and reportedly applies to any PCC based compiler.  (4.xBSD, SYS III,).
The fix came from Ed Hall at randvax.arpa
     
Here is the fix.
     
Relay-Version: version B 2.10.1 6/24/83; site randvax.ARPA
Posting-Version: version B 2.10.1 6/24/83; site randvax.ARPA
Path: randvax!edhall
From: edhall@randvax.ARPA (Ed Hall)
Newsgroups: net.bugs.4bsd,net.bugs.usg
Subject: integer op= floating evaluated incorrectly by C compiler
Message-ID: <1625@randvax.ARPA>
Date: Wed, 11-Jan-84 00:13:26 PST
Article-I.D.: randvax.1625
Posted: Wed Jan 11 00:13:26 1984
Date-Received: Wed, 11-Jan-84 00:13:26 PST
Organization: Rand Corp., Santa Monica
Lines: 67
     
Index:  usr.lib/ccom 4.2BSD 4.1BSD 3.0USG
     
Description:
    When assignement operators such as *= are used with an integer
    Left-Hand Side and a floating-point expression on the Right-
    Hand Side, results are incorrect.  For example:
     
        int i = 6;
        i *= .5;
     
    leaves a value of 0 in i, rather than 3.  The +=, -=, and /=
    operators are similarly affected.
     
    This bug may affect all pre-5.0USG C compilers, and perhaps earlier
    5.0USG compilers as well.  The below fix only works for PCC-derived
    compilers (such as the BSD VAX C compiler).
     
Repeat-By:
    Conversion of RHS of assignment to type of LHS before application
    of the operator.
     
Fix:
    The fix is in two parts.  First, the automatic forcing of type
    conversion to the LHS of an assignment op must be shut off in
    appropriate circumstances.  This requires a change to tymatch()
    in mip/trees.c:
     
1031c1031,1035
<     if( t != t2 || o==CAST ) p->in.right = makety( p->in.right, tu, 0,
(int)tu );
---
>     if( o==CAST || (t != t2
>       && ( (dope[o]&(FLOFLG|ASGOPFLG)) != (FLOFLG|ASGOPFLG)
>       || t != INT || (t2 != DOUBLE && t2 != FLOAT) )) ) {
>         p->in.right = makety( p->in.right, tu, 0, (int)tu );
>         }
     
    This causes certain assignment ops (+=, -=, *=, /=, i.e. the ones
    appropriate in floating-point) to remain in the parse tree without
    `balanced' operand types.  When these get to code-generation the
    compiler would break unless the template table had the proper pieces
    added to it.  Thus, in pcc/table.c:
     
712a713,729
>
> /* begin new stuff */
>
> ASG OPFLOAT,    INAREG|FOREFF|FORCC,
>       SAREG|AWD,      TWORD|TCHAR|TSHORT,
>       SAREG|AWD,      TDOUBLE,
>               NAREG,  RLEFT|RESCC,
>               "       cvtZLd  AL,A1\n OD2     AR,A1\n cvtdZL  A1,AL\n",
>
> ASG OPFLOAT,    INAREG|FOREFF|FORCC,
>       SAREG|AWD,      TWORD|TCHAR|TSHORT,
>       SAREG|AWD,      TFLOAT,
>               NAREG,  RLEFT|RESCC,
>               "       cvtZLf  AL,A1\n OF2     AR,A1\n cvtfZL  A1,AL\n",
>
> /* end new stuff */
>
     
    -Ed Hall
    Rand Corporation
    Santa Monica, CA
    decvax!randvax!edhall   (UUCP)
    edhall@rand-unix        (ARPA)
     
     
Hope this helps those who (like me) who hadn't seen this before.
I applied this fix last week and it works nicely.
     
            Bill D'Camp
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0219
          for JMS@ARIZMIS; Mon, 28-JUL-1986 11:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/28/86 at 12:05:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001395; 28 Jul 86 10:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012961; 28 Jul 86 9:40 EDT
From: Steve Summit <stevesu%copper.uucp@BRL.ARPA>
Newsgroups: net.bugs.2bsd,net.lang.c
Subject: Fix to Ritchie's pdp11 compiler to allow "short int"
Message-ID: <505@copper.UUCP>
Date: 27 Jul 86 21:54:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
My only problem in writing code that's portable back to the pdp11
is that I like to declare things as "short int" and the pdp11
compilers that I have access to want just "short."  I finally got
around to doing something about it.  This may well be fixed in
more modern versions of Ritchie's compiler, (including 2.9 or
2.10; I haven't checked), but the fix is so simple it can't hurt
to post it.
     
The problem is that the compiler turns the keyword "short" into
the internal token INT at lexical analysis time.  "short int"
therefore looks like "int int", an obvious type clash.  The
solution is to tokenize "short" as SHORT so that the case can be
detected.  This new "type" SHORT is just a placeholder; after
type analysis it is turned back into an INT, since that's what
the rest of the compiler expects.
     
The changes affect three files: the #definition of the type token
SHORT in c0.h, the keyword table in c00.c, and the type analysis
in c03.c.  Context diffs follow.
     
                                         Steve Summit
                                         tektronix!copper!stevesu
     
*** /tmp/,RCSt1022392    Sun Jul 27 14:31:50 1986
--- c0.h    Sun Jul 27 14:28:48 1986
***************
*** 320,323
  #define    DOUBLE    3
  #define    STRUCT    4
  #define    LONG    6
  #define    UNSIGN    7
     
--- 320,324 -----
  #define    DOUBLE    3
  #define    STRUCT    4
+ #define    SHORT    5        /* adjusted later to int */
  #define    LONG    6
  #define    UNSIGN    7
     
*** /tmp/,RCSt1022392    Sun Jul 27 14:32:01 1986
--- c00.c    Sun Jul 27 13:45:13 1986
***************
*** 30,34
      "unsigned",    UNSIGN,
      "union",    UNION,
!     "short",    INT,
      "auto",        AUTO,
      "extern",    EXTERN,
     
--- 30,34 -----
      "unsigned",    UNSIGN,
      "union",    UNION,
!     "short",    SHORT,
      "auto",        AUTO,
      "extern",    EXTERN,
     
*** /tmp/,RCSt1022392    Sun Jul 27 14:31:55 1986
--- c03.c    Sun Jul 27 13:50:21 1986
***************
*** 94,99
          case STRUCT:
              tptr->hstrp = strdec(ismos, cval);
              cval = STRUCT;
          case INT:
          case CHAR:
          case FLOAT:
     
--- 94,102 -----
          case STRUCT:
              tptr->hstrp = strdec(ismos, cval);
              cval = STRUCT;
+         case SHORT:
+             if(tkw == INT)
+                 break;        /* ignore "short" in "int short" */
          case INT:
          case CHAR:
          case FLOAT:
***************
*** 99,105
          case FLOAT:
          case DOUBLE:
          types:
!             if (tkw>=0)
                  error("Type clash");
              tkw = cval;
              break;
     
--- 102,108 -----
          case FLOAT:
          case DOUBLE:
          types:
!             if (tkw>=0 && (tkw != SHORT || cval != INT))
                  error("Type clash");
              tkw = cval;
              break;
***************
*** 108,114
              peeksym = o;
              if (isadecl==0)
                  return(0);
!             if (tkw<0)
                  tkw = INT;
              if (skw==0)
                  skw = blklev==0? DEFXTRN: AUTO;
     
--- 111,117 -----
              peeksym = o;
              if (isadecl==0)
                  return(0);
!             if (tkw<0 || tkw==SHORT) /* bug: allows "long short" */
                  tkw = INT;
              if (skw==0)
                  skw = blklev==0? DEFXTRN: AUTO;

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0697
          for JMS@ARIZMIS; Mon, 28-JUL-1986 12:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/28/86 at 12:35:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005709; 28 Jul 86 13:19 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a019426; 28 Jul 86 13:05 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA09807; Mon, 28 Jul 86 13:02:51 edt
Date: Mon, 28 Jul 86 13:02:51 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607281702.AA09807@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, throop%dg_rtp.uucp@BRL.ARPA
Subject: Re: Pointers and Arrays
     
> >>> Reason 3: "common sense"
> >> [Agreed, but make sure that the type is (int (*)[]), not (int *)]
> > If you think about it, a pointer to an int can be used (and is) as a pointer
> > to an array of ints. Unless you apply ++ to it, they are the same thing.
> > (I can already feel the flames approaching).
>
> I assume Jim really means "unless you apply ++, --, [], *, +, -, +=, or
> -=" (unless I'm overlooking one).  That is, unless you use it in
> arithmetic, subscripting, or indirection.  Sort of covers what you can
> do with a pointer, doesn't it?
>
> Remember, a type is not just an interpretation of a pattern of bits.  It
> also has to do with what operations are legal on those bits, and what
> their effects are.  Thus, just because a pointer to the first int in an
> array has the same bit pattern as a pointer to the whole array does NOT
> indicate that they are "the same thing", any more than the fact that an
> integer zero and a floating point zero often have the same bit pattern
> indicates that these are "the same thing".
     
Um, I thought I had seen a case where `char *j' was equivalent to
`char (*j)[]', the latter I take to mean `pointer to array of char'.
Perhaps it was used on function arguments, perhaps on globals. Anyway, I
have not been able to duplicate it so I will have to reluctantly agree.
     
It seems somewhat conterintuitive, however, because a pointer to char
it almost always used as a pointer to an array, hence the feeling
that the two are equivalent.
     
I am able to figure out the difference, but mostly just fly by the
seat of my pants. I don't find declarations all that interesting;
neither do I find them mystifying, as I have seen most of the
useful ones by now.
     
> C types require, when pointers pair,
> Conversions which are never there.
> They aren't there again today,
> Please, Dennis, make them go away.
> --
> Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    YOW!! I'm in a very clever and adorable INSANE ASYLUM!!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5794
          for JMS@ARIZMIS; Tue, 29-JUL-1986 01:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 03:09:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013055; 29 Jul 86 4:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024572; 29 Jul 86 3:42 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <461@watmath.UUCP>
Date: 28 Jul 86 16:10:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > void f3(which)
> > {
> >     extern void f1(),f2();
> >     which?f1():f2();
> > }
> > cc(1) gives an "incompatible types" error.
>
> As it should.  The only thing you're allowed to do with void values
> is throw them away.
     
If I'm not throwing them away, what is it you think I'm doing with them?
     
Also, the proposed ANSI draft explicitly states that the second and third
operands of ?: may each have (void) type, so I'm not trying anything
unusual here.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9897
          for JMS@ARIZMIS; Tue, 29-JUL-1986 10:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 12:15:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023040; 29 Jul 86 11:05 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a005323; 29 Jul 86 10:49 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA12738; Tue, 29 Jul 86 10:46:52 edt
Date: Tue, 29 Jul 86 10:46:52 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607291446.AA12738@icst-cmr.ARPA>
To: info-c@BRL-SMOKE.ARPA, wjvax!brett@ICST-CMR.ARPA
Subject: Re:  varargs fails on typedefs
     
    This makes the typedef completely useless.
     
Only for varargs use. You can always have *two* typedefs, one for
definitions, and one for argument declarations. I know, yuk!
     
    To fix this problem, I propose a promote() operator, as follows:
     
Clearly, as you say, there is no way to emulate this. On the other hand,
this is done so rarely as to be tolerated the way it is. Do you really
want to muck up the language with rarely used constructs?
     
As a side issue, routines requiring varargs are frowned on anyway.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
On the road, ZIPPY is a pinhead without a purpose, but never without a POINT.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9852
          for JMS@ARIZMIS; Tue, 29-JUL-1986 10:55 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 12:11:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022051; 29 Jul 86 10:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002570; 29 Jul 86 9:41 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: varargs fails on typedefs
Message-ID: <733@wjvax.wjvax.UUCP>
Date: 28 Jul 86 22:54:41 GMT
Keywords: unix
To:       info-c@BRL-SMOKE.ARPA
     
I have a complaint about the a shortcoming of the standard varargs
package (to allow use of variable nos. of arguments).  The varargs package
uses a line of the form
     
    var = va_arg(va,<type>)
     
to grab the next (variable) argument, where va is the variable argument
pointer maintained by the varargs package, and <type> is the type of the
next argument.
     
The problem is related to C's argument promotion; namely, that it promotes
char and short arguments to int's and float to double.  Because the varargs
package is a macro package, an expression of the form
     
    var = va_arg(va,short)
     
fails, because, even if the caller tried to pass a short, it got converted
to an int, and the va_arg macro will fail because it will not pick up all
the bits of the int (assuming (sizeof(short) < sizeof(int))).  So far, this
is not deadly; you just remember never to have variable arguments that
are "promotable"; i.e., always use int's or double's.
     
The problem appears when you use a typedef.  Depending on whether the
typedef was promotable or not, a variable argument of the type will or
will not fail.  For example, I may do the following:
     
    typedef    int    NUMBER;
    ...
    NUMBER    val;
    ...
    foo(val);
    ...
    foo(va_alist)
    va_dcl
    ...
    NUMBER    value;
    ...
    value = va_arg(va,NUMBER);
     
the latter part of this fragment is a function foo() with a variable
argument of type NUMBER.  If, in fact, NUMBER was an int, this will work.
If NUMBER was a short, it will fail.  This makes the typedef completely
useless.
     
To fix this problem, I propose a promote() operator, as follows:
     
    "promote(char)" => "int"
    "promote(short)" => "int"
    "promote(int)" => "int"
    "promote(float)" => "double"
    "promote(NUMBER)" => <whatever NUMBER typedef'd as>
    etc.
     
An operator like this is REQUIRED to write a varargs package that works
with typedef'd types.  Note that there is NO way to emulate promote() with
a macro.
     
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0794
          for JMS@ARIZMIS; Tue, 29-JUL-1986 11:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 13:38:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029591; 29 Jul 86 14:26 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a011622; 29 Jul 86 13:43 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a027751; 29 Jul 86 13:33 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA13024; Tue, 29 Jul 86 13:29:28 edt
Date: Tue, 29 Jul 86 13:29:28 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8607291729.AA13024@icst-cmr.ARPA>
To: UNIX-WIZARDS@BRL.ARPA
Subject: Pointerwocky
Cc: info-c@BRL.ARPA
     
> Subject: Re: (Really addressing inside struct)Re: get size of malloc'd object
> In article <403@anasazi.UUCP> john@anasazi.UUCP (John Moore) writes:
> >We have a structure with a number of structures contained within it.
> >Because of linked list processing, we have a pointer to one of the
> >structures within, and we want to derive a pointer to the top of
> >the structure without LINT complaining, and in a truly portable way.
> >struct links {
> >   struct links *forward;
> >   struct links *backward;
> >};
> >struct foo {
> >   char bar;
> >   struct links snake;
> >   struct whocares junk;
> >   struct links lizard;
> >};
>     Assume struct foo ssssss;
> >struct links *reptile = &ssssss.lizard;
> >struct foo *iwish = (mystery function of reptile);
> >Example of a wrong solution:
> >struct foo *iwish = (struct foo *)((char *)reptile + (char *)0->lizard);
>
> You can't add pointers.
     
I don't see why not. The example given would be correct if it were:
     
typedef struct foo FOO,*FOOP;
typedef char *CP;
     
FOOP iwish = (FOOP) (((CP) &reptile) + ((int) (&((FOOP) 0)->lizard)))
     
I now present <struct.h> from 4.2 BSD:
     
/*    struct.h    4.1    83/05/03    */
     
/*
 * access to information relating to the fields of a structure
 */
     
#define    fldoff(str, fld)    ((int)&(((struct str *)0)->fld))
#define    fldsiz(str, fld)    (sizeof(((struct str *)0)->fld))
#define    strbase(str, ptr, fld)    ((struct str *)((char *)(ptr)-fldoff(str,
 fld)))
     
Whereupon your mystery function becomes: `strbase(foo,reptile,lizard)'
     
> There really isn't a very good and portable solution in C.
     
There you go using the `P' word again. My solution is portable to
reasonable machines. Allright, use long instead of int if you must.
     
> Given your constraints, the best is to replace "+ (char *)0->lizard" with:
> "- ((int)(((char *)&ssssss.lizard) - ((char *)&ssssss)))"; and even
> this is not guaranteed.  What you need to do is expand your mental
> model somewhat.  Assuming that links are always inside foos (to
> get out of the necessity of using unions):
>
> struct links {
>     struct foo *forward;
>     struct foo *backward;
> };
>
> Replace mystery-function with identity.
> Replace ->forward with ->forward->lizard or ->forward->snake, as
> appropriate.  You may find yourself realizing a better yet way to
> express yourself, and say what you mean (instead of what you thought
> you wanted to cleverly express).
     
Sound advice. However, it is nice to have a generic link structure,
and a generic insque/remque (casting the result pointers where
appropriate) but you must have all your link fields at the
beginning of the structure, or go thru this malarkey.
     
Anyone for structures with negative offsets?
     
>     Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
>             jsdy@hadron.COM (not yet domainised)
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    I just remembered something about a TOAD!

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3792
          for JMS@ARIZMIS; Tue, 29-JUL-1986 17:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 19:27:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003908; 29 Jul 86 18:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019097; 29 Jul 86 17:41 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <5872@alice.uUCp>
Date: 29 Jul 86 14:22:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> If I'm not throwing them away, what is it you think I'm doing with them?
     
> Also, the proposed ANSI draft explicitly states that the second and third
> operands of ?: may each have (void) type, so I'm not trying anything
> unusual here.
     
I think you're using them to form another value.  It is irrelevant
that you're then throwing that value away.  Suppose f() is void
and you say:
     
    f()+1;
     
Now you're adding 1 to a void and throwing the result away.  Should that
be permitted?
     
More seriously, I can actually see both sides of the argument.  But the
construction ...?f():g()  where f() and g() are void is close enough
to the edge that I wouldn't want to use it in any context where I might
ultimately want to run it on a lot of compilers.  Why not just say
     
    if (...) f(); else g();
     
??

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3750
          for JMS@ARIZMIS; Tue, 29-JUL-1986 17:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 19:26:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003904; 29 Jul 86 18:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019082; 29 Jul 86 17:41 EDT
From: tan%cae780.uucp@BRL.ARPA
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <2473@cae780.UUCP>
Date: 29 Jul 86 01:26:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3130@utcsri.UUCP>, greg@utcsri.UUCP (Gregory Smith) writes:
>
> Challenge: given
>
> var    x: array [1..1000] of integer;
>
> write a code fragment to find the location of the first 0 in x. The
> condition that no zeroes exist must be distinguished.
>
> Further rules:
>     - Standard Jensen & Wirth Pascal ( no break from loop )
>     - *** x[i] must not be evaluated for i<1 or i>1000 ***
>     - The search loop must be terminated as soon as a zero is found.
>
> This is the best I can find:
>     var i: integer;
>     ...
>     i :=1 ;
>     while i<1000 and x[i] <> 0 do
>         i := i+1;
>     if x[i] = 0 then writeln('zero at location', i )
>     else writeln('not found');
>
> weird,huh? Note that the condition 'x[i]=0' is evaluated twice ( once
> in the negative sense ), which would be unacceptable if we were searching
> an array of records and the test was expensive.
>
> Nobody can call this a special case... and I don't think my rules are
> unreasonable. The problem is the behaviour of 'and' plus the lack of 'break'.
>
> --
> "You'll need more than a Tylenol if you don't tell me where my father is!"
>                         - The Ice Pirates
> ----------------------------------------------------------------------
> Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
     
     
     
  I don't like your challenge.  If breaking out of a loop can't be considered
as a language feature for Pascal (although it is an extension to the original
Pascal language construct, it is more than common in these days),  we can't
consider the 'enum' construct as a legal feature for C, and anyone who come
up with a 'challenge' that needs the service of this 'enum' monster would
have thrash C.  I suggest that broader view be taken into account when one
tries to 'compare' a programming with the other.
     
  The fully evaluation of conditional expression in Pascal may cause some
problem to some people, but they are not hard to get around.  The argued
'x[i] = 0 got executed twice == expensive' does not hold, since one
such comparison is peanut compared to, say, 100 such operations.  For the
case of 'extremely complicated' data structure, PLEASE use a flag.
     
  I have done some 'medium' programs using both languages.  I don't have
any pro or con on both of them.  I like and hate Pascal that it 'force'
me into a rigid track in programming.  I hate it because it takes me
shorter time to complete my programs, even worse, it is so readable that
anyone can take over my job at anytime !
     
  I love and hate C also.  She gives me the luxury to fool around with
whatever possible.  I love her 'cause  I know I have a safe job.  No,
I don't love C that much, once it took me weeks to found out that I
'accidentally' lost one of my mantissa bit in one of my crazy functions
in the 'greatest' program I have ever written (neat eh?).  Oh ya, you
definately can full Pascal by using variant record, but it is more fun
doing it in C.
     
  The beauties of both miss C and Mr Pascal have been globally ad.
Sorry for not including these ad's in this article for I am not an
ad. agent.
     
     
     
     
   ----------------------------------------------------
   -                                                  -
   -  I speak for myself only.                        -
   -                                                  -
   ----------------------------------------------------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3920
          for JMS@ARIZMIS; Tue, 29-JUL-1986 17:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 19:41:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003910; 29 Jul 86 18:34 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a019636; 29 Jul 86 18:08 EDT
Date:     Tue, 29 Jul 86 18:00:01 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  varargs fails on typedefs
Message-ID:  <8607291800.aa08042@VGR.BRL.ARPA>
     
This is the second such suggestion in recent weeks.
I think we should be careful to distinguish between what the
application code/programmer sees for an interface and
what the C runtime implementer needs for his implementation.
     
<varargs.h> can be used safely if the programmer specifies
the correct (possibly widened) type and if he restricts himself
to the simpler data types.  X3J11 has designed <stdarg.h> to
replace <varargs.h>, but there is still room for debate about
the current design.
     
Statements such as "<varargs.h> cannot be implemented without
a promote() or alignof() operator" are simply false.  The
existence of such operators would not even be sufficient for some
architectures.  Rather than specify such fine-grained details
of use only for implementing varargs, X3J11 is leaving it up
to the implementor how he pulls this trick, and is specifying
only the application code/programmer visible interface.  If
this interface is properly designed, it will be implementable
"somehow" on every significant architecture (although perhaps
not purely in C).

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4718
          for JMS@ARIZMIS; Tue, 29-JUL-1986 19:17 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 21:07:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000528; 29 Jul 86 21:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001126; 29 Jul 86 21:41 EDT
From: Naoto Kimura <cc@pegasus.locus.ucla.edu.edu>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Pascal vs C, again (was: Pascals Origins)
Message-ID: <175@curly.ucla-cs.ARPA>
Date: 26 Jul 86 06:54:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3130@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes:
>
>Challenge: given
>
>var    x: array [1..1000] of integer;
>
>write a code fragment to find the location of the first 0 in x. The
>condition that no zeroes exist must be distinguished.
>
>Further rules:
>    - Standard Jensen & Wirth Pascal ( no break from loop )
>    - *** x[i] must not be evaluated for i<1 or i>1000 ***
>    - The search loop must be terminated as soon as a zero is found.
>    - 'a or b', 'a and b' always evaluate both a and b ( I think
>       this is a rule in Jensen & Wirth )
>
>This is the best I can find:
>    var i: integer;
>    ...
>    i :=1 ;
>    while i<1000 and x[i] <> 0 do
>        i := i+1;
>    if x[i] = 0 then writeln('zero at location', i )
>    else writeln('not found');
>
>weird,huh? Note that the condition 'x[i]=0' is evaluated twice ( once
>in the negative sense ), which would be unacceptable if we were searching
>an array of records and the test was expensive.
>
     
to avoid the evaluation of  ``x[i]=0'' you can do the following:
     
    var
       i: integer;
       f: boolean;
    ...
    i := 0;
    repeat
       i := i + 1;
       f := x[i]=0;
    until f or i=1000
    if f then
       writeln('zero at location', i )
    else
       writeln('not found');
     
   The only thing that really looks weird in the above is the ``i := 0'',
which can cause trouble if ``i'' was to be defined as the subrange
1..1000 .
     
     
*********************************************************************
*** you've probably already heard the following at least a millon ***
*** times                                                         ***
*********************************************************************
     
    A difficult thing to write in Pascal is an interactive program.
Checking eof and eoln before reading anything can cause some problems,
since they are undefined.  Performing a read or readln before checking
the status of eoln or eof can be a problem if you use an empty file.
Either the read would fail since there isn't anything to read, or the
read or readln will set the eoln and eof, but will return some bogus
value in the variable.  These problems get to be pretty bad, since
different compiler handle eoln and eof differently.
     
Let's say we have the following:
     
    var
       i : integer;
    ...
    while not eof do
       begin
          writeln ('enter an integer : ');
          readln (i);
       end;
     
The prompt never appears until something is entered, since these
conditions cannot be checked before an attempt to read is made.
To solve this problem we might do the following:
     
    var
       i : integer;
    ...
    writeln ('enter an integer : ');
    while not eof do
       begin
          readln (i);
          writeln ('enter an integer : ');
       end;
     
   This solves the problem of getting no prompt before entering data,
but creates the problem of one extra prompt at the end.
     
   But then, you can't really complain about these problems because
Pascal wasn't designed to be used for interactive programming anyway.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4816
          for JMS@ARIZMIS; Tue, 29-JUL-1986 19:22 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 21:16:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000624; 29 Jul 86 22:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001209; 29 Jul 86 21:43 EDT
From: Charles Hedrick <root@topaz.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Interactive I/O in Pascal
Message-ID: <5458@topaz.RUTGERS.EDU>
Date: 30 Jul 86 00:06:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
You are right that I have heard the complaint about interactive I/O a
number of times in the past.  However it has appeared much less often
recently, since the various implementations seem to be converging on
the use of "lazy I/O".  Most implementors seem to believe that the ISO
standard implies that this is the correct way to handle interactive
I/O.  You complain that the following program will print an extra
prompt.
     
    writeln ('enter an integer : ');
    while not eof do
       begin
          readln (i);
          writeln ('enter an integer : ');
       end;
     
As I see it, you will have roughly the following dialog:
     
  enter an integer: 123
  enter an integer: ^D
     
at which point the program is finished.  I don't see what is wrong
with that.  Perhaps you want
     
  enter an integer: 123^D
     
If you want to be able to recognize that, you will simply have to
use a separate call to readln.  Presuming that you want to be able
to recognize ^D in either context, the program would look like
     
    while true do
       begin
       writeln ('enter an integer : ');
       if eof
         then {exitloop}                goto 666;
       read (i);
       if eof
         then {exitloop}                goto 666;
       readln;
       end;                        666:
     
This tests for eof twice because I assume you want to allow it either
place. (Sorry about the goto's, but the logic is clearer that way than
with any alternative I could think of.)
     
As far as I know, the semantics of lazy I/O allow you to check for any
possible input, printing prompts at any point.  This does not mean
that Pascal's input parsing is as powerful as scanf, or that its
output is as powerful as printf.  Obviously they are not.  Validating
input, to make sure that the user hasn't typed something bogus, can
require a bit more programming in Pascal than in C.  For example, in
the above programs, if the user types an extra CR before the ^D the
program may think that there is one more number than there is.  If you
want the program to be very careful about checking validity of its
input, you will need to write code to check that the user has typed
one and exactly one number on each line.  But as far as I know, you
can always find a way to avoid having extra prompts and misplaced
input hangs.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6005
          for JMS@ARIZMIS; Tue, 29-JUL-1986 21:11 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 23:03:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000870; 29 Jul 86 23:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002176; 29 Jul 86 23:42 EDT
From: der Mouse <mouse%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Compiler Specific Operators
Message-ID: <468@mcgill-vision.UUCP>
Date: 28 Jul 86 22:24:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[>>> and >>>> blather about coding some functions in-line]
>> Apparently the committee (or a large faction thereof) is quite
>> concerned about ensuring that there is some easy way to ensure a
>> `real function call'.
> Yes, apparently so, but WHY?  What the hell difference does it make,
> from the user's point of view?  That is, why should he ever be
> anything other than happy, if some alternative invoked by the
> compiler produces faster-running code?
     
     Just when you thought a topic had been beaten to death....
     
     There are many reasons.  Maybe I have a function j and I don't
realize that the compiler wants to try to in-line code Bessel
functions.  Maybe I want my own sin() and cos(), for example, perhaps
all the calls to sin() and cos() should remember their arguments and
compute the other function as a side effect to speed up the common case
of sin(x) and cos(x) in succession (and I can't afford the time to
rewrite my code to use sincos() or something similar).  Maybe I want to
do something with a pointer to the function (not that this prevents
in-line coding of other uses).  Maybe I am writing a game like
phantasia, where a character has the attribute of sin, and I want to
have a function sin() which has nothing to do with the sine function.
Maybe I want to be able to set breakpoints on entry to sin().  Maybe I
want to save text space badly enough to be willing to accept the
performance disadvantage (ROMing the code maybe, you don't always want
to optimize for speed).
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."
                - Piers Anthony, Bearing an Hourglass

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6065
          for JMS@ARIZMIS; Tue, 29-JUL-1986 21:12 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 23:08:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000888; 30 Jul 86 0:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002180; 29 Jul 86 23:42 EDT
From: der Mouse <mouse%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: PRECEDENT FOR USE OF =
Message-ID: <469@mcgill-vision.UUCP>
Date: 28 Jul 86 22:31:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2237@brl-smoke.ARPA>, gwyn@BRL.ARPA (VLD/VMB) quotes:
>> "I hardly ever get a program to pass through lint without getting
>> least a dozen lines of garbage."
and writes:
> Perhaps "lint" is trying to tell you something.
     
     I refuse to cast, for example, printf(), or strcpy(), to void
just to keep lint happy.  I don't cast normal assignments to void, why
should I cast strcpy() (which is conceptually a string assignment)?  I
refuse to hold with malloc(10) giving a type mismatch error (lint wants
unsigned int for the argument).  I refuse to listen to possible pointer
alignment problems when casting malloc(n) to (struct foo *).
     
     C assumes you know what you're doing and lets you do it, wherein
lies it power and usefulness.  If you want the compiler (typechecker,
whatever) to protect you from yourself, use a strongly typed language
like Pascal!  Don't complain because C isn't the best language for your
application; instead, try to pick a more appropriate one.
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."
                - Piers Anthony, Bearing an Hourglass

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6344
          for JMS@ARIZMIS; Tue, 29-JUL-1986 21:27 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/29/86 at 23:18:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000900; 30 Jul 86 0:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002184; 29 Jul 86 23:43 EDT
From: der Mouse <mouse%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: unterminated .h files, __CAT__, etc.
Message-ID: <470@mcgill-vision.UUCP>
Date: 28 Jul 86 22:54:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Recently, through no fault of my own (honest, guv'nor!) I wound up
> including a header file with no terminating newline.
     
Fun, ain't it?
     
> My questions are directed more toward the handling of the missing
> newline itself:
> What do other preprocessors do in this kind of situation?
     
Well, in my preprocessor (yes, I rewrote cpp), a # is not special
except at the beginning of a line.  Hence we have the following:
     
x.c contains
    #include "y.c"
    #include "z.c"
    #include "y.c"
    this is x.c contents
y.c contains, without a terminating newline
    this is y.c contents
z.c contains
    this is z.c contents
then cc -E (with my preprocessor) produces
    # 1 "y.c"
    this is y.c
    # 2 "x.c"
    contents#include "z.c"
    # 1 "y.c"
    this is y.c
    # 4 "x.c"
    contentsthis is x.c contents
Notice that the last token has migrated from the included file into the
including file, and that the first #include has been output literally.
     
> What *should* X3J11 say about these cases, if anything?
     
I see nothing wrong with leaving it implementation-dependent (it is an
error if the file does not end with a newline).
     
On another topic,
     
> __STR__ and __CAT__ were suggested by Tom Plum in a late-night
> working session to resolve the remaining preprocessor issues,
     
> The Reiser CPP is definitely out.
     
I don't see what's wrong with Reiser cpp's answer to the str and cat
problems (formal substitution in strings and /**/).  Could someone
enlighten me?  The former (formals inside ""s) can bite, but only if
you're not aware of it (using the same name for a formal and a global
within the macro can bite too, so the possibility of being bitten will
not go away with __STR__).  The only thing I can see wrong with /**/
for __CAT__ is that cc -E -C, such as is used by lint, won't do
contatenation, but the preprocessor could easily be made to strip /**/
even under -C).
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."
                - Piers Anthony, Bearing an Hourglass

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8778
          for JMS@ARIZMIS; Wed, 30-JUL-1986 03:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 05:29:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002050; 30 Jul 86 6:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004588; 30 Jul 86 5:42 EDT
From: Carl Zeigler <jcz%sas.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <134@sas.UUCP>
Date: 29 Jul 86 12:52:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
  In article <5858@alice.uUCp>, ark@alice.UucP (Andrew Koenig) writes:
  > > So, does anyone have a fix for this bug?
  > > I'll trade for a fix for a problem with void functions and the ?: operator
  > >
  > > void f3(which)
  > > {
  > >     extern void f1(),f2();
  > >     which?f1():f2();
  > > }
  > > cc(1) gives an "incompatible types" error.
  >
  > As it should.  The only thing you're allowed to do with void values
  > is throw them away.
     
     
Scan again, Andrew, the (void) values are being thrown away.
     
--
John Carl Zeigler         "Just once I'd like to meet an alien menace
SAS Institute Inc.            that wasn't impervious to bullets !"
Cary, NC  27511
(919) 467-8000            ...!mcnc!rti-sel!sas!jcz

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2302
          for JMS@ARIZMIS; Wed, 30-JUL-1986 09:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 11:11:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004360; 30 Jul 86 11:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000492; 30 Jul 86 11:41 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  Re:  varargs fails on typedefs
Message-ID: <736@wjvax.wjvax.UUCP>
Date: 30 Jul 86 00:49:34 GMT
Keywords: stdarg, varargs
To:       info-c@BRL-SMOKE.ARPA
     
Doug Gwyn <seismo!BRL.ARPA!gwyn> sent me E-mail responding to my posting
about the need for a promote() operator to implement varargs.  Unforunately,
our mailer is broken, so I cannot respond privately.  In any event, I
believe that his response is of interest:
     
>This is the second such suggestion in recent weeks.
>I think we should be careful to distinguish between what the
>application code/programmer sees for an interface and
>what the C runtime implementer needs for his implementation.
     
><varargs.h> can be used safely if the programmer specifies
>the correct (possibly widened) type and if he restricts himself
>to the simpler data types.  X3J11 has designed <stdarg.h> to
>replace <varargs.h>, but there is still room for debate about
>the current design.
     
>Statements such as "<varargs.h> cannot be implemented without
>a promote() or alignof() operator" are simply false.  The
>existence of such operators would not even be sufficient for some
>architectures.  Rather than specify such fine-grained details
>of use only for implementing varargs, X3J11 is leaving it up
>to the implementor how he pulls this trick, and is specifying
>only the application code/programmer visible interface.  If
>this interface is properly designed, it will be implementable
>"somehow" on every significant architecture (although perhaps
>not purely in C).
     
As might be guessed, I disagree.  Of course, varargs can be implemented
without a promote() or alignof() operator; it is so implemented now.
However, it imposes the restrictions that Doug cites: "if the programmer
specifies the correct (possibly widened) type and if he restricts himself to
the simpler data types."
     
I argue that a promote() operator is necessary to remove these restrictions.
My article referred to using typedef'd types in varargs, and, in fact, without
a promote() operator, using typedef'd types in varargs is impossible.  Note
that promote() is a necessary condition; not a sufficient condition.
     
In short, I believe that X3J11, by omitting the (normally invisible) promote()
operator, is forcing itself to limit the usefulness of the (visible) stdarg
interface.
     
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2498
          for JMS@ARIZMIS; Wed, 30-JUL-1986 09:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 11:22:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004672; 30 Jul 86 12:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000535; 30 Jul 86 11:42 EDT
From: Brandon Allbery <allbery%ncoast.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: expr?(void):(void)
Message-ID: <1327@ncoast.UUCP>
Date: 27 Jul 86 15:43:13 GMT
Followup-To: net.lang.c
To:       info-c@BRL-SMOKE.ARPA
     
Expires:
     
Quoted from <273@watmath.UUCP> ["Re: C Compiler bug (and fix for a different
 one)"], by rbutterworth@watmath.UUCP (Ray Butterworth)...
+---------------
| I'll trade for a fix for a problem with void functions and the ?: operator.
|
| void f3(which)
| {
|     extern void f1(),f2();
|     which?f1():f2();
| }
| cc(1) gives an "incompatible types" error.
+---------------
     
That's not a bug, it's a feature.  Literally.
     
Before you start complaining, consider that the intent of functions returning
(void) is that of:
     
#define procedure void
     
procedure f1(x, y) {
...
}
     
++Brandon
--
  ---------------- /--/    Brandon S. Allbery        UUCP: decvax!cwruecmp!
 /              / /|\/    Tridelta Industries, Inc.        ncoast!tdi2!brandon
----    -------- /-++    7350 Corporate Blvd.        PHONE: +1 216 974 9210
   /   / /---,  ----    Mentor, Ohio 44060        SYSOP: UNaXcess/ncoast
  /   / /    / /  /         -- HOME --             (216) 781-6201 24 hrs.
 /   / /    / /  /    6615 Center St. Apt. A1-105    ARPA:  ncoast!allbery%
----  -----~ ----    Mentor, Ohio 44060-4101         case.CSNET@csnet-relay

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4414
          for JMS@ARIZMIS; Wed, 30-JUL-1986 13:01 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 14:56:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010617; 30 Jul 86 15:31 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a009748; 30 Jul 86 15:06 EDT
Received: from bbn-labs-b.arpa by AOS.BRL.ARPA id a009967; 30 Jul 86 15:07 EDT
To: info-c@BRL.ARPA
Subject: Re: expr ? (void) : (void)
Date: 30 Jul 86 13:23:45 EDT (Wed)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     Before we go overboard on this issue, let's take a look at a couple of
points:
     
    1) C has no "function call statement".  Instead it has an "expression"
       statement which allows for constructs such as:
     
        printf ("Hello world\n");
        ptr ++;
        x + 57;            /* useless, but allowed */
        blatz ();
     
    2) Functions may be declared to be of type (void).  For example,
     
        void
        blatz ()
        {
            printf ("Hello world\n");
        }
     
Obviously, given 1) and 2), certain exceptions relating to the use of values
of type (void) have been implemented.  Yes, you can not have:
     
        void    x ();
        int    y;
     
        y = x ();
     
since you are really trying to "use" a (void) value.  However, I claim that
it should be as legal to say:
     
        z ? x () : y ();
     
as it is to say:
     
        if ( z )
            x ();
        else    y ();
     
when both x and y return (void), given that C *already knows how to throw away
the value of a (void)*.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)
     
Yow!  Now I get to think about all the BAD THINGS I did to a BOWLING BALL
 when I was in JUNIOR HIGH SCHOOL!

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8628
          for JMS@ARIZMIS; Wed, 30-JUL-1986 21:26 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 23:22:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014005; 31 Jul 86 0:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015819; 30 Jul 86 23:43 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Marilyn Monroe
Message-ID: <152@danews.UUCP>
Date: 29 Jul 86 20:05:04 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>>    Larry Cipriani        AT&T Network Systems     danews!lvc
>>    "Nothing is worse than an itch you can never scratch."
     
>    Ah yes. And Marilyn Monroe is dead.
     
And someday so will you.
     
>    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
>On the other hand, life can be an endless parade of TRANSSEXUAL QUILTING BEES
>aboard a cruise ship to DISNEYWORLD if only we let it!!
     
Are you crazy or just stupid ?!?  This is net.lang.c not net.signatures.
Perhaps there ought to be a newsgroup where we can jab each other about
signature files (more money for AT&T!) but this isn't the place for it.
Grow up Cottrell.
--
     
Larry Cipriani        AT&T Network Systems
danews!lvc        "Nothing is worse than an itch you can never scratch."

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8707
          for JMS@ARIZMIS; Wed, 30-JUL-1986 21:29 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 23:23:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014007; 31 Jul 86 0:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015823; 30 Jul 86 23:43 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Sizeof structure members
Message-ID: <153@danews.UUCP>
Date: 29 Jul 86 20:13:35 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > [How does one take sizeof a struct member without an instance of it?]
> > ....
     
> This solution is fairly portable, and may even be legal:
>
>         struct s {char a[3];};
>         void main(){
>             printf( "%d\n", sizeof( ((struct s *)0)->a ) );
>         }
>
> It works on a at least a couple of machines, and lint doesn't complain.
> It may be argued that it is not legal, since it is dereferencing the
> null pointer.  On the other hand, sizeof is guaranteed not to evaluate
> the object being sizeofed, and to only calculate resulting types, not
> values.  It's issues like these that give language lawyers headaches,
> right?
>
> Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw
     
It works on my machines Sys 5 Rel 2 3B[2/5/20]s.  I like this very much!
Thanks a lot.  I would have said thanks a week ago but danews is down more
than it is up.
--
     
Larry Cipriani        AT&T Network Systems
danews!lvc        "Nothing is worse than an itch you can never scratch."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8789
          for JMS@ARIZMIS; Wed, 30-JUL-1986 21:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 23:31:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014012; 31 Jul 86 0:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015833; 30 Jul 86 23:44 EDT
From: bright%dataio.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Int and Char
Message-ID: <1054@dataio.UUCP>
Date: 29 Jul 86 22:31:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5529@sun.uucp> guy@sun.UUCP writes:
>> For my next question, why doesn't my C compiler accept declarations
>> like 'signed char a;' or something like that?
>Because it's not an ANSI C compiler.  The ANSI X3J11 draft includes a
>"signed char" specification, but AT&T hasn't put one into the 3B20 C
>compiler yet (I suspect few, if any, other PCC-based compilers have, either).
     
Datalight C supports 'signed char' declarations. Datalight C is also the
only one I know of that supports 'const' and 'volatile' storage class
modifiers.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8848
          for JMS@ARIZMIS; Wed, 30-JUL-1986 21:38 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 23:34:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014017; 31 Jul 86 0:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015917; 30 Jul 86 23:47 EDT
From: Sam Kendall <sam@zarathustra.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)
Message-ID: <5826@think.COM>
Date: 31 Jul 86 02:01:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1327@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes:
> > [Example in which expr ? f() : g() is used, where f and g return void.]
>
> That's not a bug, it's a feature.  Literally.
>
> Before you start complaining, consider that the intent of functions returning
> (void) is that of:
>
> #define procedure void
>
> procedure f1(x, y) {
> ...
> }
     
This is misleading.  Pascal and allied languages have a more
restrictive philosphy than C does; yet you are implying that because
procedures are allowed only as statements in Pascal, void-valued
expressions should be that way in C.  void expressions are always
allowed as the left operand of the comma operator, and as the first and
third expressions in the for statement; should be ban them there, too?
More graphically, should we cut off the hands of burglars in the U.S.
because it's done that way in Iran?
     
Enough cheap shots.  Here is an example of using void in "?:".  Suppose
you are writing a stdio-like package, and one function has this
specification:
     
    void PutC(Stream, char);
     
But for efficiency you want to write PutC as a macro.  So you define it
like this:
     
extern void _WriteBuf(Stream);
#define PutC(s, c)  (--(s)->count >= 0 ? (void) (*(s)->bufp++ = (c)) \
                       : _WriteBuf(s, c))
     
One can also easily come up with examples where void is useful as the
right operand of the comma operator, another place where it is illegal
in many compilers.
     
As far as I can figure, void is only useful in these contexts within
macros, and the reason it is useful there is that you want to make
macros syntactically expressions whenever possible, so you need to use
whatever control flow you can within expressions.
     
All in all, the ANSI committee did right in allowing void in these
places!
     
---
Sam Kendall            sam@godot.think.com
Thinking Machines Corp.        ihnp4!think!sam

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8978
          for JMS@ARIZMIS; Wed, 30-JUL-1986 21:55 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/30/86 at 23:53:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014062; 31 Jul 86 0:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015814; 30 Jul 86 23:43 EDT
From: Larry Cipriani <lvc%danews.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Another bug in C compilers
Message-ID: <151@danews.UUCP>
Date: 29 Jul 86 19:40:42 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I believe I've found a bug in the C compiler for the Sys 5 Rel 2 3B20.
Say we have a structure declared as:
     
struct ABC
{
    stuff
};
     
and then follow it with:
     
struct ABC;
     
I don't get any error message.  This is also in my CB-UNIX 2.3
pdp 11/70 C compiler.  Perhaps it is in your compiler also.  Is
this really a bug or am I missing something ?  If its not a bug
what on earth is it for ?
--
     
Larry Cipriani        AT&T Network Systems
danews!lvc        "Nothing is worse than an itch you can never scratch."

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1513
          for JMS@ARIZMIS; Thu, 31-JUL-1986 03:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/31/86 at 05:42:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015047; 31 Jul 86 6:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018283; 31 Jul 86 5:42 EDT
From: Julian Onions <jpo%cs.nott.ac.uk@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Missing stdio features.
Message-ID: <2340@robin.cs.nott.ac.uk>
Date: 28 Jul 86 11:42:19 GMT
Keywords: stdio, buffering
Posted: Mon Jul 28 11:42:19 1986
To:       info-c@BRL-SMOKE.ARPA
     
I try to use stdio as often as possible for several reasons (such as
portability, efficiency, laziness ...) but I feel it lacks one or two calls
to achieve some of the less every-day options.
Most of these can be got around if you `know' the internal stdio
structure - but that negates the portability win. Anyway, anyone care to
a) comment on these
b) mention their own pet stdio hates
c) show portable ways to implement these
d) tell me they're already implemented ==> RTFM.
     
-------------------------
     
Addition:    fpending(fp)
     
Synopsis:    returns the number of characters that are buffered up
        on the stream pointed to by fp.
     
Use:        Has several uses, in particular useful when you are
        applying select(2) to a FILE, select may say there is
        nothing to read when in actual fact there is stuff
        buffered up. The only other way around this is to
        set buffering to 0 which is rather inefficient.
        It's trivial to add this as another macro.
     
-------------------------
     
Addition:    finvbuf(fp)
     
Synopsis:    invalidate in-core stdio buffer for FILE *fp.
     
Use:        If you know by other information that a file you
        currently have open has changed then you need to
        force a reread of the file ensuring that all buffered
        information is junked. The only safe/portable alternative
        is to fclose/fopen the file descriptor again which is
        reasonably expensive. It should probably not guarantee
        anything about the offset or else do a rewind(3).
     
-------------------------
     
Addition:    fslam(fp)
     
Synopsis:    shut the given descriptor in a hurry without flushing it.
     
Use:        If you know that flushing a descriptor will cause a block.
        e.g. you have a timeout writing to a terminal cos someones
        ^S'd it, so you decide to ignore that terminal & carry on.
        How can you shut it, fclose will try and flush the data
        and will hang the program again. If finvbuf() is in place
        this could be used instead. I suppose you could get around
        it with
            close(fileno(fp));
            fclose(fp);
        but it seems a bit messy and may cause indigestion for
        the fclose routine.
     
-------------------------
     
Addition:    fbufsiz(fp), fbuftype(fp)
     
Synopsis:    fbuzsiz returns size of buffer in use, fbuftype indicates
        what sort of buffering is in use (none, line or full).
     
Use:        To determine whats going on dynamically. E.g.
        if( fbufsiz(stderr) == 0 || fbuftype(stderr) == _IONBF)
        {
            printf("stderr non buffered - fixing\n");
            fclose(stderr);
            stderr = fdopen(2, "w")
            setbuf(stderr, buffer);
        }
        basically, you can set lots of interesting buffering modes
        but you can't discover whats in use.
     
-------------------------
     
An inconsistency - why is there no ungetchar(c) defined??
     
     
Julian.
     
jpo@cs.nott.ac.uk                mcvax!ukc!nott-cs!jpo
--
Julian Onions

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2673
          for JMS@ARIZMIS; Thu, 31-JUL-1986 06:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/31/86 at 08:39:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019406; 31 Jul 86 9:22 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a022626; 31 Jul 86 8:55 EDT
To: info-c@BRL-SMOKE.ARPA
cc: danews!lvc@harvard.ARPA
Subject: Signatures
Date: 31 Jul 86 08:46:08 EDT (Thu)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
In article <152@danews.UUCP>, Larry Cipriani <lvc@danews.UUCP> writes:
     
> Are you crazy or just stupid ?!?  This is net.lang.c not net.signatures.
> Perhaps there ought to be a newsgroup where we can jab each other about
> signature files (more money for AT&T!) but this isn't the place for it.
> Grow up Cottrell.
> - --
>
> Larry Cipriani        AT&T Network Systems
> danews!lvc        "Nothing is worse than an itch you can never scratch."
     
Personal attacks like this are always discouraged in global newsgroups.  If
you have a gripe with a particular author's style, you can always use the 'n'
key (or whatever it is you use to skip articles).  The only reason I post this
is to discourage others from entering a flaming match in Info-C (net.lang.c
to the Usenet).
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)
     
Yow!  Am I elected yet?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2852
          for JMS@ARIZMIS; Thu, 31-JUL-1986 07:10 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/31/86 at 09:03:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020389; 31 Jul 86 9:52 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a022230; 31 Jul 86 8:41 EDT
To: Larry Cipriani <danews!lvc@harvard.ARPA>
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: Another bug in C compilers
In-reply-to: Your message of 29 Jul 86 19:40:42 GMT.
         <151@danews.UUCP>
Date: 31 Jul 86 08:41:21 EDT (Thu)
From: Rick Genter <rgenter@BBN-LABS-B.ARPA>
     
     Accepting the declaration:
     
    struct    ABC;
     
is not a bug, it's a feature.  This is termed a *vacuous declaration*, and
permits the definition of cyclic recursive structures in an inner scope where
one of the structures renames a structure from on outer scope.  For example,
     
    struct    ABC    {
        int    foo;
        double    mumble;
    };
     
    main ()
    {
        struct    ABC;
        struct    DEF    {
            char    bar[ 128 ];
            int    bletch;
            struct    ABC    *foop;
        } a;
     
        struct    ABC    {
            double    giant[ 5000 ];
            struct    DEF    *barp;
        } b;
     
        <the rest of main>
    }
     
If you didn't have the vacuous declaration, the compiler would think that
"foop" pointed at a structure consisting of "int foo" and "double mumble".
Referencing foop->giant would get you "illegal structure pointer combination".
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)
     
CHUBBY CHECKER just had a CHICKEN SANDWICH in downtown DULUTH!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4258
          for JMS@ARIZMIS; Thu, 31-JUL-1986 09:22 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/31/86 at 11:17:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023839; 31 Jul 86 12:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029168; 31 Jul 86 11:42 EDT
From: Wolf <wolf%galbp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Survey of C Compilers for micros
Message-ID: <419@galbp.UUCP>
Date: 29 Jul 86 16:26:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I've followed this discussion with interest, but was wondering
why CI86 (Computer Inovations (?)) never made it in any of the
survey articles.  I've had limited experience with it and have had no
problems with it, whatsoever.  In other surveys (e.g., Byte) it was always
in the top 3.  Have I missed something?
     
--
     
     
Wolf Herda
Harris/Lanier
Computer R&D
{akgua,akgub,gatech}!galbp!wolf

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6372
          for JMS@ARIZMIS; Thu, 31-JUL-1986 12:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/31/86 at 14:40:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028949; 31 Jul 86 15:28 EDT
Received: from icst-cmr.arpa by SMOKE.BRL.ARPA id a005045; 31 Jul 86 14:41 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA04172; Thu, 31 Jul 86 14:40:26 edt
Date: Thu, 31 Jul 86 14:40:26 edt
From: "UNIX 4.2 BSD" <root@icst-cmr.ARPA>
Message-Id: <8607311840.AA04172@icst-cmr.ARPA>
To: danews!lvc@looney-bin, info-c@BRL-SMOKE.ARPA
Subject: Re:  Marilyn Monroe
     
    From info-c-request@BRL.ARPA Thu Jul 31 00:31:04 1986
    Received: from BRL-SMOKE.ARPA (brl-smoke.arpa.ARPA) by icst-cmr.ARPA
(4.12/4.7)
        id AA02955; Thu, 31 Jul 86 00:30:59 edt
    Received: from USENET by SMOKE.BRL.ARPA id a015819; 30 Jul 86 23:43 EDT
    From: Larry Cipriani <danews!lvc>
    Newsgroups: net.lang.c
    Subject: Marilyn Monroe
    Message-Id: <152@danews.UUCP>
    Date: 29 Jul 86 20:05:04 GMT
    To: info-c@brl-smoke.arpa
     
    >>    Larry Cipriani        AT&T Network Systems     danews!lvc
    >>    "Nothing is worse than an itch you can never scratch."
     
    >    Ah yes. And Marilyn Monroe is dead.
     
    And someday so will you.
     
I invite you to dance upon my grave.
     
    Are you crazy or just stupid ?!?  This is net.lang.c not net.signatures.
     
Are you a hypocrite or just an ass?
     
    Perhaps there ought to be a newsgroup where we can jab each other about
    signature files
     
Seems like the pot calling the kettle black.
     
(more money for AT&T!) but this isn't the place for it.
     
Or GTE or Sprint, or MCI, or ...
     
    Grow up Cottrell.
     
Go fsck yourself.
     
    Larry Cipriani    AT&T Network Systems
    danews!lvc    "Nothing is worse than an itch you can never scratch."
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There you go again.
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    While my BRAINPAN is being refused service in BURGER KING,
    Jesuit priests are DATING CAREER DIPLOMATS!!
     
I hope you like this one better.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1490
          for JMS@ARIZMIS; Thu, 31-JUL-1986 21:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 07/31/86 at 23:09:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002391; 31 Jul 86 21:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006485; 31 Jul 86 21:41 EDT
From: Jon Loeliger <jdl%purdue.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: icky C code
Message-ID: <688@mordred.purdue.UUCP>
Date: 30 Jul 86 16:56:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3117@utcsri.UUCP>, greg@utcsri.UUCP (Gregory Smith) writes:
> From a code efficiency
> standpoint, for example, a 68000 should return int's in D0 and all pointer
> types in A0, which would break the above. ( Somebody pointed out that a
> certain 68K compiler has an option to return both types in *both* regs ).
> Or am I wrong, and there is a non-unwritten ( i.e. official ) rule that
> says everything should return in the same reg whenever possible?
     
     
I am in the process of writing a 68000 backend and just
this problem arose.  As of now, I resolved it by postponing
the critical decision, and left everything in D0 upon return.
------------------------------------------------------------------------------
Jon Loeliger        I *think* these are my opinions, let me ask my boss...
jdl@Purdue.ARPA                    Dept Computer Science
jdl@Purdue.Edu                    W. Lafayette, IN 47907
jdl@mordred.cs.purdue.edu            (317) 494-6180
{ihnp4, decvax, ucbvax, pur-ee}!purdue!jdl
--
------------------------------------------------------------------------------
Jon Loeliger        I *think* these are my opinions, let me ask my boss...
     
jdl@Purdue.ARPA                    Dept Computer Science
jdl@Purdue.Edu                    W. Lafayette, IN 47907
jdl@mordred.cs.purdue.edu            (317) 494-6180
{ihnp4, decvax, ucbvax, pur-ee}!purdue!jdl

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5576
          for JMS@ARIZMIS; Fri,  1-AUG-1986 02:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 03:55:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003590; 1 Aug 86 4:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008283; 1 Aug 86 3:41 EDT
From: Jonathan Leech <jon%amdahl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)
Message-ID: <3502@amdahl.UUCP>
Date: 31 Jul 86 18:18:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5826@think.COM>, sam@think.COM (Sam Kendall) writes:
> ...
> Enough cheap shots.  Here is an example of using void in "?:".  Suppose
> you are writing a stdio-like package, and one function has this
> specification:
>
>     void PutC(Stream, char);
>
> But for efficiency you want to write PutC as a macro.  So you define it
> like this:
>
> extern void _WriteBuf(Stream);
> #define PutC(s, c)  (--(s)->count >= 0 ? (void) (*(s)->bufp++ = (c)) \
>                        : _WriteBuf(s, c))
     
    I won't argue with the desirability of being able to do this, but
I believe your example is poorly chosen. I/O functions can always fail
and some indication of this ought to be returned to the user where
possible, even though few bother to check usage like this.
     
    -- Jon Leech (...seismo!amdahl!jon)
    UTS Products / Amdahl Corporation
    __@/

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5856
          for JMS@ARIZMIS; Fri,  1-AUG-1986 02:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 04:06:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003602; 1 Aug 86 4:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008337; 1 Aug 86 3:45 EDT
From: Brandon Allbery <allbery%ncoast.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: e?v:v
Message-ID: <1341@ncoast.UUCP>
Date: 31 Jul 86 00:06:31 GMT
Followup-To: net.lang.c
To:       info-c@BRL-SMOKE.ARPA
     
Expires:
     
Quoted from <3183@utcsri.UUCP> ["Re: C Compiler bug (and fix for a different
 one)"], by greg@utcsri.UUCP (Gregory Smith)...
+---------------
| >> void f3(which)
| >> {
| >>     extern void f1(),f2();
| >>     which?f1():f2();
| >> }
| >> cc(1) gives an "incompatible types" error.
| >
| >As it should.  The only thing you're allowed to do with void values
| >is throw them away.
|
| But it is being thrown away. In e1?e2:e3, the contexts of e2 and e3 are
| inherited from the context of the ?: operator itself. In this case,
| that is in a 'for effect' or void context, so f1() and f2() should be
| treated as 'thrown away' too.
+---------------
     
If the result of ?: were an lvalue, this might be true; but it's not.  In
effect ?: evaluates its arguments and therefore teh arguments must have
values.
     
++Brandon
--
  ---------------- /--/    Brandon S. Allbery        UUCP: decvax!cwruecmp!
 /              / /|\/    Tridelta Industries, Inc.        ncoast!tdi2!brandon
----    -------- /-++    7350 Corporate Blvd.        PHONE: +1 216 974 9210
   /   / /---,  ----    Mentor, Ohio 44060        SYSOP: UNaXcess/ncoast
  /   / /    / /  /         -- HOME --             (216) 781-6201 24 hrs.
 /   / /    / /  /    6615 Center St. Apt. A1-105    ARPA:  ncoast!allbery%
----  -----~ ----    Mentor, Ohio 44060-4101         case.CSNET@csnet-relay

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6633
          for JMS@ARIZMIS; Fri,  1-AUG-1986 03:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 05:17:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003737; 1 Aug 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009587; 1 Aug 86 5:42 EDT
From: "W. H. Pollock x4575 3S235" <whp%cbnap.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (?: operator)
Message-ID: <155@cbnap.UUCP>
Date: 31 Jul 86 13:12:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <134@sas.UUCP> jcz@sas.UUCP (Carl Zeigler) writes:
>
>  > > void f3(which)
>  > > {
>  > >     extern void f1(),f2();
>  > >     which?f1():f2();
>  > > }
>  > > cc(1) gives an "incompatible types" error.
>  >
>  > As it should.  The only thing you're allowed to do with void values
>  > is throw them away.
>
>Scan again, Andrew, the (void) values are being thrown away.
     
The void values are not thrown away!  Remember that (A?B:C) is an
expression *returning a value*.  C is giving the error because it can't
determine the type of the return value.  This is clearer in the following:
     
    void f3(which)
    {
        int f1();
        void f2();
        int foo;
        ...
        foo = which?f1():f2();
        ...
    }
     
which results in the same error message, for the same reason.  Another
example:
     
    f4()
    {
        ...
        return ((void) expression);
    }
     
Note it doesn't mater what use is made of the return value (in the original
example it is thrown on the floor, which is what probably confused some
people).

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6702
          for JMS@ARIZMIS; Fri,  1-AUG-1986 03:25 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 05:19:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003745; 1 Aug 86 6:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009608; 1 Aug 86 5:43 EDT
From: Mike Farren <farren%hoptoad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)
Message-ID: <927@hoptoad.uucp>
Date: 1 Aug 86 05:10:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I don't know - maybe I'm just slow.  My understanding was that the reason for
the existence of "void" was to indicate to the compiler that a function did
not return a value, therefore no provisions need be taken to supply one,
potentially freeing up a register.  Is this wrong?  At any rate, you can
replace the "expr?(void):(void)" construction with something on the order of
"if(expr)(void); else (void);" with only a slight increase in keystrokes,
and make your compiler a lot happier.
     
     
--
----------------
Mike Farren
hoptoad!farren   "Tickle my funnybone!"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6839
          for JMS@ARIZMIS; Fri,  1-AUG-1986 03:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 05:28:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003775; 1 Aug 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009625; 1 Aug 86 5:44 EDT
From: Andy Kashyap <aka%cbrma.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <4835@cbrma.UUCP>
Date: 31 Jul 86 18:09:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <134@sas.UUCP> jcz@sas.UUCP (Carl Zeigler) writes:
>  In article <5858@alice.uUCp>, ark@alice.UucP (Andrew Koenig) writes:
>  > > So, does anyone have a fix for this bug?
>  > >
>  > > void f3(which)
>  > > {
>  > >     extern void f1(),f2();
>  > >     which?f1():f2();
>  > > }
>  > > cc(1) gives an "incompatible types" error.
>  >
>  > As it should.  The only thing you're allowed to do with void values
>  > is throw them away.
>
>Scan again, Andrew, the (void) values are being thrown away.
>
     
No they are NOT; the value from the '?:' operator is being thrown away.
The '?:' operator expects a non-void value so it can decide 'which' and
pass the result to a higher level of expression (in this case there happens
to be none). The complaint of "incompatible types" is the result of the
'?:' operator expecting a non-void type as arguments and the arguments
providing a void type.
Wasn't that obvious from the diagnostics??? ;-)
     
To re-phrase, the '?:' doesn't look at its operands (parameters or arguments)
as function calls -- they might as well be 'f1()+5' or so -- but as
expressions. Therefore it '*RETURNS THE VALUE* of one of its operands
depending on the third'.
     
A semantic point of view:
     
A function call is an expression and can, therefore, be used anywhere an
expression can be used. When you declare a function (void), you state that
you intend to use that function as a statement instead, that you do not
intend to use it in any operations. It can now only be used where a statement
can. Keep in mind that an expression is a statement, but NOT vice-versa.
     
If you look up the reference section of K&R, somewhere it says something
like this (I don't have my K&R with me):
    ...
    expression -> expression ? expression : expression
    ...
Thus you can not use a statement (ie (void) f1()) where an expression is
expected.
     
The BUG: there ain't none.
The FIX: use 'if' instead.
     
- andy kashyap
--
     
+---------------------------------------------------------------------------+
: Jim, what's the value of Pi?                         : Andy Kashyap       :
: About 3.14159. Why do you ask, Doctor?               : AT&T Bell Labs     :
: Actually, Captain, the exact value is 3.1415926535...: Columbus OH        :
: Kirk & McCoy: Shut Up, Spock!!!                      : ..!cbosgd!cbrma!aka:
+---------------------------------------------------------------------------+

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6958
          for JMS@ARIZMIS; Fri,  1-AUG-1986 03:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 05:41:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003793; 1 Aug 86 6:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009582; 1 Aug 86 5:42 EDT
From: Chris Gray <cg%myrias.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: icky C code
Message-ID: <261@myrias.UUCP>
Date: 31 Jul 86 16:25:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Jon Loeliger at Purdue writes that he needs to decide whether address results
on a 68000 compiler should be in A0 or D0. Unfortunately, the best answer is
probably obtained by looking at any code that you have to interface to - what
does it do? I ran into the exact same problem while porting my Draco compiler
to the Amiga. I planned to return address values in A0, so that they could
be used directly if that's all the code called for. All of the AmigaDos and
Kernal routines return all results in D0 however. This left me with three
choices: have interface stubs move the result to A0; require very strange
declarations and type cheating for the supplied routines; or have the compiler
return pointers in D0 as well. For now I've chosen the third alternative, but
I may eventually go back to the first.
     
            Chris Gray (..ihnp4!alberta!myrias!cg)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9477
          for JMS@ARIZMIS; Fri,  1-AUG-1986 07:26 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 09:18:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007646; 1 Aug 86 10:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015345; 1 Aug 86 9:43 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  varargs fails on typedefs
Message-ID: <737@wjvax.wjvax.UUCP>
Date: 31 Jul 86 16:45:39 GMT
Keywords: varargs
To:       info-c@BRL-SMOKE.ARPA
     
In article <2640@brl-smoke.ARPA> version B 2.10.3 4.3bsd-beta 6/6/85; site
 wjvax.wjvax.UUCP
 wjvax!qubix!saber!sun!decwrl!pyramid!hplabs!tektronix!uw-beaver!cornell!rochest
er!seismo!lll-crg!caip!brl-adm!brl-smoke!smoke!rbj@icst-cmr rbj@icst-cmr (Root
 Boy Ji
m) writes:
>>    This makes the typedef completely useless.
>Only for varargs use. You can always have *two* typedefs, one for
>definitions, and one for argument declarations. I know, yuk!
>>    To fix this problem, I propose a promote() operator, as follows:
>Clearly, as you say, there is no way to emulate this. On the other hand,
>this is done so rarely as to be tolerated the way it is. Do you really
>want to muck up the language with rarely used constructs?
>
>As a side issue, routines requiring varargs are frowned on anyway.
     
This is probably a question of varargs' role more than anything else.  I find
varargs useful, and therefor use it.  When I do, I find the restriction that
the user know about argument type promotion annoying, especially since the
compiler knows about type promotion already.
     
Apparently, you find varargs a kludge (you frown on it), and so label an
enhancement to C that would generalize variable argument parsing
"mucking up" the language.
     
Presumably, since varargs is being standardized (as stdarg), the X3J11
committee finds it to be a feature and not a kludge.  In that case, now
is the time to generalize the stdarg interface, and that requires (a)
new operator(s) in C.
     
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0229
          for JMS@ARIZMIS; Fri,  1-AUG-1986 22:02 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 22:44:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa00387; 1 Aug 86 23:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013418; 1 Aug 86 21:43 EDT
From: Robert C Sanders <sandersr%ecn-pc.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <606@ecn-pc.UUCP>
Date: 1 Aug 86 05:21:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <613@looking.UUCP> brad@looking.UUCP (Brad Templeton) writes:
>I have used several C compilers in my projects and here are the summaries:
>
>1) Microsoft C
>2) Lattice C
>3) Mark Williams C
>4) QNX C compiler
>5) DeSmet C compiler
>6) Wizard C.
>
>So in the long run, Microsoft C is the winner.  We run it under Xenix which
>means that we don't even have to use dos except for testing.  Documentation
>of the DOS functions is very poor in the Xenix version, though.
>-- Brad Templeton
     
You forgot Computer Innovations C86; it too will run under Xenix (or at least
their Xenix version), and cross compile for Xenix or MS DOS.  As someone
posted recently, CII C86 produces slightly larger code than MS C, but it too
supports ANSI style argument parsing and medium model.  It too is very UNIX
oriented (it is developed on a UNIX machine); I have no problem porting
anything across.  It also has options to make symbols 8-char or 31-char
significant.  It is better than Latice C, so on the scale above I would
rank it 1.5.
--
Continuing Engineering Education Telecommunications
Purdue University         ...!ihnp4!pur-ee!pc-ecn!sandersr
     
Let's make like a BSD process, and go FORK-OFF !!    -- bob
(and "make" a few children while we're at it ...)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0552
          for JMS@ARIZMIS; Fri,  1-AUG-1986 22:02 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 23:09:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000465; 1 Aug 86 23:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014026; 1 Aug 86 23:41 EDT
From: Charlie Sorsby <crs@LANL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Interactive I/O in Pascal
Message-ID: <5918@lanl.ARPA>
Date: 1 Aug 86 19:38:31 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> As far as I know, the semantics of lazy I/O allow you to check for any
> possible input, printing prompts at any point.  This does not mean
> that Pascal's input parsing is as powerful as scanf, or that its
> output is as powerful as printf.  Obviously they are not.  Validating
> input, to make sure that the user hasn't typed something bogus, can
> require a bit more programming in Pascal than in C.  For example, in
     
Am I missing something?
     
As I understand it, printf and scanf are not considered part of the C
language but rather are part of the standard I/O package.  Is this also
true for writeln and readln in Pascal?  If so, it appears that standard
I/O packages are being compared rather than languages.  If not, perhaps the
comparisons are between apples and oranges.
     
Is there some characteristic of the Pascal language that prevents
construction of a Pascal standard I/O package that *would* be as powerful
as that of C?  Perhaps the existence of this characteristic is implicit in
this discussion and that is what I am missing.  If so, forgive my
ignorance.  (I realize that the lack of "separate compilation" in Pascal
precludes use of precompiled libraries of functions.)
     
Of course, there is also the fact that Pascal was intended as a teaching
language to consider.
--
Charlie Sorsby
    ...!{cmcl2,ihnp4,...}!lanl!crs
                crs@lanl.arpa

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0675
          for JMS@ARIZMIS; Fri,  1-AUG-1986 22:02 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/01/86 at 23:17:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000467; 1 Aug 86 23:57 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a014136; 1 Aug 86 23:46 EDT
Received: from icst-cmr.arpa by AOS.BRL.ARPA id a000434; 1 Aug 86 23:39 EDT
Received: by icst-cmr.ARPA (4.12/4.7)
    id AA09310; Fri, 1 Aug 86 21:06:43 edt
Date: Fri, 1 Aug 86 21:06:43 edt
From: Root Boy Jim <rbj@ICST-CMR.ARPA>
Message-Id: <8608020106.AA09310@icst-cmr.ARPA>
To: info-c-request@BRL.ARPA
Subject: Removal From List
Cc: info-c@BRL.ARPA
     
Not one to go quietly, I have decided to go out in style. Good or Bad,
depending on your point of view, but style nonetheless. I leave you with:
     
    Welcome to the Net
    I guess you all know why we're here
    My name is Root Boy,
    And I've been flaming for a year
    ...
    ...
    ...
    And pinheads complete the scene
    Here comes Dennis Ritchie to guide you to
    Your very own machine.
     
And as they say back in Old Mexico City:    A. M. F. !!!
     
    (Root Boy) Jim Cottrell        <rbj@icst-cmr.arpa>
    I'm a nuclear submarine under the polar ice cap and I need a Kleenex!
     
And especially for my good buddy Henry,
     
You should all JUMP UP AND DOWN for TWO HOURS while I decide on a NEW NEWSGROUP!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3516
          for JMS@ARIZMIS; Sat,  2-AUG-1986 01:26 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 03:13:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001305; 2 Aug 86 4:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015106; 2 Aug 86 3:41 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)  (I was wrong.  I've seen the light.)
Message-ID: <1983@watmath.UUCP>
Date: 1 Aug 86 21:31:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I've received mail or news from the following people, all strongly
protesting that my fix for void functions and the ?: operator was
invalid and that the current behaviour of most compilers is correct,
and that the proposed ANSI standard is as mixed up as I am.
     
>  From: aka@cbrma.UUCP (Andy Kashyap)
>  From: allbery@ncoast.UUCP (Brandon Allbery)
>  From: ark@alice.UucP (Andrew Koenig)
>  From: hamilton@uxc.CSO.UIUC.EDU (Wayne Hamilton)
>  From: jsdy@hadron.UUCP (Joseph S. D. Yao)
>  From: <utzoo!dciem!msb>
>  From: seismo!ll-xn!mit-amt!mit-eddie!ci-dandelion!jim (Jim Fulton)
>  From: whp@cbnap.UUCP (W. H. Pollock x4575 3S235)
     
First I'd like to clear up some confusion.  We seem to be arguing about
slightly different things.  In a statement such as
    i = e1 ? e2 : e3;
there are actually three distinct points where the compiler can make
checks.  At the "=", it must make sure that the types of "i" and
the result of the "?:" expression are the same or at least compatible
for an assignment.  At the "?" it must make sure that e1 is in fact
something that can be tested against 0.  At the ":" it must make sure
that the types of e2 and e3 are the same or are at least compatible.
     
Now, my "fix" was to the check at the ":".  Rather than allowing that
the two types may both be void perhaps it would have been better to
have done a simple test that any type is allowed as long as they are
both the same.  After all, the error message at this point does
say that the two operands of the ":" are incompatible with each other,
when in fact they are not.  For instance this fix solves the problem
of using "?:" with pointers to void functions that was reported earlier.
     
Even this shouldn't cause people to get upset.  The complaints were
actually about what happens (or rather doesn't happen) at the "?".
This is where the check that people want should go.  At this point
the compiler could check that the right operand (in the parse tree)
is in fact a valid expression and not void.  This is the point at
which a message such as "'?' operator returns void expression" could
be produced.  If we added that (see below) as well as leaving in
the earlier fix, it would get rid of the misleading "incompatible"
message and still produce an error that will keep these people
happy.
     
     
>  From: aka@cbrma.UUCP (Andy Kashyap)
>  A function call is an expression and can, therefore, be used anywhere an
>  expression can be used. When you declare a function (void), you state that
>  you intend to use that function as a statement instead, that you do not
>  intend to use it in any operations. It can now only be used where a statement
>  can. Keep in mind that an expression is a statement, but NOT vice-versa.
>
>  If you look up the reference section of K&R, somewhere it says something
>  like this (I don't have my K&R with me):
>      expression -> expression ? expression : expression
>  Thus you can not use a statement (ie (void) f1()) where an expression is
>  expected.
     
That did it.  You've finally convinced me of the error of my ways.
The "?:" expression has the same value and type as the two expressions
around the ":".  This type cannot be void.
     
I'm converted.  I've seen the light.  I'm studing the Bible much more
closely.  And look what I've found:
     
    comma-expression -> expression , expression
    The type and value of the result are the type and value
    of the right operand.
                                  DMR, Chapter 7, Verse 15.
     
But, isn't that what it says about the "?:" expression too?
Hallelujah!  I've found a sin in our compiler.  It actually
allows those evil "void expressions" on the right of a comma.
Why, this means we'll have to go back through the last few
weeks of news, take all those articles talking about void
functions and "?:" and repost them, this time changing the
"?:" to ",", since all the arguments in them hold equally
well.
     
In the meantime, I urge everyone (well, those mentioned above anyway),
to put the follwing fix into their compilers.  I'm sure it will find
many occurrences of this sin that may have crept into their code over
the years.
     
     
void f3(which)
{
    extern void f1(),f2();
    which?f1():f2();
}
cc(1) gives an "incompatible types" error.
     
     
In /usr/src/lib/mip/trees.c add the lines indicated by "->>".
     
    ...
    opact( p )  NODE *p; {
    ...
        switch( optype(o=p->in.op) ){
    ...
            case QUEST:          /* Look, the two cases are already common. */
            case COMOP:          /* This must prove the devine intent. */
->> #ifdef I_HAVE_BEEN_SAVED
->>             if (!mt2) uerror("'%s' returns void expression", opts[o]);
->> #endif
    ...
            case COLON:
                if( mt12 & MENU ) return( NCVT+PUN+PTMATCH );
                else if( mt12 & MDBI ) return( TYMATCH );
    ...
                else if( mt12 & MSTR ) return( NCVT+TYPL+OTHER );
->>             else if ( mt1==mt2 ) return TYPL;
                break;
            case ASSIGN:

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3664
          for JMS@ARIZMIS; Sat,  2-AUG-1986 01:40 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 03:36:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001330; 2 Aug 86 4:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015246; 2 Aug 86 3:47 EDT
From: Charles Hedrick <root@topaz.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Interactive I/O in Pascal
Message-ID: <5475@topaz.RUTGERS.EDU>
Date: 2 Aug 86 05:31:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Because Pascal does strong type-checking, it would be hard to write
anything like printf and scanf for it.  Indeed if writeln and readln
were not built into the compiler, you would not be able to define them
yourself.  A Pascal procedure must have a fixed number of arguments,
each of a definite type.  Thus the best you could do would be
  printint(int i);
  printreal(real r);
etc.  Unfortunately, I/O libraries are not something that can be
tacked on later.  I/O affects the definition of the language.  This is
one of the most serious problems with the languges in the Algol
tradition.  There is a tendency to think I/O is a detail unfit for
computer scientists, which can be left to the "standard prolog".

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3709
          for JMS@ARIZMIS; Sat,  2-AUG-1986 01:44 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 03:38:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001332; 2 Aug 86 4:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015262; 2 Aug 86 3:47 EDT
From: Bjarne Stroustrup <bs%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: void
Message-ID: <5893@alice.uUCp>
Date: 2 Aug 86 01:30:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I tried a little program on the three 8th Edition UNIX C compilers:
     
    cc    - the standard C compiler
    cyntax    - a very competent C checker
    CC    - the C++ compiler
     
void f1(), f2();
int f3();
     
void h()
{
    int i;            /*     cc    cyntax    CC    */
    f1();            /*                */
    i = f1();        /*    error    error    error    */
    f1(),f2();        /*                */
    f1(),f3();        /*                */
    i = (f1(),f2());    /*    error    error    error    */
    i = (f1(),f3());    /*                */
    i?f1():f3();        /*    error            */
    i = i?f1():f2();    /*    error    error    error    */
    i = i?f1():f3();    /*    error    error    error    */
}
     
They don't like assigning a void to an int.
They don't mind an operand of ``,'' being void as long as it is not
assigned to anything.
They all agree that the second and third operands of ?: must be of the
same type (modulo standard conversions).
cc insists that an operand of ?: must not be void even if it is not used;
cyntax and CC disagree.
     
I think cyntax and CC are right. It is inconsistent to allow an operand
to ``,'' to be void provided it is not used and at the same time to disallow
an operand of ``?;'' from being void even when it is not used. I think cc's
behaviour is a leftover from the days where there were no void.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3810
          for JMS@ARIZMIS; Sat,  2-AUG-1986 01:51 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 03:46:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001398; 2 Aug 86 4:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015207; 2 Aug 86 3:45 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Question on getopt()
Message-ID: <5733@sun.uucp>
Date: 1 Aug 86 18:29:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >Read the code, not the manual page!
>
> This may come as a great surprise to you, but some of us don't HAVE source
> code :-(
     
This may come as a great surprise to you, but I'm at least as aware of that
as you.  However, the person in question was talking about 4.3BSD, which
means they almost certainly had source code (no vendor is offering 4.3BSD
yet, since the 4.3BSD tape only came out recently).
     
Anybody with source has certainly learned by now that the UNIX documentation
is only a rough approximation to the truth.  The source code is, in some
cases, the final arbiter; in others, the documentation is correct.  The
*only* way to resolve this is a combination of additional knowledge and good
taste (to judge whether the change to the code implied by the documentation
is correct or not).
     
This is an awful situation.  With any luck, documentation from UNIX
resellers has been cleaned up somewhat; if not, beat up your vendor to
improve their documentation.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3762
          for JMS@ARIZMIS; Sat,  2-AUG-1986 01:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 03:43:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001365; 2 Aug 86 4:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015094; 2 Aug 86 3:40 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)
Message-ID: <1688@watmath.UUCP>
Date: 1 Aug 86 18:10:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <5826@think.COM>, sam@think.COM (Sam Kendall) writes:
> >     void PutC(Stream, char);
> > But for efficiency you want to write PutC as a macro.  So you define it
> > like this:
> > extern void _WriteBuf(Stream);
> > #define PutC(s, c)  (--(s)->count >= 0 ? (void) (*(s)->bufp++ = (c)) \
> >                                        : _WriteBuf(s, c))
> I won't argue with the desirability of being able to do this, but
> I believe your example is poorly chosen. I/O functions can always fail
> and some indication of this ought to be returned to the user where
> possible, even though few bother to check usage like this.
> -- Jon Leech (...seismo!amdahl!jon)
     
But you don't know what _WriteBuf() does (neither do I).  But we
are working on a stdio-like library at waterloo which looks very
similar to this.  Checking the value returned by putchar() every
single time can be quite a waste, especially when you consider
that the only time a bad value can be returned is when the buffer
is flushed, and that only happens every 8000 characters or so
using full buffering on stdout.  It is also a pain to have to
write the code to do this check and to write whatever code is
required to handle the problem (usually print a message and exit),
especially if putchar is used in many different places in the code.
That is why "few bother to check usage like this".
     
The solution we use is to have the _WriteBuf function, instead of
returning an indication of error, either print the message and
exit itself, or "raise an event" that can be trapped in the user's
code (signals or longjumps).  That way users never need to check
the return status since the io function can never fail (or if it
does it doesn't return).  It makes writing correct code much simpler,
and makes previously incorrect code correct.  It also gets rid of
those thousands of useless status checks while adding no extra
overhead.  Of course this method isn't necessarily the best to use
in all cases, only in almost all cases.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4262
          for JMS@ARIZMIS; Sat,  2-AUG-1986 03:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 05:16:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001522; 2 Aug 86 6:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016284; 2 Aug 86 5:43 EDT
From: Chris Robertson <nonh%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Question on getopt()
Message-ID: <7009@utzoo.UUCP>
Date: 31 Jul 86 04:37:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5530@sun.uucp> guy@sun.UUCP writes:
>Read the code, not the manual page!
     
This may come as a great surprise to you, but some of us don't HAVE source
code :-(
--
Christine Robertson {linus, decvax, ihnp4}!utzoo!{nonh, toram!chris}
     
Cat, n. - lapwarmer with built-in buzzer.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4372
          for JMS@ARIZMIS; Sat,  2-AUG-1986 03:29 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 05:24:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001528; 2 Aug 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016330; 2 Aug 86 5:45 EDT
From: Michael Meissner <meissner%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: unterminated .h files, __CAT__, etc.
Message-ID: <490@dg_rtp.UUCP>
Date: 1 Aug 86 14:24:47 GMT
Keywords: ANSI X3J11
To:       info-c@BRL-SMOKE.ARPA
     
In article <470@mcgill-vision.UUCP> mouse@mcgill-vision.UUCP (der Mouse) writes:
>
>> __STR__ and __CAT__ were suggested by Tom Plum in a late-night
>> working session to resolve the remaining preprocessor issues,
>
>> The Reiser CPP is definitely out.
>
>I don't see what's wrong with Reiser cpp's answer to the str and cat
>problems (formal substitution in strings and /**/).  Could someone
>enlighten me?  The former (formals inside ""s) can bite, but only if
>you're not aware of it (using the same name for a formal and a global
>within the macro can bite too, so the possibility of being bitten will
>not go away with __STR__).  The only thing I can see wrong with /**/
>for __CAT__ is that cc -E -C, such as is used by lint, won't do
>contatenation, but the preprocessor could easily be made to strip /**/
>even under -C).
     
There are two main reaons why the reiser cpp's mechanisms (of stringizing and
token pasting) have a different syntax in the draft X3J11 standard.  First,
it is nearly impossible to formalize in a step by step manner (and the main
reason for standards is to formalize things), and also the reiser cpp violates
K&R (where it states that comments are ALWAYS turned into whitespace, and
where it explicitly states that text inside of strings and char constants.
     
The relavant K&R quotes are:
     
page 179:
    Blanks, tabs, newlines, and COMMENTS (collectively, "white space")
    as described below are ignored except as they serve to separate
    tokens.
     
page 207:
    Text inside a string or a character constant is NOT subject to
    replacement.
     
Michael Meissner, Data General, ...{decvax}!mcnc!rti-sel!dg_rtp!meissner

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5303
          for JMS@ARIZMIS; Mon,  4-AUG-1986 08:15 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 08:18:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002049; 2 Aug 86 9:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017213; 2 Aug 86 7:41 EDT
From: "DAVE B. WOOD" <dbw%ariel.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <1197@ariel.UUCP>
Date: 1 Aug 86 15:48:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> construction ...?f():g()  where f() and g() are void...
     
Don't forget side effects.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4456
          for JMS@ARIZMIS; Mon,  4-AUG-1986 09:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 05:32:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001572; 2 Aug 86 6:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016241; 2 Aug 86 5:42 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <7003@utzoo.UUCP>
Date: 30 Jul 86 21:20:43 GMT
Keywords: stdio, buffering
To:       info-c@BRL-SMOKE.ARPA
     
> Addition:    fpending(fp)
> ...
> Use:        Has several uses, in particular useful when you are
>         applying select(2) to a FILE...
     
Clearly the right solution to that is fselect(), not fpending().  I'm
surprised that there isn't an fselect(), in fact.
     
The other suggestions seem plausible at first glance.
--
EDEC:  Stupidly non-standard
brain-damaged incompatible    Henry Spencer @ U of Toronto Zoology
proprietary protocol used.    {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4523
          for JMS@ARIZMIS; Mon,  4-AUG-1986 10:41 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 05:42:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001631; 2 Aug 86 6:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016265; 2 Aug 86 5:43 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <504@hadron.UUCP>
Date: 31 Jul 86 05:35:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <461@watmath.UUCP> rbutterworth@watmath.UUCP (Ray Butterworth)
 writes:
>> > void f3(which)
>> > {
>> >     extern void f1(),f2();
>> >     which?f1():f2();
>> > }
>> > cc(1) gives an "incompatible types" error.
>> As it should.  The only thing you're allowed to do with void values
>> is throw them away.
>If I'm not throwing them away, what is it you think I'm doing with them?
>Also, the proposed ANSI draft explicitly states that the second and third
>operands of ?: may each have (void) type, so I'm not trying anything
>unusual here.
     
My 1984 version of X3J11 (has it been that long?) agrees with K&R
that each of the operands must have a value.  This makes intuitive
sense.  The meaning of X ? Y : Z is: an expression whose value is
the value of Y, if the value of X is non-zero; otherwise, the value
of Z.  By this, all three must evaluate to some value.
     
Do you have a more recent edition of X3J11 that  r e a l l y  lets
voids in there?  Ugh!  (What date?)  Besides which, all C compilers
until just recently (Lattice, Microsoft) had been written to K&R
and v7-s3-s5, not to the ANSI standard.
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4956
          for JMS@ARIZMIS; Mon,  4-AUG-1986 10:57 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/02/86 at 06:58:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001866; 2 Aug 86 7:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017189; 2 Aug 86 7:40 EDT
From: kos%ernie.berkeley.edu.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: generalized switch
Message-ID: <15093@ucbvax.BERKELEY.EDU>
Date: 1 Aug 86 22:19:22 GMT
Sender: usenet@ucb-vax.ARPA
Keywords: Suggestions wanted
To:       info-c@BRL-SMOKE.ARPA
     
One of my only memories from a brief stint as a PL/I programmer years ago
was the pleasure of using a more general switch structure than C allows.
In addition to the standard
    switch (var) {
        case value:
        case value:
            etc...
        }        (translated to C because I don't remember
                    any PL/I )
     
you also had the option of
    switch() {
        case <boolean-expr>:
            etc.
        }
if you wanted to test something other than the value of a particular variable.
     
I'm wondering whether any netland gurus have elegant suggestions for ways
of dummying up such a construct. The particular case at hand involves some
macros that look like:
     
#define IS_TYPE_A(c)    (c==this||c==that)
#define    IS_TYPE_B(c)    ((c==the_other||c==your_mother) && c != rambo)
and so on. Now what I need is
    switch () {
        IS_TYPE_A(c):
            do_type_a(c);
            break;
        IS_TYPE_B(c):
            do_type_b(c);
            break;
        }
     
But it's something I've wanted in the past in other contexts as well.
Any ideas?
     
     
    Joshua Kosman
    kos@ernie.berkeley.EDU
     
    "When I was young people used to tell me, 'When you're 50 you'll
    understand.' Well, now I'm 50. I don't understand a thing."
                -- Erik Satie

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0904
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/05/86 at 12:02:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000576; 5 Aug 86 12:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004258; 5 Aug 86 5:45 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re:  swap() macro (LISP & Algol)
Message-ID: <508@hadron.UUCP>
Date: 2 Aug 86 07:15:17 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I'm surprised nobody seems to know this.
     
LISP 2.0 [1] is a child of mating LISP 1.5 with ALGOL 60.
     
I was sure there were some MIT/SDC folk reading this.    ;-)
     
[1] Sammet, Jean, _Programming_Languages:_History_and_Fundamentals_.
    Prentice-Hall, Inc., New Jersey, 1969.
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0982
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:20 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021592; 5 Aug 86 5:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004117; 5 Aug 86 5:41 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <2716@umcp-cs.UUCP>
Date: 3 Aug 86 08:12:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <15093@ucbvax.BERKELEY.EDU> kos@ernie.Berkeley.EDU
(Joshua Kosman) writes:
>One of my only memories from a brief stint as a PL/I programmer years ago
>was the pleasure of using a more general switch structure than C allows.
     
[In particular, the compiler allowed `cases' that might have to be
determined at run time, or at any rate were not simple constants.]
     
>#define IS_TYPE_A(c)    (c==this||c==that)
>#define IS_TYPE_B(c)    ((c==the_other||c==your_mother) && c != rambo)
>and so on. Now what I need is
>    switch () {
>        IS_TYPE_A(c):
>            do_type_a(c);
>            break;
>        IS_TYPE_B(c):
>            do_type_b(c);
>            break;
>        }
     
One of the key `features' in C is that most constructs have a very
simple relationship to the machine code that will be generated for
a given statement.  switch `wants' to become a computed branch,
much like the old FORTRAN
     
    GOTO (l1, l2, l3, ..., ln), var
     
`switch' wins readability points over the computed GOTO, but not
much else: it still requires constant expressions, so that the
compiler can convert it back to one.  In C, when one wants a run-time
test, one must write a run-time test.
     
In your particular example, you probably do not care how the test
is implemented.  Unfortunately (?), C requires you to care.  This
example appears to require run-time evaluation, but in another case
(pardon the pun) you might be able to get away with this:
     
    #define IS_TYPEA(x) ((x) > 3 && (x) < 7)
    #define CASES_TYPEA    case 4: case 5: case 6:
    #define IS_TYPEB(x) (!IS_TYPEA(x))
    #define CASES_TYPEB    default:
     
You could then use
     
        if (IS_TYPEA(n)) {
            statements;
        } else if (IS_TYPEB(n)) {
            morestatements;
        }
     
and
     
        switch (n) {
     
        CASES_TYPEA:
            statements;
            break;
     
        CASES_TYPEB:
            morestatements;
            break;
        }
     
but not
     
        switch (n) {
     
        CASES_TYPEB:
            morestuff;
            break;
        /* default is to ignore */
        }
     
So this approach too has its pitfalls.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2127
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:21 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/05/86 at 11:48:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021240; 5 Aug 86 4:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003010; 5 Aug 86 3:47 EDT
From: Tom Stockfisch <tps%sdchem.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: unix documentation (was Question on getopt())
Message-ID: <269@sdchema.sdchem.UUCP>
Date: 4 Aug 86 01:30:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5733@sun.uucp> guy@sun.UUCP writes:
>> >Read the code, not the manual page!
>> This may come as a great surprise to you, but some of us don't HAVE source
>> code :-(
>This may come as a great surprise to you, but I'm at least as aware of that
>as you.  However, the person in question was talking about 4.3BSD, which
>means they almost certainly had source code...
>    Guy Harris
     
Biggest surprise:  of the more than 100 users on our system, only *4* are
allowed to look at UNIX software.  Are only local gurus supposed to use
library functions?
     
--Tom Stockfisch, UCSD Chemistry

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3137
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000565; 5 Aug 86 12:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004182; 5 Aug 86 5:43 EDT
From: Tainter <tainter%ihlpg.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <2299@ihlpg.UUCP>
Date: 4 Aug 86 22:18:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Sure, that's the way I have been doing it. But you can do that with
> any choice among cases.
> As I understand it, a switch/case setup compiles exactly the same as
>     if (var == const1) {.....};
>     else if (var == const2) {.....};
>     else  {default_action};
> anyway. (Or am i wrong?). In any case, it can be rewritten that way.
> Joshua Kosman
> kos@ernie.berkeley.EDU
     
You are wrong.
switch (a) {
    case 'a': hi();
    case 'b': ho(); break;
    case 'c': he();
    case 'd': ha(); break;
}
.  .  .
     
can be written as:
if (a == 'a') {
    hi(); goto do2; /* skip the test on 2 */
}
if (a == 'b') {
do2:
    ho(); goto done;    /* do a break */
}
if (a == 'c') {
    he(); goto do4; /* skip the test on 4 */
}
if (a == 'd') {
do4:
    ha(); goto done; /* do a break */
}
done:
.  .  .
     
A bit different than the simple if else block, ja?
The switch statement can also be coded as a jump table with generaly better
performance than the if else block.
     
It might be feasable to fold if else blocks testing the same variable repeatedly
into a jump table, but I'll wager it's unusual.
--j.a.tainter

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3084
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000574; 5 Aug 86 12:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004211; 5 Aug 86 5:43 EDT
From: Kenneth Almquist <ka%hropus.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Generating code for the switch statement
Message-ID: <610@hropus.UUCP>
Date: 4 Aug 86 20:37:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> As I understand it, a switch/case setup compiles exactly the same as
>    if (var == const1) {.....};
>    else if (var == const2) {.....};
>    else  {default_action};
> anyway.
     
A compiler should be able to do better than that.  Generating good code for
switches is one place where compiler writers can show they know something
about searching.
     
Using a branch table will produce faster and smaller code if the cases
are consecutive integers.  The only thing that may be non-obvious is the
best way to test whether the expression being switched on is within
range before accessing the branch table.  A straightforward coding of
this test requires two comparisons, but Ritchie's compiler for the
PDP-11 generated only one comparison using the machine language
equivalent of the following code:
     
    if ((unsigned)(value -= MIN) > (MAX - MIN) goto default;
     
On the PDP-11, this generates one less instruction (or two less, if MIN
is zero) than:
     
    if (value < MIN || value > MAX) goto default;
     
(Learning hacks like these is one of the benefits of reading the
compiler.)
     
Since some people like to count starting at one, a possible enhancement
would be to change MIN from 1 to 0 in this case by adding an extra entry
to the beginning of the branch table.  But real C programmer count from
0; wimps who count starting with 1 deserve to have their switch statements
execute slower.  :-)
     
If the cases are not consecutive, the branch table must be filled with
entries for the "missing" cases, making the table larger.  The Ritchie
compiler will generate a branch table if the number of entries in the
branch table would be less than three times the number of cases.  If
the cases are mostly consecutive with a few outliers, a branch table
could be augmented with a few specific tests for the outliers, but I
don't know of any compiler that does this.
     
There are two general methods for implementing tables which do not rely
on the keys being nearly consecutive:  hashing and the binary search.
Hashing, which is what the Ritchie compiler uses, has the advantage that
its performance is independent of the number of cases, just as with a
branch table.  The modulo instruction is used as the hash function; the
C compiler tries a variety of values for the modulus and selects the
best one which means that the time required to generate the hash table
is proportional to the square of the number of cases.
     
The UN*X VAX compiler, on the other hand, uses a binary search.  A
binary search executes in time proportional to the log of the number of
cases.  This makes it sound worse that the hash search; I presume
someone discovered that most switch statements contained few enough
statements that the binary search was superior.  The binary search works
best on a machine with a three way branch like that provided by the
Fortran arithmentic IF statement.  On a machine with condition codes
like the VAX, each step of the binary search is implemented by a compare
instruction followed by two branches on the condition codes.
     
Several things may be done to improve the performance of the binary
search.  First, many machines execute a conditional branch instruction
faster when no branch is taken, so that rather than testing the middle
value in the table one can test a value somewhat to one side in order to
decrease the chance that a branch will be taken.  This is implemented in
the VAX compiler, but some other possible improvements are not.  The
binary search could be abandoned in favor of the linear search at some
level (e. g. when the number of possibilities has been reduced to 2 or
3).  If there are a series of consecutive cases, this can be used to
eliminate extra tests.  (For example, if a number is known to be less
than 5 it cannot be greater than 4, and if a number is greater than 2 and
less than 4 then it must be equal to 3, but the VAX compiler will code
to test for both these cases.)  Finally, each comparison generated by
the VAX compiler looks like:
     
    cmpl    r0,$7        # compare switch value with 7
    beql    L1        # if equal, branch to the code for case 7
    bgtr    L8        # if greater, branch to L8 for the next cmpl.
    # The next cmpl instruction goes here.
     
Since the branch to L8 is more likely to be executed that the branch to
L1, the bgtr instruction should come first to minimize the number of
instructions executed.
     
For small cases, the good old linear search is used by both the Ritchie
and the VAX compilers.  Several things are done to speed up the linear
search.  First, the switch expression is copied into a register.  This
helps in general but loses when the switch instruction is a register
variable or the switch contains only one case.  (This is hard to fix
because the compilers generate the code for a switch in two pieces;
first they generate code to place the value to be switched on in r0, and
then they generate the code to implement the switch.  Another problem
with this separation appears on the PDP-11, where it may be easier to
compute an expression in r1 than in r0 due to a brain damaged multiply
instruction.)  Second, the compiler implements the search as a series of
compares followed by branch if equal instructions.  This minimizes the
time required to reach the default case because in the default case none
of the branches will be taken.  In contrast, the code at the top of this
article will probably be compiled into a series of branch if not equal
instructions, all of which will branch if there is no match.
     
The Ritchie compiler at one time actually generated a table of values
and labels, and did a linear search on it using a loop.  This saves
space but takes more time.  Furthermore, it doesn't even save space if
there are 1 or 2 cases.  (The Ritchie compiler has special handling of
switch statements with no cases except the default.)  The Ritchie
compiler was changed to generate linear searches using a series of
compare instructions quite a long time ago, but I don't know if Dennis
was responsible for the change.
     
I don't know why the VAX compiler uses with a linear search at all,
rather than using the binary search.  Probably this was a holdover from
the Ritchie compiler, which must be prepared to generate a linear search
because a linear search will outperform a hash search on a few elements.
     
In general, then, a compiler should do pretty well by using a jump table
where possible and a binary search otherwise.  What is actually optimum
must be determined by measuring various approaches on a specific machine.
                Kenneth Almquist
                ihnp4!houxm!hropus!ka    (official name)
                ihnp4!opus!ka        (shorter path)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0591
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:22 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/06/86 at 02:21:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id aa00591; 5 Aug 86 12:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001210; 5 Aug 86 5:43 EDT
From: Steven Pemberton <steven%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Separate compilation
Message-ID: <7031@boring.mcvax.UUCP>
Date: 4 Aug 86 16:27:25 GMT
Posted: Mon Aug  4 16:27:25 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <5918@lanl.ARPA> crs@lanl.UUCP writes:
> (I realize that the lack of "separate compilation" in Pascal
> precludes use of precompiled libraries of functions.)
     
This question arises every now and then. But, there is nothing about Pascal
that precludes separate compilation: just because some implementations
demand extra syntax to handle it does not mean that that extra syntax is
necessary.
     
I have used a compiler (for Algol 68 as it happens but the idea is the same)
that handled separate compilation without external declarations, includes or
the like. It worked as follows (translated into Unix-like terms):
     
Your separately compiled procedures looked like this: (it also allowed
separately compiled constants, types and variables)
     
    program whatever(...etc...);
     
    function mysqrt(x: real): real;
    begin ...etc... end;
     
    function mysin(x: real): real;
    begin ...etc... end;
     
    begin (*Empty main program, though it didn't have to be: you could
        initialise variables here*)
    end.
     
You then compiled this with the equivalent of pc -c mylib.p, and this
produced mylib.a.
     
Your program then looked like this:
     
    program p(...etc...);
    (*more procedures if you want*)
    begin
        writeln(mysqrt(4.0))
    end.
     
and you compiled this with pc mylib.a prog.p. The compiler picked up all
type information from the .a file, and so strong typing was still done.
     
It always struck me as a well thought out method.
     
Steven Pemberton, CWI, Amsterdam; steven@mcvax.uucp

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0992
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:22 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004072; 5 Aug 86 14:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002730; 5 Aug 86 13:47 EDT
From: dmr%dutoit.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: expr?(void):(void)
Message-ID: <2150@dutoit.UUCP>
Date: 5 Aug 86 08:11:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0912
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:23 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004012; 5 Aug 86 14:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002601; 5 Aug 86 13:44 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <499@dg_rtp.UUCP>
Date: 4 Aug 86 17:58:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> whp@cbnap.UUCP (W. H. Pollock x4575 3S235)
>> jcz@sas.UUCP (Carl Zeigler)
     
>>Scan again, Andrew, the (void) values are being thrown away.
>
> The void values are not thrown away!  Remember that (A?B:C) is an
> expression *returning a value*.
     
Uh, well, no actually.  I'll join in this tis-so/tis-not debate using
the radical approach of seeing what fairly-well-respected references
have to say on the subject.
     
First, note that K&R don't say anything about it, since they didn't have
(void) back then.
     
Second, Harbison and Steele say that ?: expressions come in four
flavors.  One flavor is interesting here (from page 183):
     
    3. They [the second and third subexpressions] may have identical
       types (structure, union, enumeration, or void).  The result is of
       this same type.
     
Third, the ANSI C draft standard, C.3.15.
     
    The first operand shall have scalar type.  Both the second and third
    operands shall have arithmetic type, or shall have the same
    structure, union, or pointer type, or shall be void expressions.  In
    addition, one may be an object pointer and the other a pointer to
    void, or one may be a pointer and the other a null pointer constant.
        ...
    If both the operands are void expressions, the result is a void
    expression.
     
All fairly clear and straightforward.  It is legal.  So, the objection:
     
> C is giving the error because it can't
> determine the type of the return value.
     
is incorrect.  The "type" returned from a ?: expression with void
trailing operands is void.
     
--
Any clod can have facts, but having opinions is an art.
                        --- Charles McCabe, San Francisco Chronicle
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2277
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/06/86 at 03:32:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010348; 6 Aug 86 4:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013056; 6 Aug 86 3:40 EDT
From: Dan Tilque <dant%tekla.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <696@tekla.UUCP>
Date: 4 Aug 86 20:17:31 GMT
Keywords: switch
To:       info-c@BRL-SMOKE.ARPA
     
In article <15120@ucbvax.BERKELEY.EDU>, kos@ernie.Berkeley.EDU (Joshua Kosman)
 writes:
>In article <2765@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>)
 writes:
>>In article <15093@ucbvax.BERKELEY.EDU> kos@ernie.Berkeley.EDU (Joshua Kosman)
 writes:
>>>    switch() {
>>>        case <boolean-expr>:
>>>            etc.
>>>        }
>>>...
>>>Any ideas?
>>
>>In C, such code is written:
>>
>>    if ( bool_expr_1 )
>>        action_1
>>    else if ( bool_expr_2 )
>>        action_2
>>    else if ...
>>    else
>>        default_action
>>
>>You could come up with some CPP macros for this, but why bother?
>
>Sure, that's the way I have been doing it. But you can do that with
>any choice among cases.
>As I understand it, a switch/case setup compiles exactly the same as
>    if (var == const1) {.....};
>    else if (var == const2) {.....};
>    else  {default_action};
>anyway. (Or am i wrong?). In any case, it can be rewritten that way.
>But the switch promotes comprehensibility. The situation I
>find (mildly) frustrating is when I have a choice among cases, a
>setup which is conceptually akin to a switch, but is not
>syntactically equivalent because I want to use a slightly different test
>than simple equality.
>
>
In PL/I this is probably how it is done, but many (if not most) C compilers
convert the switch-case statement to a branch table.  (There are also
statements in FORTRAN and COBOL which also convert to branch tables.)  A branch
table is just a series of assembler branch instuctions in a row.  The
first of these branches jumps to a location within the branch table
based on the switch value times the length of the branch instruction.
The rest of the branches are jumps to code to be executed if the switch
value is 0, 1, 2...  The default case must be handled before the branch
table is entered.
     
If you followed the above explanation, you should understand why the
switch value (as it is currently implemented) has to be an integral
type expression.  It's likely that the designer(s) of this statement
had a branch table in mind when the statement was designed.
     
Branch tables are very efficient if the case values have small gaps
between them, but can be somewhat inefficient otherwise.
     
=========================================================================
Dan Tilque        UUCP:        tektronics!dadla!dant
            CSnet:        dant%dadla@tektronix
            ARPAnet:    dant%dadla%tektronix@csnet-relay
I can't think of anything clever to put here.
=========================================================================

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4453
          for JMS@ARIZMIS; Wed,  6-AUG-1986 10:23 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/06/86 at 07:14:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010517; 6 Aug 86 5:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014125; 6 Aug 86 5:40 EDT
From: Mike Shannon <mikes%apple.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <111@apple.UUCP>
Date: 5 Aug 86 08:19:54 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Just to be sure we're all on the same wavelength about void expressions
with the ?: operator:
    Consider the case where you're writing a really complex #define macro,
and you decide that you'd like some sort of IF statement in it,
(take a look at getchar()).  Can't you see a case where you might want to
call a void function, and then set the value of the #define macro to be
a side effect of the function?  Sort of like
#define foo(c) buffer_empty?fill_buff(),first_char_in_buf:first_char_in_buf
    I mean, it seems to me that the 'pro' argument is that you get flow of
control in #define's. Although when you way that 'void things cannot participate
in expressions', a rational person would say that conditional expressions are
expressions and so you can't have a void thing in that kind of expression.
--
            Michael Shannon {apple!mikes}

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3463
          for JMS@ARIZMIS; Thu,  7-AUG-1986 10:18 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/07/86 at 10:40:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015951; 6 Aug 86 10:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020249; 6 Aug 86 9:44 EDT
From: Oleg Kill the bastards Kiselev <oleg@electra.locus.ucla.edu.edu>
Newsgroups: net.lang.c
Subject: Re: Survey of C Compilers for micros
Message-ID: <410@curly.ucla-cs.ARPA>
Date: 6 Aug 86 03:52:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <419@galbp.UUCP> wolf@galbp.UUCP (Wolf) writes:
>why CI86 (Computer Inovations (?)) never made it in any of the
>survey articles.  I've had limited experience with it and have had no
>problems with it, whatsoever.  In other surveys (e.g., Byte) it was always
>in the top 3.  Have I missed something?
     
CI86 is neither very fast nor does it produce very good code. The biggie is
the number of bugs in implementation of large memory model float, double and
struct handling. CI86 (the release we had used a year ago) manages to mess up
the addressing. CI86 is comfortable to use tho', and is fine (as far as we
found!) for <64K stuff.
     
--
"... having someone special for dinner?"    Oleg Kiselev
                          _Cannibal Girls_    oleg%OACVAX.BITNET
                        oleg@LOCUS.UCLA.EDU

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7999
          for JMS@ARIZMIS; Fri,  8-AUG-1986 10:05 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020951; 8 Aug 86 4:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003729; 8 Aug 86 3:42 EDT
From: Jonathan Meltzer <jsm@vax1.ccs.cornell.edu>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Query: Public Domain C Compilers
Message-ID: <57@vax1.ccs.cornell.edu>
Date: 6 Aug 86 04:49:08 GMT
Keywords: Public Domain C  Compiler
To:       info-c@BRL-SMOKE.ARPA
     
In article <2033@calmasd.CALMA.UUCP> dmm@calmasd.UUCP (David MacMillan) writes:
>>>1) Microsoft C
>>>2) Lattice C
>>>3) Mark Williams C
>>>4) QNX C compiler
>>>5) DeSmet C compiler
>>>6) Wizard C.
>
>     On a slightly different note, does anyone know of a public
>domain / shareware C compiler for the IBM PC?  It doesn't have to
>be fancy.  Source or object are both OK, (but if source, then the
>compiler must be able to compile itself.)
>
>
>                              David M. MacMillan, KB6MPN
> "If feather-dusters are      - UCSD [Lit] (ex-UCSC/Crown)
> made of feathers, what are   - Calma/GE [Info-Sci] (ex IBM)
> crop-dusters made of?"       - UCSD Soaring Club
>           - LM, 'cellist     - SSA, USHGA, ARRL
     
     
Yes. Small-C.
Get the book "Dr Dobb's Toolbox of C". This contains reprints of the
original Dobbs articles. The code is CP/M specific, but a MS-DOS version is
available on all programming-language oriented bulletin boards.
Can anyone on the West Coast give Dave a local BBS? If not, try PC-BOSS at
1-201-568-7293 (New Jersey).  .
     
Jon Meltzer
Dept. of Modern Languages and Linguistics, Cornell University
------------------------------------------------------------------------
"Disclaimer" is a trademark of Bell Laboratories.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8392
          for JMS@ARIZMIS; Fri,  8-AUG-1986 10:25 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021024; 8 Aug 86 5:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003789; 8 Aug 86 3:44 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: void and the holy writ (!)
Message-ID: <494@opus.nbires.UUCP>
Date: 6 Aug 86 06:57:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Article <499@dg_rtp.UUCP>, from throopw@dg_rtp.UUCP (Wayne Throop)
about the ?: with void results, and in particular, his summary line of
> Summary: Look it up in Holy Writ!
...brought me to a sudden realization of C's pagan nature:
     
In C, in the beginning there was no void.
     
--
Dick Dunn    {hao,ucbvax,allegra}!nbires!rcd        (303)444-5710 x3086
   ...Never attribute to malice what can be adequately explained by stupidity.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8846
          for JMS@ARIZMIS; Fri,  8-AUG-1986 10:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/08/86 at 12:04:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021169; 8 Aug 86 6:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003926; 8 Aug 86 3:49 EDT
From: Ben Cranston <zben@umd5.ARPA>
Newsgroups: net.lang.c
Subject: Re: Generating code for the switch statement
Message-ID: <1171@umd5>
Date: 6 Aug 86 23:26:26 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <610@hropus.UUCP> ka@hropus.UUCP (Kenneth Almquist) writes:
     
> If the cases are not consecutive, the branch table must be filled with
> entries for the "missing" cases, making the table larger.  The Ritchie
> compiler will generate a branch table if the number of entries in the
> branch table would be less than three times the number of cases.
     
This bit me once.  In one of an innumerable number of Impress-understanding
programs I converted an IF nest into a switch statement, and was chagrined
when the program didn't show a vast efficiency improvement.  After peeking
at the (BSD4.x) C compiler code generator we found the 1/3 fudge factor,
and that the Impress codes were only two short of being dense enough to
compile into a jump table.  We didn't actually try this, but I suppose that
if we had defined two or three bogus Impress codes and put in cases for
them then the switch statement would have suddenly started being much more
efficient.
     
Which brings me to another point: many people seem to make their programs
"more efficient" by minimizing the size of the (higher level language)
SOURCE code, rather than minimizing the output object.  Usually these go
hand-in-hand, but the above is an interesting case where MORE source code
resulted in LESS (and FASTER) object code...
     
And we won't even TALK about MOVE CORRESPONDING or SORT...
     
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9215
          for JMS@ARIZMIS; Fri,  8-AUG-1986 11:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021245; 8 Aug 86 6:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003941; 8 Aug 86 3:50 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <5910@alice.uUCp>
Date: 6 Aug 86 13:07:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>    Consider the case where you're writing a really complex #define macro,
>and you decide that you'd like some sort of IF statement in it,
>(take a look at getchar()).  Can't you see a case where you might want to
>call a void function, and then set the value of the #define macro to be
>a side effect of the function?  Sort of like
>#define foo(c) buffer_empty?fill_buff(),first_char_in_buf:first_char_in_buf
     
No problem using a void as the LHS of a comma operator, just as
there's no problem using a void before a semicolon.
     
Of course, you'd better parenthesize:
     
    #define foo(c) (empty?(fill(),first):first)
     
Moreover, fill() probably returns a value you don't want to ignore,
so maybe you should write it to return either the value of first or
an error code.  You can then write
     
    (empty?fill():first)
     
which avoids the void issue altogether.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9643
          for JMS@ARIZMIS; Fri,  8-AUG-1986 11:44 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/08/86 at 12:33:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021436; 8 Aug 86 7:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004319; 8 Aug 86 3:54 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <513@hadron.UUCP>
Date: 5 Aug 86 13:58:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I have seen several references to the address of an array vs.
the address of the first element of the array.  Would someone
care to address what they think this difference is, aside from
data type?  I.e., it is clear that the types *int and *(int[])
should be different.  But the values should be the same:
    int countdown[] = { 10, 9, 8, ... };
        gives something like
    _countdown:
    =>    .word 10
        .word 9
        .word 8
        ...
The values of both addresses should be the address of the word
'10'.
     
Well, yes, in some theoretical architectures I've heard tell of
pointers include arbitrary information on e.g. the size of the
object.  Any of these actually implemented?
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9407
          for JMS@ARIZMIS; Fri,  8-AUG-1986 12:02 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021247; 8 Aug 86 6:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004063; 8 Aug 86 3:52 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <2600072@ccvaxa>
Date: 6 Aug 86 00:16:00 GMT
Nf-ID: #R:ucbvax.BERKELEY.EDU:15093:ccvaxa:2600072:000:2537
Nf-From: ccvaxa.UUCP!aglew    Aug  5 19:16:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
... > Generalized switch
     
Agreed, a cascade of ifs is the way to implement a generalized
alternative statement in C:
    if( C1 )
        S1;
    else if( C2 )
        S2;
    else
        ...
     
However, in a higher level language than C there are many potential
advantages to a generalized switch (I prefer to say alternative)
statement.
     
If the expressions are complicated, eg. (in my preferred syntax
- the ::s would be blocks `a la Dijkstra if I had them)
     
    IF C1 AND C2 THEN ...
    :: C1 AND NOT C2 AND C3 THEN ...
    :: NOT C1 AND NOT C2 AND C3 THEN ...
    ELSE ...
    ENDIF
     
you probably would not want to implement them as a cascade of IFs
- you would probably want to use some sort of tree structure
    if( C1 )
        if( C2 ) ...
        else ...
    else if( !C2 && C3 ) ...
    else ...
as the expressions get more complicated so does the tree, obscuring
the original branching at one point nature of the original code.
A compiler that understood a bit about logical expressions could
generate a good tree for you, automatically.
     
In fact, if you can ascribe probabilities to each of the conditions
or branches, an optimum tree from the point of view of speed can
be easily generated automatically. I apply this Huffman algorithm
myself in my hand coding, when I have to worry about speed.
     
     
Also, the generalized alternative is not, strictly speaking, a cascade.
Ie. no two of the alternatives should simultaneously hold, in a
deterministic language (in an undeterministic language multiple
alternatives may be valid, of which one or more at random may be
taken). In this example
    IF C1 AND C2 THEN ...
    :: C1 AND C3 THEN ...
    ELSE ...
    ENDIF
C2 and C3 should not simultaneously hold if C1, for a deterministic
language. A compiler can easily generate checks for this.
     
     
Anyway, enough of that. Returning to the language I have to work in,
I have found a similar construct useful in C. Coming from an
engineering background, I am used to working in truth tables -
I like laying out functions
    Inputs        Outputs
    -----------------------
    TTT        S1
    TFT        S2
    F**        S3
In computational geometry I've gone 5 inputs deep (with lots of
don't care conditions). Laying these out as a tree of IFs obscures
the tabular nature of my understanding of the problem, but this
can be remedied with a few #defines in C:
     
    switch( boolvec(C1,C2,C3) ) {
        case TTT:    S1; break;
        case TFT:    S2; break;
        case Fxx:    S3; break;
    }
     
OK, folks, tell me I'm ...
     
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0087
          for JMS@ARIZMIS; Fri,  8-AUG-1986 12:27 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/08/86 at 12:40:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021733; 8 Aug 86 7:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004389; 8 Aug 86 3:58 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: is a void function invocation an expression or a statement?
Message-ID: <502@dg_rtp.UUCP>
Date: 6 Aug 86 20:57:43 GMT
Posted: Wed Aug  6 16:57:43 1986
To:       info-c@BRL-SMOKE.ARPA
     
>  From: aka@cbrma.UUCP (Andy Kashyap)
>  A function call is an expression and can, therefore, be used anywhere an
>  expression can be used. When you declare a function (void), you state that
>  you intend to use that function as a statement instead, that you do not
>  intend to use it in any operations. It can now only be used where a statement
>  can. Keep in mind that an expression is a statement, but NOT vice-versa.
     
Not quite the case at all.  When you declare a function void, you are
saying that its evaluation yields a void expression.  You are *NOT*
saying that it is a statement.  Again, let us consult Holy Writ on the
subject.
     
First, K&R have nothing to say about this, since void didn't exist then.
     
Harbison and Steele say (on page 150):
     
    The type of the function expression must be "function returning T"
    for some type T, in which case the result of the function call is of
    type T.  The result is not an lvalue.  If T is void, however, then
    the function call produces no result and may not be used in a
    context that requires the call to yield a result.
     
That is, function invocations are *ALWAYS* expressions.  Sometimes,
these expressions are void, that is, they have no value.  Clear enough.
     
Now let's see what the ANSI C draft standard has to say (in 2.2.2):
     
    The (nonexistent) value of a *void* *expression* (an expression that
    has type void) shall not be used in any way, and explicit or
    implicit conversions shall not be applied to such an expression.
     
(and in 3)
     
    An *expression* is a sequence of operators and operands that
    specifies how to compute a value, or (in the case of a void
    expression) how to generate side effects.
     
Again, fairly clear.  Void "thingies" (how's that for a technical term,
eh?) are expressions, and *NOT* statements.  (That is, not statements
except in the sense that all expressions are statements in C, right?)
The only surprising thing here is that not all expressions return values
when they are evaluated.  But this "surprise" in implicit in the meaning
of "voidness".
     
(As a small nit, I'd druther that the draft standard would allow a void
 expression to be cast to void, but that's a fairly small quibble.)
     
--
There are some forms of insanity which, driven to an ultimate
expression, can become the new models of sanity.
                                --- Bureau of Sabotage {Frank Herbert}
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0582
          for JMS@ARIZMIS; Fri,  8-AUG-1986 12:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022307; 8 Aug 86 8:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007562; 8 Aug 86 5:52 EDT
From: Jonathan Leech <jon%amdahl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <3523@amdahl.UUCP>
Date: 7 Aug 86 19:51:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <513@hadron.UUCP>, jsdy@hadron.UUCP (Joseph S. D. Yao) writes:
> I have seen several references to the address of an array vs.
> the address of the first element of the array.  Would someone
> care to address what they think this difference is, aside from
> data type?  I.e., it is clear that the types *int and *(int[])
> should be different.  But the values should be the same:
>     int countdown[] = { 10, 9, 8, ... };
>         gives something like
>     _countdown:
>     =>    .word 10
>         .word 9
>         .word 8
>         ...
> The values of both addresses should be the address of the word
> '10'.
>
> Well, yes, in some theoretical architectures I've heard tell of
> pointers include arbitrary information on e.g. the size of the
> object.  Any of these actually implemented?
     
    You could implement pointers as a triple:
     
    (low address, length, offset of current member)
     
    for range checking. Doesn't the Symbolics machine do something like
this? I recall a reference in a C compiler manual for the Symbolics but
have never actually used the machine or compiler.
     
    -- Jon Leech (...seismo!amdahl!jon)
    UTS Products / Amdahl Corporation
    __@/

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0876
          for JMS@ARIZMIS; Fri,  8-AUG-1986 12:55 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022375; 8 Aug 86 8:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007969; 8 Aug 86 5:58 EDT
From: Jerry Carlin <jmc%ptsfa.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Generic Packages
Message-ID: <1528@ptsfa.UUCP>
Date: 7 Aug 86 16:41:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In the August, 1986 issue of SIGPLAN Notices (ACM Programming Languages SIG)
there is an article on Generic Packages in C.
     
Abstract: "The structuring achieved by generic packages in Ada can be
chapely emulated in C by judicious use of the preprocessor. Two files
are required for the generic package: the specification and the body. Two
more files are used in the instantiation: one holding the instantiation
parameters and one with auxiliary code. Instantiation results in normal
C header and object files (*.h and *.o). Dependency control can be delegated
to the make program."
     
Ada "generic packages" are a way of allowing the use of 'types' as
parameters.
     
--
voice= 415 823-2441
uucp={ihnp4,dual,qantel}!ptsfa!jmc

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1140
          for JMS@ARIZMIS; Fri,  8-AUG-1986 20:46 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022519; 8 Aug 86 8:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008035; 8 Aug 86 6:00 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <86900006@haddock>
Date: 7 Aug 86 16:54:00 GMT
Nf-ID: #R:ucbvax.BERKELEY.EDU:15093:haddock:86900006:000:2910
Nf-From: haddock!karl    Aug  7 12:54:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
barmar@mit-eddie.MIT.EDU (Barry Margolin) writes:
>It might, however, be reasonable to extend the case statement to not
>require all the cases to be constants.  This would still provide the
>first two features I listed; the compiler would have to do a bit more
>work to determine if the construct can be translated into a jump table.
     
But switch as currently implemented always matches exactly one case
(assuming an implicit "default: break;" if necessary).  I like switch to be
commutative, i.e. case blocks to be interchangeable; I think this idea is a
step in the wrong direction.  (I realize that switch is not quite
commutative now, because of fallthrough.  I'd like to see this "feature"
phased out, too.  "Warning: case label entered from above"?)
     
Now, some constructive counterproposals.
     
I think one should be able to specify a list.  "case 1,4,10:" is neater than
"case 1: case 4: case 10:", and shoots down the obvious objection to my
comment about fallthrough.  (Yes, I know there are more subtle objections.
I'm willing to use a goto for them, if switch gets cleaned up.)
     
Better yet would be a list of ranges.  "case 'a' to 'z', 'A' to 'Z':"
requires 52 labels in the current syntax; this is where I normally rewrite
as if-else.  (Yes, I know that's better anyway because I can use the more
portable test isletter().  But there are other uses for range cases, and
one could always "#define UPPER 'A' to 'I', 'J' to 'R', 'S' to 'Z'" for
EBCDIC systems, to retain portability.)  It should also be possible to
specify open-ended ranges, to allow things like "switch (strcmp(s, t)) {
case LT: ... case EQ: ... case GT: ... }" where LT and GT are #define'd as
intervals extending to minus and plus infinity.
     
Syntactic issues: I introduced a new keyword "to" in the above.  This should
be a punctuation mark instead, but "-" already has meaning in this context.
(If backward compatibility were not a problem, "case 'a'-'z':" could still
be interpreted as a range, and expression containing minus would have to be
enclosed in parens -- but that would be too confusing.)  The ellipsis mark
"..." could be used, I suppose; I don't see any confusion with the varargs
function prototype notation.  Interval notation like "['a','z']" is another
interesting possibility*; it allows for both open "()" and closed "[]"
intervals, as well as mixed: "case [0,N): return a[i];".  But I don't think
the user community is ready for misbalanced hooklets**.
     
Btw, note that the use of comma is not a problem since the comma operator is
not permitted in constant expressions***.  (Nor would it be useful.)
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint
*   "[a,b)" is the American notation for a half-open interval.  The European
    notation is "[a,b[", which would be even worse.
**  hooklet: generic bracket.  See discussion in net.lang.
*** According to X3J11 draft of May, 1986 (page 48, line 12).

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0700
          for JMS@ARIZMIS; Fri,  8-AUG-1986 21:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a022339; 8 Aug 86 8:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007570; 8 Aug 86 5:53 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Generating code for the switch statement
Message-ID: <2784@umcp-cs.UUCP>
Date: 7 Aug 86 21:22:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <610@hropus.UUCP> ka@hropus.UUCP (Kenneth Almquist) writes:
>>If the cases are not consecutive, the branch table must be filled with
>>entries for the "missing" cases, making the table larger [; eventually
>>this becomes a waste of space and the compiler uses a different approach].
     
In article <1171@umd5> zben@umd5.umd.edu (Ben Cranston) writes:
>... In one of an innumerable number of Impress-understanding
>programs I converted an IF nest into a switch statement, and was
>chagrined when the program didn't show a vast efficiency improvement.
>After peeking at the (BSD4.x) C compiler code generator we found
>the 1/3 fudge factor, and that the Impress codes were only two
>short of being dense enough to compile into a jump table.
     
[... followed by speculation on the effects of adding two cases.]
     
One can force a consecutive sequence in another, less compiler
dependent, way.  Write a compressing array:
     
    char    input_class[256] = {
        /* classes for 0-127 */
        is_char, is_char, ..., is_char,
        /* classes for 128 on up */
        is_obj1, is_obj2, is_obj2, is_badobj, is_obj1, ...
    };
     
Then use
     
    switch (input_class[input]) {
    case is_char:
        ...
    case is_obj1:
        ...
    }
     
Those who are familiar with Knuth's TeX system may have seen some
of the code supplied to convert TeX .DVI files to device-dependent
data (a la Imagen's imPress language).  In these, someone---Knuth
himself most likely---has written code of the form
     
    /* translated to C for this newsgroup */
    #define two_cases(base) \
            base: case base+1
    #define four_cases(base) \
            two_cases(base): case two_cases(base+2)
    #define eight_cases(base) \
            four_cases(base): case four_cases(base+4)
    #define thirty_two_cases(base) \
            eight_cases(base): case eight_cases(base+8): \
            case eight_cases(base+16): case eight_cases(base+24)
    #define    sixty_four_cases(base) \
            thirty_two_cases(base): case thirty_two_cases(base+32)
     
then, later in the program, used these as (e.g.)
     
    #define w0    147
    ...
    #define    fntnum0    171
    ...
     
        case four_cases(w0):
            w = p;
            x += w;
            break;
        ...
     
        case sixty_four_cases(fntnum0):
            font = p;
            break;
        ...
     
I originally used rather similar code in my own Imagen and Versatec
DVI conversion programs.  For some reason I decided one day to try
a compressing array like the one above.  To my surprise, the code
was not only clearer to me, but also ran rather faster.  I verified
that the generated code indeed used a vax `casel' instruction in
both versions.  My guess is that the speedup came entirely from
fitting more of the main loop into the cache.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9579
          for JMS@ARIZMIS; Sat,  9-AUG-1986 00:07 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000798; 2 Aug 86 23:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019205; 2 Aug 86 13:41 EDT
From: "Gordon V. Cormack" <gvcormack%watmum.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Interactive I/O in Pascal
Message-ID: <563@watmum.UUCP>
Date: 2 Aug 86 11:22:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
> Am I missing something?
>
> Is there some characteristic of the Pascal language that prevents
> construction of a Pascal standard I/O package that *would* be as powerful
> as that of C?  Perhaps the existence of this characteristic is implicit in
> this discussion and that is what I am missing.
     
There are lots of reasons one can't write printf in Pascal, and they
all contribute to the conclusion that Pascal is garbage.  Just
for starters, you can't (in Wirth's Pascal, anyway) even write
a procedure that takes a quoted string as a parameter, unless its
length is hard coded.  Next, you can't write a procedure that takes
a variable number of parameters.  Finally, you can't write a
*polymorphic* procedure that operates on many types, nor can you
even overload the name "printf" to make it apply to many types.
     
I wouldn't want anyone to take this article as support for C.
For a long time I have been suppressing the urge to post an article
to the effect:
     
   STOP!!  You're both wrong.
--
Gordon V. Cormack      CS Department, University of Waterloo
uucp:  { allegra, decvax, ... }!watmath!gvcormack
csnet: gvcormack%watmum@waterloo
cdn:   gvcormack@mum.waterloo.cdn

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9389
          for JMS@ARIZMIS; Sat,  9-AUG-1986 00:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000916; 3 Aug 86 0:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019210; 2 Aug 86 13:41 EDT
From: "Gordon V. Cormack" <gvcormack%watmum.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: I/O in Algol (was I/O in Pascal)
Message-ID: <564@watmum.UUCP>
Date: 2 Aug 86 11:42:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> ...  Unfortunately, I/O libraries are not something that can be
> tacked on later.  I/O affects the definition of the language.  This is
> one of the most serious problems with the languges in the Algol
> tradition.  There is a tendency to think I/O is a detail unfit for
> computer scientists, which can be left to the "standard prolog".
     
Algol 68 treats I/O at great length.  I think it is more in the
"algol tradition" than Pascal, which is best characterised as
the anti-algol.
     
Algol 68, unlike Pascal, is sufficiently extensible to do a reasonable
(if not great; but then C is hardly great) job of defining routines
like printf.  For example, the following routine gives something
like what is needed:
     
MODE PRINTABLE = UNION(INTEGER, REAL, ... )
     
PROC printf = ( [] CHAR f, [] PRINTABLE ) VOID : BEGIN ... END
     
printf(" %d  hi there %f \n", (123, 0.123))
     
     
Over the past decade, we have seen endless discussions comparing
brain-damaged languages like Pascal and C, and the design of the
Ada, all without learning from the successes (and mistakes) of
Algol 68.
--
Gordon V. Cormack      CS Department, University of Waterloo
uucp:  { allegra, decvax, ... }!watmath!gvcormack
csnet: gvcormack%watmum@waterloo
cdn:   gvcormack@mum.waterloo.cdn

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9639
          for JMS@ARIZMIS; Sat,  9-AUG-1986 00:29 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/05/86 at 00:48:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000794; 2 Aug 86 23:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019189; 2 Aug 86 13:40 EDT
From: Rob Brunner X2830 <brunner%sdsioa.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Another bug in C compilers
Message-ID: <161@sdsioa.UUCP>
Date: 1 Aug 86 17:39:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I believe I've found a bug in the C compiler for the Sys 5 Rel 2 3B20.
> Say we have a structure declared as:
> struct ABC
> {
>     stuff
> };
> and then follow it with:
> struct ABC;
> ... no error ....
Which is equivalent to using:
int ;
as far as basic parsing is concerned.
     
This is NOT A BUG, but a feature...  If you look in K&R on pages 215,216
(in section 18.2-Declarations) you'll see essentially the following:
     
declaration:
     decl-specs init-decl-list[opt] ;    /* init-decl-list left out above */
...                     /* this is the key... you normally */
                     /* use something like 'int k;' this */
                     /* allows 'int ;'   */
decl-specs:
     type-spec decl-specs[opt] ;     /* decl-specs left out above */
...
type-spec:
     ...
     struct-or-union-spec
     ...
struct-or-union-spec:
     ...
     struct identifier
     ...
     
Why this would ever be done is beyond me.  Anyone have any applications
of this (and want to admit it)?  It might not be useful, but it is
certainly legal.
--
Rob Brunner                              email:
Scripps Institution of Oceanography      brunner@sdsioa.UUCP
Mail Code A-010, UC San Diego            sdsioa!brunner@sdcsvax
San Diego, CA 92093                      {backbone}!sdcsvax!sdsioa!brunner
Phone: (619) 534-2040 (work)             (619) 452-7656 (home)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6000
          for JMS@ARIZMIS; Mon, 11-AUG-1986 16:10 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/11/86 at 16:16:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010598; 10 Aug 86 18:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003355; 10 Aug 86 17:46 EDT
From: guy%sun.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: unix documentation (was Question on getopt())
Message-ID: <5921@sun.uucp>
Date: 7 Aug 86 07:36:54 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Biggest surprise:  of the more than 100 users on our system, only *4* are
> allowed to look at UNIX software.
     
The person in question worked at Bellcore, not UCSD, so UCSD's policies may
or may not be relevant.
     
> Are only local gurus supposed to use library functions?
     
No.  I never said that, and I'm getting tired of people inferring that I
believe that.  It *is*, however, the case that with many (if not most) UNIX
systems, anybody who *isn't* a local guru may end up getting caught by the
crappy UNIX documentation.  If you have source, you should check it if you
have any suspicion whatsoever that the UNIX documentation may not be
correct.  If you don't have source, either find somebody who does or test
the function yourself (if practical) before using it.  Asking the vendor may
or may not do any good; they may just read you the documentation.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6194
          for JMS@ARIZMIS; Mon, 11-AUG-1986 16:12 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010664; 10 Aug 86 18:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003843; 10 Aug 86 18:02 EDT
From: ignatz%aicchi.uucp@BRL.ARPA
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <783@aicchi.UUCP>
Date: 8 Aug 86 04:04:15 GMT
Keywords: 'C' compilers, Aztec
To:       info-c@BRL-SMOKE.ARPA
     
Two bits of information.  First, the August '86 Dr. Dobbs has a very good,
fairly comprehensive survey of the competetive 'C' compilers available
for MS-DOS; additionally, on Compuserve, they've provided 'electronic
updates' to compensate for 'publishing lag' (about two months) between
review and publishing.  Far too long to even paraphrase or summarize here,
it's one of the few 'C' reviews that I've seen that seems to use people
who aren't just familiar with (and thereby tout) one or two compilers,
and don't make blatantly incorrect statements about systems through a lack
of knowledge.  Although they don't fall into the trap of unequivocally
declaring any one compiler 'best for all things', it's obvious that Microsoft
4.0 is a big winner; as is IBM 'C' (Not surprising, as it's essentially
Microsoft 'C' repackaged by Big (bumbling) Blue).
     
In all the hooraw, I'm surprised that no one has mentioned Aztec 'C', especially
the Commercial Development system.  Although it's got shortcomings, it's
quite Unix compatible, and comes with quite a spread of libraries and memory
models (AND you get the complete source to all library routines!), as well
as providing a rather nice Unix-ish development environment; things such
as grep, make, 'z', diff, and a fistful of other utilities.  In addition,
the assembler is complete enough to use in it's own right, and you can
also generate ROMable code.  For the price, quite reasonable; and it shows
acceptably in the Dr. Dobb's survey.
     
Dr. Dobbs also indicates that High 'C', Wizard 'C', and Datalight 'C'
are also worth checking out, depending on your needs.  Also keep in mind
that an outfit in, I believe, Canada, is offering quite a suite of Unix
tools for MS-DOS for only about $50 US.
     
--
    Dave Ihnat
    Analysts International Corporation
    (312) 882-4673
    ihnp4!aicchi!ignatz || ihnp4!homebru!ignatz

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4095
          for JMS@ARIZMIS; Tue, 12-AUG-1986 01:20 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 03:05:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010668; 10 Aug 86 18:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004527; 10 Aug 86 18:12 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)  WHY I THINK IT'S *OK* ( or should be )
Message-ID: <2278@watmath.UUCP>
Date: 7 Aug 86 14:34:31 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Lint obviously does *some* analysis of this, since it can say
> "constant in conditional context". BTW, I have a program that gives
> that error, but the expression is in an ARRAY DIMENSION for crissake.
>         char foo[ THING1 > THING2 ? THING1 : THING2 ];
> Obviously it's going to be a constant. Any lint authors listening?
> Turn that off when a constant expression is called for. While I'm
> wishing for things, I wanna see 'assignment in conditional context'.
> We all know why by now...
     
     
------/usr/src/lib/mip/cgram.y------(look for "con_e:")
     
/*    EXPRESSIONS    */
con_e:        {
#ifdef LINT
                {extern int constexp;}
                constexp=1;
#endif
                $<intval>$=instruct; stwart=instruct=0;
            } e
            %prec CM
            ={
                $$ = icons( $2 );
                instruct=$<intval>1;
#ifdef LINT
                constexp=0;
#endif
            }
        ;
.e:           e
     
     
------/usr/src/lib/mip/trees.c------(look for warning message)
     
    case BRANCH:
    ccwarn:
#ifdef LINT
        {extern int constexp;}
        if (hflag&&!constexp)
            werror("constant in conditional context");
#endif
    case PLUS:
     
     
------/usr/src/usr.bin/lint/lpass1.c------(add to definitions of externals)
     
int constexp=0;
     
     
------/usr/src/usr.bin/lint/lpass1.c------(in function contx())
     
contx( p, down, pl, pr ) register NODE *p; register *pl, *pr; {
     
    *pl = *pr = VAL;
    if (p->in.type==UNDEF) down=VAL; /* (void) cast */
     
    switch( p->in.op ){
     
    case NOT:
        *pl=down;
    case ANDAND:
    case OROR:
        if (hflag&&(p->in.right->in.op==ASSIGN))
            werror("Possible unintended assignment");
    case QUEST:
        *pr = down;
    case CBRANCH:
        if (hflag&&(p->in.left->in.op==ASSIGN))
            werror("possible unintended assignment");
        break;
     
    case SCONV:
    case PCONV:

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6287
          for JMS@ARIZMIS; Tue, 12-AUG-1986 03:31 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 05:19:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010671; 10 Aug 86 18:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004835; 10 Aug 86 18:21 EDT
From: randy%chinet.uucp@BRL.ARPA
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers
Message-ID: <467@chinet.UUCP>
Date: 9 Aug 86 19:33:09 GMT
Keywords: 'C' compilers, Aztec
To:       info-c@BRL-SMOKE.ARPA
     
In article <783@aicchi.UUCP> ignatz@aicchi.UUCP (Ihnat) writes:
>Also keep in mind
>that an outfit in, I believe, Canada, is offering quite a suite of Unix
>tools for MS-DOS for only about $50 US.
>
    That's "MKS Toolkit" by Mortice Kern Systems
                53 Bridgeport Road East
                Waterloo, Ontario
                Canada NJ2 2J4
                519 884 2251
     
    Highly recommended!  Comes with awk, cpio, cut, paste, cp, tail,
    strings and most of the applicable tools that would work on msdos.
    awk, find, and cpio are specially nice for transfering directory
    hierarchies from one hard disk to another.
     
    I think I paid about $140 for it and received it about 4 days after
    placing my order.
    (release 1.4)
     
--
.. that's the biz, sweetheart...
Randy Suess
chinet - Public Access UN*X
(312) 545 7535 (h) (312) 283 0559 (system)
..!ihnp4!chinet!randy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6555
          for JMS@ARIZMIS; Tue, 12-AUG-1986 03:40 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010689; 10 Aug 86 18:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004910; 10 Aug 86 18:25 EDT
From: tad%killer.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: C Coding Question
Message-ID: <248@killer.UUCP>
Date: 9 Aug 86 21:39:27 GMT
Keywords: Attention all nit-pickers...
To:       info-c@BRL-SMOKE.ARPA
     
[line eater fodder]
     
Hey, everybody, I discovered a "new" (new to me) way of coding such static
things as descriptions, helps, and the like.  It goes like this:
     
#include <stdio.h>
     
char *help[] = {
    "You do it this way, dummy:",
    "",
    "so on and so forth...",
    NULL
    };
     
char *description[] = {
    "I do this...",
    "no much of anything...",
    NULL
    };
     
main()
{
    say(help);
    printf("\n");
    say(description);
}
     
say(dp)
char *dp[];
{
    while (*dp != NULL)
        printf("%s\n", *dp++);
}
     
Here's the question:  Should help and description be declared char *help[]
or char **help?  Should say() be declared void, or is there some sort of
error checking I should implement?  Are there any other suggestions or
comments?  How about any other neat "tricks" anyone has discovered lately?
     
                        Tad
--
Tad Marko
..!ihnp4!killer!tad        ||    ..!ihnp4!alamo!infoswx!ntvax!tad
UNIX Connection BBS AT&T 3B2        North Texas State U. VAX 11/780
If it's not nailed down, it's mine; If I can pick it up, it's not nailed down.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6709
          for JMS@ARIZMIS; Tue, 12-AUG-1986 03:46 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011792; 11 Aug 86 3:05 EDT
Received: from mit-multics.arpa by SMOKE.BRL.ARPA id a008207; 11 Aug 86 2:55 EDT
Date:  Mon, 11 Aug 86 02:52 EDT
From:  Paul Schauble <Schauble@MIT-MULTICS.ARPA>
Subject:  Pascal to C conversion
To:  Info-C@BRL-SMOKE.ARPA
Message-ID:  <860811065221.093634@MIT-MULTICS.ARPA>
     
I believe this has been discussed before, but my archives don't go back
far enough.
     
I have been given a program to make extensions and modifications to. It
is presently about 1 megabyte source, wrtten in Digital Research Pascal.
     
This Pascal compiler is the old CP/M MT Pascal converted to MS-DOS. It
is no longer supported. I am therefore forced to move it to another
compiler and would like to consider moving to C. For this to be
practical, much of the conversion would have to be done mechanically.
     
I recall a discussion a while back about Pascal to C converters.
Unfortunately, my archives don't go back far enough. I would greatly
appreciate hearing about programs to do this translation, and would
particularly appreciate comments from anyone who has actually used one.
     
          Thanks,
          Paul
          Schauble at MIT-Multics.arpa
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6960
          for JMS@ARIZMIS; Tue, 12-AUG-1986 03:53 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 05:43:26 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011912; 11 Aug 86 4:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008346; 11 Aug 86 3:41 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: icky C code
Message-ID: <3221@utcsri.UUCP>
Date: 4 Aug 86 03:28:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <19880@rochester.ARPA> crowl@rochtest.UUCP (Lawrence Crowl) writes:
>In article <3117@utcsri.UUCP>, greg@utcsri.UUCP (Gregory Smith) writes:
>> From a code efficiency
>> standpoint, for example, a 68000 should return int's in D0 and all pointer
>> types in A0, which would break the above. ( Somebody pointed out that a
>> certain 68K compiler has an option to return both types in *both* regs ).
>
>Since there is no type checking between an external definition of a function
     
    There is lint, which does this.
     
>and its actual definition, a programmer could implicitly type cast by listing
>the external definition with a different return type than the actual.  If
>integers are put in D0 and addresses in A0, then the calling function would
>grab the return value from the wrong register.
>
>So, the optimization would probably break some programs.
     
Very likely, but only incorrect ones. This 'implicit casting' is not
legal C. It is much the same as passing an int to a function which
expects a struct containing a single int - it will usually work, but if
(when) it doesn't, the programmer is at fault. Would you call that
'implicit casting'?
     
 I assert that a 68K C implementation could be made which returns
pointers in A0 and ints in D0, and no lintable program would be broken.
(If this is not the case, then lint needs work :-) )
     
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7032
          for JMS@ARIZMIS; Tue, 12-AUG-1986 03:55 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011915; 11 Aug 86 4:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008368; 11 Aug 86 3:42 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)
Message-ID: <7032@utzoo.UUCP>
Date: 8 Aug 86 20:39:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> we are working on a stdio-like library at waterloo which looks very
> similar to this.  Checking the value returned by putchar() every
> single time can be quite a waste...
> The solution we use is to have the _WriteBuf function, instead of
> returning an indication of error, either print the message and
> exit itself, or "raise an event" that can be trapped in the user's
> code (signals or longjumps).  [This wins big.]
     
On the whole I think this an excellent idea... but Ray, is it too late
to convince the people involved *not* to use signals for communications?
This has long been recognized as a bad idea.  And it's so unnecessary
in this case, and related ones:  it suffices to say that whenever the
_WriteBuf function fails, it calls (say) _WBerror with some suitable
parameters, and the user can substitute his own _WBerror function if he
doesn't like the default one.  This gets much of the benefit without
the various problems and unportabilities of signals.
--
                Henry Spencer @ U of Toronto Zoology
                {allegra,ihnp4,decvax,pyramid}!utzoo!henry

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7142
          for JMS@ARIZMIS; Tue, 12-AUG-1986 03:59 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011918; 11 Aug 86 4:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008386; 11 Aug 86 3:43 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Coding Question
Message-ID: <6017@sun.uucp>
Date: 10 Aug 86 23:20:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Here's the question:  Should help and description be declared char *help[]
> or char **help?
     
Since you've already shown a declaration for them, and since you've done it
correctly, I'm not sure why you're asking.  Since "help" would be an array
of pointers to characters, which is in no way equivalent to a pointer to a
pointer to a character, you obviously declare it as such - "char *help[]".
Try it the other way ('char **help = { "foo", "bar", ... };') and the
compiler will let you know, in no uncertain terms, that it's not correct.
     
> Should say() be declared void, or is there some sort of error checking I
> should implement?
     
That depends on whether you can do anything useful if you detect an error.
For example, it's rarely useful to check for errors on an "fprintf" to
"stderr" - if it fails, what can you do, print a message to "stderr"
indicating you can't print a message to "stderr"?  (The VMS routine that
prints error messages never returns a failure indication, probably for much
the same reason.)  Even if you have something useful to do on an error, you
may want to do it entirely within "say".
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7233
          for JMS@ARIZMIS; Tue, 12-AUG-1986 04:03 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013296; 11 Aug 86 8:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010342; 11 Aug 86 7:40 EDT
From: Tom Stockfisch <tps%sdchem.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: uses of void
Message-ID: <277@sdchema.sdchem.UUCP>
Date: 11 Aug 86 01:22:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I want to be able to use "void *" in a generic sorting function and I tried
something like
     
    sort( (void *)&foo[0], (void *)&foo[20], sizeof(foo), compare_foos );
    .
    .
    .
    void
    sort( beg, end, size, compare )
        void    *beg, *end;
        int    size;
        int    (*compare)();
    {
        int    nelements =    (end - beg) / size;
     
        for ( p = beg;  p < end;  p += size )
            ...;
        ...
    }
     
My compiler (4.2BSD running on a Celerity) when into an infinite loop trying
to parse
     
        (end - beg)
     
I (naively?) thought that pointer arithmetic would work with "void *", and
that it would work in the same abstract units as "sizeof()", so that all
previous generic "char *" kludges could be replaced by "void *".
     
What are the (proposed and current) legal operations for "void *" besides
assignment, casting, and passing as a parameter?
     
-- Tom Stockfisch, UCSD Chemistry
--
     
-- Tom Stockfisch, UCSD Chemistry

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7416
          for JMS@ARIZMIS; Tue, 12-AUG-1986 04:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019408; 11 Aug 86 11:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019297; 11 Aug 86 11:32 EDT
From: mouse%mcgill-vision.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <477@mcgill-vision.UUCP>
Date: 9 Aug 86 10:13:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[ > through >>>> re &array ]
>> If you think about it, a pointer to an int can be used (and is) as a
>> pointer to an array of ints. Unless you apply ++ to it, they are the
>> same thing.  (I can already feel the flames approaching).
> I assume Jim really means "unless you apply ++, --, [], *, +, -, +=, or
> -=" (unless I'm overlooking one).  That is, unless you use it in
> arithmetic, subscripting, or indirection.  Sort of covers what you can
> do with a pointer, doesn't it?
     
You are overlooking something important.  They are the same thing UNTIL
the size of what the pointer points to becomes important.  These
situations are:
    ) ++
    ) --
    ) [] with a non-zero subscript
    ) +
    ) -
    ) +=
    ) -=
As for what they SHOULD be....a pointer to an array should be just
that; indirecting off it should result in an array.  There are good
reasons this isn't done; I have yet to hear an implementation suggested
that doesn't have worse flaws than the flaw currently under discussion.
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."
            - Thanatos (Piers Anthony's Bearing an Hourglass)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7477
          for JMS@ARIZMIS; Tue, 12-AUG-1986 04:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019423; 11 Aug 86 11:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019304; 11 Aug 86 11:33 EDT
From: mouse%mcgill-vision.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: RTFM vs RTFSC (Read The Friggin' Source Code)
Message-ID: <478@mcgill-vision.UUCP>
Date: 9 Aug 86 10:22:04 GMT
Followup-To: mod.computers.sun
To:       info-c@BRL-SMOKE.ARPA
     
In article <2402@phri.UUCP>, roy@phri.UUCP (Roy Smith) writes:
> In article <5530@sun.uucp> guy@sun.UUCP writes:
> [Regarding the 4.3 *and* Sys5 getopt(3) man pages being wrong]
>> Read the code, not the manual page!
> [this is why we demand source with a system] (when we recently had to
> decide between Sun and Sequent, Sequent lost largely because they
> wouldn't release source for a reasonable price).
     
Does Sun?
     
We are a university.  We bought source from Sun.  We were given the
impression that the tapes contained full source (it was a "university
package" or some such).  Second time I look at it, it's to fix a bug in
the pixrect library.  There's no source to the pixrect library!  Turns
out there's no source to dbx, cc, or pc as well.  It seems this is
barely a skeleton system!  They want to gouge us some $K ($1K-$10K, I
forget) for 7 "packages" (pixrect, cc, etc).  Suddenly a MicroVAX with
4.[23] looks much more attractive....
     
What I consider slimy is that we were given the impression (I don't
know whether we were told outright) that the first tape was full
source.  I just hope we *were* told so, in writing....
     
By the way, the bug in the pixrect library is that depth=1 pixrects
ignore the "reverse video" flag on a pr_put()....anybody got a fix?
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."
            - Thanatos (Piers Anthony's Bearing an Hourglass)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7681
          for JMS@ARIZMIS; Tue, 12-AUG-1986 04:17 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019479; 11 Aug 86 12:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019321; 11 Aug 86 11:34 EDT
From: mouse%mcgill-vision.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <480@mcgill-vision.UUCP>
Date: 9 Aug 86 10:39:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[Discussion about switch versus if/elseif]
> As I understand it, a switch/case setup compiles exactly the same as
>     if (var == const1) {.....};
>     else if (var == const2) {.....};
>     else  {default_action};
> anyway. (Or am i wrong?).
     
In a way.  They are the same in the sense that i=i+j and i+=j are the
same.  The switch expression is evaluated only once, which can be
important:
     
    switch (*bufp++)
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."
            - Thanatos (Piers Anthony's Bearing an Hourglass)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7599
          for JMS@ARIZMIS; Tue, 12-AUG-1986 04:18 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019470; 11 Aug 86 12:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019313; 11 Aug 86 11:34 EDT
From: mouse%mcgill-vision.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <479@mcgill-vision.UUCP>
Date: 9 Aug 86 10:35:33 GMT
Keywords: stdio, buffering
To:       info-c@BRL-SMOKE.ARPA
     
> I try to use stdio as often as possible for several reasons [...] but
> I feel it lacks one or two calls [...]
> a) comment on these
> b) mention their own pet stdio hates
> c) show portable ways to implement these
> d) tell me they're already implemented ==> RTFM.
     
> Addition:    fpending(fp)
(Henry Spencer comments that "the right solution to that is fselect(),
not fpending().".  I disagree; suppose you want to select on a FILE*
and on a file descriptor both?  How do you tell the difference?
     
> Addition:    finvbuf(fp)
I wanted this one, so I wrote it.  But I called mine fdumpbuf().
     
> Addition:    fslam(fp)
Interesting.  Never wanted it, though.
     
> Addition:    fbufsiz(fp), fbuftype(fp)
Never wanted 'em.
     
> An inconsistency - why is there no ungetchar(c) defined??
I have wondered.
     
Here are the things I have wanted badly enough to add to stdio:
     
fdumpbuf(FILE *f)
    Mentioned above, throws away the in-core buffer.
     
FILE *fopenfxn(int (*fxn)(), char *mode)
    Function-stream I/O.  Returns a FILE*, open for read or write
    (not both, "r+" is treated as "r").  When a character is
    written to (resp. read from) the stream, the function is
    called.  On write, the character written is passed as an
    argument; on read, the returned value is returned to the user
    (or to scanf etc).
     
FILE *fopenstr(char *str, int len, char *mode)
    An extension to sprintf() and sscanf().  This returns a stream
    which performs I/O to a string (this makes sprintf() and
    sscanf() unnecessay, though they are still convenient).
     
unfdopen(FILE *f)
    Undoes fdopen(), that is, closes the FILE* without close()ing
    the underlying file descriptor.
     
Unfdopen is trivial; fopenfxn and fopenstr are implemented by making
the stream appear unbuffered to putc and getc and then changing _flsbuf
and _filbuf to add the functionality.
     
Comments anyone?
--
                    der Mouse
     
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse@uw-beaver.arpa
     
"Come with me a few minutes, mortal, and we shall talk."
            - Thanatos (Piers Anthony's Bearing an Hourglass)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7815
          for JMS@ARIZMIS; Tue, 12-AUG-1986 04:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019603; 11 Aug 86 12:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019261; 11 Aug 86 11:31 EDT
From: franka%mmintl.uucp@BRL.ARPA
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)
Message-ID: <1701@mmintl.UUCP>
Date: 7 Aug 86 15:13:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[Not food]
     
It seems clear that according to the ANSI draft, e1?e2:e3 is legal when e2
and e3 are both void.  The next question is, should it be?
     
It seems to me that there are two different paradigms for how to interpret
the ?: operator here.  One is as an ordinary operator, which returns one of
the values of e2 or e3, depending on the value of e1.  Under this
interpretation, it does not seem to me appropriate to permit e2 and e3 void,
since in that case they have no values.
     
The other paradigm is that e1?e2:e3 is precisely one of e2 or e3, depending
on the value of e1.  This is a very reasonable interpretation; but if it
were correct, there would be one other important consequence which is not in
fact legal.  This is that when e2 and e3 are lvalues, the compound
expression should also be an lvalue.  In particular, one could write
     
e1?e2:e3 = e4;
     
which would mean the same thing as
     
if (e1) then e2 = e4; else e3 = e4;
     
(This would be permitted only if e2 and e3 had exactly the same type, of
course; one could not do this if e2 was a short and e3 a long.)
     
This seems to me like a reasonable extension to the language.  But I believe
it should be one or the other -- the draft falls uncomfortably in the middle.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8059
          for JMS@ARIZMIS; Tue, 12-AUG-1986 04:30 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 06:19:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027812; 12 Aug 86 5:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002771; 12 Aug 86 5:30 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.pascal
Subject: Re: Interactive I/O in Pascal
Message-ID: <517@hadron.UUCP>
Date: 10 Aug 86 04:34:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <5918@lanl.ARPA> crs@lanl.ARPA (Charlie Sorsby) writes:
    [attribution omitted]
>> As far as I know, the semantics of lazy I/O ...
>As I understand it, printf and scanf are not considered part of the C
>language but rather are part of the standard I/O package.  Is this also
>true for writeln and readln in Pascal?  If so, it appears that standard
>I/O packages are being compared rather than languages.  ...
     
Yes, you are missing something.  Pascal I/O is part of the language,
and not part of any library.  It is a "built-in."
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6887
          for JMS@ARIZMIS; Tue, 12-AUG-1986 05:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 05:38:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a011870; 11 Aug 86 3:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008341; 11 Aug 86 3:40 EDT
From: Gregory Smith <greg%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: expr?(void):(void)  WHY I THINK IT'S *OK* ( or should be )
Message-ID: <3220@utcsri.UUCP>
Date: 3 Aug 86 04:19:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1983@watmath.UUCP> rbutterworth@watmath.UUCP (Ray Butterworth)
 writes:
>I'm converted.  I've seen the light.  I'm studing the Bible much more
>closely.  And look what I've found:
>
>    comma-expression -> expression , expression
>    The type and value of the result are the type and value
>    of the right operand.
>                                  DMR, Chapter 7, Verse 15.
>
>But, isn't that what it says about the "?:" expression too?
>Hallelujah!  I've found a sin in our compiler.  It actually
>allows those evil "void expressions" on the right of a comma.
>Why, this means we'll have to go back through the last few
>weeks of news, take all those articles talking about void
>functions and "?:" and repost them, this time changing the
>"?:" to ",", since all the arguments in them hold equally
>well.
>
>In the meantime, I urge everyone (well, those mentioned above anyway),
>to put the follwing fix into their compilers.  I'm sure it will find
>many occurrences of this sin that may have crept into their code over
>the years.
     
BUT... BUT .... BUT...
     
you mean I can't
     
    void a(),b(),c();
     
    for( a(), b();  ... ;  a(), c() ){
     
????????????????????
    I can't even
        i = ( a(), b(), 2 );    /* b() on RHS of 1st , */
    ???
     
     
This is getting worse! ( I strongly suspect Mr Butterworth agrees with me...)
     
There are two things going on in this debate:
     
    (1) whether the Powers That Be condone e?void:void
    (2) whether it makes sense and should be allowed.
     
I haven't the foggiest about (1) but I believe strongly that it *should* be
allowed. Herein is described in brief my belief system pertaining to this.
It is based on CONTEXTS, not an original idea by any means. There are
4 contexts of importance in C: The void context, the conditional context,
the value context, and the lvalue context.
     
    - Any expression in a void context is evaluated for
      side-effects only.
    - Any expression in a conditional context is evaluated to
      see if it is zero or non-zero. ( this is only significant
      if the expression has a logical-valued operator at its top level ).
    - The value of an expression in a value context is always used.
    - There is another context, the Lvalue context, which will
      only serve to cloud this particular issue, so I will
      ignore it, and lump it under 'value'.
     
Let    EV     = expr in void context
    EC     = expr in cond context
    EX     = expr in value context.
     
Then
    STMT    ::=     EV;
        |    while( EC ) STMT
        |    do STMT while( EC );
        |    for( EV; EC ; EV )STMT
        |    switch( EX )STMT
        |    if(EC) STMT
        |    if(EC) STMT else STMT
        |    return EX;
     
The above are all of the statement forms containing expressions (maybe
I missed a few ). The operators also create a particular context:
     
    expr ::=    EC && EC
            EC || EC
            ! EC
            EC ? EE : EE        <<< looky
            EV, EE            <<< here
            < any other unary op> EX
            EX < any other binary op> EX
            EX[EX], EX(), EX++,EX--, EX(EX,..) etc etc
     
( here's the point ) I haven't said what EE is. Any expression in an EE
context has the same effective context of the ',' or '?:' operator containing
it.  I.e. the context is inherited. Thus:
     
    if( x? p: q ) i ? a : b ;
     
Since the first ?: is in a EC context, p and q are in conditional contexts.
Likewise 'a' and 'b' are in void contexts. The expressions e1 and e2 below
are in a value context:
     
    x = ( i<j? e1 : e2 );
     
Following this system, lint should complain about the second ?: below
but not the first:
     
int func(i){
    void    p(),q();
     
    i ? p(): q();            /* value of p or q thrown away */
    return (i==7)? p(): q();    /* value of p or q returned */
}
     
What really surprises me about all this... is that I always thought the
above was the Way It Is.
     
The e?void:void form is useful as the LHS of a comma op within an
expression ( esp with macros ). As has been pointed out so nicely by
rbutterworth, the VOID,VOID usage is very common, too.
     
    if( foo)    i=0, j=0;    /* i=0 and j=0 both in void context */
    j = ( i=0, x+y );        /* x + y in value context */
     
also, if you write (p(),q(),...) in any context, you expect to be allowed
to use a void q(), right? But q() is on the RHS of the first ,:
 <groups as>    ((p(),q()),...)
So the context of q() should be inherited through the inner ',' from
the LHS of the other ',' I.e., a void context.
     
This is much more than a language purity point - this kind of analysis
is necessary to generate decent testing code. If 'x<y' appears in
a conditional context, then the code merely sets the condition codes.
If it is in a value context, it must give 0 or 1. ( It is usually treated
in effect as 'x<y?1:0', i.e. the exp. is forced into a conditional
context). Also, consider
     
    if( i? j: !k )
        foobar();
which comes out as ( VAX 4.2 BSD , no -O )
     
    tstl    -4(fp)    ;    test i
    jeql    L9998    ;    if i==0 goto L9998 { and test k }
    tstl    -8(fp)    ;    test j
    jneq    L9999    ;    if j != 0 goto L9999 ( and call foobar())
    jbr    L16    ;    if( i true but j false ) skip it
L9998:
    tstl    -12(fp)    ;    i is false. is k true?
    jneq    L16    ;    skip if i false and k true.
L9999:
    calls    $0,_foobar
L16:
     
This is clearly optimal, and the compiler has obviously treated j and
!k in conditional contexts. Note the '9999' label numbers from the
code generator (L16 is from the parser for the 'if' ). If this system
is used, then the '!' operator will be 'free' in a conditional context
( on almost any machine ).
     
Lint obviously does *some* analysis of this, since it can say
"constant in conditional context". BTW, I have a program that gives
that error, but the expression is in an ARRAY DIMENSION for crissake.
        char foo[ THING1 > THING2 ? THING1 : THING2 ];
Obviously it's going to be a constant. Any lint authors listening?
Turn that off when a constant expression is called for. While I'm
wishing for things, I wanna see 'assignment in conditional context'.
We all know why by now...
     
So what's the story? Isn't this The Way It Is? Doesn't the above make
a whole lotta sense? Why the *^&%#^&%&^@ would e?void:void _in_a_void_
_context_ be considered linty?
     
     
--
"You'll need more than a Tylenol if you don't tell me where my father is!"
                        - The Ice Pirates
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9291
          for JMS@ARIZMIS; Tue, 12-AUG-1986 05:21 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 07:10:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029346; 12 Aug 86 8:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004226; 12 Aug 86 7:33 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: error events
Message-ID: <2495@watmath.UUCP>
Date: 11 Aug 86 14:24:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> On the whole I think this an excellent idea... but Ray, is it too late
> to convince the people involved *not* to use signals for communications?
> This has long been recognized as a bad idea.  And it's so unnecessary
> in this case, and related ones:  it suffices to say that whenever the
> _WriteBuf function fails, it calls (say) _WBerror with some suitable
> parameters, and the user can substitute his own _WBerror function if he
> doesn't like the default one.  This gets much of the benefit without
> the various problems and unportabilities of signals.
     
We've already rejected the idea of signals.  Our library is intended
to be a portable interface over a number of different systems and
compilers, so signals aren't always available anyway.
     
We also rejected the call-a-function approach, although this required
a lot more arguing.
     
What we actually do is provide macros to set and unset a trap.
When an error occurs, an error message is formatted (but not printed)
and a longjump is made.  If some function has set a trap, it can ignore
the error, print the message, replace or append to the message, and/or
reraise the event.  If the event isn't explicitly trapped by the program,
the event is automattically trapped by the event mechainism, which
prints the message and exits.
     
In general, most functions don't set traps.  Those that do, do it
so that they can free malloc'ed space or reset static flags before
reraising the event.
Programs only set the traps when they expect that something might
go wrong that they might know how to recover from.
     
We do lack the ability for a trap to decide that the error isn't
important and that execution should continue from the point where
the event was raised.  So far, this hasn't been a great inconvenience.
     
A lot of extra work is required in writing the library functions.
This is rewarded by a lot less work in (correctly) writing programs.
We provide "cover functions" for many libc functions.  For example
our cover for malloc() always returns a pointer to allocated memory.
There is never any need for the caller to check every time to see
if the function failed.  Thus the programs tend to look the same
as most people (incorrectly) write normal C.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1002
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:07 MST
Received: from SRI-KL.ARPA by wiscvm.arpa on 08/12/86 at 08:44:13 CDT
Received: from decwrl.DEC.COM by SRI-KL.ARPA with TCP; Sat 9 Aug 86 18:54:09-PDT
Received: from DEC-RHEA.ARPA (rhea.dec.com) by decwrl.DEC.COM (4.22.05/4.7.34)
    id AA08869; Sat, 9 Aug 86 18:54:37 pdt
Message-Id: <8608100154.AA08869@decwrl.DEC.COM>
Date: 09-Aug-1986 2148
From: blinn%furilo.DEC@decwrl.DEC.COM  (Dr. Tom @ MRO3-3 pole T14, 297-5562)
To: info-vax@SRI-KL.ARPA, blinn%furilo.DEC@decwrl.DEC.COM
Subject: Re: Solved VMS <--> TOPS-20 DECnet
     
The restriction on maximum address to 255 when the remote node is a
TOPS-20 system being front-ended by a DN20 is a restriction caused by the
software in the DN20.  If you check out your generation of the DN20
software, I bet you'll find that you set that limitation (probably by
default) when you built the software.  I'm not sure you can set it any
larger than 255 at the DN20 end (but you're welcome to try).  This should
be documented.  If it's not, submit an SPR.  But don't expect the DN20
software to get changed -- just the documentation.
     
Are you sure you really hadn't changed ANY software at the VAX end just
before this problem surfaced, including the DECnet parameters?
     
In stating that "no software changed", it's important to remember that a
change to the parameter tables for parameter driven software (like
DECnet) is equivalent to changing the software.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1889
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:07 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 09:32:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029401; 12 Aug 86 8:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004266; 12 Aug 86 7:34 EDT
From: Jack Jansen <jack%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: is a void function invocation an expression or a statement?
Message-ID: <7046@boring.mcvax.UUCP>
Date: 10 Aug 86 21:29:26 GMT
Posted: Sun Aug 10 21:29:26 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
     
Something that has been bothering me since I read the C standard (well,
read.... paged through it), and came up again after this discussion
is the following: why haven't the C standardisers treated void like
in algol-68? There, void is a fullfledged type, having only one
value, also called void. This has a number of advantages: it makes
the standard simpler, it makes compilers simpler (no more special-casing
of void in variable definitions), and it would probably make life
easier for programs that produce C as output.
     
Are there any good reasons for not making void a normal type?
--
    Jack Jansen, jack@mcvax.UUCP
    The shell is my oyster.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1864
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:08 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 09:32:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029621; 12 Aug 86 8:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004352; 12 Aug 86 7:36 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <6024@sun.uucp>
Date: 11 Aug 86 18:17:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> As for what they SHOULD be....a pointer to an array should be just
> that; indirecting off it should result in an array.  There are good
> reasons this isn't done; I have yet to hear an implementation suggested
> that doesn't have worse flaws than the flaw currently under discussion.
     
I suspect the implementors of PCC would be interested in hearing those "good
reasons", since PCC *does* implement the type "pointer to array", and if you
dereference something of that type it does yield an array (which gets
converted to a pointer into its first element, along the lines mentioned in
the ANSI C draft).  In fact, they had no choice *but* to implement that
type, since K&R clearly indicates that "pointer to array" is a valid type
(an example is given of a pointer of that type in the C Reference Manual).
It is a nuisance to generate a *value* of that type to assign to a variable
of that type, but that's another matter.
     
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1959
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:08 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 09:36:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029506; 12 Aug 86 8:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004314; 12 Aug 86 7:35 EDT
From: Dave Haynie <daveh%cbmvax.cbm.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pascal to C conversion
Message-ID: <616@cbmvax.cbmvax.cbm.UUCP>
Date: 11 Aug 86 20:59:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
> I recall a discussion a while back about Pascal to C converters.
> Unfortunately, my archives don't go back far enough. I would greatly
> appreciate hearing about programs to do this translation, and would
> particularly appreciate comments from anyone who has actually used one.
>
>           Thanks,
>           Paul
>           Schauble at MIT-Multics.arpa
     
I used one in a job I had long ago at the CMU EE department.  I believe it
was developed there as well.  The program would translate most of the
function/procedure calls, operators, types, etc.   It did have a problem
resolving the several nested levels of WITH statements that our Pascal
code had in it.  Probably the best thing to do would be to contact the
CMU EE Department, Schenley Park, Pittsburgh, PA 19380, in reference to
this code, which may still exist, and if it does, probably in better form
than it did in '82.
     
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh
     
    "I gained nothing at all from Supreme Enlightenment, and
     for that very reason it is called Supreme Enlightenment."
                            -Gotama Buddha
     
    These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2299
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 09:42:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029774; 12 Aug 86 8:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004457; 12 Aug 86 7:39 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: exception handling (was Re: expr?(void):(void))
Message-ID: <6032@sun.uucp>
Date: 11 Aug 86 20:56:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > The solution we use is to have the _WriteBuf function, instead of
> > returning an indication of error, either print the message and
> > exit itself, or "raise an event" that can be trapped in the user's
> > code (signals or longjumps).  [This wins big.]
>
> On the whole I think this an excellent idea... but Ray, is it too late
> to convince the people involved *not* to use signals for communications?
> This has long been recognized as a bad idea.  And it's so unnecessary
> in this case, and related ones:  it suffices to say that whenever the
> _WriteBuf function fails, it calls (say) _WBerror with some suitable
> parameters, and the user can substitute his own _WBerror function if he
> doesn't like the default one.  This gets much of the benefit without
> the various problems and unportabilities of signals.
     
S5 has a "software signals" package; it provides some number of software
signals (this number happens to be the same number as the number of UNIX
signals).  If you call "ssignal", it establishes a handler for the exception
with the specified number.  If you call "gsignal", it calls the exception
handler for the exception with the specified number.  If the handler is
SIG_DFL or SIG_IGN, "gsignal" doesn't call any routine.  If there is a
handler, or if the handler is SIG_IGN, "gsignal" returns 1 (i.e., "there is
an action and it has been taken).  If the handler is SIG_DFL, it returns 0
(i.e., "there is no action so you should supply the default actions").
     
This provides the same function as the "call _WBerror" scheme does, without
the disadvantage of adding this magic name to the global name space.
     
This is a fairly straightforward function, so somebody can write it given
the S5 manual page.
     
It is amusing to note that the S5 manual page for this package clains that
"this facility is used by the Standard C Library to enable users to indicate
the disposition of error conditions..."; this is, like many other claims in
the UNIX documentation, a lie, but it does indicate that they may have
intended that this package be used for this function.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2529
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:09 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000413; 12 Aug 86 8:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004196; 12 Aug 86 7:32 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900007@haddock>
Date: 11 Aug 86 01:21:00 GMT
Nf-ID: #R:watmath.UUCP:273:haddock:86900007:000:830
Nf-From: haddock!karl    Aug 10 21:21:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
[In the expression "cond ? voidf() : voidf()",]
>The void values are not thrown away!
     
True.  They are being passed to the ?: operator.
     
>Remember that (A?B:C) is an expression *returning a value*.
     
Yes, it is an expression (as opposed to a statement); however, some
expressions have type "void" (and no value).  This is (or should be)
one of them.
     
>C is giving the error because it can't determine the type.
     
No, it's giving the error because the compiler writer overlooked a case.
I'm glad X3J11 has fixed this.
     
Btw, a case where it could be useful (and where if...else won't do) is
"(cond ? voidf0() : voidf1()), intf2())" used in an integer context.  I
admit I have no plans to use this feature in the near future, but it's a
perfectly reasonable thing to allow.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2011
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:09 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 09:36:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029711; 12 Aug 86 8:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004358; 12 Aug 86 7:37 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: uses of void
Message-ID: <6025@sun.uucp>
Date: 11 Aug 86 18:33:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I want to be able to use "void *" in a generic sorting function and I tried
> something like
>     .
>     .
>     .
> My compiler (4.2BSD running on a Celerity) when into an infinite loop trying
> to parse
>
>         (end - beg)
     
Unfortunately, PCC doesn't really implement "void *".  Other compilers may
not do so either (I don't know if Celerity's compiler is PCC-based or not).
PCC doesn't catch it as illegal, but it doesn't handle it properly either
(the internal coding for the type "void *" is also used as a special
internal indication; since, at the time, the language didn't say "void *"
was OK, *obviously* nobody was going to use it so *obviously* there was no
need to make sure nobody did, right? :-().
     
> I (naively?) thought that pointer arithmetic would work with "void *", and
> that it would work in the same abstract units as "sizeof()", so that all
> previous generic "char *" kludges could be replaced by "void *".
>
> What are the (proposed and current) legal operations for "void *" besides
> assignment, casting, and passing as a parameter?
     
There are no currently legal operations involving "void *" since K&R doesn't
describe "void *" and since PCC, at least, doesn't really implement it.
(It's not impossible to implelement in PCC, but you do have to shuffle the
type coding around to allow another bit for the base type or find some other
value to use for what the encoding of "void *" is used for now.)  The ANSI C
draft of August 11, 1985 doesn't directly say anything about subtracting two
pointers of type "void *".  What it *does* say is
     
    If two pointers that do not point to members of the same
    array object are subtracted, the behavior is undefined.
     
and since you can't define an array of "void", no two pointers to "void" can
point to members of the same array object (note: "X points to Y" is
different from "X contains the address of Y", since if X points to Y X must
have the type "pointer to type of Y") so the meaning of the difference
between two pointers to "void" is undefined.
     
If you use
     
    int    nelements = ((long)end - (long)beg) / size;
     
it might work, although it's not guaranteed by the language (things might
get messy if you try raw arithmetic on an implementation where pointers
contain data other than a machine address, like type fields, ring numbers,
etc., etc.).  Note that "qsort" takes a count of elements, rather than a
pointer to the last element; this interface is easier to describe without
stepping outside the bounds of C.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2176
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:10 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 09:42:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029733; 12 Aug 86 8:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004414; 12 Aug 86 7:38 EDT
From: AAAARRRRGGGGv <argv@SRI-SPAM.ARPA>
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <6224@sri-spam.ARPA>
Date: 12 Aug 86 04:18:09 GMT
Keywords: stdio, buffering
To:       info-c@BRL-SMOKE.ARPA
     
> Here are the things I have wanted badly enough to add to stdio:
>
     
>
> FILE *fopenfxn(int (*fxn)(), char *mode)
>     Function-stream I/O.  Returns a FILE*, open for read or write
>     (not both, "r+" is treated as "r").  When a character is
>     written to (resp. read from) the stream, the function is
>     called.  On write, the character written is passed as an
>     argument; on read, the returned value is returned to the user
>     (or to scanf etc).
     
This shouldn't be that hard to do:
first, take the fildes of the open stream, set it to be asynch IO, then loop.
When data is there to be read, you'll get a SIGIO.  For some strange reason,
I seem to remember that this is can only be done on pseudo-tty's or other
types of devices (I use it frequently for windows on the SUN); so I don't know
if this will work well on normal files or sockets.
     
/* (no error checking here -- don't try this at home without mom's help! */
     
#include <fcntl.h>
...
int fd = open ("/dev/tty", 0);  /* read a tty for example */
signal (SIGIO, io_handler);  /* this proc will get a sigio if data on a stream
                   is ready to be read */
ioctl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FASYNC)); /* set async IO */
     
for (;;)
    looping_proc();
...
     
io_handler()
{
    char buf[BUFSIZ]l
    puts("Hey, there's data to be read on the fildes!");
    read(fd, buf, BUFSIZ);
    do_something_with_data(buf);
}
     
> FILE *fopenstr(char *str, int len, char *mode)
>     An extension to sprintf() and sscanf().  This returns a stream
>     which performs I/O to a string (this makes sprintf() and
>     sscanf() unnecessay, though they are still convenient).
     
I request you more fully describe this functionality. I don't see how adding
the routines of an IO library is going to speed up what sprintf and sscanf
already do.  Perhaps to do something like this would be "interesting", but
that's about it.  Again, please elaborate.
     
> unfdopen(FILE *f)
>     Undoes fdopen(), that is, closes the FILE* without close()ing
>     the underlying file descriptor.
This would be nice.
     
> Unfdopen is trivial; fopenfxn and fopenstr are implemented by making
> the stream appear unbuffered to putc and getc and then changing _flsbuf
> and _filbuf to add the functionality.
     
Looking at the source to puts (fputs) and so forth, I've found that it
is much faster to never unbuffer anything and to simply macro that which
you'd like to have "unbuffered":
#define unbuffered_puts(s,f)   fputs(s,f), fflush(f)
     
The reason for this is that if the data is unbuffered, fputs merely sets
the buffer to a buffer within the routine, sets a few flags, goes thru a
while loop, using the macro in stdio to putc to the stream, then fflushes
again, finally resettting all the flags it started with.  Finallly (not
that this has anything to do with it), it returns the last character put
to the stream (undocumented).
     
In any event, what's preventing you from free()ing the structure and leaving
the fd open?  The biggest problem with routines that people write that do
popen like
read_write_popen(command, &Stdin, &Stdout, &Stderr);
/* open a process and be able to read and write to/from it */
is that they pipe for each fildes, fdopen, and in case of error,
return without closing all open fildes's, unallocating the FILE*'s
and closing the process if necessary. A more elegant routine to
unfdopen (as you described) would be a matter of convenience.
     
     
dan  <argv@sri-spam.arpa>
     
"Wouldn't ya like to be a pointer, too...
     (be a pointer, be a double pointer, [repeat and fade])"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2679
          for JMS@ARIZMIS; Tue, 12-AUG-1986 08:19 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/12/86 at 09:52:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000455; 12 Aug 86 8:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004222; 12 Aug 86 7:33 EDT
From: Alex White <alex%mks.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Survey of C Compilers [Really MKS toolkit]
Message-ID: <166@mks.UUCP>
Date: 11 Aug 86 13:55:02 GMT
Keywords: 'C' compilers, Aztec
To:       info-c@BRL-SMOKE.ARPA
     
Since there have been 2 messages purporting to give prices on the MKS toolkit
both of which got it wrong on both sides I thought I should just post to say
it is $99US.  [Starting in September we will be shipping release 2.1 which
includes VI, along with everything already in there and a few more utilities,
all for $139US].

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6403
          for JMS@ARIZMIS; Wed, 13-AUG-1986 03:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 05:43:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020845; 13 Aug 86 6:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005257; 13 Aug 86 5:38 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <509@dg_rtp.UUCP>
Date: 11 Aug 86 17:35:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Several interesting points are raised about just what is the difference
between a pointer to an array, and a pointer to the first element of an
array.
     
> jsdy@hadron.UUCP (Joseph S. D. Yao)
> I have seen several references to the address of an array vs.
> the address of the first element of the array.  Would someone
> care to address what they think this difference is, aside from
> data type?  I.e., it is clear that the types *int and *(int[])
> should be different.  But the values should be the same:
     
What is really the case is that the first addressable element of the
array is the same as the first addressable element of the first element
of the array.  (This is not true in all languages, but must be so in C,
unless I'm overlooking something quite tricky.)
     
But one *MUST* keep in mind that this is *NOT* the same thing as saying
that the bit patterns of these pointers must be the same.  Nor is it
meaningful to say that "they have the same value".  The most one should
say is that they have the same bit-pattern on most common architectures.
     
Consider an analogous argument.  "I have seen several references to
floating point zero vs integer zero.  It is clear that the types (float)
and (int) should be different.  But the values should be the same."
(And, just as the two pointers above are "really" indicating the same
storage element, the two values are "really" indicating the same point
on the "number line".)
     
Most people see that this is bogus (I hope). And it is bogus for
*precisely* the same reason that the same statement about pointers is
bogus.  The fact that the bit patterns of these objects are the same on
most common architectures is *irrelevant*.  Because the same operations
performed on these objects give different results, and because of this
the bit patterns are best thought of as having a *different*
*interpretation*.  Given that the interpretation is different, it is at
best meaningless and at worst dangerously misleading to say that they
"have the same value".
     
(If this is what Joe meant by "only different in datatype", then I agree
 with him.  But I disagree that this is a good phrase to use to describe
 this difference.)
     
(I agree that there are interesting distinctions between the (float) vs
 (int) case and the (int *) vs (int (*)[]) case.  But these distinctions
 are (I believe) not relevant to this point.)
     
(And lastly, if I thought "a and &a[0] have the same value" meant
 "((void *)a)==((void *)&a[0]) is true", I'd agree.  But I think
 the meaning of "same value" in common use means more than this,
 so I don't agree.)
     
> jon@amdahl.UUCP (Jonathan Leech)
>> jsdy@hadron.UUCP (Joseph S. D. Yao)
     
>> Well, yes, in some theoretical architectures I've heard tell of
>> pointers include arbitrary information on e.g. the size of the
>> object.  Any of these actually implemented?
>     You could implement pointers as a triple:
>     (low address, length, offset of current member)
>     for range checking.
     
The interesting thing here is that the address of an array and the
address of the first element, under the above scheme, would *still* have
exactly the same bitwise value!
     
This odd result depends on my interpretation of "length", and is derived
from the fact that the length is used for range checking.  The point
about range checking leads to the conclusion that the length is used to
regulate pointer arithmetic, and is thus *not* the length of the item
the pointer denotes, but rather the length of valid addressing
arithmetic from the "low address".  Now, in the case of an array
declared at top level, this range is the length of the array.  But, in
C, the valid addressing range for the first element of an array declared
at top level is *still* *the* *length* *of* *the* *array*!  Thus, in
terms of the above triple, the address of the array
     
        char a[10];
     
ought to be (whatever,10,0), and the address of the first element of
this array ought also to be (whatever,10,0).
     
> mouse@mcgill-vision.UUCP (der Mouse)
> As for what they SHOULD be....a pointer to an array should be just
> that; indirecting off it should result in an array.  There are good
> reasons this isn't done;
     
I'm a little confused by this.  On most compilers I've used indirecting
a pointer to an array yields an array, so I'm not sure what is meant by
saying that it "isn't done".  Perhaps it means that this isn't common
usage?  I'll agree with that.  But nevertheless, most implementations
get this particular fine point right.
     
> I have yet to hear an implementation suggested
> that doesn't have worse flaws than the flaw currently under discussion.
     
I presume this means that most implementations of C have worse bugs than
that of allowing (&array) and returning the address of the first element
instead.  I won't argue with that.  But what I was objecting to was
elevating this common bug to a "standard feature".  I still think it
would be wrong to do so.  If it means anything (and currently it does
*NOT*), (&array) should indicate the address of the whole array, not the
address of its first element.
     
--
God made integers, all else is the work of man.
                                --- Leopold Kronecker {1823-1891}
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6465
          for JMS@ARIZMIS; Wed, 13-AUG-1986 03:50 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 05:46:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020852; 13 Aug 86 6:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005441; 13 Aug 86 5:41 EDT
From: John Gilmore <gnu%hoptoad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Can an unneeded value be void?  An APL perspective
Message-ID: <970@hoptoad.uucp>
Date: 12 Aug 86 10:00:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
This whole discussion of e? void1(): void2(); reminds me of a similar
circumstance in the APL world many years ago.
     
People were just getting around to defining a new function "execute",
which would take a character vector containing an expression and
would run it as an APL statement.  The question was:  suppose it
didn't return a value?
     
The eventual answer was that if the expression didn't return a value,
then "execute" didn't return a value either.  If somebody wanted
that value (e.g. to assign to a variable) then a "VALUE ERROR"
would occur at that point.  If the execute was a "leftmost execute"
(execute was the leftmost function on the line) then it is a
complete statement and no value is required.
     
In the context of C's ? operator, you can think of it similarly.
'?' can be allowed to return a void value in some circumstances.
If you said
     
    a = e? v1(): v2();
     
then you'd get an error -- but not "inside" the ?.  The error
arises in assignment of ?'s result, just as if you had said:
     
    a = v1();
     
This argument only seems to come up with flow-of-control operators
which can be embedded in expressions.  Traditional flow control
*statements* don't occur in expressions so nobody notices.  What
does LISP or ALGOL 68 do for this stuff?]
     
[I support the use of ? with voids but this is more to explain
how the APL world saw a similar problem, than to argue for either way.]
--
John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   jgilmore@lll-crg.arpa
             May the Source be with you!

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6632
          for JMS@ARIZMIS; Wed, 13-AUG-1986 03:52 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 05:48:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020856; 13 Aug 86 6:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005445; 13 Aug 86 5:41 EDT
From: John Gilmore <gnu%hoptoad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Checking result of fprintf(stderr
Message-ID: <971@hoptoad.uucp>
Date: 12 Aug 86 10:09:25 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6017@sun.uucp>, guy@sun.uucp (Guy Harris) writes:
>           ...it's rarely useful to check for errors on an "fprintf" to
> "stderr" - if it fails, what can you do, print a message to "stderr"
> indicating you can't print a message to "stderr"?
     
I tend to disagree.  I often run large amounts of output e.g.
from "make" into a file, directing both stdout and stderr to the file.
Any program that doesn't stop when its writes to stderr fail will cause
the console to go nuts with "file system full" messages if your
disks are as full as mine.
     
If writing to stderr fails, I suggest that your program exit()
with some exit code (like the one it uses for other unexpected
system booboos, e.g. fork() or open("/") fails).
     
I agree with Henry that it sure would be nice if stdio would
call a user-defined function upon write errors.
--
John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   jgilmore@lll-crg.arpa
             May the Source be with you!

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6812
          for JMS@ARIZMIS; Wed, 13-AUG-1986 04:05 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 06:00:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020861; 13 Aug 86 6:34 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005524; 13 Aug 86 5:44 EDT
From: Geoff Kuenning <geoff%desint.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <243@desint.UUCP>
Date: 12 Aug 86 02:40:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
While all of this discussion is very interesting and is important to
achieving a precise language definition, let us not forget that there
is *no* reason to ever write this particular expression.  Anywhere it's
useful, you can just write
     
    if (e1)
        void_e2;
    else
        void_e3;
     
This is better style anyway;  it makes use of a construct that
people are much more used to, and it makes it clearer that what you are
doing is picking one subroutine call over another, rather than something
more subtle.  If you really care about using precious lines, you can even
put it on one line.
--
     
    Geoff Kuenning
    {hplabs,ihnp4}!trwrb!desint!geoff

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6903
          for JMS@ARIZMIS; Wed, 13-AUG-1986 04:08 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020869; 13 Aug 86 6:35 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005535; 13 Aug 86 5:44 EDT
From: Barry Shein <bzs@bu-cs.ARPA>
Newsgroups: net.lang.c
Subject: Re: Question on getopt()
Message-ID: <1009@bu-cs.bu-cs.BU.EDU>
Date: 3 Aug 86 23:38:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
     
From: guy@sun.uucp (Guy Harris)
>Anybody with source has certainly learned by now that the UNIX documentation
>is only a rough approximation to the truth.  The source code is, in some
>cases, the final arbiter; in others, the documentation is correct...
     
No, no, the COMPUTER is the final arbiter. When in doubt make up a few
little code samples and see what they do. This doesn't require
sources, except your own and works well, I'm serious. It never ceases
to astound me how many times people come in to my office and ask me a
question that is amply answered with "go ask the computer, why bother
me, I can't simulate a computer as fast as it can simulate itself..."
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7027
          for JMS@ARIZMIS; Wed, 13-AUG-1986 04:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 06:10:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020889; 13 Aug 86 6:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005685; 13 Aug 86 5:48 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900008@haddock>
Date: 12 Aug 86 18:09:00 GMT
Nf-ID: #R:watmath.UUCP:273:haddock:86900008:000:864
Nf-From: haddock!karl    Aug 12 14:09:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
dg_rtp!throopw (Wayne Throop) writes:
>(As a small nit, I'd druther that the draft standard would allow a void
> expression to be cast to void, but that's a fairly small quibble.)
     
Void to void is illegal?  Sonofagun, you're right, and they even made it
explicit.  How strange.
     
Here's another restriction I just encountered: you can't typedef to void.
This is probably because typedef is syntactically a storage class specifier,
so it "looks like" an attempt to declare a void variable.
     
I was trying to declare "typedef void dead;" so that I could distinguish
between functions that return nothing (void perror(char *), setbuf(FILE *,
char *), nullf(void)) from those that don't return (dead exit(int),
abort(void), longjmp(jmp_buf, int)).  Again, it's a small quibble; I'll
just use #define instead.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7162
          for JMS@ARIZMIS; Wed, 13-AUG-1986 04:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 06:19:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020977; 13 Aug 86 6:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005436; 13 Aug 86 5:41 EDT
From: Bjarne Stroustrup <bs%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: void*
Message-ID: <5937@alice.uUCp>
Date: 12 Aug 86 03:33:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> What are the (proposed and current) legal operations for "void *" besides
> assignment, casting, and passing as a parameter?
>
> -- Tom Stockfisch, UCSD Chemistry
     
In C++, you can also use the comparison operators ==, !=, <, <=, >, >=, and the
negation operator !.
Pointer arithmetic is specifically disallowed (since you by definition do not
know the size of the object pointed to).
Conversion from any pointer type to void* is defined, but there is no conversion
the other way:
     
    char* pc = &some_char;    // OK if some_char is a char
    void* pv = &something;    // OK
    pv = pc;        // OK; standard conversion
    pc = pv;        // not OK: no standard conversion
    pc = (char*) pv;    // OK
    if (pc == pv) ...
    if (pv == 0) ...
    if (!pv) ...
    if (pv < pc) ...
     
In addition, the draft ANSI C proposal allows uncasted assignment of a void*
to a non-void pointer. This, I consider to be an unnecessary weakening of C's
type system; in the long run it will become a rather serious nuiscance.
C++ does not allow this and I hope that ANSI C will not allow it either.
     
The reason for the proposal's rule is simple. Malloc() returns a void* and
if a void* can be assigned to any pointer without a cast you can write
     
    double* pc = malloc(100*sizeof(double));
    char* pc = malloc(100);
     
rather than
     
    double* pc = (double*) malloc(100*sizeof(double));
    char* pc = (char*) malloc(100);
     
I don't consider this minor notational convenience a sufficient reason to
create a new hole in the type system. A better solution, which unfortunately
does not appear to be open to the ANSI C committee, is to have a free store
allocation operator, such as C++'s new:
     
    double* pc = new double[100];
    char* pc = new char[100];
     
An implicit coersion to void* is OK, but an implicit coersion
from void* to another pointer type is not. The reason is the former,
simply throws information and away whereas the latter implicitly ``adds''
information. Allowing the latter (as the ANSI C proposal does and C++ does not)
would provide a new way of converting types without using casts:
     
    void* p;
    double* pd;
    char* pc;
     
    pc = pd;    // illegal
    p = pd; pc = p;    // legal under the current ANSI C proposal

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7325
          for JMS@ARIZMIS; Wed, 13-AUG-1986 04:36 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 06:32:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020882; 13 Aug 86 6:36 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005619; 13 Aug 86 5:46 EDT
From: "John W. Herman" <herman%marlin.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Query: Public Domain C Compilers
Message-ID: <646@marlin.UUCP>
Date: 12 Aug 86 14:43:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Maybe small-c can be posted to the net.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7415
          for JMS@ARIZMIS; Wed, 13-AUG-1986 04:42 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 06:35:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020973; 13 Aug 86 6:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005275; 13 Aug 86 5:39 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)
Message-ID: <511@dg_rtp.UUCP>
Date: 11 Aug 86 17:39:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> franka@mmintl.UUCP (Frank Adams)
     
> It seems clear that according to the ANSI draft, e1?e2:e3 is legal when e2
> and e3 are both void.  The next question is, should it be?
> It seems to me that there are two different paradigms for how to interpret
> the ?: operator here.  One is as an ordinary operator, which returns one of
> the values of e2 or e3, depending on the value of e1.  Under this
> interpretation, it does not seem to me appropriate to permit e2 and e3 void,
> since in that case they have no values.
     
Well, not quite.  The standard takes the position that, while a void
expression has no value, it has something that is close enough for
government work.  A way to think of is that a void expression indicates
a "value" which requires no storage and has no legal operations (other
than selection operations).  Then specifically, the ?: operation chooses
which of these odd non-value values to "evaluate".
     
> The other paradigm is that e1?e2:e3 is precisely one of e2 or e3, depending
> on the value of e1.
     
Yes.  The standard doesn't go this way.  But I think it is reasonable
for the standard to go the way it does, making void expressions legal
wherever any other expressions are, except that their result is illegal
as input for any but selection operations, such as (?:) and (,).  Any
other operation implies an interpretation and transformation of a value,
and (void) cannot be interpreted or transformed, but these operations
only imply evaluation and selection.
     
So I agree that there are two reasonable interpretations of (?:), and
the standard has chosen the first.  But it has also chosen an
interpretation of "what it means to be (void)" which makes void
expressions to the right of a "?" reasonable.
     
--
If a listener nods his head when you're explaining your program,
wake him up.
                                --- Alan J. Perlis
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7478
          for JMS@ARIZMIS; Wed, 13-AUG-1986 04:54 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 06:39:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020983; 13 Aug 86 6:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005745; 13 Aug 86 5:50 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: ANSI C
Message-ID: <86900009@haddock>
Date: 13 Aug 86 00:22:00 GMT
Nf-ID: #N:haddock:86900009:000:5440
Nf-From: haddock!karl    Aug 12 20:22:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
ANSI C folks, please take note.
     
I've found some questionable things in the May, 1986 draft that I'd like to
open up for discussion by the net.  (I don't have a more recent copy, or even
know if there is one; my apologies if some of these issues have already been
closed.)
     
In 3.2.2.3, "(void *)0" is called a null pointer constant, though 5.6.3.12
says the value of NULL is implementation-defined.  I take this to mean that
the internal representation of (void *)0 need not have all bits clear.  The
constant 0 used in a pointer context still denotes the null pointer, but an
integer variable whose value happens to be zero need not produce the null
pointer when cast.  Also, if I have a pointer variable whose value happens
to be NULL and I cast it into int, I'll likely get the internal form (what
I'd get if I used a union) rather than zero as a result, right?  In boolean
context ("if (p)"), there is an implied comparison with NULL, not an implied
cast to int.  (In the above, I am assuming sizeof(int) == sizeof(void *).)
Do I have this right?
     
In 3.3.3 and 3.3.4, we find the definitions of
 _u_n_a_r_y_-_e_x_p_r_e_s_s_i_o_n and _c_a_s_t_-\
_e_x_p_r_e_s_s_i_o_n.  Wouldn't it have been simpler to define cast
 to be a unary
operator?  (That's the way *I* always think of it.)  In other words, it seems
one could add "( _t_y_p_e_-_n_a_m_e )
 _u_n_a_r_y_-_e_x_p_r_e_s_s_i_o_n" to the 3.3.3 syntax and move
section 3.3.4 to 3.3.3.x.  Am I overlooking something?
     
In 4.2.1.1: "If NDEBUG is defined ... use of the assert macro will have no
effect."  This needs to be clarified as follows: "The expression {shall|may|
shall not} be evaluated for side effects."  (Consider e.g. "assert(getchar()\
==EOF)", for example.)  The UNIX* version currently does not evaluate it; it
sometimes would be more useful if it did.  In any case the ambiguity needs to
be resolved.
     
In 4.7.1.1, we see that all signals are initialized to SIG_DFL, a surprising
contrast to the way things currently work on UNIX, where signals can be set
to ignore (by nohup(1) or other means) before the program starts.  I see two
interpretations:
     
    [a] SIG_DFL means "die on this signal"; programs like nohup can no longer
    be written.
     
    [b] If nohup presets the signal to be ignored, then for the duration of
    the program exec'd from it, SIG_DFL means "ignore this signal".
     
The first interpretation is clearly a problem.  The second is more subtle.  I
think "if (signal(SIGINT, SIG_IGN) == SIG_IGN) signal(SIGINT, trap);" would
now be broken, because the first signal() will return SIG_DFL rather than
SIG_IGN.
     
In 4.9.3: "When opened, the standard streams are fully buffered if and only
if the stream does not refer to an interactive device."  So, stderr isn't a
special case anymore?  (It's currently unbuffered.)
     
In 4.9.6.1 and 4.9.6.2 (fprintf and fscanf), it says that any conversion
specifier other than those listed results in undefined behavior if it's a
lower-case letter, otherwise implementation-defined behavior.  In other
words, the lower-case letters are reserved for future official releases, and
the other characters are reserved to the implementation.  This is a bad idea.
Note that the flag characters occupy the same "namespace" as the conversion
specifiers; future non-alphabetic flags could potentially clash with some
implementation's conversion specifier.  I suggest that there should be *one*
character reserved for the implementation, which can be used as a prefix.
E.g. if I want my library to have a binary-output format, I could then use
"%&b" if "&" is the prefix.  Sort of like a run-time #pragma.
     
In 4.9.6.2, the documentation for the "[" conversion specifier (which scans a
string not delimited by white space) fails to mention a range syntax, but the
example on the next page uses "%[0-9]".  Also, it fails to mention whether
one can include a right-bracket in the scanset; most implementations allow
it as the first character (following the "^", if any).  (Unless they want to
allow an empty scanset, in which case *that* should be documented.)
     
In 4.10.4.4, we see that any function (presumably the user's) which is
registered by onexit() should take zero arguments and return a value of type
onexit_t.  No mention is made of what this return value should be, or who
will look at it.  The function onexit() itself returns type onexit_t, but the
only comment is that it "compares equal to a null pointer constant" if it
succeeds.  (Aha, so onexit_t must be some kind of pointer!)  If the user is
only expected to test for success/failure, why not just return an int?  It
seems to me that this could have been declared "int onexit(void (*)(void))",
omitting the onexit_t stuff completely.
     
But, back in 4.10 it was claimed that onexit_t "is the type of both the
argument to and the value returned by the onexit function".  One wonders if
"argument to [onexit]" should have been "result of the function pointed to by
the argument to [onexit]".  If not, and we take it literally, we conclude
that "onexit_t" is a synonym for "onexit_t (*)(void)", an undeclarable type.
Someone hinted at this some months ago in an earlier posting, so maybe it's
true.  But why?
     
Finally, in 5.1.3 we have a really serious error :-).  "#error" and "#pragma"
are listed in the wrong font.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint
*UNIX is a trademark of AT&T Bell Laboratories.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9184
          for JMS@ARIZMIS; Wed, 13-AUG-1986 07:00 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/13/86 at 08:52:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025438; 13 Aug 86 9:44 EDT
Received: from bbn-labs-b.arpa by SMOKE.BRL.ARPA id a011751; 13 Aug 86 9:32 EDT
To: Geoff Kuenning <geoff%desint.uucp@bbn-labs-b.ARPA>
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
In-reply-to: Your message of 12 Aug 86 02:40:18 GMT.
         <243@desint.UUCP>
Date: 13 Aug 86 09:24:36 EDT (Wed)
From: Rick Genter <rgenter@bbn-labs-b.ARPA>
     
     You obviously missed the article describing where e1 ? void_e2 : void_e3
is useful as the left part of a comma expression, and also within a macro.
In these cases, you can *not* use an if statement.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9880
          for JMS@ARIZMIS; Thu, 14-AUG-1986 03:14 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/14/86 at 05:10:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008968; 14 Aug 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015136; 14 Aug 86 5:42 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <86900010@haddock>
Date: 13 Aug 86 17:03:00 GMT
Nf-ID: #R:hadron.UUCP:513:haddock:86900010:000:1082
Nf-From: haddock!karl    Aug 13 13:03:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
hadron!jsdy writes:
>I have seen several references to the address of an array vs.
>the address of the first element of the array.  Would someone
>care to address what they think this difference is, aside from
>data type?
     
On most machines, as you imply, &a and &a[0] do indeed have the same
bit-pattern, and will compare equal if you cast them to a common type.
If, however, you want to *do* something with the pointer (*, [], +, -,
++, --, etc.) you'd better have the correct type as well as value.  In
particular, the effect of ++p on an int(*)[] is not the same as on an int*.
     
Btw, someone suggested earlier that ANSI C doesn't interpret &a as pointer
to array.  I think it does: "The operand of the unary & operator shall be
a function locator or an lvalue [other than bit-field or register].  ...
The result ... is a pointer to the object [and has type] `pointer to
 _t_y_p_e'."
(3.3.3.2, 01-May-1986 draft.)  Arrays are not mentioned as a special case.
And yes, arrays *are* (non-modifiable) lvalues in X3J11.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0318
          for JMS@ARIZMIS; Thu, 14-AUG-1986 03:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/14/86 at 05:27:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009109; 14 Aug 86 6:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015417; 14 Aug 86 5:49 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <1716@mmintl.UUCP>
Date: 11 Aug 86 17:28:21 GMT
Posted: Mon Aug 11 13:28:21 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <2600072@ccvaxa> aglew@ccvaxa.UUCP writes:
>C2 and C3 should not simultaneously hold if C1, for a deterministic
>language. A compiler can easily generate checks for this.
     
A compiler can easily generate checks for certain simple cases of this.  It
cannot generate checks which are guaranteed to work; the problem is
undecidable in general.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0255
          for JMS@ARIZMIS; Thu, 14-AUG-1986 03:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/14/86 at 05:26:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009041; 14 Aug 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015334; 14 Aug 86 5:46 EDT
From: Mike Schloss <mike%enmasse.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <354@enmasse.UUCP>
Date: 14 Aug 86 03:49:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
->[Discussion about switch versus if/elseif]
->> As I understand it, a switch/case setup compiles exactly the same as
->>     if (var == const1) {.....};
->>     else if (var == const2) {.....};
->>     else  {default_action};
->> anyway. (Or am i wrong?).
->
->In a way.  They are the same in the sense that i=i+j and i+=j are the
->same.  The switch expression is evaluated only once, which can be
->important:
->
->    switch (*bufp++)
     
One other difference is that case statements are optimized by some compilers
to use jump tables and such so they can be much more efficient than repeated
if/else statements.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0029
          for JMS@ARIZMIS; Thu, 14-AUG-1986 03:34 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/14/86 at 05:10:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009000; 14 Aug 86 6:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015318; 14 Aug 86 5:46 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: e1?(void_e2):(void_e3)
Message-ID: <2938@umcp-cs.UUCP>
Date: 14 Aug 86 03:01:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <243@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes:
>... let us not forget that there is *no* reason to ever write this
>particular expression.  Anywhere it's useful, you can just write
>
>    if (e1)
>        void_e2;
>    else
>        void_e3;
     
Not so!  The above is a statement, while `e1 ? void_e2 : void_e3' is an
expression; and expressions are useful in macros:
     
    #define strange()    ((e1 ? void_e2 : void_e3), arbitrary_e4)
     
Using
     
    #define    strange()    if (e1) void_e2; else void_e3; arbitrary_e4
     
means that
     
    if (x) strange(); else ...
     
no longer works.
     
As a last resort, I now use the following for inline functions
returning void:
     
    #ifdef lint
    #define _false_ rand()
    #else
    #define _false_ 0
    #endif
     
    #define    strange() \
        do { \
            s1; \
            ... \
            sn; \
        } while (_false_)
     
The funny `_false_' keeps lint from warning about constants in
conditional contexts.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5401
          for JMS@ARIZMIS; Thu, 14-AUG-1986 21:47 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/14/86 at 23:42:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027316; 15 Aug 86 0:33 EDT
Received: from xerox.com by SMOKE.BRL.ARPA id a007484; 14 Aug 86 18:44 EDT
Received: from CheninBlanc.ms by ArpaGateway.ms ; 14 AUG 86 09:51:36 PDT
Date: Thu, 14 Aug 86 09:48 PDT
From: nsalvador.ES@xerox.ARPA
Subject: C compilers
To: info-c@BRL-SMOKE.ARPA
cc: nsalvador.ES@xerox.ARPA
Message-ID: <860814-095136-4516@Xerox>
     
     
     
I know there's been a recent/ongoing discussion on C compilers.
Unfortunately, I haven't saved the responses.  If anyone has these
particular messages archived and can forward them to me, I would
appreciate it.  If not, I'd like to request a list of C compilers that
run on the PC.  I'm interested in pros, cons, comparisons, and costs (if
known) of the aforementioned compilers.
     
I'm also interested in finding out about any public domain C compilers
that run on the PC.  Thanks in advance.
     
     
Naomi
     

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8202
          for JMS@ARIZMIS; Fri, 15-AUG-1986 03:13 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/15/86 at 05:10:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028088; 15 Aug 86 6:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011527; 15 Aug 86 5:37 EDT
From: "Dave K. Miyashiro 45880 CB x2003 JL" <dkm%cbdkc1.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Simulation in C
Message-ID: <1525@cbdkc1.UUCP>
Date: 13 Aug 86 20:45:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I would like to do some discrete event simulation in C.
Before I start writing the necessary routines I just
thought I would ask if anyone has already tried this.
     
Please e-mail replies to cbosgd!cbdkc1!dkm.
     
Dave Miyashiro, AT&T NS - Columbus, OH.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8246
          for JMS@ARIZMIS; Fri, 15-AUG-1986 03:16 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/15/86 at 05:10:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027979; 15 Aug 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011429; 15 Aug 86 5:34 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: ANSI C
Message-ID: <6143@sun.uucp>
Date: 14 Aug 86 05:44:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In 3.2.2.3, "(void *)0" is called a null pointer constant, though 5.6.3.12
> says the value of NULL is implementation-defined.  I take this to mean that
> the internal representation of (void *)0 need not have all bits clear.
     
Yes.  I'm certain there are many machines out there that either have C
implementations or should have them that have a representation for null
pointers that is not a bucket of zero bits.
     
> The constant 0 used in a pointer context still denotes the null pointer,
> but an integer variable whose value happens to be zero need not produce
> the null pointer when cast.
     
Yes.  This may be considered questionable, since, given the declarations
     
    int i;
    char *p;
     
the statements
     
    i = 1; p = i;
     
and
     
    p = 1;
     
should be expected to stuff the same value into "p", but the statements
     
    i = 0; p = i;
     
and
     
    p = 0;
     
need not stuff the same value into "p" - i.e., the constant expression 0 is
treated differently when converting to a pointer type than any other
integral expression.  Unfortunately, there's not a hell of a lot you can do
about it.  If C had a keyword "nil" that would, when it appears in an
expression, be converted to a null pointer of the appropriate type (as the
constant expression 0 is converted now), this problem wouldn't occur;
however, it's a little to late to fix this now, given all the code out there
that uses 0 for this.
     
"Fixing" it the other way, by having any integral expression with the value
0 convert to a null pointer, would 1) add some extra inefficiency to
integer-to-pointer conversions on machines with special null pointer
representations without much benefit (if any), and 2) surprise some code
that does want to grab a pointer value, fiddle the bits (setting a ring
number, for instance) and then stuff the value back into the pointer, if a
pointer value of all zero bits is a valid pointer.
     
> Also, if I have a pointer variable whose value happens to be NULL and I
> cast it into int, I'll likely get the internal form (what I'd get if I
> used a union) rather than zero as a result, right?
     
Right.
     
> In boolean context ("if (p)"), there is an implied comparison with NULL,
> not an implied cast to int.
     
Actually, it's an implied comparison with 0; however, the 0 has to get
converted to the type of "p", so that the effect is the same as
"if (p == 0)", namely that "p" gets compared with a null pointer.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8645
          for JMS@ARIZMIS; Fri, 15-AUG-1986 03:33 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/15/86 at 05:29:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028093; 15 Aug 86 6:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011576; 15 Aug 86 5:38 EDT
From: CS 8 Readers <c8-rah@zircon.ucb-vax.ARPA>
Newsgroups: net.lang.c
Subject: Re:  is a void function invocation an expression or a statement?
Message-ID: <1095@jade.BERKELEY.EDU>
Date: 13 Aug 86 18:27:53 GMT
Sender: usenet@jade.ucb-vax.ARPA
To:       info-c@BRL-SMOKE.ARPA
     
I think that I agree that void should be a real data type, but
making sizeof(void) would create problems.  Since sizeof(void) = 0,
sizeof(void[size) = 0 regardless of size.  Since one could declare an
arbitrarily long array of void, sizeof(void *) would have to be infinite,
which does not seem possible.  My proposed solution, which may not be any
good either, is making void a real type, and sizeof(void) equal to the
sizeof a union of char,int,etc. i.e. sizeof(double).
     
If anyone has a better idea, or a good reason not to make void a real data
type, I would be interested in hearing it.
     
                                -Max Schireson

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8547
          for JMS@ARIZMIS; Fri, 15-AUG-1986 03:35 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/15/86 at 05:27:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028090; 15 Aug 86 6:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011548; 15 Aug 86 5:38 EDT
From: Walter Bright <bright%dataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <1061@dataio.UUCP>
Date: 13 Aug 86 16:29:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <243@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes:
>While all of this discussion is very interesting and is important to
>achieving a precise language definition, let us not forget that there
>is *no* reason to ever write this particular expression.  Anywhere it's
>useful, you can just write
>
>    if (e1)
>        void_e2;
>    else
>        void_e3;
     
Not quite. This type of expression is very useful for macros which must
in themselves be expressions (to avoid peculiar {} and ; problems). Such
as:
     
#define biff(pow)    ((pow) ? kayo() : oof())
     
Defining the macro as:
     
#define biff(pow)    if (pow) kayo(); else oof();
     
causes difficulties with constructs like:
     
    if (socko)
        biff(flez);
    else
        bang(glurp);
     
Similar problems exist for the other permutations of defining biff().
     
Now for the RIGHT (!) definition of when a void expressions is valid:
     
    A void expression is valid only under circumstances where the
    value of an expression is not used.
     
This means that:
     
    (a ? voidexp : voidexp),(a=b)
     
is valid. But a=a?voidexp:voidexp isn't valid, as the value is used. Apply
the rule above to all the cases and you have the RIGHT (!) answer. Note that
by implication, if the value of the ?: expression is not used, the operands
of the : need not be of compatible types, and need not be brought to a
common type.
     
I would like to see the ANSI C spec clarified on this point.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8761
          for JMS@ARIZMIS; Fri, 15-AUG-1986 03:41 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/15/86 at 05:36:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028102; 15 Aug 86 6:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011733; 15 Aug 86 5:43 EDT
From: Chen Tu <ht01%bunny.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: macro to specify output parameter
Message-ID: <522@bunny.UUCP>
Date: 14 Aug 86 19:01:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
    When I read C functions, many times I was confused about the roles
    played by their parameters:  it is hard to tell a pointer
    parameter is an array or a pointer to a scaler (to be used as an
    output parameter).  To distinguish an output parameter from an
    array parameter, where both use the '*' notation, I found it is
    useful to have a macro to replace the notation of the former.
     
        #define OUT(name) *name
     
        /*** output parameter: ***/
        foo(c)
        char OUT(c);   <== output parameter, point to a char.
        {       ...
            OUT(c) = 'a';
            ...
            }
     
        /*** array parameter: ***/
        foo(s)
        char *s;      <== input parameter, a character string.
        {
            ... *s++ ... }
     
    To make the code more readable, do not use the output parameters
    in other places, and only use OUT(name) on the lhs of assignments, i.e.,
    treat them as OUTPUT ONLY parameters.
     
    When the output parameter is also a pointer, we have
        foo(s) char * OUT(s); { ...; OUT(s) = "this is a test"; ...}
    compare to
        foo(s) char **s; { ...; *s = "this is a test"; ...}
    The former seems more readable and understandable.
     
    Another alternative style is: (I have no preference)
     
        #define OUT *
        foo(c) char OUT c; { ...; OUT c = 'a'; ...}
     
                Hai-Chen Tu
                GTE Laboratories
                Waltham, Mass 02254
                (617) 466-4124
                CSNET: ht01%gte-labs.csnet

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8701
          for JMS@ARIZMIS; Fri, 15-AUG-1986 03:46 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/15/86 at 05:33:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028100; 15 Aug 86 6:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011717; 15 Aug 86 5:43 EDT
From: Dave Lukes <dave%inset.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <1083@inset.UUCP>
Date: 13 Aug 86 11:28:17 GMT
Posted: Wed Aug 13 11:28:17 1986
To:       info-c@BRL-SMOKE.ARPA
     
FLAME WARNING:
this article contains statements of a possibly insulting/inflammatory nature:
no further warnings will be given.
     
In article <86900006@haddock> karl@haddock.UUCP writes:
>I think one should be able to specify a list.  "case 1,4,10:" is neater than
>"case 1: case 4: case 10:",
     
Sure, but
a)    is ``neatness'' the only criteria for a language feature??
    What about usefulness??
b)    I never actually type large case lists,
    I just type the constants then use an editor to insert
    the ``case''s and the ``:''s.
     
>Better yet would be a list of ranges.  "case 'a' to 'z', 'A' to 'Z':"
>requires 52 labels in the current syntax; this is where I normally rewrite
>as if-else.  (Yes, I know that's better anyway because I can use the more
>portable test isletter().  But there are other uses for range cases, and
         ^^^^^
One would have thought that someone proposing extensions to C would know
the correct name: isalpha().
Also: what ``other uses''?
First you suggest a way of using something which you admit can be done better
in other ways, then you suggest it has ``other uses'' without saying what
they are!!
>one could always "#define UPPER 'A' to 'I', 'J' to 'R', 'S' to 'Z'" for
>EBCDIC systems, to retain portability.)  It should also be possible to
            ^^^^^^^^^^^^^^^^^^
     
So that's your definition of ``portability''??
``It works on ASCII and EBCDIC''.
This is a worldwide network (not all of us speak ``English''
and spend $).
     
What happens when we introduce more (i.e. international) character sets??
(-:Don't you care, or do you make your money by porting non-portable code? :-)
     
>specify open-ended ranges, to allow things like "switch (strcmp(s, t)) {
>case LT: ... case EQ: ... case GT: ... }" where LT and GT are #define'd as
     
What's wrong with ``if''??
     
>intervals extending to minus and plus infinity.
                       ^^^^^^^^
What is ``infinity''?
This just seems like another encouragement to non-portability.
     
In summary:
the suggested ``feature(s) are useful only if you intend to write non-portable
code or save a few seconds typing and thought:
we have enough problems already with non-portabilities in C code without
adding more rope for turkeys to hang themselves with.
     
>Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint
                        ^^^^^^^^^^^^^^^^
(-:(-: From what you have said, I think you should be forced to withdraw your
.signature on the grounds of misrepresentation!
:-):-):-):-):-):-):-):-):-):-)
     
>*   "[a,b)" is the American notation for a half-open interval.  The European
>    notation is "[a,b[", which would be even worse.
     
Actually: the ``European'' (by no means universally European) notation is a
LOT better: you don't have to stare at the equation trying to disambiguate
different kinds of parenthesis (especially useful if your printer's
character set is lousy, or the copy is badly handwritten),
although I'm used to the ``American'' notation, which ``looks nicer''.
--
     
        Dave Lukes. (...!inset!dave)
     
``Fox hunting: the unspeakable chasing the inedible'' -- Oscar Wilde

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8917
          for JMS@ARIZMIS; Fri, 15-AUG-1986 03:56 MST
Received: from BRL-AOS.ARPA by wiscvm.arpa on 08/15/86 at 05:52:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028153; 15 Aug 86 6:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011761; 15 Aug 86 5:44 EDT
From: Ben Cranston <zben@umd5.ARPA>
Newsgroups: net.lang.c
Subject: Re: Question on getopt()
Message-ID: <1186@umd5>
Date: 14 Aug 86 18:10:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Sez: guy@sun.uucp (Guy Harris)
> Anybody with source has certainly learned by now that the UNIX documentation
> is only a rough approximation to the truth.  The source code is, in some
> cases, the final arbiter; in others, the documentation is correct...
     
Sez: bzs@bu-cs.BU.EDU (Barry Shein)
> No, no, the COMPUTER is the final arbiter. When in doubt make up a few
> little code samples and see what they do. This doesn't require
> sources, except your own and works well, I'm serious. It never ceases
> to astound me how many times people come in to my office and ask me a
> question that is amply answered with "go ask the computer, why bother
> me, I can't simulate a computer as fast as it can simulate itself..."
     
While I agree generally, there are sometimes questions dealing with writing
transportable code that should definitely *NOT* be determined by the use of
trivial test programs.  A code fragment like:
     
      a[i] = b[i++];
     
for example is likely to do different things on different machines, and
only an experienced human being can give you the answer you REALLY want:
     
"Yes, it does what you want on *THIS* machine, but *DON'T* use code like
this because it is not portable."
     
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2569
          for JMS@ARIZMIS; Mon, 18-AUG-1986 01:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:25:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017666; 18 Aug 86 0:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021955; 17 Aug 86 23:37 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <517@dg_rtp.UUCP>
Date: 14 Aug 86 22:50:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> jsdy@hadron.UUCP (Joseph S. D. Yao)
>> throopw@dg_rtp.UUCP (Wayne Throop)
     
>>K&R don't say anything, since no (void) back then.
>>Harbison and Steele say: [it's legal]
>>ANSI C draft standard, C.3.15. [says it's legal]
     
> *sigh*  OK, let's get this straight.  PROPOSED ANSI standard
> X3J11 describes a language [which has] not yet been implemented [...]
     
Agreed.  However, additions and differences from current C
implementations are intentionally minimized, as it is a standardization
effort.  (OK OK, const, signed, prototypes, screwing around with the
preprocessor, so they got carried away.  Doesn't change the fact that
they *intend* to standardize *existing* practice where possible.)
     
> H&S, while a very good book, does take some
> liberties at interpretation.  They are on the ANSI X3J11
> committee, and could have been influenced in their interpre-
> tations by the committees deliberations.
     
I doubt that, given the time of publication of the H&S book and so
on.  The reverse might be the case however, so this is a valid point.
(I take the point to be that H&S and the ANSI draft standard might
 actually be the "same source" on this point, so quoting both doesn't
 necessarily mean that there are two entities in agreement here.)
     
> Most compilers
> today follow K&R, which by declaring that the conditional
> expression has (1) a result (2) with a data type predicated
> on the types of the operands, seems to be prohibiting use
> of void-type objects.
     
This is the main point I disagree on.  Because the conditional
expression could (1) have a void result, and this would still count as
"having a result", and (2) its datatype would be predicated on the
types (but not the values) of the operands.  So, using the K&R
definition of (?:), and a resonable definition of what it means for an
expression to "have a result" given that some expressions are void, it
seems perfectly straightforward.
     
And it "ought to be" legal.  Really.  I just re-read the K&R exposition
of the (?:) operator, and (interpolating the existance of (void)) it
seems quite reasonable for it to allow it.  See what you think:
     
    The first expression is evaluated, and if it is non-zero, the result
    is the value of the second expression, otherwise that of the third
    expression. [details what happens for arithmetic and pointer
    expressions, omitted]  Only one of the second and third expressions
    is evaluated.
     
I think it is reasonable to say that (for the purposes of this K&R
verse) a value is whatever you get from evaluating an expression.
Remember, expressions *always* returned values in those days.  But
nowdays, sometimes that "value" is void.  Saying that "void expressions
have no value" is simply a rather naive (and, to my way of thinking,
inaccurate, but then) way of saying that they can't be used as an
argument to any operator that needs to interpret or transform it's
operands.  (,) and (?:) don't need to, so I see no reason to prohibit
void expressions on the right of these operators.
     
> Bottom line:  it's a mite early to be pointing to Proposed
> X3J11 and saying something is "right" or "not right" based
> on that.
     
Agreed.  My tongue was in my cheek in asserting that my invocation of
the draft standard legislated the debate out of existance, as might be
guessed by my calling it "Holy Writ".  Maybe I need to employ more
smileys?  Ah well, so it goes.
     
> As H&S points out, the C language is what the C compiler accepts.
     
I agree here also.  And the compiler I use (and presumably at least some
of the compilers that H&S had access to, given what they say on the
subject) accepts the construct without complaint.  So it is currently
legal, for some values of "the C compiler", right?   :-)
     
--
In programming, everything we do is a special case of something more
general -- and often we know it too quickly.
                                        --- Alan J. Perlis
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3030
          for JMS@ARIZMIS; Mon, 18-AUG-1986 01:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:54:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017920; 18 Aug 86 0:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022110; 17 Aug 86 23:42 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: macro to specify output parameter
Message-ID: <6229@sun.uucp>
Date: 15 Aug 86 22:58:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     When I read C functions, many times I was confused about the roles
>     played by their parameters:  it is hard to tell a pointer
>     parameter is an array or a pointer to a scaler (to be used as an
>     output parameter).
     
Well, actually, pointer parameters are never arrays; arrays and pointers are
two completely different things.  This may be a good argument for allowing
"&" to be applied to arrays (yielding a pointer value of type "pointer to
array of <whatever>", NOT type "pointer to <whatever>"!) and using "pointer
to array" as the argument type if you really want to pass a pointer to the
array.
     
Of course, in the second example routine "foo", it may not really be a
pointer to the first element of an array/string; that routine might be used
to stuff characters into some arbitrary place in a string, so it's not
really a pointer to a string/array, it's just a pointer to a "char" that is
assumed to be somewhere within a string/array.
     
This may, in fact, also be an argument for reference types a la C++; there,
your routine "foo" would be written as
     
    foo(c)
        char &c;
    {
        ...
        c = 'a';    /* store 'a' in the "char" referred to by
                   "c" */
        ...
    }
     
This is how call-by-reference is done in C++; in other languages that
implement call-by-reference, output parameters are generally passed by
reference.
     
Your second proposed style comes close to implementing this as best as can
be done in C.  Try
     
    #define    REF    *    /* for defining reference types */
    #define    DEREF    *    /* dereferencing operator; since C doesn't
                   know about reference types, it won't
                   automatically dereference them */
     
    foo(c)
        char REF c;
    {
        ...
        DEREF c = 'a';
        ...
    }
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2050
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 17:57:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018970; 18 Aug 86 6:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025155; 18 Aug 86 5:30 EDT
From: Tom Armistead <toma%killer.uucp@BRL.ARPA>
Newsgroups: net.micro,net.micro.pc,net.lang.c
Subject: Looking for MS-DOS Curses Pkg???
Message-ID: <256@killer.UUCP>
Date: 15 Aug 86 13:45:23 GMT
Keywords: MS-DOS C CURSES
To:       info-c@BRL-SMOKE.ARPA
     
I am looking for a UNIX compatible CURSES package for the IBM PC/XT/AT.
Something that would be compatible with MANX C Compiler or Lattice C Compiler.
     
I don't really expect anything PD, but just somewhere to look fo such a thing.
     
ADVthanxANCE
Tom
     
---
UUCP:
                          ihnp4\
                                \killer!toma
                                /
  drillsys!infoswx!convex!dj3b1/
     
Tom Armistead

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5194
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:12 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 08/16/86 at 15:49:39 CDT
Received: from WISCVM.ARPA by SRI-KL.ARPA with TCP; Thu 14 Aug 86 03:20:20-PDT
Received: from (GWD21T)DGOGWD01.BITNET by WISCVM.ARPA on 08/14/86 at
  05:19:32 CDT
Date: 13 AUG 86  19:26:16  CET
To:  info-vax@SRI-KL
From:    <GWD21T%DGOGWD01.BITNET@WISCVM.ARPA>
Subject: MAIL
     
     
Re: Critical Regions under VMS
     
The worst problem with critical regions comes from the $DELPRC system
service which is NOT A PRIVILEGED request (the owner can $ STOP
a process from any other terminal).
With $DELPRC, NO exit handler is ever executed, so you can't rely
on an exit handler at all.
The 2nd solution given by Greg W. from DEC (raising priority to IPL$_ASTDEL)
is correct only if you need no cleanup later, so it does not satisfy
the original submitter's requirement. By the way, I might prefer
to put the critical region into a kernel AST instead of
raising the IPL, so I need not care for page faults.
     
For cleanup at image/process termination, however, only the "User rundown"
routine available for privileged shareable images is guaranteed to run
within process context (remember the V.3 "Real-Time User's Guide"?).
I think that such a "user written system service" is about the only
solution.
For a more elaborate scheme, I could imagine a separate process
monitoring access to the critical regions; this process could be
triggered after image/process rundown via the lock manager, and
do the cleanup required.
                                        W.J.M.
     
J.W.Moeller, GWDG, D-3400 Goettingen, F.R.Germany  GWD21T@DGOGWD01.BITNET
                                                    Phone +49-551-201516

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1003
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 21:09:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017453; 17 Aug 86 22:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021047; 17 Aug 86 21:30 EDT
From: Simon Kenyon <simon%einode.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: generalized switch
Message-ID: <146@einode.UUCP>
Date: 14 Aug 86 11:23:33 GMT
Posted: Thu Aug 14 11:23:33 1986
To:       info-c@BRL-SMOKE.ARPA
     
>>*   "[a,b)" is the American notation for a half-open interval.  The European
>>    notation is "[a,b[", which would be even worse.
>
> Actually: the ``European'' (by no means universally European) notation is a
> LOT better: you don't have to stare at the equation trying to disambiguate
> different kinds of parenthesis (especially useful if your printer's
> character set is lousy, or the copy is badly handwritten),
> although I'm used to the ``American'' notation, which ``looks nicer''.
     
since when has [a,b[ been the european notation for a half open interval?
i was taught [a,b) thank you very much
ireland is a tadge more european that britain :-)
--
Simon Kenyon            The National Software Centre, Dublin, IRELAND
simon@einode.UUCP                        +353-1-716255
EEEK /dev/mouse escaped (Glad to see my competition went down well at USENIX)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1850
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 22:48:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017605; 17 Aug 86 23:44 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021755; 17 Aug 86 23:31 EDT
From: Les Gondor <lgondor%utcsri.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C Compiler Validation
Message-ID: <3243@utcsri.UUCP>
Date: 12 Aug 86 20:06:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Does anybody out there know of any companies able to do a
C compiler validation? The level of validation should be to
K&R, not necessarily to the most recent X3J11 draft. Please
MAIL replies to me at the address below.
     
                Thanks in Advance
                Les Gondor
     
Les Gondor, (formerly) U of Toronto
{cornell, ihnp4, allegra, uw-beaver, decvax!utzoo}!utcsri!lgondor
CSNET: lgondor@Toronto        ARPA: lgondor%Toronto@CSNET-RELAY

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2016
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:03:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017623; 17 Aug 86 23:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021905; 17 Aug 86 23:36 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <745@wjvax.wjvax.UUCP>
Date: 14 Aug 86 16:37:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <243@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes:
>While all of this discussion is very interesting and is important to
>achieving a precise language definition, let us not forget that there
>is *no* reason to ever write this particular expression.  Anywhere it's
>useful, you can just write
>
>    if (e1)
>        void_e2;
>    else
>        void_e3;
>
     
You are correct, but this is true of ALL uses of '?:`.  In fact, '?:` is
VERY useful, especially when you want to embed conditionals in a macro.
Using the if() {} else {} form restricts the contexts in which the macro
may appear.
     
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2170
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:08:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017626; 18 Aug 86 0:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021910; 17 Aug 86 23:36 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Use of lint (4.2bsd)
Message-ID: <747@wjvax.wjvax.UUCP>
Date: 14 Aug 86 23:54:11 GMT
Keywords: lint, bsd
To:       info-c@BRL-SMOKE.ARPA
     
I am currently working on some software in which I have created a number
of object libraries, and then I use those libraries to create my executables.
     
My question is how to use lint in an effective manner with these libraries,
on a 4.2 BSD system.  I would like to perform two tasks with lint.  First, I
would like to generate from each library directory a lint library for the
use of the higher-level libraries and top-level source.  Second, I would
like to run lint on the source files in each library and on the top-level
source files using the relevant lint libraries.  Therefore, I tried the
following construction in my makefile: (edited)
     
    CFILES=        <list of .c files in the library>
    LIBMISCname=    MISC
    LLIBMISC=    ../llib-l$(LIBMISCname).ln
    LLIBS=        ../llib-lGENERAL.ln <more lint libraries>
    LINT=        lint -I../../include -DLINT
     
    $(LLIBMISC):    $(CFILES)
        $(LINT) -C$(LIBMISCname) $? $(LLIBMISC)    [1]
        $(LINT) -h $(CFILES) $(LLIBS)        [2]
        @mv llib-l$(LIBMISCname).ln $(LLIBMISC)    [3]
     
The first line ([1]) supposedly lints the C source files that are out of date
together with the current lint library and drops a new library llib-lMISC.ln,
which I move onto the real lint library at the end (line [3]).
     
The second line ([2]) supposedly lints ALL the source files (since a change to
a given source file may make other unchanged C files fail which formerly
passed) together with the other relevant lint libraries.
     
My first question is whether my construction is correct and performs (in
the best way) what I want to do.
     
My second question concerns one incidental failure of this method.  My lint
documentation says that the standard C library is checked by default.  Yet
when I use this makefile for one particular library, I get complaints for the
following:
     
    Variable number of arguments in fprintf()
    Variable _iob used but not defined
    Variable errno used but not defined
    Variable _ctype_ used but not defined
     
Yet when I read /usr/lib/lint/llib-lc (the human-readable form of the standard
C lint library), I find definitions for _iob, errno, and _ctype_; and
fprintf() is declared as /*VARARGS*/.  Why, then, is lint complaining?
     
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2378
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:17:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017652; 18 Aug 86 0:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021941; 17 Aug 86 23:37 EDT
From: "Carlos L. Qualls" <clq%omssw2.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Question about C debugging.
Message-ID: <491@omssw2.UUCP>
Date: 14 Aug 86 18:21:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Is there any GOOD documentation (books, etc.) on how to debug C code?
I am not talking about just putting in printf statements.
I am talking about using adb or other methods.
     
Carlos Qualls
Intel Corp.
5200 N.E. Elam Young Parkway
Hillsboro, OR. 97124
Office (503)681-2229
_____________
     
{ihnp4,fortune}!dual\
        {qantel,idi}->!intelca!omssw2!clq
 {ucbvax,hao}!hplabs/

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2749
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:33:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017898; 18 Aug 86 0:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021845; 17 Aug 86 23:34 EDT
From: cjl%iuvax.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Pascal vs C, again (was: Pascals Ori
Message-ID: <9500032@iuvax.UUCP>
Date: 13 Aug 86 15:18:00 GMT
Nf-ID: #R:boring:-701400:iuvax:9500032:000:2051
Nf-From: iuvax!cjl    Aug 13 10:18:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
  Let us see what Pascal would be if Dr. N. Wirth could redesign it again.
In his Modula-2, both conditional boolean operators and LOOP-EXIT-END are
introduced. So with Modula-2 (Pascal-2 ??), we would write loops as :
     
   (1)  i:= 1;
        LOOP
          (* invariant : (i <= 1001) and (0 not in x[1..i-1]) *)
          IF i = 1001 THEN EXIT END;
          (* assert (i <= 1000) and (0 not in x[1..i-1]) *)
          IF x[i] = 0 THEN EXIT END;
          INC(i);
        END;
        IF i = 1001 THEN WriteString("not found."); WriteLn;
        ELSE WriteString("Zero at location "); WriteInt(i,1); WriteLn;
        END;
     
   (2)  i := 1;
        LOOP
          (* invariant : (i <= 1001) and (0 not in x[1..i-1]) *)
          IF (i =1001) OR (x[i] = 0) THEN EXIT END;
          INC(i);
        END;
        ..............
     
   (3)  i := 1;
        WHILE (i <= 1000) AND (x[i] <> 0) DO
          INC(i);
        END;
        ................
     
   (4)  i:= 1;
        LOOP
          (* invariant : (i <= 1001) and (0 not in x[1..i-1]) *)
          IF i = 1001 THEN
            WriteString("not found."); WriteLn; EXIT ;
          END;
          (* assert (i <= 1000) and (0 not in x[1..i-1]) *)
          IF x[i] = 0 THEN
            WriteString("Zero at location "); WriteInt(i,1); WriteLn; EXIT;
          END;
          INC(i);
        END;
     
Wirth likes (3) because it tries to group and document the loop exit
conditions AT one place(simpler). Personally I like (4) because it is
easier to reason. (Ref Gries : The Science of Programming)
Note there is no statment between the two exit conditions and post-loop
clean-up follows corresponding exit condition more closely. That simplies
the program reasoning.
     
  Apparently Wirth doesn't like to use boolean variables for controlling
loop-exit today. (Any other opinion ?)  Also arbitrary loop-break
without trying to group them together would make post-loop assertion
unnecessary complex. (Thus hard to read.)
     
C.J.Lo
Dept. of CIS, IUPUI
UUCP : ...!iuvax!cjl
ARPA : cjl@Indiana@CSNet-Relay

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2821
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:35:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017906; 18 Aug 86 0:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a021959; 17 Aug 86 23:37 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: is a void function invocation an expression or a statement?
Message-ID: <518@dg_rtp.UUCP>
Date: 14 Aug 86 22:51:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> jack@mcvax.uucp (Jack Jansen)
> Something that has been bothering me since I read the C standard (well,
> read.... paged through it), and came up again after this discussion
> is the following: why haven't the C standardisers treated void like
> in algol-68? There, void is a fullfledged type, having only one
> value, also called void.
     
I'm not so sure they didn't, in effect and intent, if not in so many
words.  The real differences from what you describe seem to be only two.
C's void type has no legal values at all, rather than just one.  And no
objects may be of type void (though expressions can be).
     
> Are there any good reasons for not making void a normal type?
     
Well, in putting it the way they do, X3J11 avoid the problem of what
happens if you try to take the address of a void object.  Even in Algol,
this is probably anomalous, since a void object (only one legal value)
can be stored in zero bits, so where you allocate it is sort of, well,
arbitrary, isn't it?
     
--
The importance of information is directly proportional
to its improbability.
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2947
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/17/86 at 23:47:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017909; 18 Aug 86 0:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022091; 17 Aug 86 23:42 EDT
From: John Owens <jso%edison.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Generating code for the switch statement
Message-ID: <840@edison.UUCP>
Date: 14 Aug 86 22:13:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <610@hropus.UUCP>, ka@hropus.UUCP (Kenneth Almquist) writes:
> If the cases are not consecutive, the branch table must be filled with
> entries for the "missing" cases, making the table larger.  [....]  If
> the cases are mostly consecutive with a few outliers, a branch table
> could be augmented with a few specific tests for the outliers, but I
> don't know of any compiler that does this.
     
The Microsoft Pascal/Fortran compilers, at least some of the old
ones (3.04 and 3.11) do this.  I haven't tried it to see if their
wonderful new code generators do.
     
    John Owens @ General Electric Company    (+1 804 978 5726)
    jso%edison.UUCP@seismo.CSS.GOV            [arpa]
    jso@edison.UUCP                    [w/ uucp domains]
    {cbosgd allegra ncsu xanth}!uvacs!edison!jso    [roll your own]

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2228
          for JMS@ARIZMIS; Mon, 18-AUG-1986 16:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 18:01:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018990; 18 Aug 86 6:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025585; 18 Aug 86 5:43 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: ANSI C
Message-ID: <6237@sun.uucp>
Date: 16 Aug 86 09:09:13 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> It's not too late.  In the first place, NULL already exists for this purpose
> (though some people insist on using it as a synonym for '\0' too!)  If zero-
> in-pointer-context henceforth produces a warning message, people will
> convert their programs to use NULL instead.
     
Yes, but I don't know whether the disruption that would cause at this late
date would be worth the advantages the changes you suggest would bring.
     
    1) I've seen a fair amount of code that does things like
     
        <something> *p;
        ...
        if (p == 0)
     
    (which is perfectly legitimate and type-correct C) and makes
    calls like
     
        execl("/bin/cat", "cat", "file", (char *)0);
     
    2) What happens to code like
     
        <something> *p;
        ...
        if (p)
     
    or
        if (!p)
     
    which is also, at least by my interpretation of the August 11,
    1985 ANSI C draft, perfectly legitimate and type-correct C.
    The discussions of Boolean objects (now that Root Boy is gone,
    I guess we can acknowledge the existence of Boolean objects in
    C again) in the draft talk use terms like "equals 0" or "does
    not equal 0"; I presume some expression X "equals 0" iff X == 0,
    and "does not equal 0" iff X != 0.  Both of those comparisons
    can be done on pointers.
     
     
The code in both these examples will have to be changed.  The ANSI C
committee is at least trying not to break existing code any more than is
absolutely necessary.
     
> NULL would presumably be changed from "0" to an implementation-defined
> constant like "(void *)0xF0000000".
     
Blech!  I suppose the compiler will recognize expressions like that and, if
it treats null pointers in any special way, will treat them as such, but it
seems ugly.  (Yes, a compiler *could* treat them in usefully special ways.
For instance, it might try to do dataflow analysis and figure out whether
you run the risk of dereferencing a NULL pointer or not.  Said dataflow
analysis would have to be interprocedural, of course, and cross module
boundaries; however, given the depressing amount of crap code out there that
is careless about null pointers, it might be worth it.)
     
> Hmm, there's a similar problem without the full-check conversion.  If the
> constant zero is converted into a null pointer constant, and zero is a valid
> address, and something of interest is at that absolute address, how do I
> reference it?  "x = *(int *)0" will try to dereference NULL instead of 0,
> and "i = 0; x = *(int *)i" will undoubtable fail on some optimizing
> compilers.
     
Why?  If the compiler implements C, it will NOT combine the two statements
into one, since the meaning of "x = *(int *)0" is undefined, but the meaning
of "x = *(int *)i" is defined to the extent that conversions of "int" to
"int *" is defined.  The optimizer might decide that the value of "i" is
known at that point, and compute the value of "(int *)0" at compile time,
and generate code to load the "int" value that would be located at that
address into "x".  It might then discover that "i" is dead at that point,
and throw it away.  No C compiler will generate code to dereference a null
pointer for that example; any compiler that does is compiling a language
other than C.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4731
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:22 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 20:00:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018997; 18 Aug 86 6:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025711; 18 Aug 86 5:46 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: ANSI C
Message-ID: <86900017@haddock>
Date: 16 Aug 86 00:32:00 GMT
Nf-ID: #R:haddock:86900009:haddock:86900017:000:2407
Nf-From: haddock!karl    Aug 15 20:32:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
haddock!karl (Karl Heuer) writes:
>> The constant 0 used in a pointer context still denotes the null pointer,
>> but an integer variable whose value happens to be zero need not produce
>> the null pointer when cast.
     
sun!guy (Guy Harris) replies:
>Yes.  This may be considered questionable, since, given the declarations
>"int i; char *p;" the statements "i=1; p=i;" and "p=1;" should be expected
>to stuff the same value into "p", but the statements "i=0; p=i"; and "p=0;"
>need not stuff the same value into "p" - i.e., the constant expression 0 is
>treated differently when converting to a pointer type than any other
>integral expression.
     
In particular, "p = i = 0;" is a loser!  (I don't expect many programs do
this, since it produces a pointer/integer conflict.)
     
>Unfortunately, there's not a hell of a lot you can do about it.  If C had a
>keyword "nil" that would, when it appears in an expression, be converted to
>a null pointer of the appropriate type (as the constant expression 0 is
>converted now), this problem wouldn't occur; however, it's a little to late
>to fix this now, given all the code out there that uses 0 for this.
     
It's not too late.  In the first place, NULL already exists for this purpose
(though some people insist on using it as a synonym for '\0' too!)  If zero-
in-pointer-context henceforth produces a warning message, people will convert
their programs to use NULL instead.  If the feature then goes away, only the
programmers who ignored the warning will be burned.  (This is not necessarily
a good idea, but it *can* be done.)  NULL would presumably be changed from
"0" to an implementation-defined constant like "(void *)0xF0000000".
     
>"Fixing" it the other way, by having any integral expression with the value
>0 convert to a null pointer, would ... surprise some code that does want to
>grab a pointer value [as int] and then stuff the value back into the
>pointer, if a pointer value of all zero bits is a valid pointer.
     
Hmm, there's a similar problem without the full-check conversion.  If the
constant zero is converted into a null pointer constant, and zero is a valid
address, and something of interest is at that absolute address, how do I
reference it?  "x = *(int *)0" will try to dereference NULL instead of 0, and
"i = 0; x = *(int *)i" will undoubtable fail on some optimizing compilers.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4909
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:29 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019022; 18 Aug 86 6:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025736; 18 Aug 86 5:46 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: is a void function invocation a
Message-ID: <86900013@haddock>
Date: 15 Aug 86 21:10:00 GMT
Nf-ID: #R:boring.mcvax.UUCP:7046:haddock:86900013:000:339
Nf-From: haddock!karl    Aug 15 17:10:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
mcvax!jack (Jack Jensen) writes:
>Are there any good reasons for not making void a normal type?
     
I suspect the reason is that most uses of "real" types are not useful when
extended to void, and therefore the compiler is doing the user a favor by
flagging such uses as an error.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4925
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 20:05:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019005; 18 Aug 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025727; 18 Aug 86 5:46 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: uses of void
Message-ID: <86900012@haddock>
Date: 15 Aug 86 21:07:00 GMT
Nf-ID: #R:sdchema.sdchem.UUCP:277:haddock:86900012:000:883
Nf-From: haddock!karl    Aug 15 17:07:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
sdchem!tps writes:
>sort( (void *)&foo[0], (void *)&foo[20], sizeof(foo), compare_foos );
     
First, I think you want sizeof(foo_type) or sizeof(foo[0]).
     
>void *beg, *end;
>int   nelements = (end - beg) / size;
     
>I (naively?) thought that pointer arithmetic would work with "void *", and
>that it would work in the same abstract units as "sizeof()", so that all
>previous generic "char *" kludges could be replaced by "void *".
     
The "abstract units" of sizeof() are "char" by definition.  (Too many users
have been assuming sizeof(char)==1, so it's official in C++ and ANSI C.  I
wish it had been measured in BITS in the first place!)  Since "void *" means
"pointer to object of unknown type", you can't do pointer arithmetic with it.
     
What you really want is "((char *)end - (char *)beg) / size".  (Don't use int
or long!)
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5032
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 20:10:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019038; 18 Aug 86 6:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025770; 18 Aug 86 5:47 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900011@haddock>
Date: 15 Aug 86 20:44:00 GMT
Nf-ID: #R:hadron.UUCP:518:haddock:86900011:000:1224
Nf-From: haddock!karl    Aug 15 16:44:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
mmintl!franka (Frank Adams) writes:
[re the expression e1?e2:e3 where e2 and e3 are void]
>It seems to me that there are two different paradigms for how to interpret
>the ?: operator here.  One is as an ordinary operator, which returns one of
>the values of e2 or e3, depending on the value of e1.  Under this
>interpretation, it does not seem to me appropriate to permit e2 and e3 void,
>since in that case they have no values.
>
>The other paradigm is that e1?e2:e3 is precisely one of e2 or e3 ...  This
>is a very reasonable interpretation; but [then it should preserve lvalues].
>In particular, one could write "e1?e2:e3 = e4;".
     
I see your point.  I think both voids and lvalues should be allowed, though
the argument for the latter is less obvious.  I've had a few occasions where
I wanted to use a conditional lvalue, and had to settle for an if-else and a
temporary variable (for e4).  "*(e1?&e2:&e3) = e4;" doesn't work if one of
e2 or e3 is a register or a bit-field, and it looks uglier.  (Also, it tends
to compile into "temp = e1 ? &e2 : &e3; *temp = e4;" rather than "temp = e4;
e1 ? e2 = temp : e3 = temp;", at least on the machines I've tested.)
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5117
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:36 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019041; 18 Aug 86 6:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025793; 18 Aug 86 5:47 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900015@haddock>
Date: 15 Aug 86 21:53:00 GMT
Nf-ID: #R:desint.UUCP:243:haddock:86900015:000:997
Nf-From: haddock!karl    Aug 15 17:53:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
desint!geoff (Geoff Kuenning) writes:
>While all of this discussion is very interesting and is important to
>achieving a precise language definition, let us not forget that there
>is *no* reason to ever write this particular expression.
     
I already mentioned one: "(e1?e2:e3),e4".  For another, the types might be
unknown, if they are arguments in a macro; in this case I would want the
macro to work on void as well as valued expressions.
     
>[If-else] is better style anyway;  it makes use of a construct that
>people are much more used to, and it makes it clearer [what you are doing].
     
I won't argue that; though style is less important when you're writing a
macro.  Btw, I've been hacking at tail.c recently, and noticed that it has
an expression statement of the form "flag ? f1() : f2()", where f1() and
f2() are functions returning no value.  The compiler accepted it, because
they were (implicitly) declared int rather than void.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5182
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019043; 18 Aug 86 6:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025847; 18 Aug 86 5:49 EDT
From: Davidsen <davidsen%steinmetz.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)
Message-ID: <895@kbsvax.steinmetz.UUCP>
Date: 15 Aug 86 16:12:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1701@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>The other paradigm is that e1?e2:e3 is precisely one of e2 or e3, depending
>on the value of e1.  This is a very reasonable interpretation; but if it
>were correct, there would be one other important consequence which is not in
>fact legal.  This is that when e2 and e3 are lvalues, the compound
>expression should also be an lvalue.  In particular, one could write
>
>e1?e2:e3 = e4;
>
>which would mean the same thing as
>
>if (e1) then e2 = e4; else e3 = e4;
>
     
This kicked off an interesting thought:
  *(e1 ? <ptr expr> : <ptr expr>) = expr;
     
Lo and behold it does what the quoted expression indicates. In an
actual example:
  *(a < b : &b : &a) = 70;
     
I'm not sure it *good* for anything, but if I do it with macros using
cute names, I can enter it in the obfuscated C contest...
--
    -bill davidsen
     
  ihnp4!seismo!rochester!steinmetz!--\
                                       \
                    unirot ------------->---> crdos1!davidsen
                          chinet ------/
         sixhub ---------------------/        (davidsen@ge-crd.ARPA)
     
"Stupidity, like virtue, is its own reward"

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5278
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 20:21:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019047; 18 Aug 86 6:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025893; 18 Aug 86 5:50 EDT
From: aglew%ccvaxa.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <2600073@ccvaxa>
Date: 15 Aug 86 16:51:00 GMT
Nf-ID: #R:watmath.UUCP:273:ccvaxa:2600073:000:926
Nf-From: ccvaxa.UUCP!aglew    Aug 15 11:51:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
>I was trying to declare "typedef void dead;" so that I could distinguish
>between functions that return nothing (void perror(char *), setbuf(FILE *,
>char *), nullf(void)) from those that don't return (dead exit(int),
>abort(void), longjmp(jmp_buf, int)).  Again, it's a small quibble; I'll
>just use #define instead.
>
>Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint
     
Good point, though - an optimizing compiler could take advantage of
knowledge that a function doesn't return to do better register allocation,
etc. Should this be in the langauge, or is a convention like
     
    if( error_condition ) {
    exit(1);
    /*NOTREACHED*/
    }
     
enough? (Rhetorical question: obviously, you should specify it at the point
of declaration of such a function, not at the point of use.)
     
Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801    ARPAnet: aglew@gswd-vms

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5383
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019149; 18 Aug 86 6:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026077; 18 Aug 86 5:56 EDT
From: Mark Brader <msb%dciem.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: ANSI C
Message-ID: <1917@dciem.UUCP>
Date: 15 Aug 86 16:34:43 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Somebody writes:
     
> > In 3.2.2.3, "(void *)0" is called a null pointer constant, though 5.6.3.12
> > says the value of NULL is implementation-defined.  I take this to mean that
> > the internal representation of (void *)0 need not have all bits clear.
     
Guy Harris (guy@sun.uucp) replies:
     
> Yes.  I'm certain there are many machines out there that either have C
> implementations or should have them that have a representation for null
> pointers that is not a bucket of zero bits.
     
This is almost correct.  It IS true that (void *)0 need not have all bits
clear, but this is not what the reference in 5.6.3.12 is saying.  What it is
saying is that your implementation can #define NULL as either 0 or (void *)0.
     
Mark Brader, dciem!msb
#define    MSB(type)    (~(((unsigned type)-1)>>1))

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5471
          for JMS@ARIZMIS; Mon, 18-AUG-1986 18:56 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019152; 18 Aug 86 6:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026342; 18 Aug 86 6:03 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <1133@ttrdc.UUCP>
Date: 16 Aug 86 19:21:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1061@dataio.UUCP>, bright@dataio.UUCP (Walter Bright) writes:
>#define biff(pow)    ((pow) ? kayo() : oof())
>
>Defining the macro as:
>
>#define biff(pow)    if (pow) kayo(); else oof();
>
>causes difficulties with constructs like:
>
>    if (socko)
>        biff(flez);
>    else
>        bang(glurp);
>
>Similar problems exist for the other permutations of defining biff().
     
Presuming that
     
    void kayo(), oof();
     
is intended, whatsa matter with
     
#define biff(pow)    { if (pow) kayo(); else oof(); }
     
This combines the if-else into one single statement.
     
There is a slight handicap that this doesn't work too well as the first
operand of the comma operator ("syntax error") but at least some common
modern C compilers (as on the SV 3B20) don't like Bright's macro either in
this context or for that matter in any other context
("operands of : have incompatible types").  O.K., Bright (and others) have
been saying "change the definition of C to allow this."  Well I say the same
thing about my suggestion, so THERE!  :-)
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5601
          for JMS@ARIZMIS; Mon, 18-AUG-1986 19:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019158; 18 Aug 86 6:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026464; 18 Aug 86 6:05 EDT
From: Wayne Throop <throopw%dg_rtp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <520@dg_rtp.UUCP>
Date: 16 Aug 86 19:12:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> karl@haddock (Karl W. Z. Heuer)
     
Ghak!!  It's a good thing I said I wouldn't be aghast if ANSI C made
&array legal, since they already *have* made it legal!  Karl raised a
point:
     
> Btw, someone suggested earlier that ANSI C doesn't interpret &a as pointer
> to array.  I think it does: "The operand of the unary & operator shall be
> a function locator or an lvalue [other than bit-field or register].  ...
> The result ... is a pointer to the object [and has type] `pointer to type'."
> (3.3.3.2, 01-May-1986 draft.)  Arrays are not mentioned as a special case.
> And yes, arrays *are* (non-modifiable) lvalues in X3J11.
     
And, looking up the references, I found in addition to the above points
a another that I don't know how I missed before:
     
    C.2.2.1 Except when used as an operand that may or shall be an
    lvalue, [...] an expression that has type "array of *type*" is
    converted to an expression that has type "pointer to *type*" and
    that points to the initial member of the array object.
     
Interestingly, the "may or shall be an lvalue" is a little strange.  I
assume that what is meant here is that the conversion is not done iff an
lvalue is required.  (After all, an lvalue *may* be used anywhere a
value may be used, but maybe I'm missing some subtle point.)  Note that
this is *different* than what K&R say.  K&R say that arrays are not
lvalues, and the only anomaly is for "sizeof" (and this anomaly is
listed along with sizeof, not with arrays).
     
H&S agree with K&R, (on page 97, for example):
     
    [array of T is converted to pointer to T].  This rule is one of the
    usual unary conversions.  The only exception to the conversion rule
    is when an array identifier is used as an operand of the sizeof
    operator,
     
So, when ANSI-compliant compilers hit the streets, arrays will be
lvalues, &array will be legal, and it will even behave reasonably.  They
even made the rule for array promotion reasonably simple, though the
"sizeof" is still a separate special case, and is still listed
separately.  And it's still a little difficult to get an array-typed
rvalue, so assignment still doesn't work, even aside from the fact that
ANSI doesn't make array-typed lvalues modifiable.
     
--
"They couldn't hit an elephant at this dist......"
        --- The last words of General John Sedgwick,
            at the battle of Spotsylvania, 1864
--
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5905
          for JMS@ARIZMIS; Mon, 18-AUG-1986 19:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019164; 18 Aug 86 6:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027102; 18 Aug 86 6:22 EDT
From: Doug Gwyn <gwyn@BRL-SMOKE.ARPA>
Newsgroups: net.lang.c
Subject: Re: uses of void
Message-ID: <3121@brl-smoke.ARPA>
Date: 18 Aug 86 10:22:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900012@haddock> karl@haddock writes:
>The "abstract units" of sizeof() are "char" by definition.  (Too many users
>have been assuming sizeof(char)==1, so it's official in C++ and ANSI C.
     
Don't be too sure that this won't change by the time of the final X3J11
standard.  The internationalization issue has yet to be resolved, and
my sense is that the cleanest way to do that will to be to distinguish
between the basic data chunk size and a datum that can hold a character
representation.  I'm sure there will be a lot of sentiment for using
chars in both r^oles, even though that would force an incredible
amount of kludgery in many places in the practical use of the language..

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6028
          for JMS@ARIZMIS; Mon, 18-AUG-1986 19:21 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024059; 18 Aug 86 11:18 EDT
Received: from brl-vmb.arpa by SMOKE.BRL.ARPA id a004927; 18 Aug 86 10:54 EDT
Date:     Mon, 18 Aug 86 10:44:27 EDT
From:     "Gary S. Moss (SLCBR-VLD-V)" <moss@BRL.ARPA>
To:       info-c@BRL.ARPA
Subject:  Re:  C prgram needed - read with timeout
     
Tony,
    When I use fcntl() to set O_NDELAY, I save the file status flags on
program startup, and restore them before exiting.  Here are some subroutines
out of my library that should do the job, assuming that HP's UNIX is pretty
standard...
#include <stdio.h>
#include <fcntl.h>
static int        fileStatus[_NFILE];
int            reset_Fil_Stat();
     
/*    s a v e _ F i l _ S t a t ( )
    Save file status flags for 'fd'.
 */
save_Fil_Stat( fd )
int    fd;
    {
    return    fileStatus[fd] = fcntl( fd, F_GETFL, 0 );
    }
     
/*    r e s e t _ F i l _ S t a t ( )
    Restore file status flags for file desc. 'fd' to what they were the
    last time save_Fil_Stat(fd) was called.
 */
reset_Fil_Stat( fd )
int    fd;
    {
    return    fcntl( fd, F_SETFL, fileStatus[fd] );
    }
     
/*    s e t _ O _ N D E L A Y ( )
    Set non-blocking read on 'fd'.
 */
set_O_NDELAY( fd )
int    fd;
    {
    return    fcntl( fd, F_SETFL, O_NDELAY );
    }
-moss

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6294
          for JMS@ARIZMIS; Mon, 18-AUG-1986 19:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 21:08:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018994; 18 Aug 86 6:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025700; 18 Aug 86 5:45 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <86900016@haddock>
Date: 15 Aug 86 23:40:00 GMT
Nf-ID: #R:hadron.UUCP:513:haddock:86900016:000:1087
Nf-From: haddock!karl    Aug 15 19:40:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
dg_rtp!throopw (Wayne Throop) writes:
>What I was objecting to was elevating this common bug [interpreting &a as
>&a[0]] to a "standard feature".  I still think it would be wrong to do so.
>If it means anything (and currently it does *NOT*), (&array) should indicate
>the address of the whole array, not the address of its first element.
     
As I mentioned before, X3J11 seems to have accepted the "correct" meaning.
In the case of the other "optional ampersand", if f is a function locator,
then "&f" and "f" are equivalent.  I personally think the first is more
meaningful (language purity and all that; "f" should denote the function as a
whole, even if you can't do anything with it other than "&" or "()"), but I
don't use it because lint prefers the second.  I also detest the usage of
"pf()" for "(*pf)()", but X3J11 has blessed this as well.  (In fact, they
defined "()" to *always* operate on a function *pointer* (possibly obtained
from the implied "&" on a function locator), so now the first form is more
"correct"!)
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6721
          for JMS@ARIZMIS; Mon, 18-AUG-1986 20:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 21:39:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003552; 18 Aug 86 22:28 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019552; 18 Aug 86 21:31 EDT
From: Gary Wisniewski <gary%darth.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Coding Question
Message-ID: <138@darth.UUCP>
Date: 12 Aug 86 15:32:47 GMT
Followup-To: net.lang.c
Keywords: Attention all nit-pickers...
Posted: Tue Aug 12 11:32:47 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <248@killer.UUCP> tad@killer.UUCP writes:
>Hey, everybody, I discovered a "new" (new to me) way of coding such static
>things as descriptions, helps, and the like.  It goes like this:
>
     
[At this point, the author includes code which builds a table of char *'s
which are preinitialized and terminated with a NULL ptr, then builds a
function say(char *) which prints out the entire list.]
     
>
>Here's the question:  Should help and description be declared char *help[]
>or char **help?  Should say() be declared void, or is there some sort of
>error checking I should implement?  Are there any other suggestions or
>comments?  How about any other neat "tricks" anyone has discovered lately?
>
>                        Tad
>--
>Tad Marko
     
     
The technique you've discovered is actually a small part of a much more
general facility in C.  For more interesting ideas about ways to create
complex pre-initialized structures and tables, look at K&R, page 124.
     
As far as your question about "char *help[]" and "char **help": the two
forms are IDENTICAL to virtually every C compiler (that's worth its
salt).  Arrays in C are merely special cases of pointers.  In other
words, both forms are correct.  Section 5.3 of K&R explain this
more fully.  Happy C-ing.
     
Gary J. Wisniewski
Pittsburgh, PA
     
Usenet:        {allegra, bellcore, cadre}!pitt!darth!gary

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6594
          for JMS@ARIZMIS; Mon, 18-AUG-1986 20:19 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/18/86 at 21:25:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003438; 18 Aug 86 21:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019588; 18 Aug 86 21:31 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Coding Question
Message-ID: <2973@umcp-cs.UUCP>
Date: 16 Aug 86 00:58:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <138@darth.UUCP> gary@darth.UUCP (Gary Wisniewski) writes:
>As far as your question about "char *help[]" and "char **help": the two
>forms are IDENTICAL to virtually every C compiler (that's worth its
>salt).  Arrays in C are merely special cases of pointers.  In other
>words, both forms are correct.
     
    NO!
     
Ai!  This has been asserted far too often.  Arrays and pointers are
not at all the same thing in C!
     
>Section 5.3 of K&R explain this more fully.
     
Indeed it does, and I suggest you read it rather more carefully.
     
  The correspondence between indexing and pointer arithmetic is
  evidently very close. ... The effect is that an array name *is*
  a pointer expression.  (p. 94)
     
This does not say that arrays and pointers are *the same*.
     
  There is one difference between an array name and a pointer
  that must be kept in mind.
     
Aha!  See p. 94 for that difference.
     
  As formal parameters in a function defintion,
     
    char s[];
     
  and
     
    char *s;
     
  are exactly equivalent.... (p. 95)
     
Here they *are* the same---but note the qualifier: `As formal
parameters'.  In the (unquoted) original example, the array was a
global variable.
     
There is one other thing which, I guess, adds to this confusion.
Both of the following are legal global declarations in C:
     
    char    msg0[] = "Hello, world";
    char    *msg1 = "Hello, world";
     
Given both declarations,
     
    printf("%s\n", msg0);
     
and
     
    printf("%s\n", msg1);
     
produce the same output.  Yet msg0 and msg1 are not the same:
     
    printf("%d %d\n", sizeof (msg0), sizeof (msg1));
     
prints
     
    13 4
     
on a Vax; for msg0 is an array, and msg1 is a pointer.  The code
generated for the two declarations is different:
     
    /* edited assembly output from ccom */
        .data            # Switch to data segment.
        .globl    _msg0        # The array ...
    _msg0:    .asciz    "Hello, world"    # and here it is.
     
        .data    2        # Switch to alternate data segment.
    L12:    .asciz    "Hello, world"    # The object to which msg1 will point.
        .data            # Back to regular data segment.
        .globl    _msg1        # The pointer ...
    _msg1:    .long    L12        # which points to the object.
     
String constants comprise two special cases in the compiler.  The
first case is when the constant appears anywhere *except* as an
initialiser for a `char' array.  Here the compiler uses the alternate
data segment to suddenly `create' a new array, initialised to the
string text; it then generates a pointer to that array.  In the
second case the string constant is generated in the primary data
segment, and `is' the array being initialised: the constant is
`unwrapped' into an aggregate initialisation.
     
The second case is actually the more `conventional' of the two;
other aggregates cannot be created at run time:
     
    int a[] = { 0, 1, 2, 3 };
     
is legal only outside functions.  What seems surprising to some is
that the same is true of
     
    char s[] = "foo";
     
because, unwrapped, this is equivalent to
     
    char s[] = { 'f', 'o', 'o', '\0' };
     
---even though
     
    char *s = "foo";
     
is legal anywhere a declaration is legal.
     
Ah, if only C had aggregate initialisers!
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8730
          for JMS@ARIZMIS; Tue, 19-AUG-1986 21:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/19/86 at 23:20:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023368; 20 Aug 86 0:15 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a006045; 20 Aug 86 0:01 EDT
Received: from (BJORNDAS)CLARGRAD.BITNET by WISCVM.WISC.EDU on 08/19/86
  at 19:20:47 CDT
Date: 19 AUG 86 17:05-PST
From:  BJORNDAS%CLARGRAD.BITNET@wiscvm.ARPA
To:  INFO-C@BRL-SMOKE.ARPA
Subject: fgets() returns NULL at EOF??
     
O great C gurus, help a relative greenhorn!  Why is it that fgets()
returns NULL when it reaches end of file, whereas all the other
standard i/o functions seem to return EOF at that point?  This
confuses me, especially since one would suppose fputs() to be the
partner function of fgets() and therefore to work in the same way.
     
Sterling Bjorndahl
BJORNDAS at CLARGRAD on BITNET

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6604
          for JMS@ARIZMIS; Wed, 20-AUG-1986 11:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/20/86 at 13:37:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024261; 20 Aug 86 5:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008111; 20 Aug 86 5:31 EDT
From: Jonathan Meltzer <jsm@vax1.ccs.cornell.edu>
Newsgroups: net.database,net.micro.pc,net.lang.c
Subject: Dbase III to C translator
Message-ID: <80@vax1.ccs.cornell.edu>
Date: 16 Aug 86 02:57:25 GMT
Posted: Fri Aug 15 19:57:25 1986
To:       info-c@BRL-SMOKE.ARPA
     
Has anyone had experience with the Desktop Ai dBx dBase to C translator?
We're working on an application that takes up 190K in Nantucket
Clipper-compiled .EXE code. The .EXE file contains 120K of compiler
overhead, and runs too slowly for our liking. I'm wondering if translating
the source to C will save us time and space. Please let me know your
experiences and evaluation.
     
     
Jon Meltzer
Dept. of Modern Languages and Linguistics, Cornell University
------------------------------------------------------------------------
"Disclaimer" is a trademark of Bell Laboratories.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6749
          for JMS@ARIZMIS; Wed, 20-AUG-1986 11:57 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024295; 20 Aug 86 6:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008160; 20 Aug 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re:  is a void function invocation
Message-ID: <86900018@haddock>
Date: 17 Aug 86 22:47:00 GMT
Nf-ID: #R:jade.BERKELEY.EDU:1095:haddock:86900018:000:882
Nf-From: haddock!karl    Aug 17 18:47:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
zircon!c8-rah (Max Schireson) writes:
>Since one could declare an arbitrarily long array of void, sizeof(void *)
>would have to be infinite, which does not seem possible.
     
Since the "arbitarily long array" has total size zero, there's no problem.
In fact, the compiler could store all void "objects" at the same address,
and "void *" itself -- having only one value -- could have size zero.
     
Part of the problem here, I think, is that (in X3J11) the keyword "void" now
has three meanings: "void f()" or "(void)e", "void *", and "f(void)".  The
second meaning is based on the assumption that you can't have a pointer to a
real void, and the third assumes that void expressions cannot be function
arguments.  If you want to make void a full-fledged datatype, you'd better
use a different syntax for the other two meanings.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0049
          for JMS@ARIZMIS; Wed, 20-AUG-1986 20:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/20/86 at 21:41:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008891; 20 Aug 86 19:18 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a023238; 20 Aug 86 17:42 EDT
Date:     Wed, 20 Aug 86 17:31:24 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Tomas Rokicki <rokicki@su-navajo.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Using strings as immediate character arrays
Message-ID:  <8608201731.aa19132@VGR.BRL.ARPA>
     
Yes, "string"[index] is legal, portable, etc.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0671
          for JMS@ARIZMIS; Wed, 20-AUG-1986 20:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/20/86 at 22:23:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024295; 20 Aug 86 6:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008160; 20 Aug 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re:  is a void function invocation
Message-ID: <86900018@haddock>
Date: 17 Aug 86 22:47:00 GMT
Nf-ID: #R:jade.BERKELEY.EDU:1095:haddock:86900018:000:882
Nf-From: haddock!karl    Aug 17 18:47:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
zircon!c8-rah (Max Schireson) writes:
>Since one could declare an arbitrarily long array of void, sizeof(void *)
>would have to be infinite, which does not seem possible.
     
Since the "arbitarily long array" has total size zero, there's no problem.
In fact, the compiler could store all void "objects" at the same address,
and "void *" itself -- having only one value -- could have size zero.
     
Part of the problem here, I think, is that (in X3J11) the keyword "void" now
has three meanings: "void f()" or "(void)e", "void *", and "f(void)".  The
second meaning is based on the assumption that you can't have a pointer to a
real void, and the third assumes that void expressions cannot be function
arguments.  If you want to make void a full-fledged datatype, you'd better
use a different syntax for the other two meanings.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0789
          for JMS@ARIZMIS; Wed, 20-AUG-1986 20:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024298; 20 Aug 86 6:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008191; 20 Aug 86 5:34 EDT
From: "Wayne A. Christopher" <faustus@ucbcad.ARPA>
Newsgroups: net.lang.c
Subject: Re: ANSI C
Message-ID: <971@ucbcad.BERKELEY.EDU>
Date: 18 Aug 86 18:27:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
If there is a compiler that defines NULL as something other than an
all-0 bit pattern, I certainly hope that "if (!p)" will do the right
thing, otherwise most existing code won't work.  But this should never be
a real problem, since all the loader has to do is guarantee that
nothing valid will ever have an address that corresponds to the
conversion of integer 0 to a pointer.  There are no architectural
considerations involved -- if there are tag bits, etc, just let them be
all 0 -- the pointer should never be referenced anyway, so who cares
what the tag bits are.
     
In article <86900017@haddock>, karl@haddock writes:
> > "Fixing" it the other way, by having any integral expression with the value
> > 0 convert to a null pointer, would ... surprise some code that does want to
> > grab a pointer value [as int] and then stuff the value back into the
> > pointer, if a pointer value of all zero bits is a valid pointer.
     
You can always use a union, or cast a pointer to the needed value -- these
tricks are used for things like dissecting floating point numbers.
     
> Hmm, there's a similar problem without the full-check conversion.  If the
> constant zero is converted into a null pointer constant, and zero is a valid
> address, and something of interest is at that absolute address, how do I
> reference it?
     
If there is something of interest at location 0 then you should complain to
whomever put it there.  It's a very good idea to make null pointer references
cause a fault -- this catches lots of nasty bugs.  If this isn't the case
on your machine, you can still use the tricks mentioned above.
     
    Wayne

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0943
          for JMS@ARIZMIS; Thu, 21-AUG-1986 05:52 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025605; 20 Aug 86 7:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009771; 20 Aug 86 7:31 EDT
From: "John P. Nelson" <jpn%teddy.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Query: Public Domain C Compilers
Message-ID: <3043@teddy.UUCP>
Date: 18 Aug 86 22:20:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>Maybe small-c can be posted to the net.
     
It already was.  To mod.sources.  Please don't post it again.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1177
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002306; 20 Aug 86 12:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016887; 20 Aug 86 11:37 EDT
From: Tomas Rokicki <rokicki@su-navajo.ARPA>
Newsgroups: net.lang.c
Subject: Using strings as immediate character arrays
Message-ID: <790@navajo.STANFORD.EDU>
Date: 18 Aug 86 23:18:34 GMT
Keywords: Legal or not?
To:       info-c@BRL-SMOKE.ARPA
     
[ Snugglebunnies, snugglebunnies, snuggl+~=/
     
In a program I have been writing, I have found it nice to
have immediate character arrays, so I could do things like
     
    cmdchr = "rofq"[menu_selection] ;
     
Is this legal and portable?  It seems to work.      -tom

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1041
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002115; 20 Aug 86 11:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016726; 20 Aug 86 11:35 EDT
From: Randy Murray <rtm%cbosgd.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: "\"
Message-ID: <2435@cbosgd.UUCP>
Date: 18 Aug 86 18:35:54 GMT
Keywords: spelling
To:       info-c@BRL-SMOKE.ARPA
     
     
Just a quick simple question:
     
How do you spell "\"?
     
Is it "Backslash", "Back slash", or "Back-slash"?
     
Or none of the above?
     
Please mail your reply, don't post, I won't read it.
     
Thanks in advance,
     
Randy Murray
cbosgd!rtm

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5314
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 00:26:13 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010708; 21 Aug 86 6:35 EDT
Received: from csnet-relay.arpa by SMOKE.BRL.ARPA id a027191; 21 Aug 86 5:55 EDT
Received: from bsu by csnet-relay.csnet id aa26197; 21 Aug 86 3:39 EDT
Date:     Wed, 20 Aug 86 23:31 EST
From:     Rahul Dhesi <00R0DHESI%bsu.csnet@CSNET-RELAY.ARPA>
To:       info-c@BRL-SMOKE.ARPA, cbosgd!rtm.UUCP@CSNET-RELAY.ARPA
Subject:  "\"
     
Randy Murray (cbosgd!rtm) asked:  How do you spell "\"?
     
"\" is, of course, spelled "\\".
     
                                  Rahul Dhesi
                                  dhesi%bsu@csnet-relay.ARPA
                                  ...!seismo!csnet-relay.ARPA!bsu!dhesi
     
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5393
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 00:29:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015537; 21 Aug 86 10:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002112; 21 Aug 86 9:40 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using strings as immediate character arrays
Message-ID: <6309@sun.uucp>
Date: 19 Aug 86 06:25:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>     cmdchr = "rofq"[menu_selection] ;
>
> Is this legal and portable?  It seems to work.      -tom
     
It is perfectly legal, and therefore portable to all C implementations.
There may, however, be programs that purport to be C compilers that don't
implement it, although I don't know of any.
     
(The real test, of course, is whether
     
    cmdchr = menu_selection["rofq"];
     
yields the same result.  Any compiler that doesn't produce object code that
yields the same result isn't a C compiler.)
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5572
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:13 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015743; 21 Aug 86 10:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002536; 21 Aug 86 9:52 EDT
From: "Stuart D. Gathman" <stuart%bms-at.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <158@BMS-AT.UUCP>
Date: 19 Aug 86 01:11:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1083@inset.UUCP>, dave@inset.UUCP (Dave Lukes) writes:
     
> >specify open-ended ranges, to allow things like "switch (strcmp(s, t)) {
> >case LT: ... case EQ: ... case GT: ... }" where LT and GT are #define'd as
>
> What's wrong with ``if''??
     
'if' requires the result of strcmp() to be stored in a register or else
evaluated twice.  i.e.  { if ((r = strcmp(s,t)) < 0) less(); else if (r == 0)
same(); else more(); }  Try writing a balanced binary tree routine.  Storing
the result in a register is certain to be at least as efficient as any
implementation of open ended ranges, however.  The switch does look a lot
neater; of course, if people restricted their compares to return -1,0,1
there would be no problem.  Also, open ended ranges need not be implemented
in the compiler since macros like MAXINT are available.  Ranges should
not be a problem, though; many compilers already convert adjacent cases
to ranges so that a jump table can be used.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5630
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 00:37:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015659; 21 Aug 86 10:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002465; 21 Aug 86 9:49 EDT
From: John Kempf <corwin%hope.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: entry keyword?
Message-ID: <574@hope.UUCP>
Date: 19 Aug 86 01:21:58 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Can anyone tell me what the entry keyword is supposed to do?
I have seen it mentioned in several C books, but all of them
say that it is supposed to be implimented later.
thanks,
-cory
     
"No matter how subtle the wizard, a knife between the shoulder blades
will seriously cramp his style."
     
VOICE:  (714) 788 0709
UUCP:   {ucbvax!ucdavis,sdcsvax,ucivax}!ucrmath!hope!corwin
ARPA:   ucrmath!hope!corwin@sdcsvax.ucsd.edu
USNAIL: 3637 Canyon Crest apt G302
        Riverside Ca.  92507
     
--
-cory
     
"No matter how subtle the wizard, a knife between the shoulder blades
will seriously cramp his style."
     
VOICE:  (714) 788 0709
UUCP:   {ucbvax!ucdavis,sdcsvax,ucivax}!ucrmath!hope!corwin
ARPA:   ucrmath!hope!corwin@sdcsvax.ucsd.edu
USNAIL: 3637 Canyon Crest apt G302
        Riverside Ca.  92507

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5770
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015869; 21 Aug 86 10:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002623; 21 Aug 86 9:54 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Pointers and Arrays
Message-ID: <86900020@haddock>
Date: 20 Aug 86 01:40:00 GMT
Nf-ID: #R:hadron.UUCP:513:haddock:86900020:000:822
Nf-From: haddock!karl    Aug 19 21:40:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
dg_rtp!throopw (Wayne Throop) writes:
>And [in ANSI C] it's still a little difficult to get an array-typed
>rvalue, so assignment still doesn't work, even aside from the fact that
>ANSI doesn't make array-typed lvalues modifiable.
     
I've got some ideas about that, but the first step is to deprecate the
"feature" that allows you to write "f(int a[])" for "f(int *a)".  (I refer
here to the declaration of the function, not its call.)  In my mind, since
arrays may not currently be passed as arguments, the declaration is an error,
and the compiler is "politely" figuring out what you must have *meant*.  As
has already been pointed out, "sizeof(a)" gives you "sizeof(int *)" in this
context, so the apparent acceptance of the declaration tends to be confusing.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5718
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015820; 21 Aug 86 10:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002613; 21 Aug 86 9:53 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900019@haddock>
Date: 20 Aug 86 01:26:00 GMT
Nf-ID: #R:watmath.UUCP:273:haddock:86900019:000:2814
Nf-From: haddock!karl    Aug 19 21:26:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
ccvaxa!aglew (Andy Glew) writes:
>[haddock!karl (Karl Heuer) writes:]
>>I was trying to declare "typedef void dead;" so that I could distinguish
>>between functions that return nothing (void perror(char *), setbuf(FILE *,
>>char *), nullf(void)) from those that don't return (dead exit(int),
>>abort(void), longjmp(jmp_buf, int)).
>
>Good point, though - an optimizing compiler could take advantage of
>knowledge that a function doesn't return to do better register allocation,
>etc. Should this be in the langauge, or is a convention like /*NOTREACHED*/
>enough? (Rhetorical question: obviously, you should specify it at the point
>of declaration of such a function, not at the point of use.)
     
I posted this question before, and most of the response was on the order of
"this declaration isn't NEEDED".  True.  But "void" wasn't necessary either;
the language lasted quite some time with nonvalued int functions (which are
still quite common, especially since "int" is the default datatype).  The
addition of "void" didn't improve the generated code of any compiler I know
(the function and its caller both knew that no value was being used).  As far
as I can tell, it was added merely to allow clearer code, and to simplify
catching certain kinds of errors.
     
The same can be said of boolean expressions and dead functions.  The only
reasons for not adding them, as far as I can see, are as follows:
     
[0] Inertia, of course.
     
[1] It requires a new keyword (someone suggested that dead functions can be
reuse the keyword "goto", but I don't think it's appropriate).
     
[2] It won't be usable much.  This is a valid point.  There were a *lot* of
nonvalued int functions before void was invented; there are only a handful of
standard functions that are dead-ends.  Booleans are more common, especially
in programs like "ls" that have a flag for each option.
     
But I digress.  Returning to your comments: as for optimization, the calling
function can take advantage of the knowledge by omitting extra branches (e.g.
in "if (err) exit(1); else ...") or returns ("exit(0)" at the bottom of
main()).  This improves the space (but not time) efficiency, but not by much.
     
I presume your comment about register allocation referred to the dead-end
itself, in that the caller's registers need not be saved.  I don't think you
can assume this: the function "dead f() { for (;;) pause(); }" could be
interrupted by a signal, whose handler could longjmp() to f's caller, whose
registers must be recoverable.  For similar reasons, it probably isn't okay
to optimize the function call into a jump, unless you're careful with the
stack.
     
But I really hate having to write /*NOTREACHED*/ to keep lint happy!
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint
(Sorry if I've been rambling; it's late, and I should be in bed.)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5869
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015899; 21 Aug 86 10:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002706; 21 Aug 86 9:57 EDT
From: Tomas Rokicki <rokicki@su-navajo.ARPA>
Newsgroups: net.lang.c
Subject: Indirect comma assigned from side effects
Message-ID: <792@navajo.STANFORD.EDU>
Date: 19 Aug 86 19:08:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
[ `---\-   For the plane eater ]
     
The question is whether the comma operator (which K&C guarantees will
evaluate its left operand before its right operand) may allow parts of
other expressions in the same statement to be evaluated somewhere in
the middle of the comma operands evaluation.
     
For example, consider the program:
     
    int lhs, rhs, index; int *pointers[9];
    foo() { *( index=lhs, pointers[index] ) = sideeffects(); }
     
The question is, does C allow for the possibility that the order
of evaluation might be "index=lhs" then "sideeffects()" then
"*pointers[index]=<result>"?  If so, then if "sideeffects()"
changes the value of "index", then the result of the statement
is not defined.  On the other hand, if C does not allow the
compiler to generate such code, then the statement is well
defined.
     
I realize that in general, K&C say that the order of expression
evaluation is not defined, but in certain circumstances it is,
and their wording does not make it totally clear (to me, anyway)
whether this case is covered.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5952
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015964; 21 Aug 86 10:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002852; 21 Aug 86 10:01 EDT
From: Mike McNamara <mac%tflop.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Coding Question
Message-ID: <292@tflop.UUCP>
Date: 20 Aug 86 03:09:16 GMT
Keywords: Attention all nit-pickers...
To:       info-c@BRL-SMOKE.ARPA
     
In article <248@killer.UUCP> tad@killer.UUCP writes:
> Should say() be declared void, or is there some sort of
> error checking I should implement?
     
Progammer's Maxim # 17 :
Never test for an error condition if you don't know what to do with it.
     
     
--
---------------------------------+--------------------------------------------
| Michael Mc Namara              | Let the words by yours, I'm done with mine.
| UUCP: dual!vecpyr!tflop!mac    | May your life proceed by its own design.
| ARPA: tflop!mac@ames.arpa      |
---------------------------------+--------------------------------------------

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6054
          for JMS@ARIZMIS; Thu, 21-AUG-1986 23:19 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016568; 21 Aug 86 11:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002316; 21 Aug 86 9:43 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: uses of void
Message-ID: <6311@sun.uucp>
Date: 19 Aug 86 07:09:34 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >The "abstract units" of sizeof() are "char" by definition.  (Too many users
> >have been assuming sizeof(char)==1, so it's official in C++ and ANSI C.
>
> Don't be too sure that this won't change by the time of the final X3J11
> standard.  The internationalization issue has yet to be resolved, and
> my sense is that the cleanest way to do that will to be to distinguish
> between the basic data chunk size and a datum that can hold a character
> representation.
     
Not clear.  Widening "char" to support Kanji would be disruptive and cut
performance in applications that need not deal with individual Kanji symbols
as such (rather than treating a 16-bit Kanji symbol as a pair of 8-bit
"characters", as, for instance, the C compiler could in most instances).
The best proposals I've seen are the ones from AT&T-IS that propose a
separate "long char" data type for, well, long characters.  If adding a new
data type is distasteful, one could "typedef" "short" into such a data type,
although you might have to engage in some jiggery-pokery to initialize a
"string" of "short"s from a Kanji string.
     
You can still distinguish between the unit of storage and the datum used to
hold character representations of, say, Kanji; however, you don't have to do
this by saying "char" will hold those representations, but can provide a new
data type for this.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7222
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:19 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 03:13:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016207; 21 Aug 86 11:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a002218; 21 Aug 86 9:41 EDT
From: Sam Kendall <sam@zarathustra.ARPA>
Newsgroups: net.lang.c
Subject: Re: uses of void
Message-ID: <6001@think.COM>
Date: 19 Aug 86 15:03:31 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3121@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) writes:
>In article <86900012@haddock> karl@haddock writes:
>>The "abstract units" of sizeof() are "char" by definition.  (Too many users
>>have been assuming sizeof(char)==1, so it's official in C++ and ANSI C.
>
>Don't be too sure that this won't change by the time of the final X3J11
>standard.
     
No way.  Too much code would break if sizeof (char) wasn't 1.  A
nearly infinite set of these would have to be fixed:
     
    malloc(strlen(s)+1)
     
Also plenty of uses of sizeof to count chars in a char array, and
other things like this.
     
---
Sam Kendall            sam@godot.think.com
Thinking Machines Corp.        {harvard, ihnp4, seismo}!think!sam

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7329
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:23 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016926; 21 Aug 86 12:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005841; 21 Aug 86 11:35 EDT
From: Alan Curtis <apc%cblpe.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <187@cblpe.UUCP>
Date: 20 Aug 86 01:09:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <134@sas.UUCP> jcz@sas.UUCP (Carl Zeigler) writes:
>
>  In article <5858@alice.uUCp>, ark@alice.UucP (Andrew Koenig) writes:
>  > > So, does anyone have a fix for this bug?
>  > >
>  > > void f3(which)
>  > > {
>  > >     extern void f1(),f2();
>  > >     which?f1():f2();
>  > > }
>  > > cc(1) gives an "incompatible types" error.
>  >
>  > As it should.  The only thing you're allowed to do with void values
>  > is throw them away.
>
>
>Scan again, Andrew, the (void) values are being thrown away.
>
No, the value of the statement is being thrown away, not the value
of the void(s).
     
Would you let me say:
    .
    .
    .
    f1() + f2();
    .
    .
     
Since I am throwing both away?
Alan Curtis

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7387
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 03:18:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017171; 21 Aug 86 12:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006032; 21 Aug 86 11:39 EDT
From: Jeffrey Copeland <jeff%mcnc.uucp@BRL.ARPA>
Newsgroups: net.text,net.lang.c
Subject: Re: Cweb
Message-ID: <1599@alvin.mcnc.UUCP>
Date: 19 Aug 86 13:43:52 GMT
Keywords: tex, web, cweb
To:       info-c@BRL-SMOKE.ARPA
     
In article <612@noscvax.UUCP> mball@noscvax.UUCP (Michael S. Ball) writes:
>I would like to get data on the "Cweb" system developed by H.
>Thimbleby.  Can someone help?
     
The reference I have is:
     
  Experiences of literate programming using cweb (a variant of Knuth's WEB)
  Thimbleby, H.
  Dept. of Comput. Sci., York Univ., England
  Comput. J. (GB)   vol.29, no.3    201-11   June 1986

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7443
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017251; 21 Aug 86 12:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006157; 21 Aug 86 11:42 EDT
From: "Jonathan G. Bressel" <jgb%linus.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Microsoft C 4.0 availability query
Message-ID: <238@linus.UUCP>
Date: 18 Aug 86 12:26:58 GMT
Keywords: MSC C Compiler
To:       info-c@BRL-SMOKE.ARPA
     
[]
     
I would like to buy the Microsoft C version 4.0 compiler to run on an
IBM.  Has anyone actually obtained this compiler yet?  If so, how much
did you pay, and where did you get it?  How long does it take for
delivery?  Does it come with the source line debugger even if you
don't buy it from directly from Microsoft?
--
                Jonathan G. Bressel
                The MITRE Corporation, MS E025
                P.O. Box 208
                Bedford, MA  01730
                (617) 271-2000
ARPA:    linus!jgb@mitre-bedford
UUCP:    ...{decvax,utzoo,philabs,security,allegra,genrad}!linus!jgb

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7495
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:30 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017287; 21 Aug 86 12:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006200; 21 Aug 86 11:43 EDT
From: Arthur David Olson <ado%elsie.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: ordering X3J11
Message-ID: <6194@elsie.UUCP>
Date: 20 Aug 86 19:51:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2982@brl-smoke.ARPA>, jsweet@uci-icsa.ARPA (Jerry Sweet) writes:
> . . .to order the draft ANSI standard for the C programming language. . .
> Send check (made payable to X3 Secretariat) plus
> self-addressed mailing label to:
>         X3 Secretariat/CBEMA
>         311 First St., NW
>         Washington, D.C.  20001
>     request X3J11 "Programming Language C", $30.00
     
In placing your order, *be sure* to specify that you want the July 1986 draft
which CBEMA has just received.  If you fail to ask for the July draft,
they may well send you one of the May 1986 drafts they have left over.
--
    UUCP: ..decvax!seismo!elsie!ado   ARPA: elsie!ado@seismo.ARPA
    DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7615
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:38 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019454; 21 Aug 86 13:36 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a008503; 21 Aug 86 13:11 EDT
Date:     Thu, 21 Aug 86 13:02:11 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Guy Harris <guy%sun.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  uses of void
Message-ID:  <8608211302.aa23681@VGR.BRL.ARPA>
     
The idea is not to insist that all C implementations support 16-bit
character codes, but to permit that as a deliberate implementation
decision.  I would hope that the systems I use continue to have
8-bit chars, although I do have to say that quite often I need
to know more about a "letter" than just its class name ("A").  For
example, these days I work a lot with typesetting, bitmap graphics,
and so forth, and sometimes the size and font style of a character
are about as important as its class name.
     
Of course, it is possible to come up with any number of kludges to
cope with non-traditional DP ideas of characters, and many people
have done so.  The desire, I think, in specifying the C language is
to not have such kludges intrude into implementations where they
are neither wanted nor needed.  As an example of the problems, the
AT&T 16-bit proposal requires strcpy() to handle "escapes", whereas
what one really ought to insist on is that strcpy() handles chars as
in the following simple semantic definition of its function:
     
char *strcpy( char *dest, char *src )
{
    char    *retval = dest;
     
    while ( (*dest++ = *src++) != '\0' )
        ;
     
    return retval;
}
     
If one adopts a kludge approach, then either strcpy() can no longer
be used to copy a string of text characters, or strcpy() no longer
has such a simple implementation.  If "char" is able to hold 16 bits,
then the semantics of strcpy() can continue to be the simple model
shown above, and strcpy() can copy strings of text characters (this
assumes that one would always use 16 bits per character, even if the
7-bit ASCII code subset could be used for some of them).
     
The worst example I have heard so far about international character
set kludgery is the assertion that strcmp() should be useful for
sorting native-language text into "dictionary order".  Anyone who
knows much about dictionaries (particularly oriental ones) should
appreciate how na"ive that approach is.
     
One vendor would really like to see a requirement to support in
effect multiple 8-bit translation tables, because that vendor has
already taken that particular approach and would have a competitive
edge if it were made mandatory.  I've found that most major UNIX
system vendors are currently grappling with internationalization
issues, and all have taken different approaches.  So far they all
smack of kludgery to me, although some are better than others.
     
What concerns me is, if some simple, clean sufficient solution to the
extended code set issue is not made part of the official C language
specification, demands from ISO will lead to an officially-required
kludge approach that will adversely impact even simple ASCII-based
implementations.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7811
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:44 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026160; 21 Aug 86 20:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014800; 21 Aug 86 19:34 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using strings as immediate character arrays
Message-ID: <5967@alice.uUCp>
Date: 20 Aug 86 14:15:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In a program I have been writing, I have found it nice to
> have immediate character arrays, so I could do things like
>
>    cmdchr = "rofq"[menu_selection] ;
>
> Is this legal and portable?  It seems to work.      -tom
     
Yes.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7762
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:45 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026158; 21 Aug 86 20:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014722; 21 Aug 86 19:32 EDT
From: "Stuart D. Gathman" <stuart%bms-at.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: macro to specify output parameter
Message-ID: <161@BMS-AT.UUCP>
Date: 20 Aug 86 05:05:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6229@sun.uucp>, guy@sun.uucp (Guy Harris) writes:
> This may, in fact, also be an argument for reference types a la C++; there,
> your routine "foo" would be written as
>
>     foo(c)
>         char &c;
>     {
>         ...
>         c = 'a';    /* store 'a' in the "char" referred to by
>                    "c" */
>         ...
>     }
     
I don't like this.  It violates the nice consistent way that C expressions
work.  'char *c' means that '*c' is of type char.  '&c' is not of type
char in any other context.  I don't see any problem with using '*' instead
of REF and DEREF.  In any case, either '*' or 'DEREF' is better than
the foo example above since the uses of the output parameter are marked.
This is certainly an argument for DEREF over '*', but I still think
'*' looks prettier (but then I love APL).
     
I would like to see variable size arrays allowed as local parameters.
This would be a lot more efficient than using malloc().
     
I would like to "operator definition" which would allow you to opdef
say '+' to cause it and its two arguments to be replaced by a macro
called with the two arguments whenever the arguments are of a type
specified in the definition.  This allows generalized treatment of
operators on non-native types such as 'complex'.  Perhaps new operators
could be custom defined or the syntax (left/right association, priority)
of existing operators changed (but probably not except for completeness,
changing existing operators is a good way to make a program unreadable).
     
I would like to see "structure constants" which would allow assignment
to aggregate types.
     
    typedef struct { double real, imag; } complex;
    complex z;
    int a;
    a = 0;
    z = { 0, 0 };
    . . .
    z = { a+1, exp(b) };
    foo( (complex) { a, b } );
     
Of course any of these could be coded by assigning each member in turn.
I just think the above is nicer and not hard to implement.
     
Macros would be nicer with "imbedded functions".
     
#define    foo(x,y) { float a = 0.0; while (x) { a += y * x--; }; return a; }
     
This construct is distinguished by the use of '{}' in a context
requiring a value.  The return is optional, the value of the last
expression is used.  Perhaps loops should be allowed in comma expressions
instead.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7664
          for JMS@ARIZMIS; Fri, 22-AUG-1986 01:51 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a026152; 21 Aug 86 20:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014699; 21 Aug 86 19:31 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: generalized switch
Message-ID: <86900022@haddock>
Date: 20 Aug 86 16:04:00 GMT
Nf-ID: #R:ucbvax.BERKELEY.EDU:15093:haddock:86900022:000:6891
Nf-From: haddock!karl    Aug 20 12:04:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
inset!dave (Dave Lukes) writes:
>FLAME WARNING:
     
I have resisted the urge to make this a counter-flame.
     
>In article <86900006@haddock> karl@haddock.UUCP writes:
>>I think one should be able to specify a list.  "case 1,4,10:" is neater than
>>"case 1: case 4: case 10:",
>
>Sure, but
>a)    is ``neatness'' the only criteria for a language feature??
>    What about usefulness??
     
I thought I explained why I thought it would be useful.  I'll try again below.
     
>b)    I never actually type large case lists,
>    I just type the constants then use an editor to insert
>    the ``case''s and the ``:''s.
     
That makes it easier to write, but it doesn't help the person who has to
read the code later.  "The editor can fix it" doesn't wash.
     
>>Better yet would be a list of ranges.  "case 'a' to 'z', 'A' to 'Z':"
>>requires 52 labels in the current syntax; this is where I normally rewrite
>>as if-else.  (Yes, I know that's better anyway because I can use the more
>>portable test isletter().  But there are other uses for range cases, and
>         ^^^^^
>One would have thought that someone proposing extensions to C would know
>the correct name: isalpha().
     
Oops, a Freudian slip.  I've always thought it *should* have been called
isletter(), since I prefer to use "alpha" for "alphanumeric".
     
>Also: what ``other uses''?
>First you suggest a way of using something which you admit can be done better
>in other ways, then you suggest it has ``other uses'' without saying what
>they are!!
     
("The obvious is often left unsaid in favor of brevity" -- UPM.)  Okay, how
about "case '0' to '7'" for octal, or "case '0' to '9', 'A' to 'F'" for
uppercase hexadecimal?  (Yes, I know about isxdigit().  But "dc", for
example, reserves lowercase a-f for commands.)  If the isascii() function
goes away (as in X3J11), "case 0 to 0x7f" may be useful on ASCII systems.
Moreover (lest you flame about portability again), the switch value need not
be a character; I've written programs that wanted to test some integral
expression against one or more ranges.  (Sorry, I can't give enough context
to prove the program was useful.)
     
>>one could always "#define UPPER 'A' to 'I', 'J' to 'R', 'S' to 'Z'" for
>>EBCDIC systems, to retain portability.)  It should also be possible to
>                    ^^^^^^^^^^^^^^^^^^
>
>So that's your definition of ``portability''??
>``It works on ASCII and EBCDIC''.
     
Oh, come on.  You define it as "'A' to 'Z'" on ASCII systems, the mess above
on EBCDIC, and *whatever it needs to be* on other systems!  If your machine
has the brain-damaged collating sequence "AaBbCc...Zz", you have to define it
one letter at a time, but the *use* of the macro is portable.  (The macro
itself can be defined in a standard header file.)
     
>What happens when we introduce more (i.e. international) character sets??
>(-:Don't you care, or do you make your money by porting non-portable code? :-)
     
Assuming the character set is known at compile-time, you add the national
characters to the macro.  Otherwise, you use an "if".  I am *not* trying to
make "switch" into a glorified "if-else"; my proposal simply generalizes the
*constant comparisons* already handled by "switch".  *This is important*.
     
>>specify open-ended ranges, to allow things like "switch (strcmp(s, t)) {
>>case LT: ... case EQ: ... case GT: ... }" where LT and GT are #define'd as
>
>What's wrong with ``if''??
     
It requires a temporary variable.  Also, with "if" you make two of the three
tests, and the third case falls into "else"; with "switch" there is a nice
symmetry among the three cases, making it more readable.  (And it's likely
to be more efficient, if you care.)
     
>>intervals extending to minus and plus infinity.
>                                       ^^^^^^^^
>What is ``infinity''?
>This just seems like another encouragement to non-portability.
     
I don't understand your misunderstanding.  Assume a bracket notation with an
empty string denoting infinity.  "(a,b)" would match any value x such that
a < x && x < b.  "GT" would be defined as "(0,)" which (suppressing the upper
limit) would match any value x such that 0 < x.  What's nonportable?
     
>In summary:
>the suggested ``feature(s) are useful only if you intend to write non-
>portable code or save a few seconds typing and thought:
>we have enough problems already with non-portabilities in C code without
>adding more rope for turkeys to hang themselves with.
     
I've already answered the portability question.  As for saving time and
thought, that's what computers are for.  (Not to imply that one shouldn't
think, just that one shouldn't need to worry about details the compiler can
handle easily.)
     
>(-:(-: From what you have said, I think you should be forced to withdraw your
>.signature on the grounds of misrepresentation!
>:-):-):-):-):-):-):-):-):-):-)
     
Well, this discussion has very little to do with "lint", so there's not much
to misrepresent.  Anyway, it's not a .signature (file); I type my signature
and attribution-markings by hand (with assistance from an editor).  This is
partly because of some braindamaged software, and also because it helps me
resist the urge to include a cute quote or other such nonsense.  Also, I
like postscripts and footnotes to come after the signature.  I'm explaining
all this because I realize I'm contradicting the spirit of the last clause
in my previous paragraph.
     
>>*   "[a,b)" is the American notation for a half-open interval.  The European
>>    notation is "[a,b[", which would be even worse.
>
>Actually: the ``European'' (by no means universally European) notation is a
     
Well, I didn't mean to imply that all American/European sources follow this
convention, but there does seem to be a correlation, and I had to call them
something.
     
>LOT better: you don't have to stare at the equation trying to disambiguate
>different kinds of parenthesis (especially useful if your printer's
>character set is lousy, or the copy is badly handwritten),
>although I'm used to the ``American'' notation, which ``looks nicer''.
     
Don't have to disambiguate?  "[ ... [ ... ] ... ]" could denote either nested
brackets, or a left-closed and a right-closed interval.  In the C context,
when the string "[a,b[" has been scanned, the last character could be either
a terminator for the half-open interval, or the beginning of a subscript for
the array "b".  I guess one character of lookahead will resolve it, but it
may still be a problem for the user.  Anyway, unless and until the semantics
are agreed on, the syntax is a moot issue.
     
Now, in case you missed this point in my previous posting: this proposal can
be implemented in an upward compatible way, and it would eliminate the need
for most fall-through cases.  This *may* make it possible to phase out the
switch-break.  (I believe one of the authors of the language has acknowledged
that this was a botch.)
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9678
          for JMS@ARIZMIS; Fri, 22-AUG-1986 05:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 07:15:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027996; 22 Aug 86 6:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018450; 22 Aug 86 5:31 EDT
From: martin <martin%minster.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: void *
Message-ID: <882@minster.UUCP>
Date: 20 Aug 86 09:29:36 GMT
Posted: Wed Aug 20 11:29:36 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900014@haddock> karl@haddock writes:
>alice!bs (Bjarne Stroustrup) writes:
>>In addition, the draft ANSI C proposal allows uncasted assignment of a void*
>>to a non-void pointer. This, I consider to be an unnecessary weakening of C's
>>type system; in the long run it will become a rather serious nuiscance.
>
>I agree that this is a bad idea; I'm glad to hear that C++ disallows it. ...
>...
>Having said that, I'll now point out that X3J11 draft 01-May-1986 does say in
>5.5 (Common Warnings), "[An implementation may generate a warning if] an
>implicit narrowing conversion is encountered, such as the assignment of ...
     
I don't regard the generation of a warning as being in any way satasfactory!
You only have to look at the number of warnings that various distributed
programs generate, to realise that many people simply ignore warnings.
This is an obvious portability problem, so lets (please!) have a fatal error!

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9795
          for JMS@ARIZMIS; Fri, 22-AUG-1986 05:28 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 07:22:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028009; 22 Aug 86 6:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018573; 22 Aug 86 5:35 EDT
From: "Harry W. Reed" <doon%sdcrdcf.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: What is pcc2 ?
Message-ID: <2966@sdcrdcf.UUCP>
Date: 20 Aug 86 07:40:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Hi,
    recently I've been seeing references to the 'pcc2' C compiler.
Now I'm quite familiar with pcc, but what is pcc2? A new and improved pcc
or what?
     
    Thanks,
    Harry Reed
    ...!sdcrdcf!doon

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9895
          for JMS@ARIZMIS; Fri, 22-AUG-1986 05:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 07:27:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028013; 22 Aug 86 6:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018674; 22 Aug 86 5:38 EDT
From: Joe Buck <jbuck%epimass.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Dead functions and /*NOTREACHED*/
Message-ID: <410@epimass.UUCP>
Date: 21 Aug 86 16:54:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900019@haddock> karl@haddock (The Walking Lint) writes:
>[discussion of some problems with adding "dead functions" to C]
>But I really hate having to write /*NOTREACHED*/ to keep lint happy!
     
There's a fix for this that doesn't do violence to the language.
There should be another "special comment" lint recognizes that's
present in the lint library (/*DEADEND*/ or something).  Then
functions like "exit" are marked once in the lint library, and
user-written functions that always call exit would also be understood
to be "dead".  Voila! lint now understands about exit, and is able
to find unreachable code that it currently may miss.
     
While I'm at it, a similar comment could be added to tell lint that
a function like malloc or calloc always returns an aligned pointer.
I understand that ANSI C has a different solution for this, but
every (void *) pointer isn't guaranteed to be aligned, so I suspect
that the ANSI solution will cause problems elsewhere.
     
--
- Joe Buck     {ihnp4!pesnta,oliveb,nsc!csi}!epimass!jbuck
  Entropic Processing, Inc., Cupertino, California

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3030
          for JMS@ARIZMIS; Fri, 22-AUG-1986 12:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 13:34:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028029; 22 Aug 86 6:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018745; 22 Aug 86 5:40 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: C Compiler bug (and fix for a different one)
Message-ID: <6416@sun.uucp>
Date: 21 Aug 86 18:54:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> No, the value of the statement is being thrown away, not the value
> of the void(s).
     
True, but one can imagine the ":" half-operator selecting between one of the
two "void" values.  One then throws away the value returned by the "?"/":"
operator.
     
>
> Would you let me say:
>     .
>     .
>     .
>     f1() + f2();
>     .
>     .
>
> Since I am throwing both away?
     
No, you're not.  You're adding them and then throwing the *sum* away.
"void" "value"s can't be added.  If you consider "void" to be a sort-of
type, the set of whose values is a singleton set, then you can consider
     
    boolean_expression ? void_value_1 : void_value_2
     
to select one of the two "void" values and yield it as a result, so the ":"
half-operator, unlike the "+" operator, can act on two "void" values.
(Regardless of the value of the <boolean_expression>, the value yielded by
the expression will be the same, since <void_value_1> == <void_value_2> ==
any other void value you can think of.)
     
Think of it this way: "void" values require 0 bits to represent them, since
the set of all such values has only one element.  As such, "sizeof(void)"
should be 0.  As such, if you say
     
    void x;
     
"x" takes up no memory.  Given that, declaring objects of type "void" isn't
very useful.  An attempt to do so is probably an error, so it is rejected.
     
Also, if objects of type "void" were implemented, most implementations would
run the risk of giving it the same address as the next datum declared.  So
taking the address of a "void" is kind of useless, and so "void *" isn't
useful as a true "pointer to void", so it can be overloaded.
     
Also, since all "void" values are the same, an attempt to compare them is
probably an error, so "==", etc. aren't defined over the set of "void"
values either.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7430
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 22:20:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006491; 22 Aug 86 11:39 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa25982; 22 Aug 86 11:23 EDT
Date:     Fri, 22 Aug 86 11:20:34 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       "Harry W. Reed" <doon%sdcrdcf.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  What is pcc2 ?
Message-ID:  <8608221120.aa00862@VGR.BRL.ARPA>
     
PCC2 was a newer version of PCC that attempted to support more general
machine architectures than PCC.  I believe the AT&T MC68000 SGS is based
on it.  There have been many further developments; Dave Kristol described
the PCC family evolution in a talk at the Summer 1986 USENIX, and his
paper is included in the conference proceedings (p.335).

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0489
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/23/86 at 05:08:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009597; 23 Aug 86 5:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009413; 23 Aug 86 5:40 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.lang.c++
Subject: Re: What is pcc2 ?
Message-ID: <6443@sun.uucp>
Date: 22 Aug 86 08:38:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Now I'm quite familiar with pcc, but what is pcc2? A new and improved pcc...
     
Yes.  See "Four Generations of the Portable C Compiler", from the Summer
1986 USENIX proceedings.  This also describes QCC and RCC, which are
subsequent developments to PCC2.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0358
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/23/86 at 05:02:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009593; 23 Aug 86 5:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009221; 23 Aug 86 5:35 EDT
From: Bill Fnord Wisner <billw%wolf.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: "\"
Message-ID: <177@wolf.UUCP>
Date: 21 Aug 86 23:36:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> How do you spell "\"?
>
> Is it "Backslash", "Back slash", or "Back-slash"?
     
I call it "the little thingie under the pipe symbol." :-)
--
Bill Wisner            Property is theft.
..ihnp4!jack!wolf!billw                          -- P. J. Proudhon
                Property is liberty.
Disclaimer:                              -- P. J. Proudhon
Who needs 'em?            Property is impossible.
                                  -- P. J. Proudhon
To err is humor.        Consistency is the hobgoblin of small minds.
                             -- Ralph Waldo Emerson

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0655
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/23/86 at 05:15:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009599; 23 Aug 86 5:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009543; 23 Aug 86 5:43 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: C Coding Question
Message-ID: <86900025@haddock>
Date: 22 Aug 86 17:46:00 GMT
Nf-ID: #R:killer.UUCP:248:haddock:86900025:000:513
Nf-From: haddock!karl    Aug 22 13:46:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
>["type *" and "type []"] are IDENTICAL to virtually every C compiler ...
>Arrays in C are merely special cases of pointers.
     
You are wrong, but you've got a lot of company.
     
I almost wish the language had kept arrays and pointers completely separate,
requiring "&a[0]" to change an array into a pointer, and "*(p+n)" to index
from a pointer.  Or maybe "p@[n]", where "@" is some postfix operator that
converts a pointer into an array of unknown size.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6426
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 20:27:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028082; 22 Aug 86 6:41 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018566; 22 Aug 86 5:35 EDT
From: Mike Wexler <mike%peregrine.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: void*
Message-ID: <1122@peregrine.UUCP>
Date: 18 Aug 86 17:53:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I agree that void* should not be automatically coerced to another pointer type.
I like the way the new operator is implemented in C++, but do not think it
would work as well in C.  In C++ operators can be redefined on a type by
type basis and it is convenient to have this operator called at certain
points.  In C, operators are not redefinable.  Therefor memory allocation
becomes a feature of the language and not a library function.  I do not think
this is a good idea.  One of the main advantages of C is that there is
a small kernal of the language that is all that is necessary to create a
compiler.  The rest of the features are implemented in a library written in
C and replaceable by users that don't have the source code to the compiler.
--
Mike Wexler
Email address:(trwrb|scgvaxd)!felix!peregrine!mike
Tel Co. address: (714)855-3923
;-) Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine :-(

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0431
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/23/86 at 05:07:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009595; 23 Aug 86 5:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a009375; 23 Aug 86 5:39 EDT
From: Barry Shein <bzs@bu-cs.ARPA>
Newsgroups: net.lang.c
Subject: Re: ANSI C (re: null pointers)
Message-ID: <1096@bu-cs.bu-cs.BU.EDU>
Date: 22 Aug 86 16:24:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
An amusing anecdote on NULL pointers:
     
On our large IBM system an early version of one of the screen editors
had a null pointer problem. Basically, it would load the contents of
address 0 into a register rather than a zero.
     
Of course, the contents of location zero was zero. Usually.
     
Address zero on an IBM is the Machine Check PSW double-word. This
will contain the PSW if a machine check recently occurred (PSW is
the combined processor status, program counter, machine check means
a detected hardware error, obviously not fatal or why put it there.)
     
You guessed it! Mysterious failures of the editor as address 0
contained non-zero values for fleeting microseconds after a machine
check, which was a rare event. I guess the area got re-zeroed after
the O/S logged the error (or whatever.) It handled the machine check
asynchronously (maybe this was really caused by the dual processors,
I don't remember.)
     
Fun fun. Kids, our lives were already ruined by this sort of self-abuse,
but you're young, you can be saved, ah youth, wasted on the young :-)
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6814
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000445; 22 Aug 86 7:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020242; 22 Aug 86 7:33 EDT
From: Barry Shein <bzs@bu-cs.ARPA>
Newsgroups: net.lang.c
Subject: fgets() returns NULL at EOF??
Message-ID: <1094@bu-cs.bu-cs.BU.EDU>
Date: 22 Aug 86 05:30:09 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
fgets() returns a char * to the string read. Traditionally, any
function that cannot return a promised pointer (such as when an EOF
occurs) returns NULL (there exists a few syscalls which return ((char
*) -1) or equivalent, c'est la vie, this has been hashed out, I guess
the rule that syscalls return -1 won [eg. sbrk].)
     
puts() and fputs() always return the result of the last putc() done
(at least it does in 4.2/4.3bsd.) No mention of this is made in the
manual pages I have. This will be the last character of the string
unless an error occurred, in which case it will be EOF. Notice that
for puts() this will always be '\n' (or EOF on error.)
     
You're intuitions seem right, they should probably both return a
similar thing (ie. fputs() should probably return a pointer to the
string printed, or NULL on error, or maybe fgets() should return the
value of the last 'getc()' done, I like the former better.) Oh well,
such is history.
     
Of course, in the case of getc() et al, EOF makes sense as an
out-of-band character (ie. a value that cannot be a legal char,
hence distinguishable, but no relation to a pointer.)
     
Thus, fgets() is consistent with the idea of returning a NULL as
a failed pointer while fputs() is consistent with the documentation
in that the doc seems to promise nothing...
     
    -Barry Shein, Boston University

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3514
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/23/86 at 11:04:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010140; 23 Aug 86 11:53 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a012026; 23 Aug 86 11:14 EDT
Received: from mit-ai.arpa by AOS.BRL.ARPA id a010094; 23 Aug 86 11:10 EDT
Date: Sat, 23 Aug 86 11:08:23 EDT
From: "James B. VanBokkelen" <JBVB@MIT-AI.ARPA>
Subject:  Decus C
To: info-c@BRL.ARPA
Message-ID: <[AI.AI.MIT.EDU].87013.860823.JBVB>
     
DECUS C does not 'require' floating point hardware unless you're
actually using floats and doubles.  I've used it for years on an 11/44
with no FPP. I don't think it uses FPP hardware to compile programs
with floating point in use, only to run them.  There are also options
to allow the compiler and library to run without the SXT instruction
(e.g. on an 11/05).  Don't believe the comment in the documentation
that says that the compiler has hooks to generate FPP instructions, as
they were apparently all removed.
     
In general, it is a fine (but limited, lacking many modern features)
compiler for the PDP-11, and its library and accompanying utility
programs are pretty good too. However, since the compiler and all the
I/O library are MACRO-11, it is going to be tough to maintain unless
you are somewhat conversant with assembly.  It doesn't have structure
assignments or returns, or variable definition on block boundaries,
and I have no idea how difficult this sort of thing would be to add.
     
There are some bugs in the I/O library in the newest distribution I
had, my fixes for which have been posted to _The Heap_, the newsletter
put out by the DECUS Structured Languages SIG.  They should be
essentially type-in fixes (output from the 'diff' utility provided).
Get the back issues from '83, '84 and '85, because I think that SIG
has been somewhat overrun by the VAX/Ada people, and noone is updating
the distribution of the compiler.
     
jbvb@ai.ai.mit.edu
     
"What would you do if the label came off?"
     

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5137
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:15 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028035; 22 Aug 86 6:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018774; 22 Aug 86 5:41 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Indirect comma assigned from side effects
Message-ID: <3047@umcp-cs.UUCP>
Date: 21 Aug 86 20:27:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <792@navajo.STANFORD.EDU> rokicki@navajo.STANFORD.EDU
(Tomas Rokicki) writes:
>... For example, consider the program:
>
>    int lhs, rhs, index; int *pointers[9];
>    foo() { *( index=lhs, pointers[index] ) = sideeffects(); }
>
>The question is, does C allow for the possibility that the order
>of evaluation might be "index=lhs" then "sideeffects()" then
>"*pointers[index]=<result>"?
     
No.  The compiler can, however, effectively generate either of the
following:
     
    temp = sideeffects();
    index = lhs;
    *pointers[index] = temp;
     
or
     
    index = lhs;
    tempp = pointers[index];
    *tempp = sideeffects();
     
>... On the other hand, if C does not allow the compiler to
>generate such code, then the statement is well defined.
     
Not really, since one sequence sets index=lhs before the call, and
the other after.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4728
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/22/86 at 17:54:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027993; 22 Aug 86 6:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018438; 22 Aug 86 5:30 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <751@wjvax.wjvax.UUCP>
Date: 19 Aug 86 16:17:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <248@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes:
>In article <745@wjvax.wjvax.UUCP> brett@wjvax.UUCP (Brett Galloway) writes:
>
>> You are correct, but this is true of ALL uses of '?:`.  In fact, '?:` is
>> VERY useful, especially when you want to embed conditionals in a macro.
>> Using the if() {} else {} form restricts the contexts in which the macro
>> may appear.
>
>Unfortunately, Brett is incorrect here.  You can't use if/then/else to write:
>
>    for (i = up ? 0 : 99;  up ? (i < 100) : (i >= 0);  up ? i++ : i--)
>        {
>        /* complex loop body */
>        }
>
     
I thought I said the same thing -- '?:` is useful in some cases where
if/then/else isn't.
     
>without duplicating code.  On the other hand, anywhere you want do
>if/then/else (or any other complex statement, such as loops and switches)
>inside a macro without restricting where the code can be used, you can
>just write:
>
>    #define abc(x)    do { \
>            /* anything you want goes here, even declarations */ \
>            } while (0)
     
I don't think this method is general.  For example, your macro abc() cannot be
used inside a for() construct.
     
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4858
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028031; 22 Aug 86 6:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018749; 22 Aug 86 5:40 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <6418@sun.uucp>
Date: 21 Aug 86 19:03:29 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >Here are the things I have wanted badly enough to add to stdio:
> >FILE *fopenfxn(int (*fxn)(), char *mode)
> >    Function-stream I/O.
> Can't say I've ever thought about this one. I'm not sure when you'd
> use it either.
     
It might be useful for I/O on "streams" that aren't implemented by a file or
a string.  I suspect somebody out there has wanted such a beast (for
instance, one might use it with the 4.2BSD "syslog" facility, so that each
line written to the stream was logged.
     
> >FILE *fopenstr(char *str, int len, char *mode)
> >    An extension to sprintf() and sscanf().  This returns a stream
> >    which performs I/O to a string (this makes sprintf() and
> >    sscanf() unnecessay, though they are still convenient).
     
It looks straightforward to implement IF you have the 4BSD version of
standard I/O, where there's a "this is a string" flag for each FILE
structure.  The S5 version, unfortunately, has only a "char" for the flags,
not a "short", so it says that the "last" FILE entry, and only that entry,
is a stream.  If AT&T-IS is willing to put up with the terrifying
possibility of forcing people to delete *object* files and recompile them
for S5R4 (not *executable images*, they'll work fine as long as they don't
use shared libraries; if you can control which version of a shared library
you bind to, you can even make images built against shared libraries work),
they can do this too.  (Which way did V7 do this?)
     
Given "fopenstr" you can actually provide a version of "sprintf" that
performs *bounds checking* on the string it's printing into.  (Wow, what a
unique concept, software that doesn't scribble its data space when a user
types in a string longer than it expected!)
     
> Seems like a good idea. When you've finished playing around with
> fprintf's etc. and just want the file descriptor for locking or
> some other nefarious process and not all the expensive buffering space.
> I'd prefer fdclose as the name though.
     
That name might imply that the "fd" gets "close"d.  "unfdopen" is,
admittedly, a bit awkward.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7536
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008097; 22 Aug 86 18:57 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a004571; 22 Aug 86 17:41 EDT
Received: from isi-vaxa.arpa by AOS.BRL.ARPA id a007729; 22 Aug 86 17:41 EDT
Received: by vaxa.isi.edu (4.12/4.7)
    id AA07797; Fri, 22 Aug 86 14:37:10 pdt
From: "Jeffery A. Cavallaro" <jeff@isi-vaxa.ARPA>
Message-Id: <8608222137.AA07797@vaxa.isi.edu>
Date: 22 Aug 1986 1437-PDT (Friday)
To: info-c@BRL.ARPA
Cc:
Subject: C-STYLE (goto?)
     
I am sure that this case of style has been brought up before.  It has been
bothering me for awhile.
     
Support a particular routine is supposed to perform N steps, where each step
is performed dependent on the success of the previous step, i.e., if any
step fails, then you want to clean up and return.
     
I realize that:
     
    if (
        ( (status = step_1()) == SUCCESS) &&
        ( (status = step_2()) == SUCCESS) &&
            .
            .
            .
        ( (status = step_3()) == SUCCESS)
    );
    cleanup();
    return (status);
     
accomplishes this, but significantly ups the routine count.  Some refer to this
as good programming practice, but I tend to think of it as overkill for simple
jobs - especially when each routine requires a long header block as may be
required by various programming standards imposed upon (but maybe not accepted
by) the programmer.
     
Of course, there is the massively nested "if" string, but I can't stand that
style.  I tend to really get lost in such bird nests.
     
The way I like to do it is:
     
    setup_step_1;
    if ( (status = step_1()) == FAILURE )
        goto abort_operation;
     
    setup_step_2;
    if ( (status = step_2()) == FAILURE )
        goto abort_operation;
     
        .
        .
        .
     
    setup_step_n;
    if ( (status = step_n()) == FAILURE )
        goto abort_operation;
     
abort_operation:
     
    cleanup();
    return (status);
     
Now, I know a lot of people detest this because of the use of goto's, but this
seems the nicest way to perform this function.  I really have nothing against
goto's if they are directed to the same spot (i.e., don't jump back and forth)
and enhance the readability of the code.
     
Any comments?  I am willing to adapt to another reasonable style for such
cases (if anyone really cared).
     
Thanx for any and all responses (even rude ones),
Jeff
     

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4998
          for JMS@ARIZMIS; Sat, 23-AUG-1986 10:16 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028033; 22 Aug 86 6:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018753; 22 Aug 86 5:40 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: macro to specify output parameter
Message-ID: <6421@sun.uucp>
Date: 21 Aug 86 19:44:56 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >     foo(c)
> >         char &c;
> >     {
> >         ...
> >         c = 'a';    /* store 'a' in the "char" referred to by
> >                    "c" */
     
> I don't like this.  It violates the nice consistent way that C expressions
> work.  'char *c' means that '*c' is of type char.  '&c' is not of type
> char in any other context.
     
Well, maybe a keyword like "ref" would have been preferable.  However, the
"syntax of declaration resembles syntax of use" rule of C may be consistent,
but also can be confusing, so I don't consider it particularly holy.
     
Also note that "&c" is not of type "char" in ANY context; inside the body of
"foo", "&c" is of type "pointer to char", since it takes the address of the
"char" referred to by "c".  (The code generated for that would almost
certainly just take the value of the pointer that implements "c" and use
it.)  Dereferencing of reference types is automatic, so "syntax of
declaration resembles syntax of use" doesn't apply here.
     
> I don't see any problem with using '*' instead of REF and DEREF.
     
Since reference types and pointer types have different semantics, there are
cases, at least in C++, where reference types are, I believe, necessary.
Also, there may be cases where writing code using reference types could
eliminated the possibility of aliasing and permit better optimization.
     
Also, pointer arguments are overloaded in C; they are used if you actually
want to pass a pointer to a routine (because the routine will actually be
modifying the pointer value, e.g. "strcpy", where the pointer merely
indicates the address of the *first* character to copy to and the *first*
location to copy it into), and also if you want to do "call-by-reference".
The presence of reference types makes it possible to state your intent more
directly in C++ than in C.
     
> In any case, either '*' or 'DEREF' is better than the foo example above
> since the uses of the output parameter are marked.
     
It's not clear that marking the *uses* is interesting.  Is one just trying
to find the places where the item pointed to by the argument is modified?
You might want to do that with objects other than formal parameters, so
using "*" or "DEREF" doesn't solve the entire problem.
     
One might want to mark the *definition* instead; if the object referred to
by the parameter is read-only, one obviously doesn't have to look for the
places it's modified.  This can be done with the "const" type modifier in
ANSI C and C++, both for pointer and reference types.  If the routine takes
a reference or pointer to something and *doesn't* modify that something, it
should be declared as taking "pointer to 'const' whatever" or "reference to
'const' whatever"; the compiler will refuse to compile any code that
attempts to modify that something.
     
> I would like to see variable size arrays allowed as local parameters.
> This would be a lot more efficient than using malloc().
     
I presume you mean "local variables", and not "local parameters"; you can
already handle variable-sized array parameters by the subterfuge of passing
a pointer to the array (or to its first member) along with its length (if
you *don't* pass the length, make sure you can't run off the end!).
Supporting variable-sized arrays, even just as local variables, adds some
complication to the compiler.  Consider a function with two such arrays.
The address of the second such array (or the first, depending on the order
in which they're allocated), is a variable.  This would most likely be
supported by computing the address at the time it's allocated, stuffing it
into an invisible local variable, and replacing references to the array with
dereferences of the pointer.
     
If you support them in structures, the complications get worse.
     
> I would like to "operator definition" which would allow you to opdef
> say '+' to cause it and its two arguments to be replaced by a macro
> called with the two arguments whenever the arguments are of a type
> specified in the definition.  This allows generalized treatment of
> operators on non-native types such as 'complex'.
     
Check out C++; you can do exactly that there.  You can overload existing C++
operators, binding them to functions.  You can then declare the function to
be "inline" so that the code is expanded in-line rather than producing a
function call.  In fact, one example Stroustrup gives is the addition of the
type "complex" to C++, without changing the compiler and without turning all
complex arithmetic operations into procedure calls.
     
> Perhaps new operators could be custom defined or the syntax (left/right
> association, priority) of existing operators changed (but probably not
> except for completeness, changing existing operators is a good way to
> make a program unreadable).
     
Probably not even for completeness; the added cost of complication in the
compiler doesn't seem worth it.  (Isn't there a minor industry producing
discussions of implementation of overloading in Ada compilers?)
     
> I would like to see "structure constants" which would allow assignment
> to aggregate types.
     
C++ has this, using "constructors".  Any "class", and structures are special
cases of classes, can have a "constructor" as a member function.  A
"constructor" can take arbitrary argument lists, and merely need construct
an object of the appropriate type.
     
I think if you declare the "constructor" as "inline", it will do the "right"
thing (i.e.,
     
    typedef class complex {
        double    real;
        double    imaginary;
    public:
        inline complex(double r, double i = 0) {
            real = r;
            imaginary = i;
        }
        ...
    } complex;
     
will cause
     
    complex i = complex(1, 0);
     
to generate code like
     
    i.real = 0;
    i.imaginary = 1;
     
I don't know whether it can be set up to do this at compile time for static
objects.
     
> Macros would be nicer with "imbedded functions".
>
> #define    foo(x,y) { float a = 0.0; while (x) { a += y * x--; }; \
               return a; }
     
See David Chase's recent posting; he proposes more-or-less the same sort of
thing, mentioning the similar sort of construct in BCPL.
     
Of course, for this sort of thing, C++ "inline" functions might be better.
     
Give a look at C++; don't let its syntax for reference types put you off.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)
From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA" 25-AUG-1986 03:41
To:	JMS
Subj:	Re: by-ref parameters, aggregate constants, etc

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5700
          for JMS@ARIZMIS; Mon, 25-AUG-1986 03:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/25/86 at 05:35:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015559; 25 Aug 86 6:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024308; 25 Aug 86 5:39 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: by-ref parameters, aggregate constants, etc
Message-ID: <3100@umcp-cs.UUCP>
Date: 24 Aug 86 03:52:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <6229@sun.uucp> guy@sun.uucp (Guy Harris) writes:
>>This may, in fact, also be an argument for reference types a la C++; there,
>>your routine "foo" would be written as
>>
>>     foo(c) char &c; { ...
     
In article <161@BMS-AT.UUCP> stuart@BMS-AT.UUCP (Stuart D. Gathman) writes:
>I don't like this.
     
I have no great love for this syntax either; but how else do you
propose to add by-reference parameters?  (I believe that by-reference
parameters are, in general, bad, at least if I cannot tell from
the caller that the parameter is modifiable.  I would not add them
at all.  Clearly Bjarne Stroustrup and I disagree.)
     
>I would like to see variable size arrays allowed as local parameters.
>This would be a lot more efficient than using malloc().
     
... or alloca() (since it requires a function call).  These would
indeed be useful, if more expensive than fixed arrays.  Actually,
I think a general stack allocator, possibly `built in' to the
language, would do: were alloca() a reserved word, for example, it
could be expanded in line.  (Indeed, it may not always be possible
to allocate stack objects in a called function, but it is not hard
for the caller to manage the trick.)
     
>I would like to "operator definition" which would allow you to opdef
>say '+' to cause it and its two arguments to be replaced by a macro
>called with the two arguments whenever the arguments are of a type
>specified in the definition.
     
C++ has this sort of thing, though the expansion does not use macros
(inline functions are perhaps legal).
     
>I would like to see "structure constants" which would allow assignment
>to aggregate types.
     
General aggregate types are, I think, the one thing that would
really `round out' the C language.  Currently the only legal
aggregate type is `array N of char', expressed as
     
    "string"
     
If C were given aggregate types, it would then seem appropriate to
me also to alter array names to `be' the entire array.  But such
changes would be quite substantial, and the language should not
then be called `C'.
     
>Macros would be nicer with "imbedded functions".
>
>#define foo(x,y) { float a = 0.0; while (x) { a += y * x--; }; return a; }
     
Inline functions are clearer, I think:
     
    inline int
    foo(x, y)
        int x, y;
    {
        float a = 0.0;
     
        while (x)
            a += y * x--;
        return (a);
    }
     
>This construct is distinguished by the use of '{}' in a context
>requiring a value.  The return is optional, the value of the last
>expression is used.
     
Would early `return's be legal?  What if the last statement is not
an expression?  (Back up to the most recent expression?)  Such a
change requires careful thought to ensure that all the elements of
the language still `mesh' properly.  One of the nicest things about
C-as-it-is-now is that most of its primitives do indeed mix well.
     
>Perhaps loops should be allowed in comma expressions instead.
     
This sounds to me ill-advised.  Inline functions are semantically
obvious; `embedded' functions or loops are less lucid.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"rokicki@su-navajo.ARPA" 25-AUG-1986 03:45
To:	JMS
Subj:	Re: Indirect comma assigned from side effects

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5807
          for JMS@ARIZMIS; Mon, 25-AUG-1986 03:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/25/86 at 05:40:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015563; 25 Aug 86 6:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024327; 25 Aug 86 5:39 EDT
From: Tomas Rokicki <rokicki@su-navajo.ARPA>
Newsgroups: net.lang.c
Subject: Re: Indirect comma assigned from side effects
Message-ID: <796@navajo.STANFORD.EDU>
Date: 22 Aug 86 18:14:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3047@umcp-cs.UUCP>, chris@umcp-cs.UUCP (Chris Torek) writes:
> In article <792@navajo.STANFORD.EDU> I write:
> >
> >    int lhs, rhs, index; int *pointers[9];
> >    foo() { *( index=lhs, pointers[index] ) = sideeffects(); }
> >
> >The question is, does C allow for the possibility that the order
> >of evaluation might be "index=lhs" then "sideeffects()" then
> >"*pointers[index]=<result>"?
>
> No.  The compiler can, however, effectively generate either of the
> following:
>
     
Can someone second this, or show me the appropriate reference?
It's Microsoft 4.0 that's putting the sideeffects() call between
the two parts of the comma expression, and sideeffects() modifies
index . . . you get the idea.  I could find nothing in K&R, but
I'm only been hacking C for a year or so.
     
I just tested under 4.3bsd; cc also puts the sideeffects() in the
middle.  Comments, anyone?
     
Thanks!   -tom

From:	ARPA%"tad%killer.uucp@BRL.ARPA" 25-AUG-1986 03:47
To:	JMS
Subj:	Re: C Coding Question

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5889
          for JMS@ARIZMIS; Mon, 25-AUG-1986 03:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/25/86 at 05:41:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015568; 25 Aug 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024359; 25 Aug 86 5:40 EDT
From: Tad Marko <tad%killer.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C Coding Question
Message-ID: <262@killer.UUCP>
Date: 23 Aug 86 03:13:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In my original article, I wasn't asking if this was legal:
     
char **thing = {"stuff","and more stuff"};
     
I was asking if I should use
     
foo(parm)
char **parm;
{...}
     
or
     
foo(parm)
char *parm[];
{...}
     
and I *DID* test both of them, and they both worked.
     
C'mon, give me at least a *little* credit...sheeeesh!
     
--
Tad Marko
..!ihnp4!killer!tad        ||    ..!ihnp4!alamo!infoswx!ntvax!tad
UNIX Connection BBS AT&T 3B2        North Texas State U. VAX 11/780
flames to:  /dev/your_ear

From:	jnet%"karl@haddock" 25-AUG-1986 03:52
To:	JMS
Subj:	Re: Using strings as immediate char

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6038
          for JMS@ARIZMIS; Mon, 25-AUG-1986 03:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/25/86 at 05:48:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015583; 25 Aug 86 6:23 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024558; 25 Aug 86 5:45 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Using strings as immediate char
Message-ID: <86900026@haddock>
Date: 24 Aug 86 19:59:00 GMT
Nf-ID: #R:sun.uucp:6309:haddock:86900026:000:697
Nf-From: haddock!karl    Aug 24 15:59:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
sun!guy (Guy Harris) writes:
>(The real test, of course, is whether
>        cmdchr = menu_selection["rofq"];
>yields the same result.  Any compiler that doesn't produce object code that
>yields the same result isn't a C compiler.)
     
True, and still true in ANSI C, though I'm still not sure why.  Is there any
valid reason for writing such a mess?  I think it ought to be deprecated, or
even completely illegal (but available, of course, as a "common extension" on
"some compilers").
     
No, not just for aesthetic reasons.  It makes it easier to define arrays as a
real datatype in future implementations if "x[y]" is redefined slightly.
     
Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint

From:	ARPA%"bright%dataio.uucp@BRL.ARPA" 25-AUG-1986 03:54
To:	JMS
Subj:	Re: Orphaned Response

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5980
          for JMS@ARIZMIS; Mon, 25-AUG-1986 03:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/25/86 at 05:47:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015581; 25 Aug 86 6:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024509; 25 Aug 86 5:44 EDT
From: Walter Bright <bright%dataio.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <1074@dataio.UUCP>
Date: 22 Aug 86 16:31:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900019@haddock> karl@haddock writes:
>ccvaxa!aglew (Andy Glew) writes:
>>[haddock!karl (Karl Heuer) writes:]
>>>I was trying to declare "typedef void dead;" so that I could distinguish
>>>between functions that return nothing (void perror(char *), setbuf(FILE *,
>>>char *), nullf(void)) from those that don't return (dead exit(int),
>>>abort(void), longjmp(jmp_buf, int)).
>>
>>Good point, though - an optimizing compiler could take advantage of
>>knowledge that a function doesn't return to do better register allocation,
>>etc.
>
> The only
>reasons for not adding [dead functions], as far as I can see, are as follows:
>
>[2] It won't be usable much.  This is a valid point.  There were a *lot* of
>nonvalued int functions before void was invented; there are only a handful of
>standard functions that are dead-ends.
     
    Functions that never return are used a LOT in code that is loaded
    with self-debugging assertion macros:
     
        #define assert(e) ((e) || printmsgandexit("e",__LINE__,__FILE__))
     
>As for optimization, the calling
>function can take advantage of the knowledge by omitting extra branches (e.g.
>in "if (err) exit(1); else ...") or returns ("exit(0)" at the bottom of
>main()).  This improves the space (but not time) efficiency, but not by much.
>
>I presume your comment about register allocation referred to the dead-end
>itself, in that the caller's registers need not be saved.  I don't think you
>can assume this: the function "dead f() { for (;;) pause(); }" could be
>interrupted by a signal, whose handler could longjmp() to f's caller, whose
>registers must be recoverable.  For similar reasons, it probably isn't okay
>to optimize the function call into a jump, unless you're careful with the
>stack.
     
    A good optimizer can make some important optimizations if it
    knows that a function will never return:
     
    1) Register contents destroyed by the function call do not affect
    the caller. This has important ramifications when doing register
    allocation by coloring.
     
    2) Functions are presumed to modify all globals and all indirect
    references. Thus, if the function does not return, the optimizer
    can find more common subexpressions, copy propagations, etc.

From:	ARPA%"friesen%psivax.uucp@BRL.ARPA" 25-AUG-1986 05:01
To:	JMS
Subj:	Re: entry keyword?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6702
          for JMS@ARIZMIS; Mon, 25-AUG-1986 05:01 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/25/86 at 06:56:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016084; 25 Aug 86 7:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026176; 25 Aug 86 7:30 EDT
From: Stanley Friesen <friesen%psivax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: entry keyword?
Message-ID: <1404@psivax.UUCP>
Date: 22 Aug 86 19:05:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <574@hope.UUCP> corwin@hope.UUCP (John Kempf) writes:
>Can anyone tell me what the entry keyword is supposed to do?
>I have seen it mentioned in several C books, but all of them
>say that it is supposed to be implimented later.
>thanks,
     
    It was "reserved" so that multiple entry points to a single
routine could be added to the language later, a la PL/I. For example:
     
void func1(a)
int a;
{
    int b;
     
    b = f(a);
    /* Do some stuff */
entry func2(a, b)
    /* Do some more stuff */
    return;
}
     
    Or anyway something like that. The idea is to allow related
routines to shre code more efficiently. The feature will probably
never be implemented though, so it is probably just of historical
interest.
---
     
                Sarima (Stanley Friesen)
     
UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ??

From:	ARPA%"rgenter@bbn-labs-b.ARPA" 25-AUG-1986 06:47
To:	JMS
Subj:	Re: Use of lint (4.2bsd)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7473
          for JMS@ARIZMIS; Mon, 25-AUG-1986 06:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/25/86 at 08:39:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018969; 25 Aug 86 9:32 EDT
Received: from labs-b.bbn.com by SMOKE.BRL.ARPA id a028342; 25 Aug 86 8:56 EDT
To: Brett Galloway <brett%wjvax.uucp@bbn-labs-b.ARPA>
cc: info-c@BRL-SMOKE.ARPA
Subject: Re: Use of lint (4.2bsd)
Date: 25 Aug 86 08:55:43 EDT (Mon)
From: Rick Genter <rgenter@bbn-labs-b.ARPA>
     
There is a bug in the shell script /usr/bin/lint distributed with 4.2 BSD such
that if you specify a switch to lint that has the letter 'n' *anywhere* in
its name, you will turn on the "don't check against the standard libraries"
flag.  The fix is to modify /usr/bin/lint where it says:
     
    -*n*)    P= ;;
    -*p*)    P=port ;;
     
to say:
     
    -n)    P= ;;
    -p)    P=port ;;
     
You will lose the ability to specify switches like "-hn" (i.e., you will have
to specify the -n or -p switch separately), but you will gain the ability
to have an include directory which contains the letters n and/or p!
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

From:	ARPA%"gary%darth.uucp@BRL.ARPA" 26-AUG-1986 03:12
To:	JMS
Subj:	Re: Generating code for the switch statement

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6456
          for JMS@ARIZMIS; Tue, 26-AUG-1986 03:12 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/26/86 at 05:07:01 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006258; 26 Aug 86 5:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015621; 26 Aug 86 5:35 EDT
From: Gary Wisniewski <gary%darth.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Generating code for the switch statement
Message-ID: <141@darth.UUCP>
Date: 21 Aug 86 04:49:15 GMT
Posted: Thu Aug 21 00:49:15 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <840@edison.UUCP> jso@edison.UUCP (John Owens) writes:
>In article <610@hropus.UUCP>, ka@hropus.UUCP (Kenneth Almquist) writes:
>> If the cases are not consecutive, the branch table must be filled with
>> entries for the "missing" cases, making the table larger.  [....]  If
>> the cases are mostly consecutive with a few outliers, a branch table
>> could be augmented with a few specific tests for the outliers, but I
>> don't know of any compiler that does this.
>
>The Microsoft Pascal/Fortran compilers, at least some of the old
>ones (3.04 and 3.11) do this.  I haven't tried it to see if their
>wonderful new code generators do.
     
Lattice C (for IBM PC/XT/AT) actually generates three possible code sequences
for switch statements:
     
    1.  For a small number of cases, individual comparisons
        are generated.
    2.  For a large number of cases, a branch table is generated, with
        default branches for the missing cases.
    3.  For cases which compromise space (in 2) or speed (in 1), the
        final approach builds a compact branch table and scans it
        sequentially.
     
This is true for versions 2.14/2.15 of Lattice C (which were the same
as the Microsoft C Compiler before version 3.)  Lattice no longer supplies
the Microsoft compiler, but has continued the traditional switch statement
code generation trio at Lattice version 3.00.
     
It is certainly not clear whether or not it is worth the trouble.
Especially since the Lattice code generator does not take advantage of
some of the fast compare/increment/repeat instructions for the 8086/88 when
implementing option (3).  Instead, they generate a loop which takes several
times the speed and space possible with a better technique.
     
Another interesting note about Lattice's handling of switch statements.
Lattice reduces the following:
     
    switch (i)
      {
        case '0':
        case '1':
        case '2':
        case '3':
          break;
      }
     
to:
     
    if (i >= '0' || i <= '3')
      ;
     
However, it will not perform the same optimization if other cases, not
serial with the rest, are included in the switch statement.  I hope that
this is a side effect, since this particular situation would occur
seldom, if ever, in real C code.
     
In any case, they seem to have spent some time trying to generate
interesting, if not useful, code for switch statements.  (I do
wish they had recognized the above example as useless and removed it
completely, however.)
     
Gary Wisniewski
Pittsburgh, PA
(412) 363-4685
uucp:    {allegra,bellcore,cadre}!pitt!darth!gary

From:	jnet%"karl@haddock" 26-AUG-1986 03:17
To:	JMS
Subj:	Unsigned promotions

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6608
          for JMS@ARIZMIS; Tue, 26-AUG-1986 03:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/26/86 at 05:12:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006260; 26 Aug 86 6:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015702; 26 Aug 86 5:37 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Unsigned promotions
Message-ID: <86900028@haddock>
Date: 25 Aug 86 18:41:00 GMT
Nf-ID: #N:haddock:86900028:000:497
Nf-From: haddock!karl    Aug 25 14:41:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
When an unsigned char or unsigned short is used in an expression, is it
promoted to int or unsigned int?  (It is zero-extended either way, but the
type of the result is significant, e.g. in a divide.)
     
K&R seems not to mention unsigned datatypes other than int.
My local C compiler promotes it to unsigned.
X3J11 (May, 1986) says the result is int.
     
Do some existing compilers promote to signed int?  What does H&S say?
     
Karl W. Z. Heuer (karl@haddock.isc.com; ima!haddock!karl), The Walking Lint

From:	ARPA%"quiroz@ROCHESTER.ARPA" 26-AUG-1986 03:40
To:	JMS
Subj:	Re: Using strings as immediate char

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6860
          for JMS@ARIZMIS; Tue, 26-AUG-1986 03:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/26/86 at 05:32:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006367; 26 Aug 86 6:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015505; 26 Aug 86 5:31 EDT
From: Cesar Quiroz <quiroz@ROCHESTER.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using strings as immediate char
Message-ID: <20382@rochester.ARPA>
Date: 25 Aug 86 04:34:26 GMT
Emacs: -*- Mode: subMH -*-
Expires:
Sender:
Followup-To:
To:       info-c@BRL-SMOKE.ARPA
     
In a recent posting, referring to the "abc"[2] question:
>> sun!guy (Guy Harris) writes:
>> >(The real test, of course, is whether
>> >        cmdchr = menu_selection["rofq"];
>> >yields the  same result.    Any  compiler that doesn't  produce
>> >object code that yields the same result isn't a C compiler.)
>>
     
To which karl@haddock replied asking why should it be so, and
suggested making it illegal, among other reasons because, presumably
>> ...  It makes it easier to define
>> arrays as a real datatype in future implementations  if "x[y]" is
>> redefined slightly.
     
    Please notice that  "future implementations"   always have    to
decide   whether they want  to   be reasonably   compatible with the
language as it is.  The identity x[y] = *(x+y) is  so substantial to
C as it  is now, that an  implementation that  invalidated it  would
have trouble with *lots* of  reasonable current code.   For the sake
of argument, we can imagine calling our 'foo  x[];' things something
like vectors (as  C++ does) and then  inventing real  arrays (as you
want them). Then if the real arrays don't  obey the identity  above,
we better introduce new syntax, so most old programs are still valid
and *have the same meaning*, while some legal new programs (the ones
that depend on the extension) are distinguishably illegal in the Old
Standard.  I don't think it pays to patch C even more,  but at least
let's try for extensions that don't cause trouble.
     
     
Anybody for 'char txt]100[;' as the new syntax? :-)  That's more or
less what I had in mind.  No way to confuse them.  (Or there is?)
--
Cesar Augusto  Quiroz Gonzalez
Department of Computer Science     {allegra|seismo}!rochester!quiroz
University of Rochester            or
Rochester,  NY 14627               quiroz@ROCHESTER

From:	ARPA%"ireland@ALMSA-1.ARPA" 27-AUG-1986 07:39
To:	JMS
Subj:	Re:  Use of lint (4.2bsd)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9331
          for JMS@ARIZMIS; Wed, 27-AUG-1986 07:39 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/27/86 at 08:50:09 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025681; 26 Aug 86 16:35 EDT
Received: from almsa-1.arpa by SMOKE.BRL.ARPA id a000492; 26 Aug 86 15:40 EDT
Received: from almsab by ALMSA-1.ARPA id a011799; 26 Aug 86 14:09 CDT
Date:     Tue, 26 Aug 86 13:49:35 CDT
From:     Mike Ireland <ireland@ALMSA-1.ARPA>
To:       Rick Genter <rgenter@bbn-labs-b.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  Use of lint (4.2bsd)
     
A better fix for the bug in /usr/bin/lint might be to skip include libraries
in the first case statement, i.e.:
     
    -l*)    ;;
    -*n*)    P= ;;
    -*p*)    P=port ;;
     
This fix does not require any change in specifying switches and will allow an
n or p in an include library name.
     
    -Mike.
--
Mike Ireland     <ireland@almsa-1.arpa>       ..!seismo!ireland@almsa-1.arpa
USAMC ALMSA, Box 1578, St. Louis, MO  63188-1578      (314) 263-5118, AV 693

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA" 27-AUG-1986 09:15
To:	JMS
Subj:	Re: Indirect comma assigned from side effects

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1340
          for JMS@ARIZMIS; Wed, 27-AUG-1986 09:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/27/86 at 11:07:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027656; 27 Aug 86 5:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006647; 27 Aug 86 5:32 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Indirect comma assigned from side effects
Message-ID: <3133@umcp-cs.UUCP>
Date: 26 Aug 86 13:42:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>>>    foo() { *( index=lhs, pointers[index] ) = sideeffects(); }
>>>... does C allow for the possibility that the order
>>>of evaluation might be "index=lhs" then "sideeffects()" then
>>>"*pointers[index]=<result>"?
     
>In article <3047@umcp-cs.UUCP> I wrote:
>>No.
     
In article <2401@ihlpg.UUCP> tainter@ihlpg.UUCP (Tainter) writes:
>As far as I can tell the only restriction on order of evaluation is
>index=lhs before pointers[index].
     
After more thought, I now reverse myself.  K&R (p. 192) say only
`a pair of expressions separated by a comma is evaluated left-to-
right and the value of the left expression is discarded.'  Apparently
this does not imply that nothing else may occur in between.  I may
see whether X3J11 is more explicit, but that must wait until I am
once again near a copy of the latest draft.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"dickj%tekgen.uucp@BRL.ARPA" 27-AUG-1986 09:20
To:	JMS
Subj:	Re: Microsoft C 4.0 availability query

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1435
          for JMS@ARIZMIS; Wed, 27-AUG-1986 09:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/27/86 at 11:14:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027675; 27 Aug 86 6:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006697; 27 Aug 86 5:34 EDT
From: Dick Jackson <dickj%tekgen.uucp@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Microsoft C 4.0 availability query
Message-ID: <333@tekgen.UUCP>
Date: 26 Aug 86 01:59:14 GMT
Keywords: MSC C Compiler
To:       info-c@BRL-SMOKE.ARPA
     
I just got the v4.0 compiler and am VERY pleased with it.  The new full
screen debugger is always included and is very, very useful (saved me much time
already.)
     
I purchased my copy from 47th street computer (really 47th street photo) for
299.  I actually found it cheaper some place else (don't remember where
anymore) but for the extra $10, I feel much more comfortable about using 47th
with whom I've worked several times over the last 10 years without a single
hitch.  I requested UPS Blue (Second day air) and got the product in 1 week.
     
I'm quite please with the new compiler, although I never used 3.0 much.  The
documentation now takes three binders and appears to be definitely better than
v3.0.  Again, I'm quite impressed with codeview (the debugger).  I am working
on a program that uses several 'huge' arrays, and the debugger helped find
several fairly subtle errors in pointer coersion, which reminds of another great
help: prototype arguements in 4.0.
     
     
Anyway ... its quite a good product, and 47th did a good job of delivering.
Also, although I wasn't aware of this, if you buy the compiler and MASM (which
I ordered with v4.0), you can get a $25 rebate from Microsoft.  47th back
ordered MASM for an additional week and then sent it without me ever having to
contact them.
     
CodeView comes with a demo diskette which MS gives permission to duplicate
and post.  You might try to get a hold of it, its a nice demo.
     
Steven Parkes
     
tektronix!tekgen!dickj

From:	ARPA%"asw%tony.uucp@BRL.ARPA" 27-AUG-1986 09:25
To:	JMS
Subj:	Re: Generating code for the switch statement

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1539
          for JMS@ARIZMIS; Wed, 27-AUG-1986 09:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/27/86 at 11:18:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028211; 27 Aug 86 7:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007777; 27 Aug 86 7:31 EDT
From: Tony Williams <asw%tony.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Generating code for the switch statement
Message-ID: <1611@rlvd.UUCP>
Date: 20 Aug 86 11:26:32 GMT
Sender: news%rlvd.uucp@BRL.ARPA
Posted: Wed Aug 20 13:26:32 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <840@edison.UUCP> jso@edison.UUCP (John Owens) writes:
>
>In article <610@hropus.UUCP>, ka@hropus.UUCP (Kenneth Almquist) writes:
>> If the cases are not consecutive, the branch table must be filled with
>> entries for the "missing" cases, making the table larger.  [....]  If
>> the cases are mostly consecutive with a few outliers, a branch table
>> could be augmented with a few specific tests for the outliers, but I
>> don't know of any compiler that does this.
>
>The Microsoft Pascal/Fortran compilers, at least some of the old
>ones (3.04 and 3.11) do this.  I haven't tried it to see if their
>wonderful new code generators do.
>
     
I am not sure that this is original, as I think it has been used in
BCPL compilers and the like for ages.
I implemented this in a C compiler for an unusual machine (a Three Rivers
Perq running the CMU Accent operating system, with our own Unix emulation
layered on top).  See comments following for a discussion of the advantages.
     
The algorithm is roughly as follows (barring
off-by-one errors - my favourite):
     
genSwitch( caseLabels, addresses, labelCount )
    int *caseLabels;        /* array of label values */
    <mumble> *addresses;    /* array of addresses */
    int labelCount;        /* number of labels */
{
    int labelRange = caseLabels[labelCount-1] - caseLabels[0];
    if( labelRange <= acceptable_sparseness * labelCount )
        /* suitably dense */
    genJumpTable(  caseLabels, addresses, labelCount )
    else
    {
     
    /* too sparse - generate some tests
     * first find some suitable median value of label,
     * say one that divides the table in half for simplicity
     */
     
    int median = findMedian( caseLabels, labelCount );
                /* eg labelCount / 2; */
                /* result is place in table, not value */
    genIfStmt( switchExpr, caseLabel[median], less_than );
     
    /* now do the lower half (expr < median) */
    genSwitch( caseLabels, addresses, median );
     
    startElse();
     
    /* now the upper half (expr >= median) */
    genSwitch( &caseLabels[median], &addresses[median], labelCount-median );
     
    }
}
     
This algorithm has several nice features:
  - the sparsesness threshold can be tuned without hacking code
  - the use of recursion for each portion of the divided switch
    means that locally dense clusters in a sparse switch can each have their
    own jump table, reached by test-and-jumps
  - the tests for out-of-range expressions can be factored in to the
    algorithm,
  - the choice of division point can be made more intelligently if you
    wish (eg by maximising the density of one or both portions),
    by only changing findMedian()
  - non-dense cases are effectively handle by binary search,
    coded as a jump tree.  This approaches optimal, if there is
    no information on dynamic frequencies.
     
The generated code (subject to findMedian) is usually within one extra test
of being optimal.  Not bad for a simple-minded algorithm.
     
As a footnote, the virtual machine architecture had no indirect jump
instruction, so the same technique (and code) was used here by Trudy Watson
in implementing FORTRASH computed goto's and (shudder) assigned goto's.
---------------------------------------------------------------------------
Tony Williams                    |Informatics Division
UK JANET:    asw@uk.ac.rl.vd            |Rutherford Appleton Lab
Usenet:        {... | mcvax}!ukc!rlvd!asw    |Chilton, Didcot
ARPAnet:    asw%vd.rl.ac.uk@ucl-cs.arpa    |Oxon OX11 0QX, UK

From:	ARPA%"henry%utzoo.uucp@BRL.ARPA" 27-AUG-1986 09:41
To:	JMS
Subj:	Re: entry keyword?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1731
          for JMS@ARIZMIS; Wed, 27-AUG-1986 09:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/27/86 at 11:31:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028887; 27 Aug 86 8:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007825; 27 Aug 86 7:33 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: entry keyword?
Message-ID: <7069@utzoo.UUCP>
Date: 26 Aug 86 18:59:51 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> ...probably never be implemented though, so [entry] is probably just
> of historical interest.
     
In fact, I believe X3J11 has officially dropped "entry" as a keyword.
--
                Henry Spencer @ U of Toronto Zoology
                {allegra,ihnp4,decvax,pyramid}!utzoo!henry

From:	ARPA%"zben@umd5.ARPA" 27-AUG-1986 09:49
To:	JMS
Subj:	Re: by-ref parameters

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1833
          for JMS@ARIZMIS; Wed, 27-AUG-1986 09:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/27/86 at 11:40:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028918; 27 Aug 86 8:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007852; 27 Aug 86 7:34 EDT
From: Ben Cranston <zben@umd5.ARPA>
Newsgroups: net.lang.c
Subject: Re: by-ref parameters
Message-ID: <1198@umd5>
Date: 26 Aug 86 22:56:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2400@ihlpg.UUCP> tainter@ihlpg.UUCP (Tainter) writes:
     
> The win for by-reference parameters is the syntax of their use in the callEE.
> I do extensive personal programming in pascal and C.  When rereading pascal
> with by-reference parameters I do at times lose track of what is a var
> parameter at the callER level but never at the callEE level.  C fixes this
> but at the expense of excessive clutter and confusion with pointers inside
> the callEE.
     
I work extensively with a Sperry language called Plus.  It requires reference
arguments to be marked (with a percent sign) in BOTH places.  When I started
it seemed redundant, but it is interesting that it makes *sure* you know in
*both* contexts what is going on...
--
                    umd5.UUCP    <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland Sperrows 1100/92
                    umd2.BITNET     "via HASP with RSCS"

From:	ARPA%"stuart%bms-at.uucp@BRL.ARPA" 27-AUG-1986 09:54
To:	JMS
Subj:	Re: by-ref parameters, aggregate constants, etc

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1906
          for JMS@ARIZMIS; Wed, 27-AUG-1986 09:54 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/27/86 at 11:46:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028976; 27 Aug 86 8:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007977; 27 Aug 86 7:37 EDT
From: "Stuart D. Gathman" <stuart%bms-at.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: by-ref parameters, aggregate constants, etc
Message-ID: <174@BMS-AT.UUCP>
Date: 27 Aug 86 02:32:16 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3100@umcp-cs.UUCP>, chris@umcp-cs.UUCP (Chris Torek) writes:
     
Inline functions are clearer, I think:
     
    inline int
    foo(x, y)
        int x, y;
     {
         float a = 0.0;
     
         while (x)
             a += y * x--;
         return (a);
     }
     
--
Yeah!  That is much better! (I just didn't think of it.)
--
Stuart D. Gathman    <..!seismo!{vrdxhq|dgis}!BMS-AT!stuart>

From:	jnet%"PHIL@UIUCVMD" 27-AUG-1986 09:59
To:	JMS
Subj:	Re: Large files

Received: From BITNIC(MAILER) by ARIZMIS with RSCS id 5112
          for JMS@ARIZMIS; Wed, 27-AUG-1986 09:59 MST
Received: by BITNIC (Mailer X1.23b) id 5015; Wed, 27 Aug 86 12:10:45 EDT
Received: from UIUCVMD(MAILER) by BITNIC (Mailer X1.23b) id 4587;
Comment:      Wed, 27 Aug 86 12:06:56 EDT
Received: by UIUCVMD (Mailer X1.23) id 8962; Wed, 27 Aug 86 11:02:11 CDT
Date:         Wed, 27 Aug 86 10:59:34 CDT
Sender:       (PHIL@UIUCVMD) via List Processor <LISTSERV@BITNIC>
Reply-to:     Distribution List <UG-L@BITNIC>
X-From:         Phil Howard <PHIL@UIUCVMD>
From:         PHIL@UIUCVMD
Subject:      Re: Large files
To:           JOEL M SNYDER <JMS@ARIZMIS> (Distribution: UG-L)
In-Reply-To:  Your message of Tue, 26 Aug 1986 23:05 EDT
     
One possible enhancement to RSCS V1, if anyone can figure a way to make
it, is to make RSCS defer large files for a period of time after they
arrive, before sending them again on another link.  The typical problem
is that of a 10 line file waiting behind a 100,000 line file.  When both
are going to nearly the same place, the little will stay behind the big
one if at each node, the next link was not busy at the moment the big
file arrives; it gets started immediately and RSCS can't know which files
are "soon to arrive".

From:	ARPA%"grt%twitch.uucp@BRL.ARPA" 27-AUG-1986 10:14
To:	JMS
Subj:	Reply to jeff at isi-vaxa

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2139
          for JMS@ARIZMIS; Wed, 27-AUG-1986 10:14 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029115; 27 Aug 86 8:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008100; 27 Aug 86 7:39 EDT
From: " G.R.Tomasevich" <grt%twitch.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Reply to jeff at isi-vaxa
Message-ID: <402@twitch.UUCP>
Date: 26 Aug 86 12:10:21 GMT
Keywords: avoiding goto
To:       info-c@BRL-SMOKE.ARPA
     
The mail failed with some long reply I don't understand.
     
<    if (
<        ( (status = step_1()) == SUCCESS) &&
<        ( (status = step_2()) == SUCCESS) &&
<            .
<            .
<            .
<        ( (status = step_3()) == SUCCESS)
<    );
     
One way to avoid this is to store the pointers to the functions step_?()
in an array and then run a for() loop with a break on failure.  E. g.:
     
int step_1(), step_2() ...;
int (*fst[])() = { step_1, step_2, ... };
#define N some_number    /* whatever number there are */
     
    int i, status;
    for(i=0; i<N; i++)
        if((status = (*fst[i])()) == FAILURE)
            break;
     
I checked this with trivial functions.
--
    George Tomasevich, ihnp4!twitch!grt
    AT&T Bell Laboratories, Holmdel, NJ

From:	ARPA%"jagardner%watmath.uucp@BRL.ARPA" 27-AUG-1986 11:00
To:	JMS
Subj:	Comments on proposed C standard

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2051
          for JMS@ARIZMIS; Wed, 27-AUG-1986 11:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029042; 27 Aug 86 8:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008044; 27 Aug 86 7:38 EDT
From: Jim Gardner <jagardner%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Comments on proposed C standard
Message-ID: <2807@watmath.UUCP>
Date: 21 Aug 86 18:14:22 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The following (huge) document comments on the latest proposal
for a C standard.  It is paginated, but does not contain tabs.

     
     
     
     
                        COMMENTS ON
                THE DRAFT PROPOSED STANDARD
                   (Dated July 21, 1986)
     
     
                      - prepared by -
     
               The Software Development Group
                   University of Waterloo
                     Waterloo, Ontario
     
     Our  comments  are based on the _D_r_a_f_t _P_r_o_p_o_s_e_d
 _A_m_e_r_i_c_a_n
_N_a_t_i_o_n_a_l _S_t_a_n_d_a_r_d _f_o_r
 _I_n_f_o_r_m_a_t_i_o_n  _S_y_s_t_e_m_s  --
 _P_r_o_g_r_a_m_m_i_n_g
_L_a_n_g_u_a_g_e  _C,  Doc.No. X3J11/86-104, dated July 21, 1986.  In
addition, we make a number of comments on the Rationale  for
the standard, Doc.No. X3J11/86-099, dated July 7, 1986.
     
     This  document supersedes previous submissions from the
Software Development Group, which were submitted in  comment
on previous drafts of the standard.
     
     Generally,  we  will use the same order of presentation
as the standard itself.  Our section headings correspond  to
the  appropriate sections in the standard.  However, we will
begin with some general observations.
     
_G_e_n_e_r_a_l _N_o_t_e _1: _R_e_s_e_r_v_e_d
 _W_o_r_d_s:
     
     The standard defines  many  new  symbols,  particularly
#defined  names  in  header  files.   These  are effectively
reserved words, since programs  that  use  the  symbols  for
other  things  will  get  into  trouble sooner or later.  We
count a total of 255 effectively reserved words:
     
           32 language keywords
           44 implementation limits
          179 library-related names
     
In contrast, Cobol only has 227 reserved words!
     
     To avoid a  jungle  of  symbols  that  are  effectively
reserved,  we strongly urge that the committee follow one of
its own principles: symbols that begin  with  an  underscore
are  not  for  the  programmer's use.  This is a simple rule
that gets around most of the pitfalls.  _A_l_l _n_e_w_l_y
 _i_n_t_r_o_d_u_c_e_d
_s_y_m_b_o_l_s  _s_h_o_u_l_d  _b_e_g_i_n  _w_i_t_h _a_n
 _u_n_d_e_r_s_c_o_r_e.  This means that
the symbols in <limits.h> should be
     
          _CHAR_BIT
          _CHAR_MAX
          _SCHAR_MAX
     
     
     
                           - 1 -

     
University of Waterloo                          August, 1986
     
     
          /* etc. */
     
The same holds for other new symbols: "size_t" should become
"_size_t",  "ptrdiff_t"  should  become "_ptrdiff_t", and so
on.  Of course, the old stand-bys like NULL and "errno" will
stay as they are, even if we might wish differently.
     
     Note  that  we  would  recommend  against reserving the
prefixes tttooo_, SSSIIIGGG, ssstttrrr, mmmeeemmm, and
 iiisss.   This  sort  of  rule
would  prevent implementations from supporting common opera-
tions that aren't in the standard.  For example, it actively
rules  out  "isascii"  and  "isodigit"  since  these are not
recognized by the standard.  This will break a great deal of
code.  Besides, the fewer "reserved word" rules a programmer
has to remember, the better.
     
_G_e_n_e_r_a_l _N_o_t_e _2: _P_o_r_t_a_b_i_l_i_t_y:
     
     In Section 1.2, the designers state the principle  MMMaaakkkeee
iiittt fffaaasssttt, eeevvveeennn iiifff iiittt
 iiisss nnnooottt ggguuuaaarrraaannnttteeeeeeddd
 tttooo bbbeee pppooorrrtttaaabbbllleee.  We do
not argue with this principle in general, but  we  think  it
should  be  counterbalanced  by  other considerations.  When
there are only a  few  popular  alternative  behaviors,  the
standard   should   provide  both  a  _f_a_s_t  operation  (with
implementation-defined behavior) and one  or  more  possibly
slower operations with well-defined behavior.
     
     The  whole  point  of  a  language standard is to allow
program portability.  The standard should ensure that  there
is  _s_o_m_e  way  to  write  a  portable program.  For example,
consider the ">>" operator.  The standard does not  indicate
whether  ">>"  shifts  arithmetically  (propagating the sign
bit) or logically (inserting zeros).
     
     What this effectively states is that the  operation  is
only  defined  on a subset of the possible range of operands
(i.e. when the operand to be shifted is  positive).   It  is
not  rigorously  defined  outside the range, but implementa-
tions are expected to  support  the  operation  outside  the
range.   This  sort  of situation crops up in many places in
the standard.
     
     In  order  to  make  it  possible  to  write   portable
programs,  we  suggest  that the standard should provide new
extended-range operators corresponding to each limited-range
operation.   The  standard  can  allow  ">>"  to  work in an
implementation-defined way outside of its defined range, but
it should define additional functions, macros, or operations
to handle the full range of operands.
     
     
     
     
     
                           - 2 -

     
University of Waterloo                          August, 1986
     
     
     For example, you might have _ARITH_RS(A,B) which  works
like "A>>B" when A is positive, but which always performs an
arithmetic shift when B  is  negative.   If  the  programmer
wants to be sure of a _l_o_g_i_c_a_l right shift, the operand to be
shifted  can  be  cast  to  uuunnnsssiiigggnnneeeddd.   In
 this  way,   the
programmer  could  always  dictate  whether an arithmetic or
logical shift was desired.
     
     A second way to make portable programs possible  is  to
make  appropriate  definitions  in  <stdefs.h> or some other
header.  In most cases  where  behavior  is  implementation-
defined,  there  are a limited number of possibilities.  For
example,   an   implementation   could   define   a   symbol
_ARITH_SHIFT   to  indicate  that  right  shifts  were  done
arithmetically and _LOG_SHIFT to indicate that right  shifts
were  done  logically.   With appropriate #iiifffdddeeefff directives,
source code could be adapted to either possibility.  Similar
symbols  would  tell how "A%B" works when B is negative, how
integer division worked in the same situation,  and  so  on.
Note  that this technique adds _n_o extra expense at execution
time to determine how an implementation behaves.
     
_G_e_n_e_r_a_l _N_o_t_e _3: _T_h_e _9_0% _R_u_l_e:
     
     The portability of  a  program  is  influenced  by  two
factors:  how  it  uses  C code, and how it uses the library
functions.  If a program is ported from system A  to  system
B,  the implementation on B will usually report places where
code is used incorrectly.   However,  it  usually  will  not
report  situations  where  B's  implementation  of a library
function  differs  significantly  from  A's  implementation.
Thus, compatibility of library functions is of major concern
in porting programs, and therefore in design of  a  standard
for writing portable programs.
     
     Our  philosophy  is  that a function on system A should
not have the same name as a function on system B, unless the
A  function  is at least 90% the same as the B function.  If
the two functions are not almost identical in functionality,
pretending  that  they  _a_r_e the same by giving them the same
name is just asking for trouble.
     
     In the context of the C standard, the 90% rule suggests
that  the  standard  library  functions  should  behave in a
manner that is almost identical on all  systems.   It  is  a
mistake,  for  example,  to  make the definition of a binary
file loose enough to encompass a widely divergent set of I/O
devices  and  file formats.  We would rather see the defini-
tion restricted to allow operations that could reasonably be
regarded  as  portable,  and  nothing more.  If a particular
system had special file formats that needed to be supported,
     
     
     
                           - 3 -

     
University of Waterloo                          August, 1986
     
     
the implementation on that system could  provide  additional
I/O routines to deal with such formats.
     
     If  a  program  is  written  using special routines for
system-dependent  I/O,  porting  the  program  is   actually
simpler.   When  the program is taken to a new system, the C
implementation will issue diagnostic messages indicating the
special  I/O  routines  that  are  not  available on the new
system, and the programmer finds out what has to be changed.
When   porting   a  program  written  only  with  "standard"
routines, the programmer must laboriously track down  system
dependencies  that  were  disguised  by using the "standard"
routines and this is usually a great deal more work.
     
     In general, then, we believe that the standard  library
should  _n_o_t  be  designed to conceal the system dependencies
that exist on a  particular  machine.   Instead,  it  should
provide   support  for  features  that  are  common  to  _a_l_l
machines, leaving it up to the individual implementation  to
support dependencies.
     
_G_e_n_e_r_a_l _N_o_t_e _4: _T_h_e _C_o_r_r_e_c_t
 _A_n_s_w_e_r:
     
     At times, efficiency has been put ahead of correctness.
A good example of this occurs with mixed signed and unsigned
operations.  Consider the following code.
     
          short i;
          unsigned short u;
             ...
          if ( i < u ) ...
     
Since the committee allows this to result in either a signed
or    an   unsigned   comparison   (depending   on   whether
sssiiizzzeeeooofff(ssshhhooorrrttt) is less than
 sssiiizzzeeeooofff(iiinnnttt)), iiittt iiisss
 pppooossssssiiibbbllleee ttthhhaaattt
aaa  nnneeegggaaatttiiivvveee vvvaaallluuueee
 ooofff "iii" cccooouuulllddd bbbeee
 fffooouuunnnddd greater than a posi-
tive value of  "u".   Correctness  has  been  sacrificed  to
efficiency.
     
     This  situation should be avoided.  If a signed integer
is negative, it should be less than all  unsigned  integers.
All  other considerations of lengthening or converting argu-
ments are secondary.  Note  that  efficiency  doesn't  enter
into  this  --  a  compiler or interpreter has a much better
chance of generating efficient code than a user checking for
the   situation  explicitly  by  writing  iiifff  statements  or
conditional expressions.
     
     
     
     
     
     
     
                           - 4 -

     
University of Waterloo                          August, 1986
     
     
     If a programmer really wants the possibility of a nega-
tive  integer  being larger than a signed one, he or she can
always use explicit casts, as in
     
          if ( (unsigned)i < (unsigned)u ) ...
     
Similarly, if a programmer knows that a particular  form  of
comparison is more efficient than the default, he or she can
always use explicit casting to ask for  the  more  efficient
comparison  method.   When it _i_s possible for the programmer
to control efficiency, why give a more naive programmer  the
wrong answer?
     
_G_e_n_e_r_a_l _N_o_t_e _5: _E_x_i_s_t_i_n_g
 _I_m_p_l_e_m_e_n_t_a_t_i_o_n_s:
     
     The  Rationale  states that existing code is important,
but existing implementations are not.   We  agree  with  the
principle,  but  must point out that many popular C programs
are intimately connected  to  a  particular  implementation.
Adopting  practices  contrary to the way popular implementa-
tions work (e.g. the UNIX  C  compilers)  may  indeed  break
programs  in  subtle  ways.   For  this reason, our comments
sometimes state, "Implementation X does  this  differently."
In such cases, we are not saying that the standard should be
changed to do things X's way; we simply want  to  point  out
that  some  important  compiler does not behave in the given
manner, and one should  expect  some  code  to  break  as  a
result.
     
_G_e_n_e_r_a_l _N_o_t_e _6: _M_e_a_n_i_n_g_f_u_l
 _S_l_o_p_p_y _C_o_d_e:
     
     In   a  few  instances,  the  designers  have  made  it
necessary for conforming implementations to support "sloppy"
programming  practices.   For  example,  the  following  are
supposed to be equivalent.
     
          extern int i;
          int extern i;
     
When  a  sloppy  practice is well-established, the designers
are justified, because existing programs should continue  to
work.   However, the above practice is virtually unknown (at
least to the people we have talked to and in the programs we
have examined), and requiring all implementations to support
it is surprising.
     More  to  the  point, making sloppy code meaningful has
undesirable side effects.  A user  who  accidentally  writes
such  code  receives no diagnostic message, because the code
is correct...even when the code is  probably  not  what  the
user  intended  to  write.   The  program  may  behave in an
unexpected way because a typing mistake is accepted.
     
     
     
                           - 5 -

     
University of Waterloo                          August, 1986
     
     
     In addition,  the  implementation  that  is  forced  to
accept  sloppy  code  has  more  difficulty generating error
messages.  It has less chance of identifying precisely where
the code went wrong, because the programmer has so much more
leeway.  Consequently,  the  diagnostic  facilities  of  the
implementation  are  degraded  for  _a_l_l  users,  in order to
support the sloppy few.
     The  standard  should  not  require  implementations to
support "loose" language constructs that  are  seldom  used.
Obviously,  there  are  instances  where  the designers must
decide whether a construct is or isn't  used  and  different
people  may  have  different opinions on the matter.  Still,
the  basic  principle  should  be,  "No  sloppiness,  unless
required by common practice."
     
_G_e_n_e_r_a_l _N_o_t_e _7: _R_a_t_i_o_n_a_l_e:
     
     The  purpose  of  the  Rationale  document should be to
explain why particular decisions were made.  All too  often,
the  Rationale  is  used  to explain what the standard says.
Obviously then, the standard  itself  should  be  made  more
clear, with more examples and illustrations.
     
_S_p_e_c_i_f_i_c _S_e_c_t_i_o_n _C_o_m_m_e_n_t_s:
     
     The rest of this document talks about specific sections
of the standard and the Rationale.
     
_1._6  _C_o_m_p_l_i_a_n_c_e:
     
     A conforming freestanding implementation should provide
the standard header <stddef.h> in addition to <limits.h> and
<float.h>.  The <stddef.h> should _n_o_t include a  declaration
for  "errno".  For more on "errno", see our comments on Sec-
tion 4.1.1.
     
_2._1._1._2  _T_r_a_n_s_l_a_t_i_o_n _P_h_a_s_e_s:
     
     Since the process of linking translated source files is
described  in  this  section, one might believe that linking
must  take  place  in  the  translation  environment.    The
standard should explicitly state that linking can take place
in either  the  translation  environment  or  the  execution
environment (or in some other environment, for that matter).
     
_2._2._4._2  _N_u_m_e_r_i_c_a_l _L_i_m_i_t_s:
     
     We  do  not  understand  why so many #defined names are
missing their vowels.  For example, why use SHRT instead  of
SHORT?   The  difference  in  keystrokes is minimal, and the
standard guarantees that #defined names can be 31 characters
     
     
     
                           - 6 -

     
University of Waterloo                          August, 1986
     
     
long.  This criticism applies to many of the names chosen by
the designers.
     
     Technically  speaking,  the definition of FLT_ROUNDS is
incorrect.  The beginning of the section  states  that  each
macro must be at least the given value.  The given value for
FLT_ROUNDS is 0, but  the  value  -1  is  also  said  to  be
meaningful.   Also,  the  alternatives  for  this  value are
"rounds", "chops", and "indeterminate".  This overlooks  the
fact  that  "chops"  could  mean  "truncate towards zero" or
"truncate towards  negative  infinity".   We  conclude  that
there  should  actually be four alternatives for FLT_ROUNDS,
not just three.
     
_3._1._2._1  _S_c_o_p_e_s _o_f _I_d_e_n_t_i_f_i_e_r_s:
     
     The Rationale says that the behavior  is  undefined  if
you  use  an  identifier  outside  its  scope.  The standard
itself says nothing about this possibility.
     
_3._1._2._2  _L_i_n_k_a_g_e_s _o_f
 _I_d_e_n_t_i_f_i_e_r_s:
     
     According to the rules for  declarations  that  include
the keyword eeexxxttteeerrrnnn, it is not possible to declare
     
          extern i;
            ...
          static i;
     
inside a file and have the first declaration of "i" refer to
the static (internal linkage) "i".  The Rationale says  this
decision  was made in order to allow one-pass compilers, but
in  fact,  one-pass  compilers  are  possible  without  this
restriction.   All  that the one-pass compiler needs to make
this work is a loader with a bit of intelligence.
     
     We believe that  this  is  contrary  to  the  principle
stated  in  Section  1.2  of the Rationale: Existing code is
important, existing implementations are not.  Ruling out the
above  construct  will  break  a  good  many  existing  UNIX
programs, since the existing  UNIX  compilers  allow
 eeexxxttteeerrrnnn
declarations to be resolved to ssstttaaatttiiiccc objects that have
 file
scope and internal linkage.  Therefore, we believe the above
construct should be made legal.
     
     We  note also that if the eeexxxttteeerrrnnn definition occurs
 in a
function and the  ssstttaaatttiiiccc  outside  a  function,  we
 have  a
different situation.  For example, consider
     
     
     
     
     
     
                           - 7 -

     
University of Waterloo                          August, 1986
     
     
          f()
          {
              extern int i;
                   ...
          }
          static float i;
     
According  to  the second paragraph of the Semantics section
in 3.5.1, an eeexxxttteeerrrnnn definition inside a function
 refers  to
an  object  that  is  defined somewhere with file scope.  It
cannot refer to the ssstttaaatttiiiccc definition  (because  that
 comes
later),  so  it  must refer to some definition with external
linkage.  As soon as the ssstttaaatttiiiccc declaration  is
 encountered
however,  all subsequent references in the file refer to the
static variable.  This is odd, to say the least.
     
_3._1._2._3  _N_a_m_e _S_p_a_c_e _o_f
 _I_d_e_n_t_i_f_i_e_r_s:
     
     The Rationale states that the intention is to _p_e_r_m_i_t as
many  separate name spaces as possible.  In fact, we believe
it _r_e_q_u_i_r_e_s as many separate name spaces as possible.
     
     The standard says that all tags (structure, union,  and
enum tags) should be folded together.  We don't see why this
is necessary.  Distinguishing the different  types  of  tags
will  not  break  any  existing  programs,  but folding them
together  may  break  programs  that  were  written  for  an
implementation that _d_i_d distinguish the different tags.
     
_3._1._2._5  _T_y_p_e_s:
     
     An  unsigned and signed integer take up the same amount
of memory.  The standard should also  state  they  have  the
same alignment requirements.  This assumption is true of all
machines we know, and  allows  simpler  coding  of  portable
programs.
     
     There  is also the implication at various points in the
standard that an integral zero consists of all 0-bits.   For
example,  Footnote  71 (to "calloc") implies that every zero
except pointers and floating point types  consists  entirely
of  0-bits.   Furthermore,  the range of values available to
the unsigned type overlaps the range of non-negative  values
for the signed type.
     
     This  argues  that  the  document should state that all
values which can be represented by both signed and  unsigned
integers   (i.e.  the  non-negative  integers  that  can  be
represented by sssiiigggnnneeeddd iiinnnttt) have the same
 bit pattern.   This
is true for all common representation schemes: one's comple-
ment, two's complement, and signed  magnitude.   We  believe
     
     
     
                           - 8 -

     
University of Waterloo                          August, 1986
     
     
that the signed-unsigned algorithm stated in 3.2.1.2 tacitly
assumes that this equivalence is true.  The equivalence also
legitimizes many of  the  bit  operations  that  take  place
inside existing C programs.
     
     The explanation of pointer types should be considerably
expanded.  Our reading of the standard shows several assump-
tions  about  various  pointer  types  that are never stated
explicitly.  We believe  that  users  would  understand  the
language  better if these assumptions were stated explicitly
in this section.
     
     For example, footnote 36  to  section  3.5.2.2  assumes
that  the  alignment  and  size  of  all  pointers to struc-
ture/union types will be the same.  We believe this  assump-
tion  is  valid,  but  it  should  be  stated  explicitly in
3.1.2.5.
     
     Similarly, if A is a pointer to type T,  it  should  be
true that
     
          (char *) (A + 1) == ((char *) A) + sizeof(T)
     
(If  this  were  not  true,  "malloc"  would  be  in serious
trouble.) This should be stated explicitly.
     
     As another example, given that the alignment of  signed
and  unsigned  integers  is equal, and given that arrays are
made  up  of  contiguous  objects,  a  statement  like   the
following is true.
     
          int *p;
          (int *) ( (unsigned *)p + 10) == p+10
     
It would  be  helpful  if  the  standard  or  the  Rationale
actually pointed this out.
     
     Also,  we  cannot  find  an  explicit definition of the
phrase "pointer to object".   We  assume  that  it  means  a
pointer  type  which is not a pointer to a function or vvvoooiiiddd,
but we could not find such a definition.
     
_3._1._3._2  _I_n_t_e_g_e_r _C_o_n_s_t_a_n_t_s:
     
     According to the standard, an unsuffixed octal  or  hex
integer  constant  can  be  interpreted  as either signed or
unsigned.  Certain constants will be interpreted  as  signed
on   some  machines  and  unsigned  on  others,  because  of
differences in machine word size.  Due to the drastic effect
an  unsigned  operand  may have (e.g. in a comparison opera-
tion), there must be some way to ensure  that  a  number  is
taken as signed.  We suggest an "s" suffix.
     
     
                           - 9 -

     
University of Waterloo                          August, 1986
     
     
     Since the sign is not  part  of  the  definition  of  a
constant,  the  "number"  -32768  will  be treated as a long
integer, even though  it  fits  into  16  bits.   This  will
surprise  programmers  who  use  it as the smallest possible
short integer.
     
_3._2._2._1  _A_r_r_a_y_s, _f_u_n_c_t_i_o_n_s, _a_n_d
 _p_o_i_n_t_e_r_s:
     
     The second paragraph of this section states
     
     Except when used as an operand that may  or  shall
     be  a  function locator, an identifier declared as
     "function  returning  type"  is  converted  to  an
     expression  that  has  type  "pointer  to function
     returning type".
     
The way we read this, it appears that we can  say  something
like
     
          extern int f();
          (*f)();
     
Since the "*" operator may not take a function locator,  the
function locator is regarded as a pointer, and therefore the
"*" operator accepts it.  By  applying  recursion,  it  then
seems legal to say
     
          (**f)()
          (***f)()
          (****f)()
     
and so on.
     
     The  Rationale  should point out that function pointers
cannot be cast into other pointer types, and that  the  only
thing  that  can  be  assigned  to  a  function pointer is a
pointer of the same type or (vvvoooiiiddd *) 000.
     
     We believe the document has a built-in assumption  that
any  pointer  cast  to  (vvvoooiiiddd *) yields a unique value.  (If
this assumption is not true, a function like "memcpy"  could
not  work.)  We  think  this  assumption  should  be  stated
explicitly.
     
_3._3._2._2  _F_u_n_c_t_i_o_n _C_a_l_l_s:
     
     The second paragraph of the Semantics section should be
changed to the following:
     
     If    the   postfix   expression   preceding   the
     parentheses in a function call consists solely  of
     
     
     
                           - 10 -

     
University of Waterloo                          August, 1986
     
     
     an identifier, and if no declaration is  in  scope
     for  this identifier, the identifier is implicitly
     declared exactly as if,  in  the  innermost  block
     containing the function call, the declaration
     
          extern int identifier;
     
     appeared.
     
This  prevents  implicit  declaration when the function call
has a form like
     
          (f)()    or
          (*f)()
     
     
_3._3._3._2  _A_d_d_r_e_s_s _a_n_d
 _I_n_d_i_r_e_c_t_i_o_n _O_p_e_r_a_t_o_r_s:
     
     Consider an array declared with
     
          int A[10];
     
By 3.3.3.4, we have
     
          sizeof(A) == sizeof(int) * 10
     
We also have
     
          (char *)(A+1) == (char *)A + sizeof(int)
     
What is the value of
     
          (char *)( (&A) + 1)
     
Is it
     
          ( (char *)A ) + sizeof(int)
                   or
          ( (char *)A ) + 10 * sizeof(int)
     
3.3.3.2 implies the second (i.e. that &A is a pointer to  an
array of 10 ints), but does not state it precisely.
     
_3._3._4  _C_a_s_t _O_p_e_r_a_t_o_r_s:
     
     This  section  says that a pointer to type ccchhhaaarrr has the
least strict alignment.  It should also  make  some  comment
saying  that  a  pointer to vvvoooiiiddd is the most
 _g_e_n_e_r_a_l pointer
type, and therefore shares the least strict  alignment  with
ccchhhaaarrr.
     
     
     
     
                           - 11 -

     
University of Waterloo                          August, 1986
     
     
_3._3._6  _A_d_d_i_t_i_v_e _O_p_e_r_a_t_o_r_s:
     
     A very close reading of  this  section  indicates  that
arithmetic  with (vvvoooiiiddd *) pointers is illegal.  However, the
point is very subtle and could easily be missed.  We suggest
that  it  be  emphasized.   The same point should be made in
3.3.8 (on relational operators).
     
_3._3._1_5  _C_o_n_d_i_t_i_o_n_a_l
 _E_x_p_r_e_s_s_i_o_n:
     
     The standard states that you can  have  expressions  of
the form
     
          i ? p : v
     
where  "p"  is  a  pointer  type and "v" is a (vvvoooiiiddd *).  The
result of this expression is said to be a (vvvoooiiiddd *).
     
     It seems to us that  this  is  the  wrong  way  around.
Instead,  the  result of the expression should have the type
of the pointer "p".  For example, consider
     
          char *cp;
          int *ip;
            ...
          ip = cp ? cp : malloc(10);
     
Since  the  result of "malloc" is (vvvoooiiiddd *) the result of the
right hand side of the assignment will be  (vvvoooiiiddd  *).   This
will  be  quietly assigned to "ip", even if the actual value
of the expression is "cp".  To avoid  such  quiet  problems,
the result should be the pointer type that is not (vvvoooiiiddd *).
     
_3._3._1_6._1  _S_i_m_p_l_e _A_s_s_i_g_n_m_e_n_t:
     
     The  standard  must  be  more  clear  on assignments of
"pointers to functions".  Suppose A and B are both  pointers
to  functions returning iiinnnttt but the functions have different
prototypes (or one function has a prototype  and  the  other
doesn't).   Is  A=B  legal?   Guidelines  for  compatibility
between function pointers should be established.  We believe
the  guidelines should follow the rules for type equivalence
given in 3.5.5.
     
     The standard says that assigning overlapping objects to
one  another is undefined (and therefore illegal).  While we
recognize that  there  are  many  instances  when  assigning
overlapping  objects  to  one  another cannot be done safely
(e.g. when objects are referenced with pointers), there  are
some  instances  where we believe it is a mistake to say the
operation is illegal.  In particular,  many  of  our  own  C
programs use the operation
     
     
                           - 12 -

     
University of Waterloo                          August, 1986
     
     
          union {
              float f;
              int i;
          } u;
            ...
          u.f = u.i;
     
According  to  the  standard,  this  operation  will  become
illegal.
     
     We might point out the odd effect that
     
          u.f = (float) u.i;
     
would still seem to be legal, even if the assignment without
the  cast  is  not.  The cast operation presumably takes the
value of "u.i", converts it, and stores it in some temporary
storage,  so  assigning  it  to "u.f" causes no overlap.  If
this really is  intended,  the  standard  or  the  Rationale
should comment on it.
     
     The  difference between ccchhhaaarrr,
 uuunnnsssiiigggnnneeeddd ccchhhaaarrr, and
 sssiiigggnnneeeddd
ccchhhaaarrr must be discussed.  If a program declares
     
          char *p;
          unsigned char *u;
          signed char *s;
     
is it possible to make assignments like
     
          p = u;
          u = p;
          u = s;
          s = u;
          p = s;
          s = p;
     
This  question  arises  because  ccchhhaaarrr  may be signed in some
implementations and unsigned in others.  As a  result,  some
of  the above assignments will be valid on some machines but
not on others.
     
     We suggest that the  assignment  rules  be  changed  to
allow  the  (uncast) assignment of ccchhhaaarrr to
 uuunnnsssiiigggnnneeeddd ccchhhaaarrr and
vice versa.  The same should  apply  to  pointers  to  these
types.
     
     Note  that  people writing portable programs will never
use the ccchhhaaarrr type; they will use sssiiigggnnneeeddd
 ccchhhaaarrr when  they  are
using  the  value arithmetically and uuunnnsssiiigggnnneeeddd
 ccchhhaaarrr when they
are using the character as a  character.   Using  the  plain
     
     
     
                           - 13 -

     
University of Waterloo                          August, 1986
     
     
ccchhhaaarrr type will be non-portable.   However,  this  runs  into
other problems.  In particular, suppose someone writes
     
          unsigned char a[] = "string";
          unsigned char *cp;
              ...
          cp = "abc";
     
These operations  will  work  on  a  system  where  ccchhhaaarrr  is
unsigned,  but  not  if ccchhhaaarrr is signed.  To make such opera-
tions possible, it must be possible to intermix  plain  ccchhhaaarrr
and uuunnnsssiiigggnnneeeddd ccchhhaaarrr types in the
 ways shown above.
     
_3._3._1_6._2  _C_o_m_p_o_u_n_d _A_s_s_i_g_n_m_e_n_t:
     
     According to the standard, an operation like
     
          int i;
          i /= 3.5;
     
would be performed using floating point division.   However,
the  Berkeley  C  compiler  uses integer division.  For this
reason, this should be marked as a quite change.
     
_3._3._1_7  _C_o_m_m_a _O_p_e_r_a_t_o_r:
     
     The standard  states  that  the  comma  operator  is  a
sequence  point, but it is not clear what point of the comma
operation is _t_h_e point.  For example, consider  the  expres-
sion
     
          A = ((B=1),B) + ((B=2),B) + ((B=3),B);
     
What  should A equal?  (We note that the Berkeley C compiler
assigns the value 9 to A in the expression above.) Does  the
sequence  point  take place at the comma (i.e. when only the
left half of the expression has been evaluated) or  does  it
take place when both sides of the comma have been evaluated?
Are there actually two sequence points?  The  same  sort  of
problem obviously occurs with
     
          func( (b=1,b) , (b=2,b) );
     
In  fact, the question generalizes.  Several operators (e.g.
"&&", "||") are said to be sequence points, when the  opera-
tion  actually  has  several  "points"  to it.  The standard
should be more explicit, e.g.
     
     There is a sequence point after the evaluation  of
     the left operand.
     
or
     
     
                           - 14 -

     
University of Waterloo                          August, 1986
     
     
     There is a sequence point after the evaluation  of
     the result of the operator.
     
The  second  paragraph  of  3.3 makes some effort to address
this problem, but it is too nebulous to be much help.
     
_3._4  _C_o_n_s_t_a_n_t _E_x_p_r_e_s_s_i_o_n_s:
     
     We  point  out  that  if  the   "offsetof"   macro   is
implemented  as suggested in the rationale, it will not be a
constant expression according to the rules of this  section.
Since  we  like the suggested implementation, we suggest the
definition  of  constant  expressions   be   modified.    In
particular,  the  standard  should  say that the implementa-
tion's behavior is _u_n_d_e_f_i_n_e_d if a constant  expression  does
not  comply with the given rules.  This gives an implementa-
tion the  freedom  to  support  an  expanded  definition  of
constant expressions if desired.
     
_3._5  _D_e_c_l_a_r_a_t_i_o_n_s:
     
     For  the sake of readability, it should not be legal to
enclose an entire declarator in parentheses, as in
     
          int (x);
     
A function prototype containing such a declaration  is  very
deceptive.  For example,
     
          int f(int (x));
     
means  that  "f" has an integer parameter named "x"...unless
"x" happens to be the name  of  a  type  as  declared  in  a
tttyyypppeeedddeeefff  statement,  in  which case the argument of
 "f" is a
function that takes an argument of type "x" and  returns  an
integer.   Confusion  can  be  avoided  if  such  extraneous
parentheses are not allowed.
     
     We were surprised  that  the  standard  allows  storage
class  specifiers  to be intermixed with type specifiers, as
in
     
          const int extern long a;
     
We were even more surprised to discover that the Berkeley  C
compiler  already supports such constructs.  We don't really
understand why it is necessary to support this sort of thing
--  we  would be surprised if any existing programs make use
of it.  An implementation that accepts this kind of code has
a  good  deal  of  trouble  generating  comprehensible error
messages, since it cannot be so rigid  in  its  approach  to
     
     
     
                           - 15 -

     
University of Waterloo                          August, 1986
     
     
parsing.  _A_l_l programmers  will  receive  poorer  diagnostic
messages  in  the  interests  of  catering  to  the very few
programmers who would want to ignore  very  well-established
code-writing conventions.
     
_3._5._1  _S_t_o_r_a_g_e-_C_l_a_s_s
 _S_p_e_c_i_f_i_e_r_s:
     
     The  semantic description of the rrreeegggiiisssttteeerrr
 storage class
should be reworded to the following:
     
     A   declaration   with   storage-class   specifier
     rrreeegggiiisssttteeerrr  is an aaauuutttooo
 declaration with a suggestion
     that the object will be frequently  accessed,  and
     thus  that the compiler should attempt to speed up
     access to the object.  One restriction applies  to
     an  object  declared  with storage-class specifier
     rrreeegggiiisssttteeerrr:  the  unary  "&"  (address-of)
 operator
     must  not  be  applied  to  it.  Since the program
     cannot  legitimately  generate  a  pointer  to  an
     object  with the storage-class specifier
 rrreeegggiiisssttteeerrr,
     a frequently-used  optimization  is  to  keep  the
     object  in  fast  storage which cannot be accessed
     through a pointer, e.g. a hardware register.
     
By rephrasing the definition this way, you give the
 rrreeegggiiisssttteeerrr
storage-class  more  meaning.   In  particular, you open the
door to compilers that perform  global  optimizations  using
the fact that rrreeegggiiisssttteeerrr variables can never have
 their values
changed by indirection through a pointer.  The compiler  can
optimize the use of rrreeegggiiisssttteeerrr variables because
 it can always
know when the register values are used and changed.
     
     As currently defined in the standard,
 rrreeegggiiisssttteeerrr  is  an
all-or-nothing  optimization.   We  feel that machines which
can't give "all" (due to a shortage of registers)  shouldn't
be forced to give "nothing".
     
     The  standard  might  also  make some statement on what
implementations should do  if  there  are  several
 rrreeegggiiisssttteeerrr
declarations  and  only  some  of  these  can  be  used  for
optimizations.  We propose that the standard  say  that  the
declarations  which  come  lexically first will be optimized
first.  This gives  a  programmer  some  way  of  indicating
preference of optimization.
     
_3._5._2._1  _S_t_r_u_c_t_u_r_e _a_n_d _U_n_i_o_n
 _S_p_e_c_i_f_i_e_r_s:
     
     We suggest that the definition for "struct-declaration"
be changed to
     
     
     
     
     
                           - 16 -

     
University of Waterloo                          August, 1986
     
     
          struct-declaration:
              type-specifier-list struct-declarator-list;
              struct-or-union-specifier;
     
The added possibility lets you define an unnamed element  of
this type.  The sub-elements will appear as first-level ele-
ments in the enclosing structure.  Using  this  scheme,  the
example in 3.3.2.3 could become
     
          struct {
              int type;
              union {
                  int intnode;
                  double doublenode;
              };
          } u;
          /* ... */
          u.type = 1;
          u.doublenode = 3.14;
          /* ... */
          if (u.type == 1)
              /* ... */ sin(u.doublenode) /* ... */
     
     
_3._5._2._2  _S_t_r_u_c_t_u_r_e _a_n_d _U_n_i_o_n
 _T_a_g_s:
     
     The form
     
          struct y;
     
now has a special meaning.  Suppose we define
     
          typedef struct y z;
     
Does the code
     
          z;
     
have the same effect as
     
          struct y;
     
We note that you can  use  pointers  to  structures  without
having  to define the structure itself.  Do you ever have to
define a structure's contents in a particular source file?
     
_3._5._2._3  _E_n_u_m_e_r_a_t_i_o_n _T_y_p_e_s:
     
     If we have
     
     
     
     
     
                           - 17 -

     
University of Waterloo                          August, 1986
     
     
          enum E1 { e1 } var;
          enum E2 { e2 };
     
is it legal to say
     
          var = e2;
     
The  answer  is almost certainly yes...but we would be happy
if we were allowed to give a warning or an error message for
the  operation, if there is no explicit cast.  Similarly, we
would like to give a warning for things like
     
          var = e2 + 1;
     
     
_3._5._2._4  _c_o_n_s_t _a_n_d _v_o_l_a_t_i_l_e:
     
     According to our reading of the standard, the following
code is illegal.
     
          f1() {
              extern const x;
                  ...
          }
          f2() {
              extern x;
                  ...
          }
          int x;
     
On the other hand, it would be very convenient if one  func-
tion  could  declare  an object cccooonnnsssttt while another did not.
This would let a function indicate when it did not intend to
change  the  value  of an external object, and thereby allow
local optimizations.  The actual definition  of  the  object
would  establish  whether or not the object really was cccooonnnsssttt
(and therefore suitable for allocation in read-only memory).
     
     The same principle would hold for vvvooolllaaatttiiillleee.
     
_3._5._3._3  _F_u_n_c_t_i_o_n _D_e_c_l_a_r_a_t_o_r_s:
     
     The last sentence of the Semantics section reads
     
     If the list is empty  in  a  function  declaration
     that  is  part of a function definition, the func-
     tion has no parameters.
     
What does this say about a function definition like
     
     
     
     
     
                           - 18 -

     
University of Waterloo                          August, 1986
     
     
          int (*F(int a))() {...
     
Since the empty identifier list appears as part of  a  func-
tion definition, the function pointed to by F's return value
takes no arguments.  This rules out returning a  pointer  to
an arbitrary integer function.
     
_3._5._5  _T_y_p_e _D_e_f_i_n_i_t_i_o_n_s _a_n_d
 _T_y_p_e _E_q_u_i_v_a_l_e_n_c_e:
     
     The  standard should discuss structs that have the same
tag but different internal structures.
     
     We also have some questions about the situation where a
tttyyypppeeedddeeefff  declares  a  named  type  with  the  same
 name as a
variable defined in an enclosing scope.  Inside the scope of
the  named  type,  is the variable completely invisible?  Or
can the variable be visible in contexts where  the  compiler
can clearly determine that the named type is not valid?
     
     As another questionable construction, consider the code
     
          typedef int X;
          typedef X *Y;
          f(void)
          {
              typedef char X;
              Y b;
     
The definition of X inside the function  clearly  supercedes
the  external  definition of X.  However, it is not clear if
"b" is a pointer to an integer (using the definition of X at
the  time  Y  was defined) or a pointer to a character (as X
was defined at the time "b" was declared).
     
     An even more subtle situation is
     
          struct X { /* definition 1 */ };
          typedef struct X *Y;
               ...
          f(void)
          {
              struct X { /* new definition */ };
              Y Z;
              ...
     
Is  Z  a  pointer to the old X structure or the new one?  We
believe that most people would expect Z to be a  pointer  to
the  old  X  structure.   However,  a  strict reading of the
definition of tttyyypppeeedddeeefff suggests otherwise.  The
 standard says
that  a  typedef  type is not a new type; it is a name for a
type that could be defined in another way.  Since a  pointer
     
     
     
                           - 19 -

     
University of Waterloo                          August, 1986
     
     
to the old X structure could _n_o_t be defined in  another  way
after  the  declaration  of the new X structure, the typedef
type Y would have to refer to the new structure.   To  avoid
such  hair-splitting,  the  standard  should state precisely
what happens in such a case.
     
_3._5._6  _I_n_i_t_i_a_l_i_z_a_t_i_o_n:
     
     Is the following initialization legal?
     
          int f(int a)
          {
              const int b = a*2;
     
     Consider
     
          struct X {
              int a,b;
          };
          f() {
              struct X Z;
              int junk = (Z.a=1,Z.b=2,7);
              int more_declarations;
     
Is this allowed?  Can we initialize  an  aaauuutttooo  structure  in
this  way?  Can we use the side effects in an initializer to
initialize another object?  (We note that the  designers  of
the  standard  ruled out the use of non-constant expressions
to initialize  auto  aggregates  precisely  because  of  the
problem  of side effects.  The above example shows that side
effects are still possible.)
     
     Can auto initializers make use  of  external  variables
with  the  same  name  as the symbol being initialized?  For
example, is the following valid?
     
          int i = 1;
          f() {
              char i = i * 2;
              ...
     
This  sort of construction is allowed and used in Berkeley C
code.
     
     It appears that the standard says that the following is
legal.
     
          int i = {{{{{10}}}}};
     
     
     
     
     
     
                           - 20 -

     
University of Waterloo                          August, 1986
     
     
Is this really intended?
     
     The paragraph beginning at line 542 (about  initializa-
tion  of subaggregates inside aggregates) is very confusing.
At the very least, it should be reworded to be  more  clear.
We  also  believe  that it might not say what you mean it to
say, but it's too hard to construe for us to be  sure.   For
example, how is the following interpreted?
     
          int a[4][5][6] =
          {
              { 1, 2 },
              { 3, 4, 5 },
              { 6, 7, 8, 9 }
          };
     
     
_3._6._4._2  _T_h_e _s_w_i_t_c_h _S_t_a_t_e_m_e_n_t:
     
     The  Rationale  says  that  ranges  in case labels were
rejected  because  many  current  compilers  would  generate
excessive  amounts of code.  This does not seem to be a good
reason for rejecting something that could be  quite  useful.
Making  a  compiler  generate  the  equivalent iiifff code for a
switch  range  is  trivial  compared  with   (for   example)
requiring  both  signed  and  unsigned  characters.  This is
indeed a minor extension.
     
     It is our belief that a compiler  is  usually  able  to
produce better code for case ranges than a programmer trying
to do it by hand using iiifff statements.  Therefore  efficiency
is actually improved by supporting case ranges.
     
     If  you  do not want to sanctify case ranges as part of
the standard, the committee should still recognize that case
ranges  are  likely  to be common extensions to the language
and should be listed in Section 5.6.4.  More to  the  point,
the  committee should develop some syntax for case labels so
that implementations that want to offer the extension can do
so in a consistent way.
     
     The  ".."  notation  mentioned  in the Rationale is not
acceptable because of the tokenizing  rules:  1..3  will  be
interpreted  as  the two floating point numbers 1.0 and 0.3.
We  would  suggest  using  the  tilde  as  the  case   range
separator, as in
     
          case 1~10: ...
     
     
     
     
     
     
                           - 21 -

     
University of Waterloo                          August, 1986
     
     
This does not introduce a new operator and yet it is easy to
parse  because  tilde  has no binary meaning.  It also looks
good (i.e. the visual appearance suggests its meaning).
     
     To  improve  ssswwwiiitttccchhh  statements  even  more,  we
 would
recommend  provisions  for "open-ended" case ranges as well,
of the form
     
          case >n:
          case >=n:
          case <n:
          case <=n:
     
These avoid the example
     
          case 0..65535:
     
given in the Rationale, since the case just becomes
     
          case >=0:
     
Moreover,  _t_h_i_s  form  is  completely  portable,  since it's
independent of the number of bits in the switch variable.
     
_3._7._1  _F_u_n_c_t_i_o_n _D_e_f_i_n_i_t_i_o_n_s:
     
     The standard seems to allow extraneous declarations  in
a function heading, as in
     
          f(a,b,c)
          int a;
          typedef struct X ...;
          int b;
          int c;
          { ...
     
Was this the intention?  It strikes us as a poor idea.
     
     Also note that the UNIX C compiler currently allows the
form
     
          int (*f())(a,b,c) {...
     
in function definitions, but the standard will require
     
          int (*f(a,b,c))() {...
     
We believe this is a quiet change.
     
     
     
     
     
     
                           - 22 -

     
University of Waterloo                          August, 1986
     
     
_3._8._1  _C_o_n_d_i_t_i_o_n_a_l _I_n_c_l_u_s_i_o_n:
     
     The directive #elif  should  be  renamed  to  the  more
mnemonic  #elseif.   As  an  alternative, the compiler might
recognize the following.
     
          #else if
          #else ifdef
          #else ifndef
     
     If an undefined identifier appears in  an  #if  expres-
sion, _a_n_d _i_f _i_t_s _v_a_l_u_e _w_a_s _n_e_e_d_e_d,
 an error should be given.
Thus if A is not defined,
     
          #if A
     
gives an error.  However, if B is defined and non-zero
     
          #if (B||A)
     
does  not  give  an  error,  because  the  value  of  A   is
irrelevant.
     
     Note  that the confusion of an undefined symbol meaning
"zero" does not arise from something simple like
     
          #if UNDEF_SYMBOL
     
but from code like
     
          #define X (5*y)
          int y = 0;
             ...
          printf("%d ",X);
          #if X
          printf("is non-zero");
          #else
          printf("is zero");
          #endif
     
In the #iiifff directive, the X is replaced with  "(5*y)".   The
preprocessor then checks to see if "y" is a #defined symbol.
It isn't so, it turns into zero and the final result of  the
#iiifff condition is zero, even though X itself was defined.  If
the definition of X is changed to some different  expression
(e.g. a simple constant), the #iiifff condition suddenly becomes
true.
     
     
     
     
     
     
     
                           - 23 -

     
University of Waterloo                          August, 1986
     
     
     If the user really wants to  assume  "undefined"  means
zero, he or she should write
     
          #if defined(A)&&A
     
or
     
          #ifndef A
          #define A 0
          #endif
     
     
_3._8._3  _M_a_c_r_o _R_e_p_l_a_c_e_m_e_n_t:
     
     What happens if a macro with parameters is invoked with
the  wrong  number of parameters or no parameters?  Is it an
error, or is the text preserved?
     
     The fourth paragraph on page 80 (lines 7 through 12) is
very  difficult  to  understand.  An example would certainly
help clarify what it is trying to say.
     
_S_e_c_t_i_o_n _4: _G_e_n_e_r_a_l _N_o_t_e_s:
     
     It should be stated that if a program mixes  macro  and
non-macro  invocations  of  the  same library functions, the
results are unpredictable.  For example, characters  written
with   the   "putchar"  macro  and  the  "putchar"  function
intermixed may come out in the wrong order (or perhaps won't
come out at all).
     
     Many  functions  return  pointers  to  values  that are
created by the system.  For example,  "strerror"  returns  a
pointer  to  a  string  that  the  system sets up.  Are such
values placed in static storage areas or in memory that  has
been  dynamically  allocated  (by  "malloc")?  The answer to
this question must be stated exactly in each  case  to  make
for uniformity across systems.  The difference is important,
since static storage makes a function dangerous  to  use  in
exception  handlers.  In addition, storage allocated through
"malloc" can be freed if  it  is  no  longer  needed,  while
static storage cannot be.
     
_4._1._1  _T_e_r_m_s _a_n_d _C_o_m_m_o_n
 _D_e_f_i_n_i_t_i_o_n_s:
     
     The  file <stddef.h> should be required for stand-alone
operation.  However,  it  should  not  mention  the  "errno"
value.    All   the   other   contents   of  <stddef.h>  are
characteristics of the hardware and the implementation.  The
"errno"  value is related to the library and should have its
own header <errno.h>.
     
     
     
                           - 24 -

     
University of Waterloo                          August, 1986
     
     
     The standard implies that  headers  which  need  symbol
definitions  that  are  "officially"  in  other headers will
redefine the symbols.  For example, <stdlib.h> needs to  use
"size_t"  in function prototypes, so it will include its own
definition of "size_t".  We feel that it  makes  more  sense
for  <stdlib.h>  to  explicitly  #include  the  header  that
defines "size_t" rather  than  giving  its  own  definition.
Multiple definitions of the same symbol always mean trouble.
     
     A similar problem is raised with the functions "strtod"
and  "strtol".   Their  definition  implies  that  including
<stdlib.h>  is  all  you  have  to  do to use the functions.
However, the user may also need to use the symbols HUGE_VAL,
ERANGE,   LONG_MAX,   LONG_MIN,  and  "errno".   Should  the
<stdlib.h> file make these available (by defining the values
directly  or  including  the  appropriate  header  files) or
should the user have  to  include  the  appropriate  headers
explicitly?  The standard should answer this question.
     
_4._1._2  _H_e_a_d_e_r_s:
     
     The first paragraph contains the sentence
     
     If  the  program  redefines  a  reserved  external
     identifier, even with  a  semantically  equivalent
     form, the behavior is implementation-defined.
     
The  term  "implementation-defined"  should  be  changed  to
"undefined".  By definition, "implementation-defined" refers
to  behavior  of a correct program construct.  We believe it
is too broad-sweeping to say that redefinition of a reserved
external  identifier  should  always  be allowed; therefore,
"undefined" is the better term, giving  implementations  the
choice  to  accept  or  not  accept  the  construct.   Also,
"implementation-defined"  implies  that  the  implementation
must   document   how  it  behaves.   The  ramifications  of
redefining a library symbol  may  be  too  unpredictable  to
document.
     
_4._3._1._9  _T_h_e _i_s_s_p_a_c_e _F_u_n_c_t_i_o_n:
     
     The  "isspace"  function should also test for the line-
feed character if it is not identical with the new-line.
     
_4._5._4._6  _T_h_e _m_o_d_f _F_u_n_c_t_i_o_n:
     
     We feel "modf" should behave in the same way  as  float
to integer conversions.  This means that "*iptr" should have
the same value as
     
     
     
     
     
                           - 25 -

     
University of Waterloo                          August, 1986
     
     
          (double)(long) value
     
when this  operation  does  not  cause  an  overflow.   This
definition  is  more consistent in the (-1,0) range than the
definition  proposed  in  the  standard.   Even   when   the
"(double)(long)"  conversion would cause an overflow, "modf"
should still behave as if it  is  performing  this  sort  of
conversion, in the interests of consistency.
     
     If  the integer part of "value" is exactly equal to the
most  negative  long  integer,  a   problem   arises.    The
"(double)(long)"  approach  is likely to give one lower than
the most negative integer.  The "modf" code should recognize
this problem and issue an EDOM error in such cases.
     
_4._5._6._5  _T_h_e _f_m_o_d _F_u_n_c_t_i_o_n:
     
     "fmod"  should follow the same principle as "modf".  In
the expression
     
          x == i*y + f
     
the sign of "f" should be such that
     
          i == (long) (x/y)
     
Alternatively, you might declare that "f"  is  always  posi-
tive.   Either alternative is better than declaring that "f"
has the same sign as "x".
     
_4._7  _S_i_g_n_a_l _H_a_n_d_l_i_n_g:
     
     Does the SIGABRT signal catch other  abnormal  termina-
tions  besides one raised by "raise" or "abort"?  We believe
it should not.
     
_4._7._2._1  _T_h_e _r_a_i_s_e _F_u_n_c_t_i_o_n:
     
     Must "raise" be able to generate _e_v_e_r_y valid signal, or
is  the  implementation  allowed  to  restrict  the  sort of
signals that "raise" can send?  Is it allowed to issue  more
than the standard signals?
     
_4._8._1  _V_a_r_i_a_b_l_e _A_r_g_u_m_e_n_t _L_i_s_t
 _A_c_c_e_s_s _M_a_c_r_o_s:
     
     The standard does not explain why these routines should
be implemented as macros.  We realize  that  the  reason  is
that  the parameters aren't necessarily expressions, but the
standard should say this; otherwise, it just sounds  like  a
petty rule.
     
     
     
     
                           - 26 -

     
University of Waterloo                          August, 1986
     
     
_4._9._1  _I/_O _I_n_t_r_o_d_u_c_t_i_o_n:
     
     What happens if the BUFSIZ default value depends on the
type  of device that is connected to the I/O stream?  Making
this a fixed constant may be inadvisable.
     
_4._9._2  _S_t_r_e_a_m_s:
     
     The sentence beginning at line 59 should read
     
     Data  read  in  from  a  text  stream   will   not
     necessarily  compare  equal  to the data that were
     earlier written out to  that  stream,  unless  the
     data consist only of complete _n_o_n-_n_u_l_l lines, _w_i_t_h
     _n_o _t_r_a_i_l_i_n_g _b_l_a_n_k_s, and composed only of
 printable
     characters  and  the control characters horizontal
     tab, new-line, vertical tab, and form feed.
     
     Also, we do not know why  the  backspace  was  excluded
from  the set of characters that could be safely written and
read on a text stream.
     
     The committee obviously believes that binary files will
map  into  some machine-dependent idea of what a binary file
is.  This is not necessarily so.  For  example,  it  is  not
obvious  how  to  map the binary file concept into a record-
based file system.  Such systems can have random  access  to
records, but if records do not have a fixed length, there is
no simple relationship between the UNIX  concept  of  random
access and the file system's.
     
     The  committee  says that the contents of a binary file
stream  will  be   exactly   what   is   written   with   an
implementation-defined  number  of  NUL characters appended.
This is a  curious  change  on  existing  UNIX  file  system
concepts.   One  of  the most important principles of binary
file streams on UNIX is that you can write a file, then read
it  and  get back _e_x_a_c_t_l_y what was written.  The addition of
extra NUL characters violates this principle.
     
     Evidently,  the  designers  allowed   the   extra   NUL
characters  in  order to accommodate systems that might need
to pad files out to a certain length.  However,  it  is  not
clear  that  the freedom to add NUL characters is sufficient
to satisfy arbitrary file  system  requirements.   The  file
system  may  be  just as upset at extra NUL characters as it
would be with data that was not padded to  some  appropriate
boundary.  For this reason, we feel that the standard should
simply state that reading from a binary  file  stream  gives
precisely  what was written to the file stream, and leave it
up to the implementation to figure out how to provide such a
service.
     
     
                           - 27 -

     
University of Waterloo                          August, 1986
     
     
     It is not  the  business  of  a  portable  standard  to
describe   how   to  perform  non-portable  operations.   In
particular, we believe it is a mistake to encourage the  use
of  binary  streams  when  creating files in system-specific
formats.  A program that builds formatted files in  a  byte-
by-byte  manner  will  certainly  not be portable to systems
that use different file formats.  If  someone  does  try  to
port such a program, it is better for the program to fail in
a very obvious way than to write out a distorted version  of
some  other  system's  file  format.   If  an implementation
believes users will need to create certain kinds of  system-
specific  files,  the  implementation should provide its own
routines to accomplish such tasks.
     
_4._9._6._1  _T_h_e _f_p_r_i_n_t_f _F_u_n_c_t_i_o_n:
     
     The description of the "%f"  specifier  says  that  the
output should have six decimal places (if there is no preci-
sion field) and that the number should  be  widened  to  the
appropriate number of digits.  Since the IEEE floating point
standards indicate that floating point  numbers  may  be  as
great  as  10**308,  the  standard  may result in widening a
floating point number to as many as 314 (308+6) digits.   We
recommend  that implementations be allowed to use scientific
notation ("%e" format) in cases  where  the  other  approach
would  widen the value beyond the maximum possible number of
significant digits.  This would probably require the defini-
tion  of a macro in <float.h> to indicate the maximum number
of significant digits.
     
     The standard explicitly states that the  "#"  qualifier
has  no  effect  on  "%s".   We  see  no  reason why this is
necessary.  In fact, we believe that a  natural  interpreta-
tion  of  "%#s"  would be to print out a string using escape
sequences for non-printable characters.  While this behavior
need  not  be  required by the standard, we don't see why it
should be explicitly ruled out when it would  clearly  be  a
useful  facility.   The  same  point  applies to "%#c".  All
things being considered, it would be easier to say that  the
use   of  "#"  in  "%c",  "%d",  "%i",  "%s",  and  "%u"  is
implementation-defined.
     
     The Environmental Limit section reads
     
     The minimum value for  the  number  of  characters
     produced  by  any  single  conversion  shall be at
     least 509.
     
Obviously, what you really mean is
     
     Implementations may place a maximum on the  number
     
     
     
                           - 28 -

     
University of Waterloo                          August, 1986
     
     
     of characters produced by any  single  conversion,
     but this maximum cannot be less than 509.
     
     It   seems   perverse   that   lllooonnnggg
 dddooouuubbbllleee  conversion
specifiers must use an upper case 'L' while lllooonnnggg  ones  must
use  lower  case.  It is more sensible to allow either upper
or lower case in both instances.
     
_4._9._6._2  _T_h_e _f_s_c_a_n_f _F_u_n_c_t_i_o_n:
     
     The  last  sentence  of  the  first   paragraph   seems
redundant.  The excess arguments will obviously be evaluated
before they are passed to "fscanf".  What you mean to say is
that  no  error  occurs if too many arguments are specified,
but the excess arguments are ignored.
     
     It seems odd that "fscanf" returns EOF if  input  items
cannot  be  read.   EOF  is conceptually a special character
value (though of course, it is an integer).  Since  "fscanf"
returns  an  integer  in all other cases, it would make more
sense for "fscanf" to return -1.
     
_4._9._6._7-_9  _v_f_p_r_i_n_t_f, _v_p_r_i_n_t_f,
 _v_s_p_r_i_n_t_f:
     
     The Rationale states that a format for  variable-length
argument   lists   was   rejected   because   the  functions
"vfprintf",  etc.  were  "more  controlled".   This  comment
confuses   us,   because  we  don't  understand  what  "more
controlled" means.  Very clearly,  the  "vfprintf"  approach
offers less freedom and therefore is less useful.
     
     We  suggest  that  "printf"  and  friends  obtain a new
specifier "%v", which accepts two arguments:  a  new  format
string  and a "va_list" of items to format.  This is similar
to the existing "%r" construct on UNIX systems.
     
     Given the "%v" specifier, writing functions to  perform
the  work of "vprintf" and friends is trivial.  However, the
opposite  is  _n_o_t  true  --  "vprintf"  and   friends   have
significant  difficulty  in  simulating  many of the results
that are possible with "%v".
     
     The "%v" approach is simply faster, more readable,  and
more  versatile  than  using  "vprintf"  and  friends.   For
example, a call to "printf" could take several normal  argu-
ments,  followed  by  a  "va_list"  argument  pointing  to a
variable list, followed  by  more  normal  arguments.   This
avoids  the  problem  of having to make three calls, one for
the normal arguments, one for the variable list, and one for
the remaining normal arguments.
     
     
     
     
                           - 29 -

     
University of Waterloo                          August, 1986
     
     
_4._9._1_0._2  _T_h_e _f_e_o_f _F_u_n_c_t_i_o_n:
     
     The semantics of the EOF "indicator" are based  on  the
UNIX  stream I/O implementation.  Not all systems treat end-
of-file in this manner, so we suggest adopting the following
simple and consistent rule:
     
     "feof"  should return TRUE if and only if the next
     "getchar" will return  EOF  and  the  most  recent
     "getchar" also returned EOF.
     
(The  second  part  of  the  provision  is  needed  to avoid
Pascal's problem of having to read ahead.)
     
     Thus  "fseek"  should  _n_o_t  clear  the  EOF  indicator;
instead, it should re-evaluate it.  After a call like
     
          ungetc(non_EOF_character);
     
"feof" should return FALSE.
     
     If  a program reaches end-of-file, then another program
grows the file, it should be possible  to  continue  reading
without explicitly clearing the EOF indicator.
     
_4._1_0._1._4  _T_h_e _s_t_r_t_o_d _F_u_n_c_t_i_o_n:
     
     What  do  "strtod"  and  related  functions  assign  to
"*endptr" if there is a range error?
     
_4._1_0._3  _M_e_m_o_r_y _M_a_n_a_g_e_m_e_n_t
 _F_u_n_c_t_i_o_n_s:
     
     The standard states that  pointer  values  returned  by
"malloc"  et  al may be assigned to a pointer to any type of
object, then used to access such  an  object  in  the  space
allocated.   We suggest that this be changed to read "may be
assigned to a pointer to any type of object  _w_h_o_s_e  _s_i_z_e
 _i_s
_l_e_s_s  _t_h_a_n  _t_h_e  _a_m_o_u_n_t  _o_f
 _m_e_m_o_r_y _r_e_q_u_e_s_t_e_d".  This allows
greater  efficiency  of  memory  allocation,  especially  on
machines  that  have  a  high alignment requirement for some
data types.  For  example,  some  machines  require  32-byte
alignment for their highest precision floating point, but it
is silly to hand out memory in 32 byte chunks when the  user
only requests a few bytes.
     
     It  would  also  be  useful  to  have  a  library func-
tion/macro similar to "malloc" that would take both a length
and  an  alignment as arguments.  This would allow for finer
allocation of memory, to shorter alignment boundaries.
     
     
     
     
     
                           - 30 -

     
University of Waterloo                          August, 1986
     
     
     In order  to  make  such  a  function/macro  useful  in
portable   programs,  an  aaallliiigggnnnooofff  operator  would
 be  very
convenient.  This operator would behave in much the same way
as sssiiizzzeeeooofff:  it would return an integral value
 indicating the
alignment of a type or object.  For example,  if  a  machine
has  words  containing four bytes and a particular type must
be aligned on a word boundary, the result of
 aaallliiigggnnnooofff  would
be  4  (indicating four-byte alignment).  The actual type of
the result of aaallliiigggnnnooofff would be
 implementation-defined  like
"size_t".
     
     Note  that  aaallliiigggnnnooofff would allow programs to
 write their
own efficient portable memory allocators.  Memory  could  be
"nibbled"  away  in  alignments  suitable  to  whatever data
object needed the storage.  It would not be necessary to get
the largest possible alignment for _e_v_e_r_y object.
     
_4._1_0._4._3  _T_h_e _g_e_t_e_n_v _F_u_n_c_t_i_o_n:
     
     The   description  of  this  function  should  read  as
follows.
     
     The  "getenv"  function  searches  an  _e_n_v_i_r_o_n_m_e_n_t
     _l_i_s_t,  provided  by  the  host environment, for an
     entry identified  by  the  string  pointed  to  by
     "name".   The  set  of  environment  names and the
     method  for  altering  the  environment  list  are
     implementation-defined.
          The "getenv" function returns a pointer to  a
     string  containing  the  value associated with the
     given name.
     
Our point is that the
     
          name=value
     
format is strictly a UNIX concept and need  not  be  grafted
onto other techniques for handling environment variables.
     
     The  standard  should decide whether the returned value
is stored in a static storage area or  in  storage  obtained
through "malloc".
     
_4._1_0._4._4  _T_h_e _o_n_e_x_i_t _F_u_n_c_t_i_o_n:
     
     Why isn't the "onexit" defined as
     
          int onexit(void (*f)(void));
     
     
     
     
     
     
                           - 31 -

     
University of Waterloo                          August, 1986
     
     
This simplifies the definition considerably.
     
_4._1_0._4._5  _T_h_e _s_y_s_t_e_m _F_u_n_c_t_i_o_n:
     
     The explanation of "system" should be expanded to  make
it  more  clear that passing a null pointer is a query about
the existence of a command processor.
     
_4._1_0._6._2  _T_h_e _d_i_v _F_u_n_c_t_i_o_n:
     
     We certainly recognize the need to  implement  a  well-
specified  integer  division and remainder operation, but we
do not believe the given "div" function suits the need.
     
     First, "div" is an inappropriate name  for  a  function
that performs both a division and a remainder operation.  In
fact, we believe that the function should _n_o_t  perform  both
operations.  Instead, you should have
     
          int _div(int numer,int denom);
          int _rem(int numer,int denom);
     
This approach has several advantages.
     
(a)  You  do  not  have  the  overhead  of  calculating  the
     remainder  when  you want the quotient, and vice versa.
     While it is true that many machines generate a quotient
     and remainder simultaneously, this practice is far from
     universal.  VAX machines, for example, can only perform
     division.   To calculate A%B, the machine must make the
     calculation A-(B*(A/B)).  It is expensive to  calculate
     this number when it may not even be needed.
     
(b)  On   some   machines,   the   two  functions  could  be
     implemented  as  macros.   With   a   single   function
     returning a structure, macros could never be used, even
     if the hardware did the division and  remainder  opera-
     tions in the prescribed manner.
     
     We  also  note  that  the  operation  prescribed by the
standard's "div" function is the  less  useful  of  the  two
alternatives.   In  our  experience,  the operation that you
usually want to perform is the one that always gives a posi-
tive remainder.  For example, it is much more common to want
(-2)/3 to have a quotient of -1 and a remainder of  +1  than
to  have  a quotient of 0 and a remainder of -1.  You almost
always want to  move  negative  quotients  towards  negative
infinity, not towards zero.
     
     
     
     
     
     
                           - 32 -

     
University of Waterloo                          August, 1986
     
     
_4._1_1._3._2  _T_h_e _s_t_r_n_c_a_t _F_u_n_c_t_i_o_n:
     
     It seems odd that "strncat" always adds a trailing '\0'
but "strncpy" does not.
     
_4._1_1._4  _C_o_m_p_a_r_i_s_o_n _F_u_n_c_t_i_o_n_s:
     
     In  the  interests  of  portability,  we  believe  that
character comparisons for "memcmp", "strcmp", and  "strncmp"
should   be   made   using  uuunnnsssiiigggnnneeeddd
 ccchhhaaarrr  instead  of  the
implementation-defined approach specified in the standard.
     
_4._1_1._5._6  _T_h_e _s_t_r_s_p_n _F_u_n_c_t_i_o_n:
     
     For greater  uniformity,  the  name  of  this  function
should  be changed to "strpspn".  This emphasizes the way it
parallels "strpbrk".
     
_4._1_1._6._2  _T_h_e _s_t_r_e_r_r_o_r _F_u_n_c_t_i_o_n:
     
     The standard should be more explicit about the  connec-
tion  between  the  "errnum" argument for "strerror" and the
possible values of "errno".
     
_4._1_2._1  _C_o_m_p_o_n_e_n_t_s _o_f _T_i_m_e:
     
     Again, we wonder why vowels have fallen into disrepute.
CLK_TCK could easily be named _CLK_TICK or _CLOCK_TICK.
     
     It  should  be  explicitly  stated  that values of type
"time_t" may not represent time in meaningful units and  may
not even give values that are uniformly distributed.
     
_4._1_2._2._1  _T_h_e _c_l_o_c_k _F_u_n_c_t_i_o_n:
     
     "clock"  is  a  poor  name  for a function that returns
processor time.   A  name  like  "processor_time"  would  be
better.
     
     The  description  of  "clock" says it returns processor
time used since some point in time related only  to  program
invocation.   We  believe  that  it  should  instead  return
processor time accumulated  since  some  previous  point  in
time,  e.g.  the  time  when  the user logged on.  To time a
particular  program,  the  user  would  make  two  calls  to
"clock":   one  at the beginning of execution and one at the
end (or whenever a time check is required).
     
     
     
     
     
     
     
                           - 33 -

     
University of Waterloo                          August, 1986
     
     
     The reason for our suggestion  is  that  many  non-UNIX
systems  have  no  system  call  to get per-process timings.
Instead, many just keep track of  total  session  time.   If
implementations  are  forced to support "clock" as it is now
described, many  implementations  will  have  to  put  "time
check"  code  into  the  set-up routine for every C program.
This seems very inefficient, especially because  "clock"  is
not the sort of function that will be used frequently.
     
     If  a  program calls another process using the "system"
function, it may be more efficient on some systems  for  the
processor  time  of  the child process to be included in the
parent's time, while on other systems it is  more  efficient
not  to  include  the child's CPU time.  Thus, this behavior
should be implementation-defined.
     
_4._1_2._2._4  _T_h_e _t_i_m_e _F_u_n_c_t_i_o_n:
     
     The standard states that "time" returns
     
          ((time_t)-1)
     
if the current time is not available.  However, -1 may  well
be a valid time value on many systems.
     
     If   you   are   going   to  select  a  reserved  value
arbitrarily, choosing 0 makes more sense,  since  it  allows
tests of the form
     
          if (time(p)) ...
     
A   better  solution  would  be  to  create  a  macro  named
_TIME_UNAVAILABLE with
     
          #define _TIME_UNAVAILABLE ( (time_t) X )
     
where X is some implementation-defined value.  "time"  would
return this value if the time was undefined.
     
_4._1_2._3  _T_i_m_e _M_a_n_i_p_u_l_a_t_i_o_n
 _F_u_n_c_t_i_o_n_s:
     
     It  has  always been a nuisance to get the current time
of day in string format because you must  declare  your  own
variable  of  type  "time_t".   The library needs a function
that behaves like "ctime" but which is declared with
     
          char *timefunc(time_t timer);
     
We could then use
     
     
     
     
     
                           - 34 -

     
University of Waterloo                          August, 1986
     
     
          timefunc( time( (time_t) 0 ) )
     
to get the current time-of-day string.
     
_S_u_m_m_a_r_y:
     
     In order to avoid a deluge of reserved words, all newly
introduced   symbols  should  follow  a  simple  rule,  e.g.
beginning with an underscore.  Ambiguities  in  the  defini-
tions  of  structures, unions, and tttyyypppeeedddeeefff
 constructs should
be clarified or eliminated.
     
     If you have any questions or comments about any of  the
material  in  this  document,  please  contact Peter Fraser,
manager  of  the  Software  Development  Group,   at   (519)
888-4546.
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                           - 35 -


From:	ARPA%"franka%mmintl.uucp@BRL.ARPA" 28-AUG-1986 04:16
To:	JMS
Subj:	Re: Orphaned Response

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0637
          for JMS@ARIZMIS; Thu, 28-AUG-1986 04:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/28/86 at 06:08:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017009; 28 Aug 86 7:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025596; 28 Aug 86 5:35 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <1761@mmintl.UUCP>
Date: 22 Aug 86 22:07:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900015@haddock> karl@haddock.UUCP writes:
>... "(e1?e2:e3),e4".
     
It occurred to me that there is a workaround which deals not only with the
void case, but also with the case where the types of e2 and e3 are different
(and the result is to be ignored): "e1?(e2,0):(e3,0)".  I'm not sure whether
to recommend this in cases where an expression is required instead of a
statement, or to draw back in horror.
     
>For another, the types might be
>unknown, if they are arguments in a macro; in this case I would want the
>macro to work on void as well as valued expressions.
     
This case is not covered by my suggestion.  I find it hard to imagine doing
it, however.
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

From:	ARPA%"cary%methods.uucp@BRL.ARPA" 29-AUG-1986 09:52
To:	JMS
Subj:	Re: e1?(void_e2):(void_e3)     so, is it legal or what?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3841
          for JMS@ARIZMIS; Fri, 29-AUG-1986 09:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/29/86 at 11:37:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002101; 29 Aug 86 6:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016865; 29 Aug 86 5:35 EDT
From: Cary Timar <cary%methods.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <114@methods.UUCP>
Date: 26 Aug 86 00:26:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <248@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes:
>
>Unfortunately, Brett is incorrect here.  You can't use if/then/else to write:
>
>    for (i = up ? 0 : 99;  up ? (i < 100) : (i >= 0);  up ? i++ : i--)
>        {
>        /* complex loop body */
>        }
>
>without duplicating code.  On the other hand, anywhere you want do
     
What about:
     
    if (up)
        {
        i = 0;
        step = 1;
        }
    else
        {
        i = 99;
        step = -1;
        }
    for (; i < 100 && i >= 0; i += step)
        {
        /* complex loop body */
        }
     
????
     
            -- Cary Timar /* NOT REACHABLE */
            < Generic Disclaimer >

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 29-AUG-1986 10:10
To:	JMS
Subj:	Re: Comments on proposed C standard

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3998
          for JMS@ARIZMIS; Fri, 29-AUG-1986 10:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002104; 29 Aug 86 6:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016987; 29 Aug 86 5:38 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Comments on proposed C standard
Message-ID: <6632@sun.uucp>
Date: 28 Aug 86 09:43:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>      According to the standard, an operation like
>
>           int i;
>           i /= 3.5;
>
> would be performed using floating point division.   However,
> the  Berkeley  C  compiler  uses integer division.  For this
> reason, this should be marked as a quite change.
     
*Which* "Berkeley C compiler"?  The 4.3BSD one performs this operation
correctly; it uses floating-point division.  The 4.2BSD compiler (and
probably the System III compiler it was derived from) had a bug which made
them do integer division in this case.  As such, there is no need to make
note of this, as it is not a change.
     
> By rephrasing the definition this way, you give the "register"
> storage-class  more  meaning.   In  particular, you open the
> door to compilers that perform  global  optimizations  using
> the fact that "register" variables can never have their values
> changed by indirection through a pointer.  The compiler  can
> optimize the use of "register" variables because it can always
> know when the register values are used and changed.
     
Well, maybe.  What about something of storage class "static" or "external"
that is never aliased?  Should "external register foo" be allowed?  If it
is, should the compiler actually try (somehow) to place it into a register?
What about something that is a member of a structure or array?
     
It may give the "register" storage class more meaning, but the meaning isn't
what people think of when they think "register".  If such a construct is
truly necessary, some other keyword should be provided.  I'm not convinced
there aren't better ways of accomplishing this goal.
     
>      If we have
>
>           enum E1 { e1 } var;
>           enum E2 { e2 };
>
> is it legal to say
>
>           var = e2;
>
> The  answer  is almost certainly yes...but we would be happy
> if we were allowed to give a warning or an error message for
> the  operation, if there is no explicit cast.  Similarly, we
> would like to give a warning for things like
>
>           var = e2 + 1;
     
Yes.  100 votes for this.
     
> On the other hand, it would be very convenient if one  func-
> tion  could  declare  an object "const" while another did not.
> This would let a function indicate when it did not intend to
> change  the  value  of an external object, and thereby allow
> local optimizations.
     
Presumably, an optimizing compiler can figure this out without the
programmer's help.  1) "const" is supposed to be part of the type of an
object, so that attempts to modify a "const" object can be detected at
compile time.  Allowing this sort of thing muddies the waters somewhat.  2)
It might be tricky to implement with some loaders.
     
>      The last sentence of the Semantics section reads
>
>      If the list is empty  in  a  function  declaration
>      that  is  part of a function definition, the func-
>      tion has no parameters.
>
> What does this say about a function definition like
>
>           int (*F(int a))() {...
>
> Since the empty identifier list appears as part of  a  func-
> tion definition, the function pointed to by F's return value
> takes no arguments.
     
This was probably not what they intended; presumably, the intent was that
     
    int
    foo()
    {
        ...
    }
     
was to declare a function with no arguments.  The term "part of" is poorly
chosen; some more specific term should be used.  (Or C++ should be used,
where "int foo();" also declares a function with no arguments;
unfortunately, this can't be changed in C.  Yet.)
     
>      Can auto initializers make use  of  external  variables
> with  the  same  name  as the symbol being initialized?  For
> example, is the following valid?
>
>           int i = 1;
>           f() {
>               char i = i * 2;
>               ...
>
> This  sort of construction is allowed and used in Berkeley C
> code.
     
Where is this code used?  Sounds like it should be cleaned up to me.  This
kind of construct is going to cause somebody to trip over it when reading
code.
     
>      The Rationale states that a format for  variable-length
> argument   lists   was   rejected   because   the  functions
> "vfprintf",  etc.  were  "more  controlled".   This  comment
> confuses   us,   because  we  don't  understand  what  "more
> controlled" means.  Very clearly,  the  "vfprintf"  approach
> offers less freedom and therefore is less useful.
     
Can "%v" and the like be implemented on any system on which "vfprintf" can
be implemented?  If no, the "vfprintf" will be more widely available and is
therefore more useful.
     
>      We  suggest  that  "printf"  and  friends  obtain a new
> specifier "%v", which accepts two arguments:  a  new  format
> string  and a "va_list" of items to format.  This is similar
> to the existing "%r" construct on UNIX systems.
     
*Some* UNIX systems.  It's not in 4.2BSD or System V, and it wasn't
documented in V7 (I don't remember whether it was there or not).
     
>      It seems odd that "strncat" always adds a trailing '\0'
> but "strncpy" does not.
     
It may be considered odd, but that's the way UNIX works.  Too late to change
it now, unless you want to give the new function a different name.  (I think
the intent can best be described by discussing two character string types;
null-terminated strings, and null-or-end-of-buffer-terminated strings.  The
latter appear, for example, in directories on UNIX systems using the V6 or
V7 file systems, where a 14-character name has no null terminator.
"strncpy" copies one null-or-end-of-buffer-terminated string to another,
while "strncat" appends a null-or-end-of-buffer-terminated string to a
null-terminated string.  (If you want a version of "strncpy" that copies a
null-or-end-of-buffer-terminated string to a null-terminated string, clear
out the null-terminated string and "strcat" the other string to it.)
     
>      For greater  uniformity,  the  name  of  this  function
> should  be changed to "strpspn".  This emphasizes the way it
> parallels "strpbrk".
     
For greater compatibility with existing UNIX implementations, the name of
the function should be left as "strspn".  This emphasizes the fact that it
does the same thing as the UNIX function with that name.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"LEICHTER-JERRY@YALE.ARPA" 29-AUG-1986 13:41
To:	JMS
Subj:	Re: Problem with VAX C 2.x file writes

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6448
          for JMS@ARIZMIS; Fri, 29-AUG-1986 13:41 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 08/29/86 at 13:59:33 CDT
Received: from yale.ARPA (YALE-VENUS.ARPA.#Internet) by SRI-KL.ARPA with TCP;
  Thu 28 Aug 86 10:13:17-PDT
Date: 28 AUG 1986 13:15:23 EST
From: <LEICHTER-JERRY@YALE.ARPA>
To: jso@edison.GE.COM
cc: info-vax@sri-kl.arpa,carpenter_l@imstop.aco.ge.com
Subject:  Re: Problem with VAX C 2.x file writes
Reply-To: <LEICHTER-JERRY@YALE.ARPA>
     
    ...
    When creating text files that are used and input to VAX utilities, such as
    the C compiler or macro assembler, we have been told by DEC S/W support to
    avoid "fprint" and "fwrite" and to use just "write" instead....
     
    They are running VMS v4.4 and C v2.1 and have tried C v2.2 with same
    results.  Analyze/rms shows the file as corrupted....
     
    Temporary fix is to have the new line character as the last char. of the
    last write of the last line of the file.
Since the problem statement only indicates a workaround, and no indication of
what was observed, it's hard to be certain; but this is almost surely a
previously-reported (and SPR'ed) problem that Gnu Emacs, among others, has
run into trouble with:  RMS cannot deal with a STREAM_LF file that does not
have a trailing LF (C '\n') character.  The symptom seen is RMS bugchecks
when the file is read.  (RMS bugchecks are non-fatal from the system's point
of view, but usually blow away the user's process with no message.  You can
check the accounting entry for the process and look at its final status to
see what happened.)
     
Anyway, it's an RMS problem, not a C problem, and will be fixed "in a future
release of VMS".  In the meantime, there are at least two work-arounds:
     
    Don't use STREAM_LF files.  With V2.x of VAX C, the fopen() (and
    open() and all related) function(s) allow you to specify the attri-
    butes of the file being created.  Use "rfm=var" and "rat=cr" (variable
    length records, carriage return control) to get a "plain vanilla"
    text file.  Every program will accept these files; some may have
    problems with stream files.  The only limitation is that you can't
    do arbitrary fseek's in such files - you can only seek to the begin-
    ning of records.  In my experience, very few applications need this
    anyway.
     
    If you need to do arbitrary seeks, just make sure to write a LF at
    the end of your last record.
     
Either of these should be pretty easy to fit into existing code.
     
BTW, as far as I can tell, the use of "write" rather than "fprint" or "fwrite"
should have no bearing on this problem.
                            -- Jerry
-------

From:	ARPA%"toma%killer.uucp@BRL.ARPA" 30-AUG-1986 03:17
To:	JMS
Subj:	Re: C-STYLE (goto?)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7437
          for JMS@ARIZMIS; Sat, 30-AUG-1986 03:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/30/86 at 05:11:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a019246; 30 Aug 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a003637; 30 Aug 86 5:33 EDT
From: Tom Armistead <toma%killer.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C-STYLE (goto?)
Message-ID: <264@killer.UUCP>
Date: 27 Aug 86 17:16:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3253@brl-smoke.ARPA>, jeff@isi-vaxa.ARPA writes:
> I am sure that this case of style has been brought up before.  It has been
> bothering me for awhile.
>
> The way I like to do it is:
>
>     setup_step_1;
>     if ( (status = step_1()) == FAILURE )
>         goto abort_operation;
>
>     setup_step_2;
>     if ( (status = step_2()) == FAILURE )
>         goto abort_operation;
>
>         .
>         .
>         .
>
>     setup_step_n;
>     if ( (status = step_n()) == FAILURE )
>         goto abort_operation;
>
> abort_operation:
>
>     cleanup();
>     return (status);
>
> Now, I know a lot of people detest this because of the use of goto's, but this
> seems the nicest way to perform this function.  I really have nothing against
> goto's if they are directed to the same spot (i.e., don't jump back and forth)
> and enhance the readability of the code.
>
> Any comments?  I am willing to adapt to another reasonable style for such
> cases (if anyone really cared).
     
There is always the use of setjmp and longjmp to acomplish this task,
sometging like this:
     
#include <setjmp.h>
#define FAILURE    1    /* cannot == 0, due to setjmp conventions */
     
routine()
{
    jmp_buf        env;    /* envireoment for setjmp,lonjmp */
    int        val,    /* used in return to setjmp */
            status;
     
    if (setjmp(env) == FAILURE)    /* if abort return, cleanup and exit */
        {
        cleanup();
        return(status);
        }
    /* setup_step_1 */
    if ((status = step_1()) == FAILURE)
        longjmp(env,FAILURE);    /* return to setjmp call w/FAILURE */
     
    /* setup_step_2 */
    if ((status = step_2()) == FAILURE)
        longjmp(env,FAILURE);    /* return to setjmp call w/FAILURE */
     
        .
        .
        .
     
    /* setup_step_n */
    if ((status = step_n()) == FAILURE)
        longjmp(env,FAILURE);    /* return to setjmp call w/failure */
     
        .
        .
        .
     
    /* continue on from here ... */
}
     
This will accomplish the same thing and possibly not affend the goto haters,
although it is somewhat harder to follow if you are no farmiliar with
setjmp() and lonjmp().
     
Tom
---
UUCP:
                          ihnp4\
                                \killer!toma
                                /
  drillsys!infoswx!convex!dj3b1/
     
Tom Armistead

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA" 31-AUG-1986 05:22
To:	JMS
Subj:	Re: C-STYLE (goto?)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5674
          for JMS@ARIZMIS; Sun, 31-AUG-1986 05:22 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/31/86 at 07:13:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021646; 31 Aug 86 5:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010724; 31 Aug 86 5:35 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C-STYLE (goto?)
Message-ID: <3200@umcp-cs.UUCP>
Date: 30 Aug 86 12:47:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <3253@brl-smoke.ARPA> jeff@isi-vaxa.ARPA writes:
>>    setup_step_1;
>>    if ( (status = step_1()) == FAILURE )
>>        goto abort_operation;
    ...
>>    setup_step_n;
>>    if ( (status = step_n()) == FAILURE )
>>        goto abort_operation;
>>
>>abort_operation:
>>
>>    cleanup();
>>    return (status);
     
>>Now, I know a lot of people detest this because of the use of goto's ....
     
In article <264@killer.UUCP> toma@killer.UUCP (Tom Armistead) replies:
>There is always the use of setjmp and longjmp to acomplish this task ....
[example deleted]
>This will accomplish the same thing and possibly not affend the goto haters,
>although it is somewhat harder to follow if you are no farmiliar with
>setjmp() and lonjmp().
     
Alas, longjmp() is nothing more than goto in disguise.  Indeed,
this is a far more powerful version of goto than the `plain C'
goto, and should by rights be correspondingly more offensive to
goto haters.  In general, when choosing between two existing
primitives, if one is less powerful but does what you need, use
that.  When designing primitives, the choice is more difficult:
something that does less is easier to understand, but you may need
too many of those things, making the whole harder to comprehend.
     
As to a specific solution to the original problem above, I think
there is no `best' answer, at least not without more information.
I happen to like the pointer table method proposed by grt@twitch;
it can be expanded in a useful way for recovery and/or error
explanation:
     
    int    dostep1(), dostep2(), dostep3(), dostep4();
    int    fix1or3(), fix2();
     
    struct step {
        char    *s_name;    /* name of this step */
        int    (*s_func)();    /* function that implements it */
        int    (*s_fixup)();    /* repair after error */
    } steps[] = {
        { "step1",    dostep1,    fix1or3 },
        { "step2",    dostep2,    fix2 },
        { "step3",    dostep3,    fix1or3 },
        { "step4",    dostep4,    0 },
        0            /* marks end of table */
    };
     
    f()
    {
        register struct step *s;
        int status;
     
        for (s = steps; s->s_func != NULL; s++) {
            if ((status = (*s->s_func)()) != SUCCESS) {
                if (s->s_fixup == NULL ||
                    (*s->s_fixup)(status) != SUCCESS) {
                    fprintf(stderr, "\
    Unrecoverable failure in %s, code %d\n",
                        s->s_name, status;
                    break;
                }
            }
        }
        return (status);
    }
     
There may be cases, however, where a direct-coded state machine
with a `switch' statement would be better; and there may be cases
where the original code runs fastest and/or is clearest (whichever
is more important to the coder/maintainer and user).
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	edu%"sr16@andrew.cmu.edu" 31-AUG-1986 20:59
To:	JMS
Subj:	Microsoft C 4.00

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0881
          for JMS@ARIZMIS; Sun, 31-AUG-1986 20:59 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/31/86 at 22:56:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023009; 31 Aug 86 23:43 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a017115; 31 Aug 86 23:05 EDT
Received: from PO2.ANDREW.CMU.EDU by VGR.BRL.ARPA id aa21044;
          31 Aug 86 22:45 EDT
Received: by po2.andrew.cmu.edu (4.12/3.15) id <AA00676>; Sun, 31 Aug 86
  21:11:57 edt
Received: FROM gettysburg VIA queuemail
          ID </cmu/common/mailqs/q000/QF.gettysburg.1f58eb0d.4>;
          Sun, 31 Aug 86 21:10:43 edt
Message-Id: <MS.sr16.0.gettysburg.1283.0@andrew.cmu.edu>
Date: Sun, 31 Aug 86 21:10:27 edt
From: Seth Benjamin Rothenberg <sr16@andrew.cmu.edu>
To: info-c@BRL.ARPA
Subject: Microsoft C 4.00
     
I have been asked to forward this....
     
/* To: info-c@brl.arpa */
     
I have Version 4.00 of the Microsoft 'C' Compiler, including the public domain
demostration diskette, if anyone wants a copy or a demonstration.
     
Jay Libove (JL42)
     
     
     

From:	ARPA%"LINNDR%VUENGVAX.BITNET@wiscvm.ARPA" 31-AUG-1986 21:20
To:	JMS
Subj:	C programming style

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1001
          for JMS@ARIZMIS; Sun, 31-AUG-1986 21:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 08/31/86 at 23:17:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a023097; 1 Sep 86 0:04 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a017522; 31 Aug 86 23:31 EDT
Received: from WISCVM.WISC.EDU by VGR.BRL.ARPA id aa21244; 31 Aug 86 22:53 EDT
Received: from (LINNDR)VUENGVAX.BITNET by WISCVM.WISC.EDU on 08/31/86
  at 21:52:05 CDT
Date:     Sun, 31 Aug 86 21:49 CST
From:        LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject:  C programming style
To:  info-c@BRL.ARPA
X-Original-To:  info-c@brl.arpa, LINNDR
Message-ID:  <8608312253.aa21244@VGR.BRL.ARPA>
     
Since I am currently in a situation where I need the sort of behavior
described by Jeff Cavallaro in the original posting (an N step process
with abort on any failed step), I reread his text. I'm not read sure
how his example that "significantly upsthe routine count" is different
his preferred style example. In fact, his preferred style example look to
me to be what the compiler will actually produce for the
     
if (step1() && step2() && ... && stepn())
     
example (which I have simplified here by assuming that each step returns
a 1 for success).

From:	ARPA%"jeff@isi-vaxa.ARPA"  1-SEP-1986 14:29
To:	JMS
Subj:	More info on GOTO question

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6892
          for JMS@ARIZMIS; Mon,  1-SEP-1986 14:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/01/86 at 16:20:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024658; 1 Sep 86 17:13 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa24695; 1 Sep 86 16:42 EDT
Received: from vaxa.isi.edu by VGR.BRL.ARPA id aa25857; 1 Sep 86 16:35 EDT
Received: by vaxa.isi.edu (4.12/4.7)
    id AA00757; Mon, 1 Sep 86 13:35:30 pdt
From: "Jeffery A. Cavallaro" <jeff@isi-vaxa.ARPA>
Message-Id: <8609012035.AA00757@vaxa.isi.edu>
Date:  1 Sep 1986 1335-PDT (Monday)
To: info-c@BRL.ARPA
Cc:
Subject: More info on GOTO question
     
Thanks to all for the informative (and kind) responses to my "goto" style
query.  A few people wanted a little more info on the application, and it is
sort of interesting, so I will share it with the net, as well as the solution
I chose.  If you are not interested, might as well abort here...
     
I am implementing a relay channel between MMDF-II (a pre-release version), and
various commercial mail networks (e.g. TELEMAIL, MCIMAIL, etc.).  Submitting
(or receiving) mail to (from) MMDF is a multi-step process that draws upon an
"instruction set".  The submit sequence is basically as follows:
     
    1.  Init.
    2.  Fork submit job to be communicated with via pipes.
    3.  Init for next message.
    4.  Submit addresses.
    5.  Submit text.
    6.  Indicate message end, and loop to (3) if more messages.
    7.  Release fork.
     
Each step involves complicated "handshaking" between the commercial mail system
channel and MMDF.  If any of the above steps fails, cleanup and a possible
return-to-sender operation will occur.
     
The solution involved developing a software FSM which is composed of a
state/event matrix, an event generator, and a dispatcher.  The matrix is
used to address an action routine, according to the current state/event pair,
and the next state information depending upon the success or failure of the
action routine.  This solution is a more complicated version of the while-loop
solution proposed by many people.  The cleanup process can now be moved from
the inline code to a different state/event pair.
     
This solution is VERY flexible.  By adding state change and event occurrance
debug calls, debugging large SM's is greatly facilitated.  I have used this
solution before on other projects, with great success.  The only reason why I
hesitated using it for this project is that "events" become too complicated to
isolate due to the seemingly non-deterministic nature of the commercial mail
system human interfaces.  This is solved by allowing the action routines
corresponding to the state/event pairs to determine the next event.
     
If anyone is interested, I would be glad to send or post a synopsis of the
technique.  The FSM development tools consist of an include file, the
dispatcher code, and some man pages.  The event handler and matrix contents
are up to the developer.
     
Thanx,
Jeff

From:	ARPA%"levy%ttrdc.uucp@BRL.ARPA"  1-SEP-1986 18:50
To:	JMS
Subj:	Re: strcpy, strncpy, strcat, strncat

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8411
          for JMS@ARIZMIS; Mon,  1-SEP-1986 18:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/01/86 at 20:45:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024933; 1 Sep 86 21:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026064; 1 Sep 86 21:30 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: strcpy, strncpy, strcat, strncat
Message-ID: <1162@ttrdc.UUCP>
Date: 31 Aug 86 23:28:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6632@sun.uucp>, guy@sun.UUCP writes:
>>      It seems odd that "strncat" always adds a trailing '\0'
>> but "strncpy" does not.
>
>It may be considered odd, but that's the way UNIX works.
                                              ^^^^
THE UNIX(trademark of AT&T) SYSTEM
     
>(If you want a version of "strncpy" that copies a
>null-or-end-of-buffer-terminated string to a null-terminated string, clear
>out the null-terminated string and "strcat" the other string to it.)
     
1) Surely, "strncat()" was meant here.  "strcat()" expects a null-terminated
   string as input, whereas "strncat()" accepts a maximum count.
     
2) Why "clear out" the null-terminated string (better, "buffer") to be
   copied to?  Just null its first character (at least under UNIX(tm)
   System V this works with strncat(), dunno about Berzerkeley).
     
3) Better yet, if one is obsessed over performance (avoiding the check for the
   length of the string in the destination buffer), write one's own routine
   for this and include it in one's source code.  The routine would likely be
   under 10 lines long.  Or make it a macro.  The UNIX(tm) system doesn't
   promise to provide the kitchen sink ready-made, rather, it furnishes
   the tools to construct it with.  Use them.
     
4) I kind of doubt that Guy will ever read these comments, at least not
   unless someone else quotes them (I think my name/site is in his kill file).
   But comments from others as to whether I have truly caught some things
   that Guy has omitted/missed/forgotten would be welcome.
     
>    Guy Harris
>    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
>    guy@sun.com (or guy@sun.arpa)
     
Dan at the "Deathstar"
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy

From:	ARPA%"bnfb@UW-JUNE.ARPA"  2-SEP-1986 07:30
To:	JMS
Subj:	Optimizing C compilers, and their use...

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2651
          for JMS@ARIZMIS; Tue,  2-SEP-1986 07:30 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/02/86 at 07:35:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027550; 2 Sep 86 8:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029864; 2 Sep 86 7:31 EDT
From: Benson <bnfb@UW-JUNE.ARPA>
Newsgroups: net.lang.c
Subject: Optimizing C compilers, and their use...
Message-ID: <1184@uw-june>
Date: 1 Sep 86 22:13:03 GMT
Keywords: optimize, C, compiler
To:       info-c@BRL-SMOKE.ARPA
     
All the time, on the net, in casual conversation, in literature and
especially in discussions of the forthcoming C Language Standard, I have
heard the statement:
    "You can allow/do/write <anything> because any
     decent optimizing compiler will fix/compile it."
My question is:
    How many of you who say this (or even just how many of you
    on the net) have an optimizing C compiler?  And how many of
    those actually use them?
Until people have them, work-arounds ("kludges") will have to be.  And
until people use the compilers, just writing <anything> won't do.
     
                        Bjorn Freeman-Benson
     
P.S. Oh, and what would you be willing to pay (up-and-above normal
C compiler costs) for such an optimizing compiler?  Remember - until
you have one, you can't take advantage of it, but them engineers who
wrote it have a done a lot of work...

From:	jnet%"stef@nrtc-gremlin"  2-SEP-1986 15:05
To:	JMS
Subj:	REPEAT C Call for Papers WG 6.5

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7558
          for JMS@ARIZMIS; Tue,  2-SEP-1986 15:05 MST
Received: from OZ.AI.MIT.EDU by wiscvm.wisc.edu on 09/02/86 at 16:39:15 CDT
Received: from MC.LCS.MIT.EDU by OZ.AI.MIT.EDU via Chaosnet; 2 Sep 86 16:41-EDT
Received: from NRTC-GREMLIN.NORTHROP.COM by MC.LCS.MIT.EDU  2 Sep 86 16:43:20
  EDT
Received: from nrtc-gremlin by NRTC-GREMLIN.NORTHROP.COM id a004967;
          2 Sep 86 13:19 PDT
To: ARPA-MHS@brl.ARPA, ARPANET-BBOARDS@mc.lcs.mit.EDU, Taylor@hplabs.hp.COM,
    Header-People@ai.ai.mit.EDU, HUMAN-NETS@rutgers.EDU,
    INFO-NETS%MIT-OZ@mc.lcs.mit.EDU, MMM-PEOPLE@b.isi.EDU,
    NAMEDROPPERS@sri-nic.ARPA, TELECOM@xx.lcs.mit.EDU,
    MHS_IMPLEMENTATION@rsch.wisc.EDU
Subject: REPEAT C Call for Papers WG 6.5
Reply-to: stef@nrtc-gremlin
Date: Tue, 02 Sep 86 13:19:15 -0700
Message-ID: <4965.526076355@nrtc-gremlin.northrop.com>
From: Einar Stefferud <stef@nrtc-gremlin>
     
------- Forwarded Message
     
Subject: Call for Papers WG 6.5
From: Peter Schicker <schicker%ean.cs.nott.ac.uk@cs.ucl.ac.UK>
To: Hugh Smith <hugh%computer-science.nottingham.ac.uk@cs.ucl.ac.UK>,
    Einar Stefferud <stef@brl.ARPA>
Cc: Rolf Speth <Rolf_Speth_QZ%com.york.ac.uk@cs.ucl.ac.UK>
Date: 13 Jun 86 7:55 -0100 BST
     
Hugh and Stef
     
Could you post the following call for papers on the US and European nets,
please.
     
- -----------------------------------------------------------------------
     
             CALL  FOR  PAPERS
     
      IFIP WG 6.5 International Working Conference on
     
              MESSAGE HANDLING SYSTEMS
          (State of the Art and Future Directions)
     
             27 to 29 April 1987
                   Munich
            Fed. Rep. of Germany
     
- ----------------------------------------------------------------------
Program
     
The purpose of the conference is to provide an international forum for the
exchange of information on the technical, economic, social, and political
impacts of computer message and office systems. The conference format will
be two days of conference paper presentations followed by one day of work-
shops.
     
Papers are desired in the following topic areas:
     
MHS Interconnection and Interworking
  Interconnection of X.400 Systems (Private and public)
  Gateways to X.400 Systems
  X.400 Shell to non-X.400 Systems
  Interworking between X.400 and the Postal System
  Interworking with other Architectures (e.g., DIA/DCA, All-In-1, etc.)
  Multi-Vendor Private Message Systems
     
Documents and Messages
  Document and Message Architectures
  Multimedia Documents and Messages
  Graphics (GKS) vs. Facsimile
  Communication of Business Forms and Trade Documents
     
Directory Services
  Naming and Addressing
  Public Directory Systems
  Interworking between Public and Private Directory Systems
     
New Access Protocols
  Mailbox Services
  Extensions to X.400 Series Recommendations
     
Message Management
  Personal Message Management
  Message and Document Filing and Retrieval
     
Group Communication
  Distribution Lists
  Organization of Message Flow
  Real-Time Conferencing
  Models for Group Communication
     
Workstations and User Interface
  Workstation and Cluster Design
  Backup and Archiving
  User Interface Issues
  Message Editing
     
Security Aspects
  Authentication
  Confidentiality
     
Impacts of MHS
  Social and Behavioral Impacts
  Impacts on Organizations
  Impacts on Nations
  Inpacts on Relieving Impairment
     
Policy Issues
  Public Policy Issues in MHS
  Transborder Data Flow
  Legal Status of MHS
  Privacy and Confidentiality
     
- ------------------------------------------------------------------------
     
Instructions to Authors:
     
Prospective Authors are invited to submit for review unpublished original
contributions (not exceeding 5000 words) which describe recent developments
on any design or service aspect of computer message systems.
     
Accepted papers will appear in the Conference Proceedings published by
North-Holland Publishing Company.
     
Deadlines:
     
Today               Send a postcard with your name, telephone, and EMail
                    address to:
                       Message Systems '87
                       Mrs. Stenzel
                       Siemens AG
                       D-AP.11
                       Otto Hahn Ring 6
                       D-8000 Munich 83
                       Fed. Rep. of Germany
                    This will ensure that you will receive further information
                    about the conference. Please indicate also the provisio-
                    nal title if you intend to submit a paper.
Sept. 30, 1986      Draft versions of papers required
Nov. 30, 1986       Notification of acceptance
Jan. 31, 1987       Camera-ready papers required
     
Papers should be submitted to:
     
Peter Schicker
Zellweger Telecommunications AG
CH-8634 Hombrechtikon
Switzerland
     
- ----------------------------------------------------------------------
     
------- End of Forwarded Message

From:	jnet%"karl@haddock"  4-SEP-1986 03:05
To:	JMS
Subj:	Re: fgets() returns NULL at EOF??

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6162
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:01:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029008; 4 Sep 86 5:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012728; 4 Sep 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: fgets() returns NULL at EOF??
Message-ID: <86900031@haddock>
Date: 3 Sep 86 17:32:00 GMT
Nf-ID: #R:sun.uucp:6444:haddock:86900031:000:774
Nf-From: haddock!karl    Sep  3 13:32:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
sun!guy (Guy Harris) writes:
>Now, you can ask "why does 'fgets' return a value of type 'char *'?"  at
>this point.  It returns a pointer to the buffer that it just filled in;
>obviously *somebody* found this useful, although I don't find it so.
     
Me neither.  It sounds like a "why not?" situation.
     
>If "fgets" didn't return that pointer, it could have been defined as
>returning a value of type "int" instead, and that value would have been 0 on
>success and EOF on failure.
     
Better yet, return the number of characters read (so 0 on failure).
     
>It's too late to change it, though.
     
Not without changing the name again.  (That's how fgets() evolved from
gets(), though the latter still exists.)
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  4-SEP-1986 03:09
To:	JMS
Subj:	Re: Orphaned Response

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6223
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:02:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029010; 4 Sep 86 5:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012733; 4 Sep 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900032@haddock>
Date: 3 Sep 86 18:13:00 GMT
Nf-ID: #R:dataio.UUCP:1074:haddock:86900032:000:2453
Nf-From: haddock!karl    Sep  3 14:13:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
Note: In my earlier posting I came to the tentative conclusion that the "dead
function" concept (a function which never returns, e.g. exit) would probably
not be sufficiently useful to be worth adding a new builtin type.  I haven't
changed my mind; I just want to point out some possibilities.
     
dataio!bright writes:
>In article <86900019@haddock> karl@haddock writes:
>>[2] It won't be usable much.  This is a valid point.  There were a *lot* of
>>nonvalued int functions before void was invented; there are only a handful
>>of standard functions that are dead-ends.
>
>Functions that never return are used a LOT in code that is loaded
>with self-debugging assertion macros:
>           #define assert(e) ((e) || printmsgandexit("e",__LINE__,__FILE__))
     
But there are typically a very small number of such functions (usually one)
per application.  (Btw, I wouldn't want to assume that a dead function can be
the right argument of "||".)
     
>A good optimizer can make some important optimizations [with register usage,
>information about global and indirect references] if it knows that a
>function will never return.
     
Good point.  I hadn't thought of that type of optimization.
     
Another "advantage" of an explicit declaration for dead functions is that,
logically, one should be able to cast from "dead" into any other type -- a
feature not available with "void".  Since the code that would implement the
cast is never reached, it need not do anything.  This would allow
    extern double atod();
    extern dead abort();
    x = isfloatstr(s) ? atod(s) : abort();
which is a pretty bad example, so let me try again.
     
"pointer to dead function" (I can't really call it "pointer to function
returning dead", can I?) could be cast into "pointer to function returning T"
for any type T.  This would allow
    extern T f0(), f1(), f2(), f4();
    extern dead abort();
    T (*)() tab[] = { f0, f1, f2, abort, f4 };
     
Note that this can ALREADY BE DONE using an implicitly dead function.  The
functions in libc are declared "void" (that being the closest match), but it
is perfectly legal to write
    double bomb(char *s) {
        write(2, s, strlen(s));
        exit(1);
    }
An explicit "dead" declaration, with permission to cast to other types, would
seem to be more sensible.  (Though I think I'd want to require the cast to be
explicit.)
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint
(The opinions expressed above are not necessarily those of the author.)

From:	jnet%"karl@haddock"  4-SEP-1986 03:21
To:	JMS
Subj:	Re: Missing stdio features.

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6372
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:21 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:12:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029014; 4 Sep 86 5:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012743; 4 Sep 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <86900034@haddock>
Date: 3 Sep 86 18:47:00 GMT
Nf-ID: #R:robin.cs.nott.ac.uk:3438:haddock:86900034:000:1762
Nf-From: haddock!karl    Sep  3 14:47:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
jpo@cs.nott.ac.uk (Julian Onions) writes:
>All in all, fselect is the right way to go (stdio features tracking
>system calls), ...
     
Hasn't anyone noticed that at least part of the purpose of stdio is to make
code portable?  Some systems (even some UNIXes) don't have any way to write
a function such as fselect().
     
>>FILE *fopenfxn(int (*fxn)(), char *mode)
>>       Function-stream I/O.
>Can't say I've ever thought about this one. I'm not sure when you'd
>use it either.
     
Potentially useful, though kind of slow if it has to pass one character at a
time through the function.  But (ignoring error conditions) the first arg
should be "char (*)(void)" if the second is "r", or "void (*)(char)" if the
second is "w"; this could cause problems with type-checking.  (Best solution
is to drop the second arg and use two functions, I think.)
     
Actually, the function argument should probably be analogous to read/write
rather than getc/putc.  But there should be one more argument to fopenfxn(),
viz. a (void *) argument to be passed to fxn() to distinguish streams.
     
>>FILE *fopenstr(char *str, int len, char *mode)
>>      An extension to sprintf() and sscanf().  This returns a stream
>>      which performs I/O to a string (this makes sprintf() and
>>      sscanf() unnecessay, though they are still convenient).
>I like this one, C++ has something like this in its streams stuff,
>and I liked the idea there. Being able to treat incore strings and
>files the same seems a good idea.
     
I like it too, but maybe it should be called "stropen" (cf. "fdopen").  It's
a good idea to require the len argument even for string reading, so '\0' can
be treated as an ordinary character if desired.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  4-SEP-1986 03:26
To:	JMS
Subj:	Re: Missing stdio features.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6489
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:19:38 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029016; 4 Sep 86 5:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012747; 4 Sep 86 5:34 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <86900035@haddock>
Date: 3 Sep 86 18:55:00 GMT
Nf-ID: #R:robin.cs.nott.ac.uk:3438:haddock:86900035:000:1020
Nf-From: haddock!karl    Sep  3 14:55:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
sun!guy (Guy Harris) writes:
> >FILE *fopenstr(char *str, int len, char *mode)
>It looks straightforward to implement IF you have the 4BSD version of
>standard I/O, where there's a "this is a string" flag for each FILE
>structure.  The S5 version, unfortunately, has only a "char" for the flags,
>not a "short", so it says that the "last" FILE entry, and only that entry,
>is a stream.
     
Making the last FILE special was indeed a botch, but it isn't necessary to
expand the _flag field to fix it.  Just use (iop->_file == -1) on string
files.
     
>Given "fopenstr" you can actually provide a version of "sprintf" that
>performs *bounds checking* on the string it's printing into.  (Wow, what a
>unique concept, software that doesn't scribble its data space when a user
>types in a string longer than it expected!)
     
And given "fopenfxn", you could provide a version of "sprintf" that not only
detects the overflow, but *fixes* it with a realloc()!
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  4-SEP-1986 03:35
To:	JMS
Subj:	Re: macro to specify output paramet

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6636
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:27:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029019; 4 Sep 86 5:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012751; 4 Sep 86 5:34 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: macro to specify output paramet
Message-ID: <86900036@haddock>
Date: 3 Sep 86 19:06:00 GMT
Nf-ID: #R:BMS-AT.UUCP:161:haddock:86900036:000:1085
Nf-From: haddock!karl    Sep  3 15:06:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
BMS-AT!stuart writes:
>[re the declaration of reference types "foo(char &c)"]
>I don't like this.  It violates the nice consistent way that C expressions
>work.  'char *c' means that '*c' is of type char.  '&c' is not of type
>char in any other context.
     
I am also somewhat uneasy about calling it "char &c".  The consistent way to
declare it would be "char *&c", since you have to write "&c" to get ahold of
the "char *" object you are really using.
     
>I would like to see "structure constants" which would allow assignment to
>aggregate types.
>       complex z;
>       z = { a+1, exp(b) };
>       foo( (complex) { a, b } );
     
The problem, as your last example points out, is that the notation "{...}"
doesn't distinguish between different structure types.  I suppose the cast
notation is workable, but kinda ugly.
     
>Of course any of these could be coded by assigning each member in turn.
     
No, the last example requires assigning each member to a temporary, and then
passing that temporary as an argument.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  4-SEP-1986 03:48
To:	JMS
Subj:	Re: Arrays as files

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6826
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:48 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:41:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029012; 4 Sep 86 5:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012737; 4 Sep 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Arrays as files
Message-ID: <86900033@haddock>
Date: 3 Sep 86 18:27:00 GMT
Nf-ID: #R:ihlpa.UUCP:1718:haddock:86900033:000:1259
Nf-From: haddock!karl    Sep  3 14:27:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
ihlpa!reb2 (Rick Brown) writes:
>I would like to do the following:  1) Read an input file line
>by line and save each line in an array (using an AWK-like
>interface)  2) Then, within the same program, cause STDIN
>to point to the array so that the program can read from STDIN
>and get each of the saved input lines.
     
There are some NON-PORTABLE tricks that can make a FILE* use a string rather
than a file descriptor.  I won't go into them here.
     
But, if you really have an array of lines (each of which is an array of char)
then you need more power than this anyway.  When you're at the end of a line,
you have to convert your EOL indicator ('\0', '\n', count==0, or whatever)
into a newline for getc() to return, and reset your pointers to get to the
next input line.
     
I would suggest that you introduce a new type ("gfile", say) for an object
that may be connected to either a string or a stdio FILE.  (You could bypass
the stdio FILE and use the system calls, if appropriate.)  Make your own
function ("ggetc()") which checks a flag member of its argument to see if it
refers to a FILE (in which case it calls getc()) or an array (in which case
it performs as described above).
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  4-SEP-1986 03:56
To:	JMS
Subj:	Re: Dead functions and /*NOTREACHED*/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 6967
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:56 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:46:17 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029021; 4 Sep 86 5:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012755; 4 Sep 86 5:34 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Dead functions and /*NOTREACHED*/
Message-ID: <86900037@haddock>
Date: 3 Sep 86 19:21:00 GMT
Nf-ID: #R:epimass.UUCP:410:haddock:86900037:000:1522
Nf-From: haddock!karl    Sep  3 15:21:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
epimass!jbuck (Joe Buck) writes:
>In article <86900019@haddock> karl@haddock (The Walking Lint) writes:
>>[discussion of some problems with adding "dead functions" to C]
>>But I really hate having to write /*NOTREACHED*/ to keep lint happy!
>
>There's a fix for this that doesn't do violence to the language.
>There should be another "special comment" lint recognizes that's
>present in the lint library (/*DEADEND*/ or something).  Then
>functions like "exit" are marked once in the lint library, and
>user-written functions that always call exit would also be understood
>to be "dead".  Voila! lint now understands about exit, and is able
>to find unreachable code that it currently may miss.
     
(I don't think adding a new type is "violence to the language", but...)
Not bad; it doesn't help with the compiler's optimization, but it would take
care of the /*NOTREACHED*/ problem.  And the user can use /*DEADEND*/ on his
own functions even if lint isn't smart enough to propagate dead-knowledge.
(If it is, then the magic comment may not even be necessary; the line
    void    exit(int) { for (;;); }
int the lint library should suffice.)
     
>While I'm at it, a similar comment could be added to tell lint that
>a function like malloc or calloc always returns an aligned pointer.
     
Perhaps.
     
>I understand that ANSI C has a different solution for this,
     
No.  "void *" has nothing to do with guaranteed alignment, it just means
"pointer to unknown".
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  4-SEP-1986 03:57
To:	JMS
Subj:	Re: fgets() returns NULL at EOF??

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7057
          for JMS@ARIZMIS; Thu,  4-SEP-1986 03:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:53:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029024; 4 Sep 86 5:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012760; 4 Sep 86 5:34 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: fgets() returns NULL at EOF??
Message-ID: <86900038@haddock>
Date: 3 Sep 86 19:35:00 GMT
Nf-ID: #R:bu-cs.bu-cs.BU.EDU:1094:haddock:86900038:000:792
Nf-From: haddock!karl    Sep  3 15:35:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
bzs@bu-cs.BU.EDU (Barry Shein) writes:
     
>Traditionally, any function that cannot return a promised pointer ...
>returns NULL (there exists a few syscalls which return ((char *) -1) or
>equivalent, c'est la vie, this has been hashed out, I guess the rule that
>syscalls return -1 won [eg. sbrk].)
     
Last time I used a pdp11, there was a bug in lseek().  The error return,
which should have been (long)-1 (i.e. 0xffffffff) was 0xffff0000.  I never
determined whether this was an AT&T standard bug or a local glitch.  The
surprising thing is that lseek *was* making the check, but it explicitly
set r1 (the lower half) to 0 instead of -1!  On systems where char* is wider
than int, sbrk() could have a similar problem.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  4-SEP-1986 04:00
To:	JMS
Subj:	Re: by-ref parameters, aggregate co

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7118
          for JMS@ARIZMIS; Thu,  4-SEP-1986 04:00 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:56:22 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029026; 4 Sep 86 5:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012764; 4 Sep 86 5:34 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: by-ref parameters, aggregate co
Message-ID: <86900039@haddock>
Date: 3 Sep 86 19:45:00 GMT
Nf-ID: #R:umcp-cs.UUCP:3100:haddock:86900039:000:768
Nf-From: haddock!karl    Sep  3 15:45:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
umcp-cs!chris (Chris Torek) writes:
>>     foo(c) char &c; { ...
>I have no great love for this syntax either; but how else do you
>propose to add by-reference parameters?
     
Since you asked.  I once suggested "foo(&c) char c; { ... }"; this makes the
declaration in the callee match the syntax in the caller.  However, I have
since decided that the more general reference objects a la C++ are better,
since it allows you to write "lfunctions" that can be used on the left side
of an assignment (e.g. "x = pop(); ...; push() = x").  But as I mentioned in
another posting, "char *&c" is more consistent than "char &c" to declare a
reference.  (And it's probably better than adding a new keyword.)
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"banner%acf2.uucp@BRL.ARPA"  4-SEP-1986 04:02
To:	JMS
Subj:	reading directory under SYSTEM V

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7184
          for JMS@ARIZMIS; Thu,  4-SEP-1986 04:02 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 05:58:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029064; 4 Sep 86 6:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012786; 4 Sep 86 5:35 EDT
From: Bernard Banner <banner%acf2.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: reading directory under SYSTEM V
Message-ID: <5770001@acf2.UUCP>
Date: 3 Sep 86 20:50:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
Cound anybody suggest a method of reading directory information from a C
program under SYSTEM V UNIX? I need something equivalent to the opendir and
readdir functionality supplied under BSD.

From:	ARPA%"dvk@cmu-sei.ARPA"  4-SEP-1986 04:05
To:	JMS
Subj:	Optimizing C Compilers

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7245
          for JMS@ARIZMIS; Thu,  4-SEP-1986 04:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 06:01:40 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029067; 4 Sep 86 6:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012826; 4 Sep 86 5:36 EDT
From: Daniel Klein <dvk@cmu-sei.ARPA>
Newsgroups: net.lang.c
Subject: Optimizing C Compilers
Message-ID: <303@sei.cmu.edu>
Date: 3 Sep 86 14:23:12 GMT
Posted: Wed Sep  3 10:23:12 1986
To:       info-c@BRL-SMOKE.ARPA
     
In response to Bjorn Freeman-Benson's note on optimizing C compilers, there
is a VERY good compiler sold by Tartan Labs, Pittsburgh PA 15213.
     
I have seen programs run 10-35% faster with Tartan's compiler, and some of the
code it generates is very impressive.  It is a true optimizing compiler, not
a hokey post processor.  And, no, they didn't pay me to say this.

From:	ARPA%"brett%wjvax.uucp@BRL.ARPA"  4-SEP-1986 04:08
To:	JMS
Subj:	Re: e1?(void_e2):(void_e3)     so, is it legal or what?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7331
          for JMS@ARIZMIS; Thu,  4-SEP-1986 04:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 06:05:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029075; 4 Sep 86 6:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a013037; 4 Sep 86 5:43 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?(void_e2):(void_e3)     so, is it legal or what?
Message-ID: <754@wjvax.wjvax.UUCP>
Date: 2 Sep 86 17:11:05 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <114@methods.UUCP> cary@methods.UUCP (Cary Timar (U of W co-op))
 writes:
>In article <248@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes:
>>
>>Unfortunately, Brett is incorrect here.  You can't use if/then/else to write:
>>
>>    for (i = up ? 0 : 99;  up ? (i < 100) : (i >= 0);  up ? i++ : i--)
>>        {
>>        /* complex loop body */
>>        }
I don't know what I originally said.  What I MEANT to say was that the
'?:` operator is useful.  There are cases (such as within macros) where
if/then/else is not appropriate.  That's all.
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

From:	jnet%"karl@haddock"  4-SEP-1986 04:21
To:	JMS
Subj:	Re: Comments on proposed C standard

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7478
          for JMS@ARIZMIS; Thu,  4-SEP-1986 04:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 06:17:14 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029028; 4 Sep 86 6:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012768; 4 Sep 86 5:34 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Comments on proposed C standard
Message-ID: <86900040@haddock>
Date: 3 Sep 86 19:55:00 GMT
Nf-ID: #R:watmath.UUCP:2807:haddock:86900040:000:497
Nf-From: haddock!karl    Sep  3 15:55:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
watmath!jagardner writes:
>The following (huge) document comments on the latest proposal
>for a C standard.  It is paginated, but does not contain tabs.
     
In fact, it was so huge that the last 15% got truncated here.  Would you care
to repost or mail from 4.10.3 onward?
     
Perhaps it should be in mod.std.c (mail to cbosgd!std-c)?  I'm planning to
summarize/repost/followup my earlier ANSI ramblings there, Real Soon Now.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"gwyn@BRL.ARPA"  4-SEP-1986 07:33
To:	JMS
Subj:	Re:  reading directory under SYSTEM V

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9057
          for JMS@ARIZMIS; Thu,  4-SEP-1986 07:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 08:56:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003506; 4 Sep 86 9:40 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a017609; 4 Sep 86 9:23 EDT
Date:     Thu, 4 Sep 86 9:16:38 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       Bernard Banner <banner%acf2.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  reading directory under SYSTEM V
Message-ID:  <8609040916.aa00319@VGR.BRL.ARPA>
     
SVR3 comes with the 1003.1 directory access library routines.
For earlier releases, I have a public-domain package I can send you.

From:	gov%"mcvax!vu44!kleef@seismo.css.gov"  4-SEP-1986 08:57
To:	JMS
Subj:	Microsoft C 4.00

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 0692
          for JMS@ARIZMIS; Thu,  4-SEP-1986 08:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 10:46:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006637; 4 Sep 86 11:32 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id aa19730; 4 Sep 86 10:50 EDT
Received: from seismo.CSS.GOV by VGR.BRL.ARPA id aa01504; 4 Sep 86 10:46 EDT
Return-Path: <mcvax!vu44!kleef>
Received: from mcvax.UUCP by seismo.CSS.GOV with UUCP; Thu, 4 Sep 86 10:30:50
  EDT
Received: by mcvax.uucp; Thu, 4 Sep 86 15:59:08 +0200 (MET)
Received: from ark.vu44.uucp by botter.vu44.UUCP id aa09179; 4 Sep 86 15:56 MDT
Date:     Thu, 4 Sep 86 15:47:59 MDT
From: Patrick van Kleef <mcvax!vu44!kleef@seismo.css.gov>
To: info-c@BRL.ARPA
Subject:  Microsoft C 4.00
Message-Id:  <8609041548.aa13283@ark.vu44.UUCP>
     
     
> Relay-Version: version B 2.10.1 6/24/83 (MC840302); site ark.UUCP
> Path:
 ark!botter!mcvax!seismo!columbia!caip!brl-adm!brl-smoke!smoke!sr16@andrew.cmu.E
DU
> From: sr16@andrew.cmu.EDU (Seth Benjamin Rothenberg)
> Newsgroups: net.lang.c
> Subject: Microsoft C 4.00
> Message-ID: <3448@brl-smoke.ARPA>
> Date: Mon, 1-Sep-86 05:05:09 -0200
> Date-Received: Tue, 2-Sep-86 22:47:00 -0200
> Sender: news@brl-smoke.ARPA
> Lines: 8
>
> I have been asked to forward this....
>
> /* To: info-c@brl.arpa */
>
> I have Version 4.00 of the Microsoft 'C' Compiler, including the public domain
> demostration diskette, if anyone wants a copy or a demonstration.
>
> Jay Libove (JL42)
     
Yes, i would like a copy.
     
My adress is :
        Patrick van Kleef,
        Free University of Amsterdam,
        Computer Science Department,
        The Netherlands,
      -->    kleef@ark.uucp.
     
     
Greetings,
        Patrick van Kleef.

From:	ARPA%"rbbb@rice.ARPA"  4-SEP-1986 11:57
To:	JMS
Subj:	Structure alignment question

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2914
          for JMS@ARIZMIS; Thu,  4-SEP-1986 11:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 13:30:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a009645; 4 Sep 86 14:24 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a025499; 4 Sep 86 14:07 EDT
Received: from dione.rice.edu by VGR.BRL.ARPA id aa04272; 4 Sep 86 14:06 EDT
Received: from titan.rice.edu by dione.rice.edu (AA12425); Wed, 3 Sep 86
  16:38:04 CDT
Received: by titan.rice.edu (AA06846); Wed, 3 Sep 86 16:35:33 CDT
Date:     Wed,  3 Sep 86 16:23:21 CDT
From: David Chase <rbbb@rice.ARPA>
Subject:  Structure alignment question
To: info-c@BRL.ARPA
Cc: acw@rice.ARPA, fbag@rice.ARPA
Message-Id: <585.rbbb.titan@Rice>
     
Suppose I have a structure "foo" and function returning a "struct foo".
     
    struct foo {
    int a,b;
    };
    struct foo bar() {
    struct foo baz;
    ...
    return baz;
    };
     
Note that the structure contains two ints.  I will assume that an "int" is
the same size as some machine quantity called a "word", and that
word alignment is desirable.  I assume therefore that all instances of the
structure generated by the compiler will be word-aligned.
     
C compilers that I have seen supporting structure-valued functions pass a
hidden parameter to the function containing the address to store the
result.
     
Can a compiler assume that the storage for the result is word-aligned?
(That is, can a compiler make the same assumptions when returning a
structure that it does when assigning a structure?)
If so, why?  If not, why not?
     
David

From:	edu%"Bader@b.psy.cmu.edu"  4-SEP-1986 19:03
To:	JMS
Subj:	Re: fgets() returns NULL at EOF??

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7562
          for JMS@ARIZMIS; Thu,  4-SEP-1986 19:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/04/86 at 20:51:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013321; 4 Sep 86 21:41 EDT
Received: from brl-tgr.arpa by SMOKE.BRL.ARPA id a002083; 4 Sep 86 21:27 EDT
Received: from cmu-psy-a.arpa by TGR.BRL.ARPA id a013123; 4 Sep 86 21:16 EDT
Received: from b.psy.cmu.edu by a.psy.cmu.edu with DECNET ; 04 Sep 86 20:42:28
  EDT
Date:    Thu,  4 Sep 1986 19:18:34-EST
From:    Miles Bader <Bader@b.psy.cmu.edu>
Subject: Re: fgets() returns NULL at EOF??
To:      info-c@BRL-TGR.ARPA
Message-ID: <BMS.526241915.Bader@b.psy.cmu.edu>
     
Neither of your suggestions (# of characters, EOF or 0) makes any more sense
to me than the current behavior, which seems perfectly reasonable.  If
nothing better is being offered, why waste time arguing about it?
     

From:	ARPA%"cjl%iuvax.uucp@BRL.ARPA"  5-SEP-1986 03:13
To:	JMS
Subj:	Re: C-STYLE (goto?)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2324
          for JMS@ARIZMIS; Fri,  5-SEP-1986 03:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 05:00:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015146; 5 Sep 86 5:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005429; 5 Sep 86 5:33 EDT
From: cjl%iuvax.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: C-STYLE (goto?)
Message-ID: <9500033@iuvax>
Date: 2 Sep 86 20:48:00 GMT
Nf-ID: #R:brl-smok:-325300:iuvax:9500033:000:789
Nf-From: iuvax.UUCP!cjl    Sep  2 15:48:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
     
> /* ---------- "C-STYLE (goto?)" ---------- */
> ....
>
> Now, I know a lot of people detest this because of the use of goto's, but this
> seems the nicest way to perform this function.  I really have nothing against
> goto's if they are directed to the same spot (i.e., don't jump back and forth)
> and enhance the readability of the code.
>
> Any comments?  I am willing to adapt to another reasonable style for such
> cases (if anyone really cared).
     
The principle of exception handling in software engineering is
well accepted and practiced today, especially through the direct support of
Ada language. You shall find more and more people start to feel
comfortable with this disciplined use of goto.
     
     
C.J.Lo
Dept. of CIS, IUPUI
UUCP : ...!iuvax!cjl
ARPA : cjl@Indiana@CSNet-Relay

From:	ARPA%"cbbrowne%watnot.uucp@BRL.ARPA"  5-SEP-1986 03:24
To:	JMS
Subj:	Re: C compilers for 8 bit machines

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2543
          for JMS@ARIZMIS; Fri,  5-SEP-1986 03:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 05:13:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015202; 5 Sep 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005624; 5 Sep 86 5:38 EDT
From: Christopher Browne <cbbrowne%watnot.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.apple,net.micro.cbm,net.micro.cpm
Subject: Re: C compilers for 8 bit machines
Message-ID: <11986@watnot.UUCP>
Date: 4 Sep 86 15:46:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2503@cbosgd.UUCP> mark@cbosgd.UUCP (Mark Horton) writes:
>I would appreciate any references to C compilers for popular 8 bit
>machines, such as the Apple II, Commodore 64, Atari 800, and CP/M machines.
>I'd prefer products, but public domain offerings are OK too, especially
>if a source can be given.
>
>    Mark Horton
>    cbosgd!mark
     
For the Atari 8 bit series, there are two C compilers worthy of note:
     
    1)  C/65: formerly sold by OSS (I can obtain the address, if it is
    desired).  This is an assembling compiler, that is, it produces 6502
    assembly language which must be assembled using their assembler.  It
    is no longer available from them, but is available from some dealers
    who have had it in stock for several years.  I cannot comment further,
    since I have not used it.
     
    2) Deep Blue C (the package I would recommend) is an extensively
    modified version of Ron Cain's Small C compiler.  It is available from
    Antic Magazine (see your local newsstand for a catalog) and there is a
    floating point library available.  Information on the original C
    compiler on which this one is based can be obtained from Dr. Dobbs
    Journal.  This is a fairly decent compiler, with calls for i/o routines,
    the 'standard' C stuff (slightly modified so as to be appropriate for the
    Atari operating system), and calls for graphics routines which are better
    than the commands provided in Atari Basic.  I'm not sure how much support
    this product has, but it has been available for a LONG time, so the bugs
    should be worked out of it.
     
Hope this is an aid to you.
     
     
--
            Christopher Browne
            University of Waterloo
            Faculty of Mathematics
     
            "To do is to be."  -- Aristotle
             "To be is to do."  -- Socrates
             "Do be do be do."  -- Sinatra
             "Do be a do bee."  -- Miss Sally of Romper Room fame.
            "Yabba dabba do."  -- Fred Flintstone

From:	ARPA%"operator%pogo.uucp@BRL.ARPA"  5-SEP-1986 03:41
To:	JMS
Subj:	Re: for != while

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2903
          for JMS@ARIZMIS; Fri,  5-SEP-1986 03:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 05:34:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015293; 5 Sep 86 6:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005786; 5 Sep 86 5:43 EDT
From: Vax Operators <operator%pogo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: for != while
Message-ID: <2711@pogo.UUCP>
Date: 4 Sep 86 16:20:40 GMT
Keywords: statement, scope
To:       info-c@BRL-SMOKE.ARPA
     
In article <570@copper.UUCP> mikeb@copper.UUCP (Mike Beckerman) writes:
>In article <15525@ucbvax.BERKELEY.EDU> ballou@brahms.UUCP (Kenneth R. Ballou)
 writes:
>>In article <86900030@haddock> karl@haddock writes:
>>>
>>>main() {
>>>    char *foo = "outer";
>>>    for (;; printf(foo),exit(0)) {
>>>        char *foo = "inner";
>>>    }
>>>}
>>>
>>>This prints "outer" (vax SVR2 compiler), though the for-while equivalence
>>>might lead one to expect "inner".
>>
>>I don't think the issue here is equivalence of for and while statements.
>>The point is that the scope of the inner 'foo' is the compound statement
                                                        ^^^^^^^^
     
>>which is the body of the for statement.  So, quite rightly, the 'foo'
>>given as the argument to printf in the third expression of the for statement
>>refers to the most closely nested declaration of 'foo' -- the body of the
>>for statement is one block level higher and is not visible at this point.
                       ^^^^^^^^^^^^^^^^^^
>
>That was my first thought as well, but both K&R and the proposed ANSI C
 standard
>define the "for" loop as follows:
>
>    for (expression-1 ; expression-2 ; expression-3) statement
>
>        is equivalent to
>
>    expression-1;
>    while (expression-2) {
>        statement
>        expression-3;
>    }
>
>which to me says that the example should have printed "inner".
     
     
I think the mistake being made here is a confusion with scope.  Yes,
that's the definition of while and for, but look carefully at the
definition for 'while':  it has { statement } (brackets surrounding
the statement) after the conditional, while the for has no brackets.
Therefore, the correct translation of your for loop into a while loop
is as follows:
     
main() {
    char *foo = "outer";
    while (TRUE)
    {
        {
            char *foo = "inner";
        }
        printf(foo);
        exit(0)
    }
}
     
The for loop execution order is  /* for (exp1; exp2; exp3) statement; */
     
        exp1;        <=>        ;
        exp2;        <=>        ;
        statement;    <=>    { char *foo = "inner" }
        exp3;        <=>    printf(foo); exit(0);
     
     
The 'char *foo = "inner"' disappears when the deeper scope gets popped,
therefore the foo that gets printed is still "outer".
     
Shannon Nelson
"Where there is a will, there's lot's of relatives...'

From:	ARPA%"guy%sun.uucp@BRL.ARPA"  5-SEP-1986 03:46
To:	JMS
Subj:	Re: soundex algorithm wanted

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3011
          for JMS@ARIZMIS; Fri,  5-SEP-1986 03:46 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 05:36:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015297; 5 Sep 86 6:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005796; 5 Sep 86 5:43 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: soundex algorithm wanted
Message-ID: <6909@sun.uucp>
Date: 4 Sep 86 20:50:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> All the compilers I have used ignore the `register' on `register
> char' declarations.
     
This was a change made to the System III compiler for 4(3?)BSD.  The claim
was that the compiler produced "poor, and sometimes incorrect, code" for
register variables less than 32 bits long.  The System V compiler, like the
System III compiler, puts "char" and "short" data into registers.  I have no
idea whether the S5 compiler produces the "poor, and sometimes incorrect,
code" mentioned or not, as I don't know what the code in question was.
     
> Are there any extant compilers for which the latter will generate *worse*
> code?
     
Script started on Thu Sep  4 13:41:45 1986
gorodish$ cat foo.c
foo()
{
    register char c;
    register int i;
     
    if (i == 'c')
        bar();
    if (c == 'c')
        bar();
}
gorodish$ cc -S -O foo.c
gorodish$ cat foo.s
    ...(boring preamble deleted)...
    moveq    #99,d1
    cmpl    d1,d6
    jne    L14
    jbsr    _bar
L14:
    cmpb    #99,d7
    jne    LE12
    jbsr    _bar
LE12:
    moveml    a6@(-8),#192
    unlk    a6
    rts
gorodish$
     
Script done on Thu Sep  4 13:42:01 1986
     
As the M68000 Programmer's Reference Manual says for CMPI, "The size of the
immediate data matches the operation size", so it uses a scratch register
and a "moveq"/"cmp.l" pair rather than a "cmpi.l".  Even given that, it'd
rather compare 8 bits of immediate data against 8 bits in a register than
compare 32 bits of data against 32 bits in a register, especially on the
M68XXX for XXX < 020.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA"  5-SEP-1986 03:51
To:	JMS
Subj:	Re: Missing stdio features.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3080
          for JMS@ARIZMIS; Fri,  5-SEP-1986 03:51 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 05:43:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015299; 5 Sep 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005953; 5 Sep 86 5:46 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <3265@umcp-cs.UUCP>
Date: 4 Sep 86 13:13:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900034@haddock> karl@haddock writes:
>>>FILE *fopenfxn(int (*fxn)(), char *mode)
>Actually, the function argument should probably be analogous to read/write
>rather than getc/putc.  But there should be one more argument to fopenfxn(),
>viz. a (void *) argument to be passed to fxn() to distinguish streams.
     
Indeed, there would be a certain symmetry to the whole thing if one
could write
     
    reader(f, buf, len)
        FILE *f;
    {
     
        return (read(fileno(f), buf, len));
    }
     
    ...
        FILE *f = fopenrf(reader, "r");
        fileno(f) = fd;
     
instead of
     
        FILE *f = fdopen(fd, "r");
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA"  5-SEP-1986 03:54
To:	JMS
Subj:	Re: Missing stdio features.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3173
          for JMS@ARIZMIS; Fri,  5-SEP-1986 03:54 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 05:49:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015316; 5 Sep 86 6:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a006022; 5 Sep 86 5:48 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <3268@umcp-cs.UUCP>
Date: 4 Sep 86 14:25:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3265@umcp-cs.UUCP>, I left out a declaration:
>    reader(f, buf, len)
>        FILE *f;
        char *buf;
        int len;
>    {
    ...
     
(`len' would have defaulted properly, of course.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA"  5-SEP-1986 03:55
To:	JMS
Subj:	Re: soundex algorithm wanted

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3229
          for JMS@ARIZMIS; Fri,  5-SEP-1986 03:55 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 05:50:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015312; 5 Sep 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005963; 5 Sep 86 5:47 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: soundex algorithm wanted
Message-ID: <3266@umcp-cs.UUCP>
Date: 4 Sep 86 13:31:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1239@whuxl.UUCP> mike@whuxl.UUCP (BALDWIN) writes:
>    register char    c, lc, prev = '0';
     
All the compilers I have used ignore the `register' on `register
char' declarations.  In any case, an `int' will hold everything
that will fit in a `char', and is (usually) the `natural word size'
of the machine.  Is there ever any reason to declare a variable
`register char' rather than `register int'?  Are there any extant
compilers for which the latter will generate *worse* code?
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"colonel%sunybcs.uucp@BRL.ARPA"  5-SEP-1986 04:53
To:	JMS
Subj:	Re: "\"

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3818
          for JMS@ARIZMIS; Fri,  5-SEP-1986 04:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/05/86 at 06:49:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a016255; 5 Sep 86 7:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007116; 5 Sep 86 7:30 EDT
From: "Col. G. L. Sicherman" <colonel%sunybcs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: "\"
Message-ID: <800@sunybcs.UUCP>
Date: 4 Sep 86 19:07:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> > How do you spell "\"?
> > Is it "Backslash", "Back slash", or "Back-slash"?
>
> I call it "the little thingie under the pipe symbol." :-)
     
I call it "Bash" (pronounced "BAAAAAASH!").  Rhymes with / ("Slash"),
- ("Dash"), and # ("Hash").
     
Is it time for another round of "terminal madness"?  See you in net.misc!
--
Col. G. L. Sicherman
UU: ...{rocksvax|decvax}!sunybcs!colonel
CS: colonel@buffalo-cs
BI: colonel@sunybcs, csdsicher@sunyabva

From:	ARPA%"urjlew%ecsvax.uucp@BRL.ARPA"  6-SEP-1986 03:10
To:	JMS
Subj:	Naive C question

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7030
          for JMS@ARIZMIS; Sat,  6-SEP-1986 03:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 05:06:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001307; 6 Sep 86 6:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027440; 6 Sep 86 5:34 EDT
From: Rostyk Lewyckyj <urjlew%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.micro.amiga,net.lang.c
Subject: Naive C question
Message-ID: <1993@ecsvax.UUCP>
Date: 4 Sep 86 07:11:58 GMT
Posted: Thu Sep  4 03:11:58 1986
To:       info-c@BRL-SMOKE.ARPA
     
[This line shouldn't really be nee
     
     
I am just beginning to learn C, so this is probably just a
stupid error on my part but perhaps some kind soul will tell
me, why does this simple program does not stop for me to enter
a line of input from the keyboard?
I am using Manx Aztec C68K Version 3.20a on the Amiga.
     
  #include  <stdio.h>;
     
  main()
     
  {
  char *inln, *gets(), *malloc();
     
  inln=malloc(81);
     
  printf("Enter an input line \n");
  gets(inln);
  printf("%s\n",inln);
  printf("***  End of Job *** \n");
  free(inln);
  exit(0);
  }
     
  Reply-To: Rostyk Lewyckyj    urjlew@ecsvax.uucp

From:	ARPA%"nathan@mit-eddie.ARPA"  6-SEP-1986 03:11
To:	JMS
Subj:	Is this a known bug?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7099
          for JMS@ARIZMIS; Sat,  6-SEP-1986 03:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 05:06:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001309; 6 Sep 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027485; 6 Sep 86 5:36 EDT
From: Nathan Glasser <nathan@mit-eddie.ARPA>
Newsgroups: net.lang.c
Subject: Is this a known bug?
Message-ID: <3127@mit-eddie.MIT.EDU>
Date: 5 Sep 86 19:34:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Is the following a known 4.2bsc C compiler bug? I think I had heard
of something related to this.
     
The following program segment:
     
foo()
{
    void goo();
    void (*moo)();
     
    moo = goo;
}
     
Produces the error:
     
"void.c", line 6: operands of = have incompatible types
     
Yet this should be a valid use of a function pointer, and replacing
the void's by int's removes the error.
     
Also, does anybody whether the 4.3 compiler still has this bug?
     
                Thanks,
     
--
                Nathan Glasser
                nathan@mit-eddie.uucp (usenet)
                nathan@xx.lcs.mit.edu (arpa)

From:	ARPA%"tomc%oakhill.uucp@BRL.ARPA"  6-SEP-1986 03:19
To:	JMS
Subj:	Expression sequencing query

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7180
          for JMS@ARIZMIS; Sat,  6-SEP-1986 03:19 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 05:15:07 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001311; 6 Sep 86 6:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027655; 6 Sep 86 5:41 EDT
From: Tom Cunningham <tomc%oakhill.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Expression sequencing query
Message-ID: <760@oakhill.UUCP>
Date: 5 Sep 86 22:16:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Sorry if this topic has been overly exercised already.  In the following
code fragment:
     
    /* a = b + b + b */
    a = ((b=1),b) + ((b=2),b) + ((b=3),b)
     
I expected the result to be 6.  With the Microsoft C compiler and the
compiler on the Sun 3, the result is 9.  Apparently the parenthetical
assignments are all getting done before the comma and addition.  Any
thoughts on thi
     
Tom Cunningham     "Good, fast, cheap -- select two."
USPS:  Motorola Inc.  6501 William Cannon Dr. W.  Austin, TX 78735-8598
UUCP:  {ihnp4,seismo,ctvax,gatech}!ut-sally!oakhill!tomc
Phone: 512-440-2953

From:	jnet%"karl@haddock"  6-SEP-1986 03:32
To:	JMS
Subj:	Re: Orphaned Response

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7549
          for JMS@ARIZMIS; Sat,  6-SEP-1986 03:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 05:28:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001344; 6 Sep 86 6:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027723; 6 Sep 86 5:43 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900041@haddock>
Date: 5 Sep 86 15:09:00 GMT
Nf-ID: #R:tflop.UUCP:292:haddock:86900041:000:1167
Nf-From: haddock!karl    Sep  5 11:09:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
killer!tad (Tad Marko) writes:
>In my original article, ... I was asking if I should use
>"foo(parm) char **parm; {...}" or "foo(parm) char *parm[]; {...}"
>and I *DID* test both of them, and they both worked.
     
Okay, that's a more sensible question.  The official truth is that in this
context, they are equivalent.  However, my *personal opinion* is that the
former is "more correct"; the latter is a kludge where the compiler figures
out what you "must have really meant" and converts it for you.  (Kind of like
how some compilers will interpret "&a" as "&a[0]" if "a" is an array, though
in that case you'll probably get a warning at least.)
     
My recommendation is to write "char **parm"; it causes less confusion.  Even
if you do write "char *parm[]", you are declaring a pointer, not an array.
(Similarly, a formal argument declared "float parm" really declares a double,
which is also quite confusing, e.g. if you take its address.)
     
Oh yes, some compilers used to consider a parameter declared "type x[]" to be
a *non-modifiable* pointer to type.  That no longer seems to be popular.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"ralph%ee.brunel.ac.uk@BRL.ARPA"  6-SEP-1986 03:38
To:	JMS
Subj:	Re: Query: Public Domain C Compilers

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7633
          for JMS@ARIZMIS; Sat,  6-SEP-1986 03:38 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 05:34:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001366; 6 Sep 86 6:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027800; 6 Sep 86 5:45 EDT
From: Ralph Mitchell <ralph%ee.brunel.ac.uk@BRL.ARPA>
Newsgroups: net.micro.pc,net.lang.c
Subject: Re: Query: Public Domain C Compilers
Message-ID: <377@brueer.ee.brunel.ac.uk>
Date: 29 Aug 86 10:41:16 GMT
Posted: Fri Aug 29 12:41:16 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <3043@teddy.UUCP> jpn@teddy.UUCP (John P. Nelson) writes:
>>Maybe small-c can be posted to the net.
>
>It already was.  To mod.sources.  Please don't post it again.
     
     
Have I missed something here ??  I didn't think the SmallC compiler had
a code generation stage for 8086/8 processors.  I presume that's what is
required, since this is the PC newboard...  :-)
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ralph Mitchell                 | VOICE: +44 895 74000 Ext 2561
Computer Centre                | ARPA:  ralph%ee.brunel.ac.uk@ucl-cs.arpa
Brunel University              | UUCP:  ...!mcvax!ukc!ee.brunel.ac.uk!ralph
Uxbridge                       | JANET: ralph@uk.ac.brunel.ee
UB8 3PH                        |
UNITED KINGDOM                 |     "Noli illegitemi carborundum"
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

From:	ARPA%"cramer%kontron.uucp@BRL.ARPA"  6-SEP-1986 03:40
To:	JMS
Subj:	Re: reading directory under SYSTEM V

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7683
          for JMS@ARIZMIS; Sat,  6-SEP-1986 03:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 05:36:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001377; 6 Sep 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027862; 6 Sep 86 5:46 EDT
From: Clayton Cramer <cramer%kontron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: reading directory under SYSTEM V
Message-ID: <1058@kontron.UUCP>
Date: 6 Sep 86 01:36:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
> Cound anybody suggest a method of reading directory information from a C
> program under SYSTEM V UNIX? I need something equivalent to the opendir and
> readdir functionality supplied under BSD.
     
Ditto.
     
Clayton E. Cramer

From:	ARPA%"bs%alice.uucp@BRL.ARPA"  6-SEP-1986 11:20
To:	JMS
Subj:	references - C++

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1705
          for JMS@ARIZMIS; Sat,  6-SEP-1986 11:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 13:07:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002267; 6 Sep 86 13:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001390; 6 Sep 86 13:32 EDT
From: Bjarne Stroustrup <bs%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: references - C++
Message-ID: <6023@alice.uUCp>
Date: 6 Sep 86 01:36:18 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Karl W. Z. Heuer writes:
     
> BMS-AT!stuart writes:
> >[re the declaration of reference types "foo(char &c)"]
> >I don't like this.  It violates the nice consistent way that C expressions
> >work.  'char *c' means that '*c' is of type char.  '&c' is not of type
> >char in any other context.
>
> I am also somewhat uneasy about calling it "char &c".  The consistent way to
> declare it would be "char *&c", since you have to write "&c" to get ahold of
> the "char *" object you are really using.
     
The notation T& is the C++ notation for a reference to an object of type T.
    char& c;    declares c to be a reference to a char
    char*& r;    declares r to be a reference to a char*
& is a declarator operator exactly like *

From:	ARPA%"ranger%ecsvax.uucp@BRL.ARPA"  6-SEP-1986 11:32
To:	JMS
Subj:	Re: C compilers for 8 bit machines

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1797
          for JMS@ARIZMIS; Sat,  6-SEP-1986 11:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 13:19:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002269; 6 Sep 86 13:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001416; 6 Sep 86 13:33 EDT
From: "Rick N. Fincher" <ranger%ecsvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.micro.apple,net.micro.cbm,net.micro.cpm
Subject: Re: C compilers for 8 bit machines
Message-ID: <2004@ecsvax.UUCP>
Date: 5 Sep 86 13:54:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I would appreciate any references to C compilers for popular 8 bit
> machines, such as the Apple II, Commodore 64, Atari 800, and CP/M machines.
> I'd prefer products, but public domain offerings are OK too, especially
> if a source can be given.
     
Aztec C runs on the Apple, CP/M systems and the C64.  Its different
versions seem to be very compatible at the source code level and a
Unix-style user interface makes the various versions very similar in
operation.
     
>
> This info is for a book about C portability, so you probably don't want
> to offer to send a copy of Tiny C personally.  Also, any comments about
> the compiler you mention (if you like it, what it's limits are, etc)
> would be appreciated.
>
The Aztec compiler for the Apple has very slow screen handling because
it uses a console driver that emulates a terminal.  Terminal screen
control codes are decoded into control codes for the particular hardware
being used.  This is great for portability but is very slow.
The other gripe I have with Aztec C on the Apple concerns float and d
double data types.  The Aztec systems comes with two compilers, one
that compiles into compact pseudo code (nice for 8 bit machines) and
one that compiles into fast but long native code.  The problem is that the fast
     
the fast native code compiler does not support float or double.  This
makes operations using these types fairly slow.  Fortunately, the
linker that comes with the system will link modules compiled with either
compiler, so you are not forced to compile everything in pseudo code.

From:	ARPA%"bs%alice.uucp@BRL.ARPA"  6-SEP-1986 13:26
To:	JMS
Subj:	"structure constants" C++

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2799
          for JMS@ARIZMIS; Sat,  6-SEP-1986 13:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 15:16:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002291; 6 Sep 86 14:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001386; 6 Sep 86 13:32 EDT
From: Bjarne Stroustrup <bs%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: "structure constants" C++
Message-ID: <6022@alice.uUCp>
Date: 6 Sep 86 01:35:33 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Karl W. Z. Heuer writes:
     
> BMS-AT!stuart writes:
> >I would like to see "structure constants" which would allow assignment to
> >aggregate types.
> >       complex z;
> >       z = { a+1, exp(b) };
> >       foo( (complex) { a, b } );
>
> The problem, as your last example points out, is that the notation "{...}"
> doesn't distinguish between different structure types.  I suppose the cast
> notation is workable, but kinda ugly.
     
Or in C++:
     
#include <complex.h>
     
void foo(complex);
     
void f() {
    double a,b;
    complex z;
    z = complex(a+1,exp(b));
    foo( complex(a,b) );
}
     
> >Of course any of these could be coded by assigning each member in turn.
>
> No, the last example requires assigning each member to a temporary, and then
> passing that temporary as an argument.
     
However, a clever compiler might use the calling stack as the temporary, but
 that
is tricky (C++ doesn't attempt that feat).

From:	ARPA%"BJORNDAS%CLARGRAD.BITNET@wiscvm.ARPA"  6-SEP-1986 13:40
To:	JMS
Subj:	need help with a delcaration

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2919
          for JMS@ARIZMIS; Sat,  6-SEP-1986 13:40 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 15:21:06 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002333; 6 Sep 86 14:41 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a001800; 6 Sep 86 14:35 EDT
Received: from (BJORNDAS)CLARGRAD.BITNET by WISCVM.WISC.EDU on 09/06/86
  at 13:31:01 CDT
Date: 6 SEP 86 11:29-PST
From:  BJORNDAS%CLARGRAD.BITNET@wiscvm.ARPA
To:  INFO-C@BRL-SMOKE.ARPA
Subject: need help with a delcaration
     
Very simple question here, folks.  What is the correct way to
declare the variable in the called function below:
     
main()
    {
    char c = 'W';
    foo(c);
    }
     
foo(ch)
char ch;  /* Or should this be "int ch;" because it gets promoted? */
  {}
     
On my micro it MUST be declared an int; I think this is screwy, but
I'm not an expert.
     
---
Sterling Bjorndahl, Claremont Graduate School
BJORNDAS @ CLARGRAD on BITNET
     

From:	edu%"conrad@cgl.ucsf.edu"  6-SEP-1986 15:57
To:	JMS
Subj:	VAX C help needed

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5060
          for JMS@ARIZMIS; Sat,  6-SEP-1986 15:57 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 09/06/86 at 17:48:06 CDT
Received: from cgl.ucsf.edu ([128.32.140.1].#Internet) by SRI-KL.ARPA with TCP;
  Fri 5 Sep 86 18:35:32-PDT
Received: by cgl.ucsf.edu (4.46/GSC4.0)
    id AA23826; Fri, 5 Sep 86 17:37:57 PDT
Date: Fri, 5 Sep 86 17:37:57 PDT
From: conrad@cgl.ucsf.edu (Conrad Huang)
Message-Id: <8609060037.AA23826@cgl.ucsf.edu>
To: info-vax@sri-kl.ARPA
Subject: VAX C help needed
     
I've been trying to port ex/vi from 4.3BSD Unix to 4.3VMS (with VAX C
V2.0-003) for the past two weeks.  Ex/vi is a Unix editor written entirely
in C.  One of the problems that I ran into while porting it was getting
access violations at strange places.  Ex/vi uses sbrk() and brk() exclusively
for memory management (there is no reference anywhere to malloc(), free(),
etc).  It also uses two files for temporary storage.  The sequence of event
that lead up to the access violation is as follows:
     
    open(temp_file_1)
    sbrk(xxx);
    end1 = sbrk(0);
    ... lots of processing ...
    open(temp_file_2)
    ... more processing with I/O to temp_file_2...
    end2 = sbrk(yyy);
    ... copy data to "end1"
    -> ACCESS VIOLATION
        VIRTUAL ADDRESS = end1
     
If I do not use temp_file_2 (delete the open and I/O), then I do *not*
get the access violation.  I suspect the problem is that opening the
second file somehow allocates memory starting at "end1" and makes it
somehow outside the legal addressing space.  Would anyone who knows
about VAX C innards please let me know whether this is correct?  I'm
completely baffled as to how to fix this problem and would greatly
appreciate any pointers.  Thanks,
     
Conrad
     
PS    I've moved the second "open" call around in the code.  It doesn't
matter where it appears.  As long as the second "open" is present, the
program bombs out with an ACCESS VIOLATION sooner or later.

From:	ARPA%"gwyn@BRL.ARPA"  6-SEP-1986 19:55
To:	JMS
Subj:	Re:  need help with a delcaration

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6687
          for JMS@ARIZMIS; Sat,  6-SEP-1986 19:55 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 21:33:53 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002963; 6 Sep 86 22:27 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a004478; 6 Sep 86 22:21 EDT
Date:     Sat, 6 Sep 86 22:15:55 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       BJORNDAS%CLARGRAD.BITNET@BRL-SMOKE.ARPA
cc:       INFO-C@BRL-SMOKE.ARPA
Subject:  Re:  need help with a delcaration
Message-ID:  <8609062215.aa01593@VGR.BRL.ARPA>
     
foo(ch)
char ch;  /* Or should this be "int ch;" because it gets promoted? */
  {}
     
Since it IS an (int), you should declare it an (int).  Some compilers
will fix this for you automatically, but why not write it explicitly
the way it is?  After all, some other function might really pass an
(int) quantity to the routine.
     
One of the most common portability violations I encounter is:
    char c;
    while ( (c = getchar()) != EOF )
        process(c);
I leave it as an exercise for the reader to analyze this error.

From:	ARPA%"ark%alice.uucp@BRL.ARPA"  6-SEP-1986 20:53
To:	JMS
Subj:	references - C++

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7041
          for JMS@ARIZMIS; Sat,  6-SEP-1986 20:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/06/86 at 22:48:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003097; 6 Sep 86 23:43 EDT
Received: from USENET by SMOKE.BRL.ARPA id a005085; 6 Sep 86 23:36 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: references - C++
Message-ID: <6027@alice.uUCp>
Date: 6 Sep 86 21:23:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Karl W. Z. Heuer writes:
     
> BMS-AT!stuart writes:
> >[re the declaration of reference types "foo(char &c)"]
> >I don't like this.  It violates the nice consistent way that C expressions
> >work.  'char *c' means that '*c' is of type char.  '&c' is not of type
> >char in any other context.
>
> I am also somewhat uneasy about calling it "char &c".  The consistent way to
> declare it would be "char *&c", since you have to write "&c" to get ahold of
> the "char *" object you are really using.
     
Bjarne Stroustrup made a comment on this about the way C++ does
things, but I suspect his remark is a little too abbreviated for
people not familiar with C++.  Here is some more detail:
     
In C++ one can declare a reference using the & declarator operator
in much the same way as one can declare a pointer using the * declarator
operator.  There is one big difference:  a reference MUST always be
initialized at the time it is declared.  Thus, I can write:
     
    char c;
    char &cr = c;
    char *cp = &c;
     
The first example declares a character.  No problem there.  The third
declares a character pointer and initializes it to the address of c.
No problem there either.  The second line declares a character reference
named cr and makes it a synonym for c.  Thus, if I write
     
    *cp = '?';
     
that sets the value of c to '?'; and so does
     
    cr = '?';
     
You can see a few things from this example:
     
    1. A reference must always be initialized as it is delcared.
     
    2. Subsequent uses of the reference denote the object with
       which the reference was initialized.
     
    3. Therefore, the initializer for a reference must be an lvalue.
     
In other words:
     
    char c;
    char &cr = c;        /* legal */
    char &cr;        /* illegal -- no initialization */
    char &cr = &c;        /* illegal -- &c is not an lvalue */

From:	ARPA%"ark%alice.uucp@BRL.ARPA"  6-SEP-1986 23:09
To:	JMS
Subj:	Re: Is this a known bug?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7945
          for JMS@ARIZMIS; Sat,  6-SEP-1986 23:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/07/86 at 01:04:57 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003219; 7 Sep 86 0:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004982; 6 Sep 86 23:31 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Is this a known bug?
Message-ID: <6025@alice.uUCp>
Date: 6 Sep 86 17:03:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> The following program segment:
>
> foo()
> {
>     void goo();
>     void (*moo)();
>
>     moo = goo;
> }
>
> Produces the error:
>
> "void.c", line 6: operands of = have incompatible types
     
In that case, your compiler is broken.

From:	ARPA%"steiny%scc.uucp@BRL.ARPA"  6-SEP-1986 23:15
To:	JMS
Subj:	Re: reading directory under SYSTEM V

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8004
          for JMS@ARIZMIS; Sat,  6-SEP-1986 23:15 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/07/86 at 01:08:18 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003221; 7 Sep 86 0:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a004993; 6 Sep 86 23:32 EDT
From: Don Steiny <steiny%scc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: reading directory under SYSTEM V
Message-ID: <717@scc.UUCP>
Date: 6 Sep 86 18:25:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
**
     
    In my source for netnews there were some routines that do the trick.
They say for V7, but I have used them on several system V systems.
     
-----
: This is a shar archieve.  Extract with sh, not csh.
: The rest of this file will extract:
: ndir.c ndir.h
echo extracting - ndir.c
sed 's/^X//' > ndir.c << '~FUNKY STUFF~'
X#include "defs.h"
X#if !defined(BSD4_2) && !defined(BSD4_1C)
X#include <sys/param.h>
X#include "ndir.h"
X
X#ifdef SCCSID
Xstatic char    *SccsId = "@(#)ndir.c    1.8    4/26/85";
X#endif /* SCCSID */
X
X/*
X * support for Berkeley directory reading routine on a V7 file system
X */
X
Xextern char *malloc();
X
X/*
X * open a directory.
X */
XDIR *
Xopendir(name)
Xchar *name;
X{
X    register DIR *dirp;
X    register int fd;
X
X    if ((fd = open(name, 0)) == -1)
X        return NULL;
X    if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
X        close (fd);
X        return NULL;
X    }
X    dirp->dd_fd = fd;
X    dirp->dd_loc = 0;
X    return dirp;
X}
X
X/*
X * read an old style directory entry and present it as a new one
X */
X#ifdef pyr
X/* Pyramid in the AT&T universe */
X#define ODIRSIZ 248
Xstruct olddirect {
X    long    od_ino;
X    short    od_fill1, od_fill2;
X    char od_name[ODIRSIZ];
X};
X#else /* V7 file system */
X#define    ODIRSIZ    14
X
Xstruct    olddirect {
X    short    od_ino;
X    char    od_name[ODIRSIZ];
X};
X#endif /* V7 */
X
X/*
X * get next entry in a directory.
X */
Xstruct direct *
Xreaddir(dirp)
Xregister DIR *dirp;
X{
X    register struct olddirect *dp;
X    static struct direct dir;
X
X    for (;;) {
X        if (dirp->dd_loc == 0) {
X            dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
X                DIRBLKSIZ);
X            if (dirp->dd_size <= 0)
X                return NULL;
X        }
X        if (dirp->dd_loc >= dirp->dd_size) {
X            dirp->dd_loc = 0;
X            continue;
X        }
X        dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
X        dirp->dd_loc += sizeof(struct olddirect);
X        if (dp->od_ino == 0)
X            continue;
X        dir.d_ino = dp->od_ino;
X        strncpy(dir.d_name, dp->od_name, ODIRSIZ);
X        dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
X        dir.d_namlen = strlen(dir.d_name);
X        dir.d_reclen = DIRSIZ(&dir);
X        return (&dir);
X    }
X}
X
X/*
X * close a directory.
X */
Xvoid
Xclosedir(dirp)
Xregister DIR *dirp;
X{
X    close(dirp->dd_fd);
X    dirp->dd_fd = -1;
X    dirp->dd_loc = 0;
X    free((char *)dirp);
X}
X#endif /* !BSD4_2 && !BSD4_1C */
~FUNKY STUFF~
echo extracting - ndir.h
sed 's/^X//' > ndir.h << '~FUNKY STUFF~'
X/* @(#)ndir.h    1.4    4/16/85 */
X#ifndef DEV_BSIZE
X#define    DEV_BSIZE    512
X#endif
X#define DIRBLKSIZ    DEV_BSIZE
X#define    MAXNAMLEN    255
X
Xstruct    direct {
X    long    d_ino;            /* inode number of entry */
X    short    d_reclen;        /* length of this record */
X    short    d_namlen;        /* length of string in d_name */
X    char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
X};
X
X/*
X * The DIRSIZ macro gives the minimum record length which will hold
X * the directory entry.  This requires the amount of space in struct direct
X * without the d_name field, plus enough space for the name with a terminating
X * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
X */
X
X#ifdef DIRSIZ
X#undef DIRSIZ
X#endif /* DIRSIZ */
X#define DIRSIZ(dp) \
X    ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
X
X/*
X * Definitions for library routines operating on directories.
X */
Xtypedef struct _dirdesc {
X    int    dd_fd;
X    long    dd_loc;
X    long    dd_size;
X    char    dd_buf[DIRBLKSIZ];
X} DIR;
X#ifndef NULL
X#define NULL 0
X#endif
Xextern    DIR *opendir();
Xextern    struct direct *readdir();
Xextern    void closedir();
~FUNKY STUFF~
exit 0;
     
     
--
scc!steiny
Don Steiny @ Don Steiny Software
109 Torrey Pine Terrace
Santa Cruz, Calif. 95060
(408) 425-0382

From:	ARPA%"nunn@nbs-vms.ARPA"  7-SEP-1986 00:20
To:	JMS
Subj:	Re: VAX C help needed

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8661
          for JMS@ARIZMIS; Sun,  7-SEP-1986 00:20 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 09/07/86 at 02:14:22 CDT
Received: from nbs-vms.ARPA by SRI-KL.ARPA with TCP; Sat 6 Sep 86 11:47:08-PDT
Date: 6 Sep 86 14:43:00 EDT
From: "NUNN, JOHN C." <nunn@nbs-vms.ARPA>
Subject: Re: VAX C help needed
To: "info-vax" <info-vax@sri-kl.arpa>
cc: nunn
Reply-To: "NUNN, JOHN C." <nunn@nbs-vms.ARPA>
     
     
Conrad,
     
Provided 4.3BSD ex/vi hasn't changed much from ex/vi of 4.2BSD, you
shouldn't have a problem with sbrk/brk.  The problem I discovered,
in porting ex/vi to vms, was a bug in VAX C V2.0.  Ex/vi tries to
open files and assumes that if it fails (file does not exist) that
the file-descriptor will be available on the next successful open.
This is normally the case in the UNIX environment.  However, the VAX C
OPEN fails to free the file-descriptor. Ex/vi, assuming that the
file-descriptor value (I think it was 0) is assigned to an open file,
tries to read on the failed file-descriptor.
     
    John <nunn@nbs-vms.arpa>
------

From:	jnet%"karl@haddock"  7-SEP-1986 19:30
To:	JMS
Subj:	Re: for != while

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5397
          for JMS@ARIZMIS; Sun,  7-SEP-1986 19:30 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/07/86 at 21:27:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007516; 7 Sep 86 20:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011730; 7 Sep 86 19:30 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: for != while
Message-ID: <86900042@haddock>
Date: 6 Sep 86 16:52:00 GMT
Nf-ID: #R:haddock:86900030:haddock:86900042:000:648
Nf-From: haddock!karl    Sep  6 12:52:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
pogo!operator (Shannon Nelson) writes:
>... The correct translation of your for loop into a while loop is:
>main() {
>        char *foo = "outer";
>        while (TRUE) {
>                { char *foo = "inner"; }
>                printf(foo);
>                exit(0);
>        }
>}
     
Oops.  You're right; I forgot about the extra braces.
     
But as long as we're on the subject, shouldn't the general whilified for be
written "{ e1; while (e2) { statement e3; } }", with the extra pair of braces
surrounding the whole mess?  (Consider "if (e0) for (e1; e2; e3) statement".)
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"dant%tekla.uucp@BRL.ARPA"  8-SEP-1986 03:17
To:	JMS
Subj:	Re: for != while

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8935
          for JMS@ARIZMIS; Mon,  8-SEP-1986 03:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/08/86 at 05:11:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008435; 8 Sep 86 5:59 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014740; 8 Sep 86 5:36 EDT
From: Dan Tilque <dant%tekla.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: for != while
Message-ID: <749@tekla.UUCP>
Date: 5 Sep 86 20:44:41 GMT
Posted: Fri Sep  5 16:44:41 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
From: mikeb@copper.UUCP (Mike Beckerman)
>In article <15525@ucbvax.BERKELEY.EDU> ballou@brahms.UUCP (Kenneth R. Ballou)
 writes:
>>In article <86900030@haddock> karl@haddock writes:
>>>
>>>It's well known that the equivalence between for and while breaks down if
>>>there's a "continue" statement.  Here's another case I just discovered:
>>>
>>>main() {
>>>    char *foo = "outer";
>>>    for (;; printf(foo),exit(0)) {
>>>        char *foo = "inner";
>>>    }
>>>}
>>>
>>>This prints "outer" (vax SVR2 compiler), though the for-while equivalence
>>>might lead one to expect "inner".
>>
>>I don't think the issue here is equivalence of for and while statements.
>>The point is that the scope of the inner 'foo' is the compound statement
>>which is the body of the for statement.  So, quite rightly, the 'foo'
>>given as the argument to printf in the third expression of the for statement
>>refers to the most closely nested declaration of 'foo' -- the body of the
>>for statement is one block level higher and is not visible at this point.
>
>That was my first thought as well, but both K&R and the proposed ANSI C
 standard
>define the "for" loop as follows:
>
>    for (expression-1 ; expression-2 ; expression-3) statement
>
>        is equivalent to
>
>    expression-1;
>    while (expression-2) {
>        statement
>        expression-3;
>    }
>
>which to me says that the example should have printed "inner".
>
     
Ken Ballou is correct, and the equivalence above is correct.  The
equivalence of the first example is this:
     
main() {
    char *foo = "outer";
    while () {
        {
            char *foo = "inner";
        }
    printf(foo),exit(0));
    }
}
     
The *foo = "inner" applies only within the inner braces (which
delineate the statement).  The printf(foo) goes outside those braces.
     
     
 Dan Tilque        UUCP:        tektronix!dadla!dant
            CSnet:        dant%dadla@tektronix
            ARPAnet:    dant%dadla%tektronix@csnet-relay
     
 Mass extinction; it's not just for dinosaurs anymore.

From:	ARPA%"trost%reed.uucp@BRL.ARPA"  8-SEP-1986 03:21
To:	JMS
Subj:	e1?e2:e3     so, is it useful or what?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9037
          for JMS@ARIZMIS; Mon,  8-SEP-1986 03:21 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/08/86 at 05:17:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008448; 8 Sep 86 6:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014890; 8 Sep 86 5:42 EDT
From: Bill Trost <trost%reed.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: e1?e2:e3     so, is it useful or what?
Message-ID: <4064@reed.UUCP>
Date: 8 Sep 86 02:30:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
All these various examples make it quite obvious that you can do anything
without using ?:.  The question is, why would you want to?  The construct
exists as a programmer's convenience.  I also suspect (but am uncertain)
that the use of ?: is more effecient in terms of code size and speed.

From:	ARPA%"corwin%hope.uucp@BRL.ARPA"  8-SEP-1986 03:32
To:	JMS
Subj:	Re: Is this a known bug?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9131
          for JMS@ARIZMIS; Mon,  8-SEP-1986 03:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/08/86 at 05:29:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008508; 8 Sep 86 6:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014685; 8 Sep 86 5:34 EDT
From: John Kempf <corwin%hope.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Is this a known bug?
Message-ID: <620@hope.UUCP>
Date: 7 Sep 86 09:49:10 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>
> Is the following a known 4.2bsc C compiler bug? I think I had heard
> of something related to this.
>
> The following program segment:
>
> foo()
> {
>     void goo();
>     void (*moo)();
>
>     moo = goo;
> }
>
> Produces the error:
>
> "void.c", line 6: operands of = have incompatible types
     
> Also, does anybody whether the 4.3 compiler still has this bug?
     
"Fixed in 4.3"
--
-cory
     
"No matter how subtle the wizard, a knife between the shoulder blades
will seriously cramp his style."
     
VOICE:  (714) 788 0709
UUCP:   {ucbvax!ucdavis,sdcsvax,ucivax}!ucrmath!hope!corwin
ARPA:   ucrmath!hope!corwin@sdcsvax.ucsd.edu
USNAIL: 3637 Canyon Crest apt G302
        Riverside Ca.  92507

From:	jnet%"karl@haddock"  9-SEP-1986 03:01
To:	JMS
Subj:	Re: Missing stdio features.

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1698
          for JMS@ARIZMIS; Tue,  9-SEP-1986 03:01 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/09/86 at 04:56:03 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021802; 9 Sep 86 5:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007797; 9 Sep 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <86900044@haddock>
Date: 8 Sep 86 18:54:00 GMT
Nf-ID: #R:robin.cs.nott.ac.uk:3438:haddock:86900044:000:1545
Nf-From: haddock!karl    Sep  8 14:54:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
umcp-cs!chris (Chris Torek) writes:
>In article <86900034@haddock> karl@haddock writes:
>>>>FILE *fopenfxn(int (*fxn)(), char *mode)
>>Actually, the function argument should probably be analogous to read/write
>>rather than getc/putc.  But there should be one more argument to fopenfxn(),
>>viz. a (void *) argument to be passed to fxn() to distinguish streams.
>
>Indeed, there would be a certain symmetry to the whole thing if one
>could write
>    reader(f, buf, len) FILE *f; { return (read(fileno(f), buf, len)); }
>    FILE *f = fopenrf(reader, "r");
>    fileno(f) = fd;
>instead of
>    FILE *f = fdopen(fd, "r");
     
As I mentioned, I think it has to be (void *) in general, thus
   reader(void *v, char *buf, int len) {
       return (read(*(int *)v, buf, len));
   }
   FILE *f = fopenrf(&fd, reader, "r");
so that the more general cases could be supported, e.g. read from string:
   typedef struct { char *t_start, *t_end; } tbuf;
   reader(void *v, char *buf, int len) {
       register tbuf *t = (tbuf *)v;
       len = min(len, t->t_end - t->t_start);
       memcpy(buf, t->t_start, len);
       t->start += len;
       return (len);
   }
   FILE *f = fopenrf(&t, reader, "r");
     
You could get away with having the first arg to reader() be "FILE *", but in
any case "void *_id" needs to replace or supplement the existing "int _file"
in the FILE structure.
     
If there are separate functions fopenrf() and fopenwf(), is there any need
for the third argument?
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock"  9-SEP-1986 03:04
To:	JMS
Subj:	Re: Dead functions and /*NOTREACHED*/

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1760
          for JMS@ARIZMIS; Tue,  9-SEP-1986 03:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/09/86 at 04:57:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021807; 9 Sep 86 5:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007801; 9 Sep 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Dead functions and /*NOTREACHED*/
Message-ID: <86900045@haddock>
Date: 8 Sep 86 19:47:00 GMT
Nf-ID: #R:epimass.UUCP:410:haddock:86900045:000:2295
Nf-From: haddock!karl    Sep  8 15:47:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
sun!guy (Guy Harris) writes:
>complaints about "possible pointer alignment problems" when "malloc" is used
>are pure noise.
     
Certainly.  I guess the addition of a lint comment (on the *declaration* of
malloc, not its use, of course) is a pretty clean way to handle it.  A
pointer type that (unlike "void *") is guaranteed to be fully aligned would
solve it too (and be more efficient on word-addressible machines), but since
only malloc et al would use it, it's not worth a language change.
     
>Nothing prevents a compiler or "lint" from treating *all* "void *" pointers
>as always being properly aligned;
     
If you mean a compiler can generate code assuming "void *" is always aligned,
you're wrong -- the user can legally stuff a "char *" value into a "void *"
object.  I assume you mean the compiler/lint can be silent about uncasted
assignments like "intp = voidp".
     
>the most common uses of "void *" are [malloc and] when a data structure is
>used [as a pseudo-union of pointers] - in this case, the compiler can't do
>the checking properly anyway, so warnings are largely useless.
     
The former is actually a special case of the latter, the only difference
being that the result is known to be maximally aligned.  I think the only
other functions that return "void *" (in X3J11 01-May-1986) are those like
bsearch() and memcpy(), which expect arguments of arbitrary pointer type
cast into "void *", and return the same.  The problem is that the compiler
isn't smart enough to know that "(int *)memcpy((void *)intp, (void *)intp);"
is correct whereas "voidp = (void *)charp; intp = (int *)voidp;" is likely
to cause trouble.  In my opinion, the best solution is to assume that the
user knows what he's doing if an explicit cast is present, and otherwise
give a warning message.  (Likewise for using an int in a float context.)
     
Btw, I sometimes handle the malloc problem with the (ANSIfied) code below,
which can easily be modified for other functions like memcpy().
     
#ifdef lint
extern int    *imalloc(unsigned int);
extern double *dmalloc(unsigned int);
#else
extern void   *malloc(unsigned int);
#define imalloc(n) ((int    *)malloc((n)*sizeof(int)))
#define dmalloc(n) ((double *)malloc((n)*sizeof(double)))
#endif
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"qwerty%drutx.uucp@BRL.ARPA"  9-SEP-1986 03:10
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1850
          for JMS@ARIZMIS; Tue,  9-SEP-1986 03:10 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/09/86 at 05:05:08 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021811; 9 Sep 86 5:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007873; 9 Sep 86 5:35 EDT
From: Brian Jones <qwerty%drutx.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <1219@drutx.UUCP>
Date: 8 Sep 86 02:52:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In the sequence:
     
    main()
    {
        char c = 'w';
        foo(c)
    }
     
    foo(ch)
    char ch;
     
char ch is the correct declaration.  The compiler/code generator should
handle pulling the character portion of the promoted variable off the
stack correctly.  Declaring it 'int' is asking for trouble.
     
Brian Jones  aka  {ihnp4,}!{drutx,druhi}!qwerty  @  AT&T-IS, Denver
--
     
Brian Jones  aka  {ihnp4,}!{drutx,druhi}!qwerty  @  AT&T-IS, Denver

From:	jnet%"karl@haddock"  9-SEP-1986 03:14
To:	JMS
Subj:	Re: fgets() returns NULL at EOF??

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1898
          for JMS@ARIZMIS; Tue,  9-SEP-1986 03:14 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/09/86 at 05:05:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021809; 9 Sep 86 5:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007805; 9 Sep 86 5:33 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: fgets() returns NULL at EOF??
Message-ID: <86900046@haddock>
Date: 8 Sep 86 20:36:00 GMT
Nf-ID: #R:bu-cs.bu-cs.BU.EDU:1094:haddock:86900046:000:2083
Nf-From: haddock!karl    Sep  8 16:36:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
sun!guy (Guy Harris) writes:
>[haddock!karl writes:]
>>Better yet, return the number of characters read (so 0 on failure).
     
>Better still, return the number of characters read, or EOF;
     
One could argue that zero is the number of chars read, and that there is no
failure return as such (cf. fread()).  But see below.
     
>1) this is what "fputs" does
     
The successful result of fputs/puts is not mentioned in my manual; all one
can conclude is that it differs from the failure result (EOF).  X3J11 says
that the successful result is zero.
     
>and 2) this encourages you to distinguish between EOF and error.
     
Are you suggesting that the result should be EOF if end-of-file was reached,
but 0 if a read error occurred?  This is workable for gets()/puts() (except
for fputs() of an empty string), but not (e.g.) scanf(), and is probably a
bad idea in general.
     
My revised opinion: functions other than system calls should return NULL for
an out-of-band pointer, EOF for an OOB character, or ERROR (which should be
defined someplace) for an OOB int.  ERROR and EOF are logically different,
even if they have the same value.  Physical end-of-file, read-error, and a
legitimate result of -1 can (and should) be distinguished with feof, ferror,
and/or errno.
     
The ngets() function (if it gets written) should return ERROR on failure.
It can return zero only if passed a zero-length buffer.  Similarly, nputs()
should return the number of characters written, or ERROR.  (This one could
be called "puts", except that on an implementation that uses zero for puts()
success it may break programs that depend on this.)
     
>distinguish between EOF and error, something that several UNIX utilities,
>to their everlasting shame, do not do.
     
Programs should always check for failure returns, and distinguish the types
of failure when it matters (as it usually does when end-of-file is one type).
But that's a more general problem, and although there are some fairly nice
ways to solve it, they would break a lot of existing code.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"wong%rtech.uucp@BRL.ARPA"  9-SEP-1986 03:31
To:	JMS
Subj:	Re: e1?e2:e3     so, is it useful or what?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2160
          for JMS@ARIZMIS; Tue,  9-SEP-1986 03:30 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/09/86 at 05:26:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021892; 9 Sep 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a008060; 9 Sep 86 5:42 EDT
From: "J. Wong" <wong%rtech.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.bugs
Subject: Re: e1?e2:e3     so, is it useful or what?
Message-ID: <437@rtech.UUCP>
Date: 8 Sep 86 18:51:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <4064@reed.UUCP> trost@reed.UUCP (Bill Trost) writes:
>
>            ...  I also suspect (but am uncertain)
>that the use of ?: is more effecient in terms of code size and speed.
     
No, in most cases ?: is less efficient.  It does result is less source
code, however (and I feel results in more readable code, as long as you
don't nest them.)
--
                J. Wong        ucbvax!mtxinu!rtech!wong
     
****************************************************************
You start a conversation, you can't even finish it.
You're talking alot, but you're not saying anything.
When I have nothing to say, my lips are sealed.
Say something once, why say it again.        - David Byrne

From:	jnet%"karl@haddock"  9-SEP-1986 03:31
To:	JMS
Subj:	Re: soundex algorithm wanted

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2111
          for JMS@ARIZMIS; Tue,  9-SEP-1986 03:31 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/09/86 at 05:26:16 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021833; 9 Sep 86 6:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007992; 9 Sep 86 5:40 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: soundex algorithm wanted
Message-ID: <86900048@haddock>
Date: 8 Sep 86 21:16:00 GMT
Nf-ID: #R:umcp-cs.UUCP:3266:haddock:86900048:000:1315
Nf-From: haddock!karl    Sep  8 17:16:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
umcp-cs!chris (Chris Torek) writes:
>In article <1239@whuxl.UUCP> mike@whuxl.UUCP (BALDWIN) writes:
>>       register char   c, lc, prev = '0';
>All the compilers I have used ignore the `register' on `register char'
>declarations.
     
Well, the compilers I've used will put it in a register, but do extra work
(usually unnecessary) to clear the higher bits.  This is unfortunate.
     
>Is there ever any reason to declare a variable `register char' rather than
>`register int'?
     
If the range of the variable really is char (so EOF is excluded), then it
logically should be declared char.  I find it distasteful to write something
I don't mean just because it's more efficient than what I'd like*.  If the
machine has some one-byte registers available, `register char' is clearly a
good idea (assuming the compiler has any brains).  If the machine has only
full-word registers but allows byte access to them, `register char c0, c1,
c2, c3' could be packed into a single register; even on a VAX there are some
situations where the packing/unpacking cost is negligible (for non-numerical
usage, e.g.), and it saves on registers.  I don't know of any machines that
do this.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint
*Like the keyword `register' itself, which is a crutch for dumb compilers.

From:	ARPA%"sam@zarathustra.ARPA"  9-SEP-1986 03:37
To:	JMS
Subj:	Re: references - C++

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2262
          for JMS@ARIZMIS; Tue,  9-SEP-1986 03:37 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/09/86 at 05:33:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a021916; 9 Sep 86 6:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a007793; 9 Sep 86 5:33 EDT
From: Sam Kendall <sam@zarathustra.ARPA>
Newsgroups: net.lang.c
Subject: Re: references - C++
Message-ID: <6170@think.COM>
Date: 8 Sep 86 21:51:35 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <6027@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes:
>    1. A reference must always be initialized as it is delcared.
     
Except of course for formal arguments, which are initialized by their
actuals.
     
>    3. Therefore, the initializer for a reference must be an lvalue.
     
C++ Ref Man 3.6.3:
     
    If the initializer for a reference to type T is not an lvalue an
    object of type T will be created and initialized with the
    initializer.  The reference then becomes a name for that object.
     
This is also the semantics of Fortran argument passing, and I'm sure
people calling Fortran from C++ are very happy -- `sin(2.3)', if `sin'
is a Fortran function, works!
     
>    char c;
>    char &cr = &c;        /* illegal -- &c is not an lvalue */
     
The last line is illegal because `&c' has the wrong type, not because
it is an rvalue.
     
---
Sam Kendall            sam@Think.COM
Thinking Machines Corp.        ihnp4!think!sam

From:	ARPA%"glidden%morgoth.uucp@BRL.ARPA" 10-SEP-1986 06:44
To:	JMS
Subj:	C compiler recommendations?

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3555
          for JMS@ARIZMIS; Wed, 10-SEP-1986 06:43 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/10/86 at 05:34:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001124; 10 Sep 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001584; 10 Sep 86 5:42 EDT
From: "Ken A. Glidden" <glidden%morgoth.uucp@BRL.ARPA>
Newsgroups: net.lang.c,net.emacs,net.micro.pc
Subject: C compiler recommendations?
Message-ID: <124@morgoth.UUCP>
Date: 9 Sep 86 18:51:30 GMT
Keywords: C, compiler, IBM PC
To:       info-c@BRL-SMOKE.ARPA
     
Well I've decided to take the plunge and both learn C and get a C
compiler for my IBM PCs, ATs, and Compaqs.  The first thing I want to
do with  the C compiler, is compile the uEMACS ver. 3.7 sources that
I've recently received over the net.
     
So, here is my question:  With the above in mind, which C compiler
should I get????
     
     
In anticipation...
Ken Glidden

From:	jnet%"karl@haddock" 10-SEP-1986 06:47
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3381
          for JMS@ARIZMIS; Wed, 10-SEP-1986 06:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/10/86 at 05:20:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001064; 10 Sep 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001485; 10 Sep 86 5:39 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <86900051@haddock>
Date: 9 Sep 86 18:00:00 GMT
Nf-ID: #R:brl-smoke.ARPA:3594:haddock:86900051:000:692
Nf-From: haddock!karl    Sep  9 14:00:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
BJORNDAS%CLARGRA@WISCVM.WISC.EDU (Sterling Bjorndahl) writes:
>foo(ch)
>char ch;  /* Or should this be "int ch;" because it gets promoted? */
>{}
>
>On my micro it MUST be declared an int; I think this is screwy...
     
This relates to what I just said in another topic.  Discounting function
prototyping (ANSI proposed), actual arguments of type char, short, float,
and array are converted; therefore one should never declare formal arguments
of these types.  However, you are right -- the C language is supposed to
silently fix it for you by interpreting your "char" declaration as an "int".
Your compiler is broken.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"gt6294b%gitpyr.uucp@BRL.ARPA" 10-SEP-1986 06:49
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3495
          for JMS@ARIZMIS; Wed, 10-SEP-1986 06:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/10/86 at 05:26:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001066; 10 Sep 86 6:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001563; 10 Sep 86 5:41 EDT
From: "SCHEUTZOW,MICHAEL J" <gt6294b%gitpyr.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <2225@gitpyr.UUCP>
Date: 8 Sep 86 13:58:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3594@brl-smoke.ARPA> BJORNDAS%CLARGRAD.BITNET@WISCVM.WISC.EDU
 writes:
>Very simple question here, folks.  What is the correct way to
>declare the variable in the called function below:
>
>main()
>    {
>    char c = 'W';
>    foo(c);
>    }
>
>foo(ch)
>char ch;  /* Or should this be "int ch;" because it gets promoted? */
>  {}
>
>On my micro it MUST be declared an int; I think this is screwy, but
>I'm not an expert.
>
>---
>Sterling Bjorndahl, Claremont Graduate School
>BJORNDAS @ CLARGRAD on BITNET

From:	jnet%"karl@haddock" 10-SEP-1986 06:49
To:	JMS
Subj:	Re: fgets() returns NULL at EOF??

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3750
          for JMS@ARIZMIS; Wed, 10-SEP-1986 06:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/10/86 at 05:54:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001060; 10 Sep 86 6:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001474; 10 Sep 86 5:38 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: fgets() returns NULL at EOF??
Message-ID: <86900049@haddock>
Date: 9 Sep 86 17:20:00 GMT
Nf-ID: #R:bu-cs.bu-cs.BU.EDU:1094:haddock:86900049:000:968
Nf-From: haddock!karl    Sep  9 13:20:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
Bader@b.psy.cmu.edu writes:
>[concerning the return value of gets()/fgets()]
>Neither of your suggestions (# of characters, EOF or 0) makes any more sense
>to me than the current behavior, which seems perfectly reasonable.  If
>nothing better is being offered, why waste time arguing about it?
     
In the current behavior, the value on successful return is the buffer arg --
a useless value already available to the user.  The character count is not
available except by calling strlen(), which is somewhat redundant since the
library function already has the value (or enough information to construct
it in constant time).
     
There is a similar duplication of effort in strcpy() followed by strcat(),
for which reason I think strcpy() should've returned the END of the string
(pointer to the '\0') instead of the beginning.  I need that value more
often than I need a copy of the first argument.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"ark%alice.uucp@BRL.ARPA" 10-SEP-1986 06:52
To:	JMS
Subj:	Re: references - C++

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3659
          for JMS@ARIZMIS; Wed, 10-SEP-1986 06:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/10/86 at 05:40:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001126; 10 Sep 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001613; 10 Sep 86 5:43 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: references - C++
Message-ID: <6035@alice.uUCp>
Date: 9 Sep 86 14:08:40 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Apparently I caught whatever was affecting Bjarne when he posted his
original note about references.  Sigh.  I'll try again.
     
Sam Kendall is right -- if you initialize a reference with something
that isn't an lvalue then the reference refers to a temporary.  Thus:
     
    char c;
    char &cr;        /* illegal -- no initialization */
    char &cr = c;        /* legal */
    char &cr = 'a';        /* equivalent to:  char temp='a'; char &cr=temp; */
    char &cr = &c;        /* illegal -- &c is not a char */
     
Sam is also right in saying that initializers do not have to be
explicitly provided for references declared as formal parameters.
This is indeed because the initializers will appear whenever the
function is called.  Thus:
     
    void zap (int& x) { x = 0; }
     
    int z;
    zap (z);        /* sets z to 0 */
     
However:
     
    double d;
    zap (d);        /* illegal -- d is the wrong type */
    zap ((int) d);        /* sets a copy of the integer value
                   of d to 0.  Essentially no effect */

From:	jnet%"karl@haddock" 10-SEP-1986 06:53
To:	JMS
Subj:	Re: references - C++

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3314
          for JMS@ARIZMIS; Wed, 10-SEP-1986 06:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/10/86 at 05:16:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001062; 10 Sep 86 6:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001480; 10 Sep 86 5:39 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: references - C++
Message-ID: <86900050@haddock>
Date: 9 Sep 86 17:53:00 GMT
Nf-ID: #R:alice.uUCp:6023:haddock:86900050:000:1602
Nf-From: haddock!karl    Sep  9 13:53:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
alice!bs (Bjarne Stroustrup) writes:
>Karl W. Z. Heuer writes:
>>BMS-AT!stuart writes:
>>>[re the declaration of reference types "foo(char &c)"]
>>>I don't like this.  It violates the nice consistent way ...
>>
>>I am also somewhat uneasy about calling it "char &c".  The consistent way to
>>declare it would be "char *&c", since you have to write "&c" to get ahold of
>>the "char *" object you are really using.
>
>The notation T& is the C++ notation for a reference to an object of type T.
>        char& c;        declares c to be a reference to a char
>        char*& r;       declares r to be a reference to a char*
>& is a declarator operator exactly like *
     
Understood.  The point was that (in C) a declaration like "int *(*f[])();"
asserts that "*(*f[])()" is an int (so one can work backwards to show that
f must be an array of pointers to functions returning pointers to int).  The
use of "&" for the reference declarator operator breaks this heuristic; now
"char &c" declares a reference to a "char", so "&c" is of type "char *".  If
the operator were spelled "*&" instead, then "char *&c" would denote a
reference to a "char", "char **&r" would be a reference to a "char *", and
"char &x" would be illegal.  Since "**&r" really does give you an object of
type "char", this notation might be easier to interpret.  (I suspect that
stuart was (incorrectly) applying this heuristic, and it led him to believe
that "&c" was somehow an object of type "char".)
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com)
This isn't C (not even ANSI proposed), so let's move it to net.lang.c++, OK?

From:	ARPA%"thomps%gitpyr.uucp@BRL.ARPA" 10-SEP-1986 06:54
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3831
          for JMS@ARIZMIS; Wed, 10-SEP-1986 06:54 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001069; 10 Sep 86 6:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001578; 10 Sep 86 5:42 EDT
From: Ken Thompson <thomps%gitpyr.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <2233@gitpyr.UUCP>
Date: 9 Sep 86 13:41:38 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
     
In article <1219@drutx.UUCP>, qwerty@drutx.UUCP (Brian Jones) writes:
> In the sequence:
>
>     main()
>     {
>         char c = 'w';
>         foo(c)
>     }
>
>     foo(ch)
>     char ch;
>
> char ch is the correct declaration.  The compiler/code generator should
> handle pulling the character portion of the promoted variable off the
> stack correctly.  Declaring it 'int' is asking for trouble.
>
  If I understand what Kernighan and Ritchie say in their book, then ch
  is automatically converted to an int when foo is called because a function
  argument is an expression and a character is always converted to an int in
  an expression. See K&R page 41 - 42.
  I know that some compilers take care of this and allow you to
  still declare ch as a char. However, I note that K&R always declare
  ch as an int in their examples. I would suppose that the compiler being
  used requires the int declaration. Since the conversion occurs by definition
  of the language, there is no danger in declaring it an int and this is
  commonly done in most C code. Declare it as an int and go to it. It also
  sounds like the asker of the original question should get hold of K&R and
  learn about the relationship between char and int in C.
--
Ken Thompson
Georgia Tech Research Institute
Georgia Insitute of Technology, Atlanta Georgia, 30332
...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!thomps

From:	ARPA%"moore@mit-eddie.ARPA" 11-SEP-1986 06:43
To:	JMS
Subj:	Help! How to compile Aztec C programs

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7685
          for JMS@ARIZMIS; Thu, 11-SEP-1986 06:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/11/86 at 07:07:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017403; 11 Sep 86 7:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024828; 11 Sep 86 7:39 EDT
From: "Andrew M. Moore" <moore@mit-eddie.ARPA>
Newsgroups: net.lang.c,net.micro.apple
Subject: Help! How to compile Aztec C programs
Message-ID: <3179@mit-eddie.MIT.EDU>
Date: 10 Sep 86 21:59:35 GMT
Keywords: C AZTEC HELP
To:       info-c@BRL-SMOKE.ARPA
     
     
     
   I have a disk containing Aztec C under DOS 3.3, which came with my II+
when I bought it used, but unfortunately it came with no documentation or
intructions of any kind.  Can anyone tell me how to go about editing and
compiling a program under DOS 3.3 Aztec C?  (does Aztec have an editor,
what are the commands, etc.?)
     
Andrew Moore
arpa MOORE%MIT-EECS@MIT-MC.ARPA
uucp ...mit-eddie!moore
 tel 617/479-9208 BBS Sat-Sun 300/1200
  us Box 121, North Quincy, MA  02171

From:	ARPA%"ark%alice.uucp@BRL.ARPA" 11-SEP-1986 08:00
To:	JMS
Subj:	Re: Using SCANF with DOUBLE precision variables...

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9358
          for JMS@ARIZMIS; Thu, 11-SEP-1986 08:00 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/11/86 at 09:55:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a017306; 11 Sep 86 7:53 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024752; 11 Sep 86 7:37 EDT
From: Andrew Koenig <ark%alice.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using SCANF with DOUBLE precision variables...
Message-ID: <6043@alice.uUCp>
Date: 10 Sep 86 20:13:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> 'Ello,
>       I've been doing a little matrix algebra in C lately, and in the process
> I have been wanting to read in some real numbers, preferably thru SCANF, but I
> get nothing but 0.000 returned when i try to put the result of a SCANF in a
 var
> declared as DOUBLE.  The only thing that I could think of was either writing
 my
> own algorithm, or reading the number in as FLOAT and storing it in the DOUBLE
> variable.  Perchance someone else has had this problem and found a better
> solution without re-inventing several wheels?  I guess there really isn't any
> reason why I just couldn't use FLOAT variables, but then there shouldn't be
 any
> reason why I can't use SCANF on DOUBLE vars either.
>      Thanks in advance,
>                        Dave
     
    float f;
    double d;
     
    scanf ("%f", &f);        /* should work */
    scanf ("%f", &d);        /* garbage */
    scanf ("%lf", &d);        /* should work */
    scanf ("%lf", &f);        /* garbage */

From:	ARPA%"jsdy%hadron.uucp@BRL.ARPA" 12-SEP-1986 04:50
To:	JMS
Subj:	Re: Orphaned Response

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8887
          for JMS@ARIZMIS; Fri, 12-SEP-1986 04:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/12/86 at 05:12:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002274; 12 Sep 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017744; 12 Sep 86 5:41 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <559@hadron.UUCP>
Date: 11 Sep 86 11:16:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1761@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>>For another, the types might be
>>unknown, if they are arguments in a macro; in this case I would want the
>>macro to work on void as well as valued expressions.
>This case is not covered by my suggestion.  I find it hard to imagine doing
>it, however.
     
When would one try to pass a void "value" to anything, whether or
not it is a macro?  (I agree, that is  v e r y  hard to imagine!)
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

From:	ARPA%"hitchins%gec-mi-at.co.uk@BRL.ARPA" 12-SEP-1986 05:01
To:	JMS
Subj:	C grammar

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9017
          for JMS@ARIZMIS; Fri, 12-SEP-1986 05:00 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/12/86 at 05:25:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002277; 12 Sep 86 6:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017772; 12 Sep 86 5:42 EDT
From: Andy Hitchins <hitchins%gec-mi-at.co.uk@BRL.ARPA>
Newsgroups: net.lang.c
Subject: C grammar
Message-ID: <216@miduet.gec-mi-at.co.uk>
Date: 10 Sep 86 14:13:41 GMT
Keywords: C
Posted: Wed Sep 10 16:13:41 1986
To:       info-c@BRL-SMOKE.ARPA
     
Has anyone got a copy of the 'C' grammar (ansi C if possible) in a form
suitable for top down parsing. (Recursive Decent).
     
                    Thanks in advance
     
                        Andy Hitchins
     
     
*****************************************************************************
**  Marconi Instruments Ltd  **  UUCP : ...mcvax!ukc!hrc63!miduet!hitchins **
**  St. Albans    AL4 0JN    **  NRS  : hitchins@uk.co.gec-mi-at           **
**  Herts.   UK              **                                            **
*****************************************************************************
**         "The views expressed herein do not necessarily reflect"         **
**         "those of my employer, and may not even reflect my own"         **
*****************************************************************************
**         Andy Hitchins     **          Phone: 44 727 59292 x202          **
*****************************************************************************

From:	ARPA%"tps%sdchem.uucp@BRL.ARPA" 12-SEP-1986 05:29
To:	JMS
Subj:	enum function bug?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8808
          for JMS@ARIZMIS; Fri, 12-SEP-1986 05:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/12/86 at 05:10:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002231; 12 Sep 86 6:03 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017673; 12 Sep 86 5:39 EDT
From: Tom Stockfisch <tps%sdchem.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: enum function bug?
Message-ID: <299@sdchema.sdchem.UUCP>
Date: 11 Sep 86 02:48:52 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
I want to pass a
    pointer to function returning "bool"
to a function, but lint says I'm not doing it right.  I think I am, aren't I?
Sample code follows with messages from lint inserted.  Is this a bug?
     
     
typedef enum { FALSE = 0, TRUE = 1 }    bool;
     
bool    truth();
void    f(), g();
     
main()
{
/*###8 [lint] f arg. 1 used inconsistently testbool.c(14) :: testbool.c(8)%%%*/
    f( truth );
}
     
void
f( ft )
    bool    (*ft)();
/*###14 [lint] f arg. 1 used inconsistently testbool.c(14) :: testbool.c(8)%%%*/
{
/*###15 [lint] g arg. 1 used inconsistently testbool.c(21) :: testbool.c
(15)%%%*/
    g( ft );
}
     
void
g( gt )
/*###20 [lint] warning argument gt unused in function g%%%*/
    bool    (*gt)();
/*###21 [lint] g arg. 1 used inconsistently testbool.c(21) :: testbool.c
(15)%%%*/
{
}
     
bool
truth()
{
    return    TRUE;
}
--
     
-- Tom Stockfisch, UCSD Chemistry

From:	ARPA%"dml%loral.uucp@BRL.ARPA" 12-SEP-1986 06:11
To:	JMS
Subj:	Re: Calendar Functions

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0400
          for JMS@ARIZMIS; Fri, 12-SEP-1986 06:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/12/86 at 07:57:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002279; 12 Sep 86 6:08 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018038; 12 Sep 86 5:48 EDT
From: Dave Lewis <dml%loral.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions
Message-ID: <1229@loral.UUCP>
Date: 10 Sep 86 16:47:34 GMT
Keywords: Calendars
To:       info-c@BRL-SMOKE.ARPA
     
In article <206@cascade.STANFORD.EDU> leeke@cascade.UUCP (Steven D. Leeke)
writes:
>Could someone please give me some pointers to functions for creating
>calendars? e.g. for any day from 1900 to as far in the future as possible.
>Actual code would be GREATLY appreciated - C preferred.
>
     
  Here's a collection of calendar functions; writing a main() driver
function should be trivial. These were originally assignments for a Pascal
class (what the hey, an easy 4 credits with an A+) and I rewrote them in
C for the hell of it. Good for contrasting Pascal and C - things I had to
work around in Pascal came out as straight code in C.
     
/*  Determines whether a given year is a leap year
 */
     
leapyear (year)
int year;
{
  if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
     return (1);
  else
     return (0);
}
     
/*  Returns #days in month given month and year, taking
 *    leap years into account for February.
 */
     
daysinmonth (month, year)
int month, year;
{
  if (month == 2)          /* Is it February?             */
     if (leapyear (year))  /* If so, is it a leap year?   */
    return (29);       /* 29 days in Feb in leap year */
     else
    return (28);       /* 28 days if not              */
  else{
     if (month > 7)        /* Is it August -> December?   */
    month++;           /* Invert even/odd state if so */
     if (month & 1)        /* Odd months have 31 days     */
    return (31);
     else
    return (30);       /* Even months have 30 days    */
  }
}
     
/*  Determines whether a given date is valid
 */
     
validdate (month, day, year)
int month, day, year;
{
  if (month < 1 || month > 12 || day < 1 ||
     day > daysinmonth (month, day, year) ||
     year < 1583 || year > 9999)
    return (0);
  else
    return (1);
}
     
/*  Given a valid date (month, day, and year) Zeller will
 *    return an integer representing the day of week that
 *    date will fall on. 0 = Sunday, 6 = Saturday.
 */
     
zeller (month, day, year)
int month, day, year;
{
  int century;
  month -= 2;       /* Years start on March 1 so adjust standard date */
  if (month < 1) {
     month += 12;
     year--;
  }
  century = year / 100;
  year = year % 100;
  return (((2.6 * month - 0.1) + day + year + year / 4
       + century / 4 - century * 2) % 7);
}
     
  These functions will work for any date between March 1, 1583 and December 31,
9999. Have fun!
     
-------------------------------
        Dave Lewis    Loral Instrumentation   San Diego
     
  hp-sdd --\     ihnp4 --\
  sdcrdcf --\      bang --\   kontron -\
  csndvax ---\   calmasd -->-->!crash --\
  celerity --->------->!sdcsvax!sdcc3 --->--->!loral!dml  (uucp)
  dcdwest ---/                 gould9 --/
     
 When the government runs it, it's called a Lottery.
 When somebody else runs it, it's called a Numbers Racket.
     
-------------------------------

From:	ARPA%"dml%loral.uucp@BRL.ARPA" 12-SEP-1986 06:25
To:	JMS
Subj:	Re: C compilers for 8 bit machines

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0599
          for JMS@ARIZMIS; Fri, 12-SEP-1986 06:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/12/86 at 08:07:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002281; 12 Sep 86 6:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018042; 12 Sep 86 5:48 EDT
From: Dave Lewis <dml%loral.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: C compilers for 8 bit machines
Message-ID: <1230@loral.UUCP>
Date: 10 Sep 86 19:10:35 GMT
To:       info-c@BRL-SMOKE.ARPA
     
------------------------------
     
  I have Microware's C-09 for the Radio Shack Color Computer (6809) which
runs under OS-9. Due to memory constraints, the two-pass compiler resides
in two separate disk files. It also has an optimizer which the docs say
reduces code size by ~11%. It produces small and relatively fast code, has
a very few departures from K&R which are all documented in the docs intro
section, and supports a lot of high- and low-level system and I/O functions.
     
-------------------------------
        Dave Lewis    Loral Instrumentation   San Diego
     
  hp-sdd --\     ihnp4 --\
  sdcrdcf --\      bang --\   kontron -\
  csndvax ---\   calmasd -->-->!crash --\
  celerity --->------->!sdcsvax!sdcc3 --->--->!loral!dml  (uucp)
  dcdwest ---/                 gould9 --/
     
 A portable program is one that has the same bugs on many different computers.
     
-------------------------------

From:	ARPA%"greg%ncr-sd.uucp@BRL.ARPA" 12-SEP-1986 09:04
To:	JMS
Subj:	Re: Calendar Functions

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2243
          for JMS@ARIZMIS; Fri, 12-SEP-1986 09:04 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/12/86 at 10:08:24 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002284; 12 Sep 86 6:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018084; 12 Sep 86 5:50 EDT
From: Greg Noel <greg%ncr-sd.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions
Message-ID: <1165@ncr-sd.UUCP>
Date: 11 Sep 86 22:27:20 GMT
Keywords: Calendars
To:       info-c@BRL-SMOKE.ARPA
     
In article <1229@loral.UUCP> dml@loral.UUCP (Dave Lewis) writes:
>/*  Given a valid date (month, day, and year) Zeller will
> *    return an integer representing the day of week that
> *    date will fall on. 0 = Sunday, 6 = Saturday.
> */
>
>zeller (month, day, year)
>int month, day, year;
>{
>    [ various code deleted..... ]
>  return (((2.6 * month - 0.1) + day + year + year / 4
>       + century / 4 - century * 2) % 7);
>}
     
Note that the expression above is in floating point.  This may produce bogus
results if the divisions (which are supposed to be truncated) end up being
done in floating point (they \shouldn't/ be, but....).  Certainly, converting
all those ints to floats to be added and converted back to an int will take
a lot of time.  Also, it is possible that the major expression (prior to the
modulo operation) can be negative, so it is best to add in a bias value that
is zero mod seven to be sure that the calculated modulus is also positive.
Thus, a logically equivalent version, done with all integer arithmetic is:
     
    return ((26 * month - 1)/10 + day + year + year/4
        + century/4 - century*2 + 777) % 7;
     
BTW, the reason it's called a congruence is that with this formulation it's
easy to demonstrate that the the day-of-the-year pattern repeats every three
hundred years.
--
-- Greg Noel, NCR Rancho Bernardo    Greg@ncr-sd.UUCP or Greg@nosc.ARPA

From:	edu%"jl42@andrew.cmu.edu" 13-SEP-1986 07:33
To:	JMS
Subj:	Char vs. Int

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1033
          for JMS@ARIZMIS; Sat, 13-SEP-1986 07:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/13/86 at 06:22:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018370; 13 Sep 86 5:07 EDT
Received: from po3.andrew.cmu.edu by SMOKE.BRL.ARPA id a010020;
          13 Sep 86 4:17 EDT
Received: by po3.andrew.cmu.edu (4.12/3.15) id <AA00244>; Fri, 12 Sep 86
  08:19:34 edt
Received: FROM carlisle VIA queuemail
          ID </cmu/common/mailqs/q003/QF.carlisle.1f6807d5.7>;
          Fri, 12 Sep 86 08:17:32 edt
Message-Id: <MS.jl42.0.carlisle.1307.0@andrew.cmu.edu>
Date: Fri, 12 Sep 86 08:17:05 edt
From: Jay Mathew Libove <jl42@andrew.cmu.edu>
To: info-c@BRL-SMOKE.ARPA
Subject: Char vs. Int
     
I have always been under the impression that a CHAR variable and an INT variable
were the same in 'C'- yet I now see:
     
Message-Id: <1219@drutx.UUCP>
Date: 8 Sep 86 02:52:47 GMT
To: info-c@brl-smoke.arpa
     
In the sequence:
     
    main()
    {
        char c = 'w';
        foo(c)
    }
     
    foo(ch)
    char ch;
     
char ch is the correct declaration.  The compiler/code generator should
handle pulling the character portion of the promoted variable off the
stack correctly.  Declaring it 'int' is asking for trouble.
     
Why is it asking for trouble to declare ch as INT when K&R says they are the
same?
     

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 13-SEP-1986 12:16
To:	JMS
Subj:	Re: enum function bug?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4180
          for JMS@ARIZMIS; Sat, 13-SEP-1986 12:16 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/13/86 at 13:24:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a018619; 13 Sep 86 7:48 EDT
Received: from USENET by SMOKE.BRL.ARPA id a011271; 13 Sep 86 7:32 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: enum function bug?
Message-ID: <7198@sun.uucp>
Date: 12 Sep 86 09:33:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I want to pass a
>     pointer to function returning "bool"
> to a function, but lint says I'm not doing it right.  I think I am,
> aren't I? ... Is this a bug?
     
     
Yes, and yes.  PCC converts "enum"s into "char"s, "short"s, or "int"s at a
fairly early stage in its processing.  Unfortunately, this means "lint" does
also.  As such, "pointer to function returning enum" gets converted to
"pointer to function returning char/short/int", which collides with the
formal argument of "f".  In this particular case, I tried it and it gave the
errors listed; I changed the function pointer declarations to "int (*xx)()"
and it passed.
     
The fix is not to convert "enum"s in that fashion in "lint", and fix pass 2
to check that enum formal arguments match the actual arguments used.
     
You can tell the parts of the language that were added later; the front end
of PCC doesn't really handle them right.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"mike%whuxl.uucp@BRL.ARPA" 14-SEP-1986 03:11
To:	JMS
Subj:	Re: soundex algorithm wanted

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2329
          for JMS@ARIZMIS; Sun, 14-SEP-1986 03:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 05:07:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020588; 14 Sep 86 5:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019535; 14 Sep 86 5:33 EDT
From: BALDWIN <mike%whuxl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: soundex algorithm wanted
Message-ID: <1244@whuxl.UUCP>
Date: 11 Sep 86 17:43:27 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <1239@whuxl.UUCP> mike@whuxl.UUCP (BALDWIN) writes:
> >    register char    c, lc, prev = '0';
>
> All the compilers I have used ignore the `register' on `register
> char' declarations.  In any case, an `int' will hold everything
> that will fit in a `char', and is (usually) the `natural word size'
> of the machine.  Is there ever any reason to declare a variable
> `register char' rather than `register int'?  Are there any extant
> compilers for which the latter will generate *worse* code?
     
On a 3B20, `register char c' is indeed put in a register, and
generates exactly the same code as `register int c', except
the instruction is `cmpb' instead of `cmpw'.  Of course there's
a reason for declaring a variable as char instead of int; if it
is used as a char, it should be declared char.
--
                        Michael Baldwin
            (not the opinions of)    AT&T Bell Laboratories
                        {at&t}!whuxl!mike

From:	ARPA%"moore@mit-eddie.ARPA" 14-SEP-1986 03:29
To:	JMS
Subj:	Help with BDSC float

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2597
          for JMS@ARIZMIS; Sun, 14-SEP-1986 03:29 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 05:25:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020629; 14 Sep 86 6:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019899; 14 Sep 86 5:44 EDT
From: "Andrew M. Moore" <moore@mit-eddie.ARPA>
Newsgroups: net.lang.c
Subject: Help with BDSC float
Message-ID: <3211@mit-eddie.MIT.EDU>
Date: 13 Sep 86 14:02:08 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
     
     
   My BDS C compiler doesn't want to accept  %6.3f  (example) in printf's.
Nor does it accept "float" as a data type declaration.  On some compilers,
I don't have to declare a variable as "float" before using it:
     
    printf("Float: %6.3f", (5.0/4.0));
     
...but in BDS, this is not accepted.  How is "float" different in BDS C?
     
Andrew Moore
arpa MOORE%MIT-EECS@MIT-MC.ARPA
uucp ...mit-eddie!moore
  us Box 121, North Quincy, MA  02171

From:	ARPA%"hoffman%hdsvx1.uucp@BRL.ARPA" 14-SEP-1986 03:34
To:	JMS
Subj:	Re: Optimizing C compilers, and their use...

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2667
          for JMS@ARIZMIS; Sun, 14-SEP-1986 03:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 05:27:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020637; 14 Sep 86 6:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020205; 14 Sep 86 5:51 EDT
From: Richard Hoffman <hoffman%hdsvx1.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Optimizing C compilers, and their use...
Message-ID: <498@hdsvx1.UUCP>
Date: 7 Sep 86 20:36:04 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1184@uw-june> bnfb@uw-june (Benson) writes:
>All the time, on the net, in casual conversation, in literature and
>especially in discussions of the forthcoming C Language Standard, I have
>heard the statement:
>    "You can allow/do/write <anything> because any
>     decent optimizing compiler will fix/compile it."
>My question is:
>    How many of you who say this (or even just how many of you
>    on the net) have an optimizing C compiler?  And how many of
>    those actually use them?
     
If one develops programs on VMS, each compiler has an optimizer, and
optimized output is the default (at least, this is true for the compilers
I use -- FORTRAN, C, PL/I -- I assume it's true for most of the other
major languages DEC supports).  Also, every IBM compiler I ever worked
with had an optimizer, and typically the last step before releasing a
program was to run it through the optimizer.  So I would imagine that
probably the majority of programs are compiled these days with an optimizing
compiler, whether the optimizer is used or not.  Nevertheless, unless one
is intimately familiar with the sorts of optimization that the compiler does,
it makes sense to clean up one's one mess to the best extent possible.
--
 Richard Hoffman                | "Oh life is a wonderful cycle of song,
 Schlumberger Well Services     |     A medley of extemporanea.
 hoffman%hdsvx1@slb-doll.csnet  | And Love is a thing that can never go wrong
 PO Box 2175, Houston, TX 77252 | ... And I am Marie of Roumania." --D. PARKER

From:	ARPA%"hoffman%hdsvx1.uucp@BRL.ARPA" 14-SEP-1986 05:44
To:	JMS
Subj:	Re: "\"

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4390
          for JMS@ARIZMIS; Sun, 14-SEP-1986 05:44 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 07:39:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020649; 14 Sep 86 6:17 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020210; 14 Sep 86 5:52 EDT
From: Richard Hoffman <hoffman%hdsvx1.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: "\"
Message-ID: <508@hdsvx1.UUCP>
Date: 9 Sep 86 13:32:36 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> How do you spell "\"?
     
"\\", of course.
--
 Richard Hoffman                | "Oh life is a wonderful cycle of song,
 Schlumberger Well Services     |     A medley of extemporanea.
 hoffman%hdsvx1@slb-doll.csnet  | And Love is a thing that can never go wrong
 PO Box 2175, Houston, TX 77252 | ... And I am Marie of Roumania." --D. PARKER

From:	ARPA%"leei%mcgill-vision.uucp@BRL.ARPA" 14-SEP-1986 05:49
To:	JMS
Subj:	Re: lint

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4536
          for JMS@ARIZMIS; Sun, 14-SEP-1986 05:49 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 07:43:54 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020653; 14 Sep 86 6:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020232; 14 Sep 86 5:52 EDT
From: Lee Iverson <leei%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: lint
Message-ID: <484@mcgill-vision.UUCP>
Date: 29 Aug 86 00:48:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1391@lll-crg.ARpA> brooks@lll-crg.UUCP (Eugene D. Brooks III)
 writes:
>Not for money, love, drugs or sex would I do software development
>on a system other than UNIX.  The rest of you guys can suffer if
>you want to but I have seen enough pain in my lifetime.
     
This is obviously a man who has either not heard of Lisp Machines,
has never used one, or has no faith in the future.
     
"After you had a man wi' no legs, they ain't no goin' back, baby!"
     
--
                Lee Iverson
                utcsri!mcgill-vision!leei
                Mcgill University, Montreal
                Computer Vision and Robotics Lab

From:	ARPA%"mouse%mcgill-vision.uucp@BRL.ARPA" 14-SEP-1986 05:53
To:	JMS
Subj:	Re: Missing stdio features.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4494
          for JMS@ARIZMIS; Sun, 14-SEP-1986 05:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 07:43:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020655; 14 Sep 86 6:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020240; 14 Sep 86 5:53 EDT
From: der Mouse <mouse%mcgill-vision.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <490@mcgill-vision.UUCP>
Date: 4 Sep 86 05:32:38 GMT
Keywords: stdio, buffering
To:       info-c@BRL-SMOKE.ARPA
     
In article <6224@sri-spam.ARPA>, argv@sri-spam.ARPA (AAAARRRRGGGGv) writes:
[>> is AAAARRRRGGGGv quoting me]
>> Here are the things I have wanted badly enough to add to stdio:
>> FILE *fopenfxn(int (*fxn)(), char *mode)
>>    Function-stream I/O.  Returns a FILE*, open for read or write
>>     (not both, "r+" is treated as "r").  When a character is
>>     written to (resp. read from) the stream, the function is
>>     called.
> This shouldn't be that hard to do:
> first, take the fildes of the open stream, set it to be asynch IO,
> then loop.  When data is there to be read, you'll get a SIGIO.  For
> some strange reason, I seem to remember that this is can only be done
> on pseudo-tty's or other types of devices (I use it frequently for
> windows on the SUN); so I don't know if this will work well on normal
> files or sockets.
(By the way, the "strange reason" is that the code isn't in the kernel
for it!)
[excerpted example follows:]
> int fd = open ("/dev/tty", 0);
> signal (SIGIO, io_handler);
> ioctl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FASYNC));
> io_handler()
> {
>     puts("Hey, there's data to be read on the fildes!");
> }
     
You apparently misunderstood (ok, let's be nice, I didn't make myself
clear).  What fopenfxn does is not what the above does (or even what it
appears to be trying to do).  There is no file descriptor associated
with a function stream!  For example, if we do
    f = fopenfxn(foo_fxn,"w");
then
    putc(c,f);
and
    foo_fxn(c,f);
are equivalent.  The advantage is that functions like printf() can be
used on the resulting stream, and call the function once for each
character generated.  Reading works analogously:
    f = fopenfxn(foo_fxn,"r");
    c = getc(f);
is equivalent to
    c = foo_fxn(f);
but makes scanf() and friends work as well.
     
>> FILE *fopenstr(char *str, int len, char *mode)
>>     An extension to sprintf() and sscanf().  This returns a stream
>>     which performs I/O to a string (this makes sprintf() and
>>     sscanf() unnecessay, though they are still convenient).
>
> I request you more fully describe this functionality. I don't see how
> adding the routines of an IO library is going to speed up what
> sprintf and sscanf already do.  Perhaps to do something like this
> would be "interesting", but that's about it.  Again, please
> elaborate.
     
Sure.
     
    f = fopenstr(buf,"w");
    fprintf(f,"Current square is: ");
    print_square(f,current_square);
    fprintf(f,"and no other!");
    fclose(f);
     
Or
     
    f = fopenstr(buf,"w");
    fprintf(f,"List is:");
    for (element=list;element;element=element->link)
     { fprintf(f," %d",element->value);
     }
    fprintf(f,".");
    fclose(f);
     
Using this instead of sprintf or sscanf should produce no speed
difference (well, actually, it should be slightly slower because of the
extra function calls involved....).
     
>> unfdopen(FILE *f)
>>     Undoes fdopen(), that is, closes the FILE* without close()ing
>>     the underlying file descriptor.
> This would be nice.
     
Yeah.  To get it with vanilla stdio requires playing games with dup,
and will cause lots more pain if (as for stdin/out/err) you want the
original descriptor number.  Even then, you gotta have a descriptor
free.
     
>> Unfdopen is trivial; fopenfxn and fopenstr are implemented by making
>> the stream appear unbuffered to putc and getc and then changing _flsbuf
>> and _filbuf to add the functionality.
>
> Looking at the source to puts (fputs) and so forth, I've found that
> it is much faster to never unbuffer anything and to simply macro that
> which you'd like to have "unbuffered":
> #define unbuffered_puts(s,f)   fputs(s,f), fflush(f)
     
The point of telling stdio that the stream is unbuffered is that then
other stdio functions such as printf and scanf will call _flsbuf (resp.
_filbuf) for every character.
     
> The reason for this is that if the data is unbuffered, fputs merely
> sets the buffer to a buffer within the routine, sets a few flags,
> goes thru a while loop, using the macro in stdio to putc to the
> stream, then fflushes again, finally resettting all the flags it
> started with.  Finallly (not that this has anything to do with it),
> it returns the last character put to the stream (undocumented).
     
You are running 4.3, right?  It was fun making these work when we
shifted to 4.3....4.2 puts (and similar functions) didn't do this
"let's pretend it's buffered for a little while...." trick.
     
> In any event, what's preventing you from free()ing the structure and
> leaving the fd open?
     
Huh?  What does this have to do with any of the above?

From:	ARPA%"devine%vianet.uucp@BRL.ARPA" 14-SEP-1986 05:59
To:	JMS
Subj:	Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4865
          for JMS@ARIZMIS; Sun, 14-SEP-1986 05:59 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 07:49:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020674; 14 Sep 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020277; 14 Sep 86 5:54 EDT
From: Bob Devine <devine%vianet.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <34@vianet.UUCP>
Date: 12 Sep 86 20:33:30 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Dave Lewis writes:
> leapyear (year)
> int year;
> {
>   if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
>      return (1);
>   else
>      return (0);
> }
     
  While this works, it is overkill.  Unless you believe that your
code will make it to the year 2100, a simple test for divisibility
by 4 is sufficient.  If you really want an algorithm for all years,
you then need to also test for years divisible by 4000...
     
int
leapyear(year)
    int year;
{
    /* works for the years 1901-2099 */
    return(year%4);
}
     
Or if you want a simple cpp macro:
     
#define  isleapyear(year)   ((year)%4)
     
Bob Devine

From:	ARPA%"rlk%chinet.uucp@BRL.ARPA" 14-SEP-1986 06:00
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4780
          for JMS@ARIZMIS; Sun, 14-SEP-1986 06:00 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 07:49:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020663; 14 Sep 86 6:20 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020267; 14 Sep 86 5:54 EDT
From: Richard Klappal <rlk%chinet.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <547@chinet.UUCP>
Date: 13 Sep 86 18:26:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <2233@gitpyr.UUCP> thomps@gitpyr.UUCP writes:
>
>
>In article <1219@drutx.UUCP>, qwerty@drutx.UUCP (Brian Jones) writes:
>> In the sequence:
>>
>>     main()
>>     {
>>         char c = 'w';
>>         foo(c)
>>     }
>>
>>     foo(ch)
>>     char ch;
>>
>> char ch is the correct declaration.  The compiler/code generator should
>> handle pulling the character portion of the promoted variable off the
>> stack correctly.  Declaring it 'int' is asking for trouble.
>>
>  If I understand what Kernighan and Ritchie say in their book, then ch
>  is automatically converted to an int when foo is called because a function
>  argument is an expression and a character is always converted to an int in
>  an expression. See K&R page 41 - 42.
>  I know that some compilers take care of this and allow you to
>  still declare ch as a char. However, I note that K&R always declare
>  ch as an int in their examples. I would suppose that the compiler being
>  used requires the int declaration. Since the conversion occurs by definition
>  of the language, there is no danger in declaring it an int and this is
>  commonly done in most C code. Declare it as an int and go to it. It also
>  sounds like the asker of the original question should get hold of K&R and
>  learn about the relationship between char and int in C.
>--
>Ken Thompson
>Georgia Tech Research Institute
>Georgia Insitute of Technology, Atlanta Georgia, 30332
>...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!thomps
     
Balderdash!!!!!
K&R declare all chars as ints so that routines that return EOF will
work correctly regardless of whether chars are signed or unsigned
in your hardware/software combination.
     
Your compiler is broken if it will not work as shown in the example,
and if you define the arg as an int in the subroutine, you \'should\'
cast the char arg to an int in the calling sequence.  The automatic
promotion of char to integer only means that everything will probably
work if you don't do the casting.
     
     
--
---
UUCP: ..!ihnp4!chinet!uklpl!rlk || MCIMail: rklappal || Compuserve: 74106,1021
      ..!ihnp4!ihu1h!rlk
---

From:	ARPA%"rbutterworth%watmath.uucp@BRL.ARPA" 14-SEP-1986 17:19
To:	JMS
Subj:	Bug in 4.2 cc code generator (result type of assignment)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0524
          for JMS@ARIZMIS; Sun, 14-SEP-1986 17:19 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 19:14:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024600; 14 Sep 86 19:54 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025563; 14 Sep 86 19:30 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Bug in 4.2 cc code generator (result type of assignment)
Message-ID: <3150@watmath.UUCP>
Date: 14 Sep 86 15:59:11 GMT
To:       info-c@BRL-SMOKE.ARPA
     
/*
 * The following two loops should be identical,
 * the second test possibly generating more efficient code.
 * i.e. ((c=exp1),(c!=exp2))  versus  ((c=exp1)!=(exp2)).
     
 * This is true on all the other compilers I have tried,
 * regardless of sign-extension, byte order, word size, etc.
     
 * But on the 4.2 cc, the second test rather than being more
 * efficient, actually generates more code, and in fact generates
 * incorrect code (the loop never terminates (well almost never)).
 * In this particular case it seems to think that the type of
 * (c=exp1) is the same as the type of (exp1) and not that of (c).
 * According to both K&R and the proposed X3J11 this is wrong.
     
 * (I realize that the "&0377" is actually redundant, but it is
 * one way of invoking the bug in this contrived example.)
 */
     
main()
{
    char *data="see should_not_see";
    char stop='\345';
    char *p;
    char c;
     
    data[3]=stop;
     
    p = data;
    printf("Using comma operator\n");
    while ( (c=(*p++&0377)), (c!=stop) )
        printf("%3.3o ", c);
    printf("\n");
     
    p = data;
    printf("Using asignment!=\n");
    while ( (c=(*p++&0377))!=stop )
        printf("%3.3o ", c);
    printf("\n");
     
    return 0;
}
     
/*
 *This is the correct code generated for the first loop:
L19:
    cvtbl   *-12(fp),r0
    bicl2   $-256,r0
    cvtlb   r0,-13(fp)
    incl    -12(fp)
    cmpb    -13(fp),-5(fp)
    jeql    L20
     
 *This is the incorrect code generated for the second (more efficient) loop:
L24:
    movl    -12(fp),r0
    incl    -12(fp)
    cvtbl   (r0),r0
    bicl2   $-256,r0
    cvtlb   r0,-13(fp)
    cvtbl   -5(fp),r1
    cmpl    r0,r1
    jeql    L25
 */

From:	ARPA%"cagordon%watnot.uucp@BRL.ARPA" 14-SEP-1986 17:25
To:	JMS
Subj:	signal() help needed

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0617
          for JMS@ARIZMIS; Sun, 14-SEP-1986 17:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/14/86 at 19:21:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024473; 14 Sep 86 18:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024839; 14 Sep 86 17:30 EDT
From: Chris Gordon <cagordon%watnot.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: signal() help needed
Message-ID: <11997@watnot.UUCP>
Date: 14 Sep 86 04:24:34 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Forgive me, I'm not that experienced using C.
     
If I have a function defined like:
     
func()
{
  .
  .
  .
}
     
(no args)
     
And I wish to catch SIGINT and SIGQUIT to execute this function just before an
 exit(0), what would be the EXACT signal() statement (and do I need any others)?
     
Any help would be greatly appreciated.
     
Chris
     
cagordon@watnot.UUCP

From:	ARPA%"mdapoz%watrose.uucp@BRL.ARPA" 14-SEP-1986 23:22
To:	JMS
Subj:	Re: Help with BDSC float

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3353
          for JMS@ARIZMIS; Sun, 14-SEP-1986 23:22 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/15/86 at 01:16:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024926; 14 Sep 86 23:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027277; 14 Sep 86 23:30 EDT
From: Mark Dapoz <mdapoz%watrose.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Help with BDSC float
Message-ID: <8142@watrose.UUCP>
Date: 14 Sep 86 17:48:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3211@mit-eddie.MIT.EDU> moore@mit-eddie.MIT.EDU (Andrew M. Moore)
 writes:
>   My BDS C compiler doesn't want to accept  %6.3f  (example) in printf's.
>Nor does it accept "float" as a data type declaration.  On some compilers,
>I don't have to declare a variable as "float" before using it:
>
>    printf("Float: %6.3f", (5.0/4.0));
>
>...but in BDS, this is not accepted.  How is "float" different in BDS C?
     
   BDS C 1.5 does NOT support the float data type.  If you want to use floating
point arithmetic then you must use an additional library of functions called
float.c.  It's public domain and found on most RCP/M's.  I've heard rumour that
BDS C (2.0?) has floating point arithmetic and is much more K&R standard.
You'll have to check with the author to see if this is true though.
   Mark Dapoz

From:	ARPA%"HOWESDW%WSUVM1.BITNET@wiscvm.ARPA" 15-SEP-1986 23:51
To:	JMS
Subj:	Looking for compiler

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4526
          for JMS@ARIZMIS; Mon, 15-SEP-1986 23:51 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/16/86 at 01:36:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012509; 15 Sep 86 18:43 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a019402; 15 Sep 86 18:26 EDT
Received: from WISCVM.WISC.EDU by VGR.BRL.ARPA id aa03400; 15 Sep 86 18:15 EDT
Received: from (VM1MAIL)WSUVM1.BITNET by WISCVM.WISC.EDU on 09/15/86 at
  17:14:14 CDT
Received: by WSUVM1 (Mailer X1.23) id 9163; Mon, 15 Sep 86 15:13:31 PLT
Date:         Mon, 15 Sep 86 15:11:20 PLT
From:           Don Howes <HOWESDW%WSUVM1.BITNET@wiscvm.ARPA>
Subject:      Looking for compiler
To:  INFO-C@BRL.ARPA
Message-ID:  <8609151815.aa03400@VGR.BRL.ARPA>
     
I am looking for a public domain C compiler to run on a VAX 11/785
(Small C would be nice). Does anyone out there know where I can get
one, or put me in contact with someone who does?
     
Thanks in advance.

From:	ARPA%"UKC340%UKCC.BITNET@wiscvm.ARPA" 16-SEP-1986 01:41
To:	JMS
Subj:	

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5494
          for JMS@ARIZMIS; Tue, 16-SEP-1986 01:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/16/86 at 03:14:34 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012673; 15 Sep 86 19:34 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a019808; 15 Sep 86 19:11 EDT
Received: from WISCVM.WISC.EDU by VGR.BRL.ARPA id aa03665; 15 Sep 86 18:54 EDT
Received: from (MAILER)UKCC.BITNET by WISCVM.WISC.EDU on 09/15/86 at
  07:34:57 CDT
Received: by UKCC (Mailer X1.23) id 9393; Mon, 15 Sep 86 08:35:30 EST
Date:         Mon, 15 Sep 1986 08:31 EST
From:           "Wayne E. Beech" <UKC340%UKCC.BITNET@wiscvm.ARPA>
To:  INFO-C@BRL.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Message-ID:  <8609151855.aa03665@VGR.BRL.ARPA>
     
     
     
someone asked why they were having trouble with the float data type when
using BDS-C.  the problem is that BDS-C is not a K&R implementation of
the C language.  their is a library supplied with the compiler though
that implements alot of floating point routines.  i like the BDS-C
compiler and have a copy of it but you just have to remember that its
not K&R.

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA" 16-SEP-1986 13:05
To:	JMS
Subj:	Re: Missing stdio features.

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 0179
          for JMS@ARIZMIS; Tue, 16-SEP-1986 13:05 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/16/86 at 10:41:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014428; 16 Sep 86 5:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024393; 16 Sep 86 5:33 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <3417@umcp-cs.UUCP>
Date: 14 Sep 86 07:46:44 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I wrote:
>>Indeed, there would be a certain symmetry to the whole thing if one
>>could write
>>    reader(f, buf, len) FILE *f; { return (read(fileno(f), buf, len)); }
>>    FILE *f = fopenrf(reader, "r");
>>    fileno(f) = fd;
>>instead of
>>    FILE *f = fdopen(fd, "r");
     
In article <86900044@haddock> karl@haddock writes:
>As I mentioned, I think it has to be (void *) in general, thus
>   reader(void *v, char *buf, int len) {
>       return (read(*(int *)v, buf, len));
>   }
>   FILE *f = fopenrf(&fd, reader, "r");
     
I agree.  Indeed, I had a more voluminous example that used generic
pointers, but I thought that the idea would be hidden by all the
implementation details, so I trimmed it down to the one in >> above.
     
>You could get away with having the first arg to reader() be "FILE *", but in
>any case "void *_id" needs to replace or supplement the existing "int _file"
>in the FILE structure.
     
I think the generic pointer is better.  The reading or writing
routine should need no access to the stdio structures, just as
read() and write() need none.
     
>If there are separate functions fopenrf() and fopenwf(), is there any need
>for the third argument?
     
I had a reason for including it at the time, but now I cannot recall
it.  Ah well.  There should be some provision for read-and-write modes,
though:
     
    typedef int (*iofunc)(void *cookie, char *buf, int len);
    FILE *fopenrwf(void *cookie, iofunc r, iofunc w);
     
(to specify types everywhere).
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA" 18-SEP-1986 02:17
To:	JMS
Subj:	Re: soundex algorithm wanted

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4603
          for JMS@ARIZMIS; Thu, 18-SEP-1986 02:17 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/18/86 at 04:07:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014430; 16 Sep 86 5:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024398; 16 Sep 86 5:33 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: soundex algorithm wanted
Message-ID: <3421@umcp-cs.UUCP>
Date: 14 Sep 86 08:51:07 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <3266@umcp-cs.UUCP> I wrote:
>>All the compilers I have used ignore the `register' on `register
>>char' declarations. ... Is there ever any reason to declare a variable
>>`register char' rather than `register int'?  Are there any extant
>>compilers for which the latter will generate *worse* code?
     
In article <1244@whuxl.UUCP> mike@whuxl.UUCP (BALDWIN) writes:
>On a 3B20, `register char c' is indeed put in a register ....
>Of course there's a reason for declaring a variable as char
>instead of int; if it is used as a char, it should be declared char.
     
I agree, in principle; this is just a part of saying what you mean.
I meant to ask `is there ever any reason, other than saying what
you mean'.  I have, since I discovered that the 4BSD compiler
ignores `register' on `char's, given in to expediency.  I suppose
I was really looking for an excuse to work on the compiler.  Well,
now I have one:  Sun's compiler does indeed generate better code,
in some cases, for `register char's than for `register int's.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"lesh@BRL.ARPA" 19-SEP-1986 18:52
To:	JMS
Subj:	public-domainn matrix inversion in C

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7424
          for JMS@ARIZMIS; Fri, 19-SEP-1986 18:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/19/86 at 20:44:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014191; 17 Sep 86 22:40 EDT
Date:     Wed, 17 Sep 86 22:17:46 EDT
From:     Steve Lesh (ISC) <lesh@BRL.ARPA>
To:       info-c@BRL.ARPA
cc:       golub@SU-SCORE.ARPA
Subject:  public-domainn matrix inversion in C
     
    Does anybody know where I can find source for matrix inversion or
Gaussian elimination routines or programs?

From:	ARPA%"lesh@BRL.ARPA" 19-SEP-1986 19:00
To:	JMS
Subj:	Re:  signal() help needed

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7588
          for JMS@ARIZMIS; Fri, 19-SEP-1986 19:00 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014220; 17 Sep 86 23:02 EDT
Date:     Wed, 17 Sep 86 22:09:55 EDT
From:     Steve Lesh (ISC) <lesh@BRL.ARPA>
To:       cagordon%watnot.uucp@BRL.ARPA
cc:       info-c@BRL.ARPA
Subject:  Re:  signal() help needed
     
    To really understand what's going on with signals, I suggest you read
Marc J. Rochkind's ADVANCED UNIX PROGRAMMING.  If you still need help after
yyou've read chapter 8 in Rochkind's book, get back.

From:	ARPA%"jsdy%hadron.uucp@BRL.ARPA" 19-SEP-1986 19:36
To:	JMS
Subj:	Re: Bug in 4.3 C

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7870
          for JMS@ARIZMIS; Fri, 19-SEP-1986 19:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/19/86 at 20:59:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008993; 18 Sep 86 14:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a001247; 18 Sep 86 13:34 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Bug in 4.3 C
Message-ID: <563@hadron.UUCP>
Date: 16 Sep 86 13:23:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <809@navajo.STANFORD.EDU> rokicki@navajo.STANFORD.EDU (Tomas
 Rokicki) writes:
>/*   This program should print out: -1 0
> *   however, under 4.3 bsd, it prints out -1 1 */
>main () {
>  register unsigned char a=1, b=2 ;
>  printf("%d %d\n", ((int)(a))-((int)(b)), ((int)(a))-(int)(b))) > 1 ) ;
>}
     
Your parenthesisation is bad:  in this form, no compiler could
accept it.
     
printf("%d %d\n", ((int)(a))-((int)(b)), ((int)(a))-(int)(b))) > 1 );
      1          23   33 32 23   33 32  23   33 32 2   22 210     -1
     
I'm not suggesting that this is your entire problem; but why don't
you turn on the sm [showmatch] option of vi [which I normally hate],
re-write this line, and try it again?  Then post the results.
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

From:	jnet%"karl@haddock" 19-SEP-1986 21:46
To:	JMS
Subj:	Re: C-STYLE (goto?)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9250
          for JMS@ARIZMIS; Fri, 19-SEP-1986 21:46 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014470; 16 Sep 86 6:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024321; 16 Sep 86 5:30 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: C-STYLE (goto?)
Message-ID: <86900052@haddock>
Date: 10 Sep 86 21:33:00 GMT
Nf-ID: #R:brl-smok:-325300:haddock:86900052:000:1042
Nf-From: haddock!karl    Sep 10 17:33:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
killer!toma (Tom Armistead) writes:
>In article <3253@brl-smoke.ARPA>, jeff@isi-vaxa.ARPA writes:
>>[code deleted]
>>Now, I know a lot of people detest this because of the use of goto's, but
>>this seems the nicest way to perform this function.
>
>There is always the use of setjmp and longjmp ...: [code deleted]
>This will accomplish the same thing and possibly not affend the goto haters,
     
Mother of swapper!  A longjmp is *worse* than a goto.  It's just a goto that
doesn't respect function boundaries!  Anyone who disapproves of goto but
considers longjmp acceptable is objecting to the keyword rather than the
concept ("I know goto is bad because my teacher said so").  (I'm not flaming
Tom; his posting did not imply approval.)
     
Lest you misunderstand me -- I am not a "goto hater".  There are three valid
uses of goto, one of which is error handling.  Jeff, your program is a good
example of proper goto usage.  Leave it that way, but learn why it's right.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA" 19-SEP-1986 21:47
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9053
          for JMS@ARIZMIS; Fri, 19-SEP-1986 21:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/19/86 at 23:18:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014432; 16 Sep 86 5:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024404; 16 Sep 86 5:33 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <3422@umcp-cs.UUCP>
Date: 14 Sep 86 09:30:46 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>In article <2233@gitpyr.UUCP> thomps@gitpyr.UUCP writes:
>>If I understand what Kernighan and Ritchie say in their book, then ch
>>is automatically converted to an int when foo is called because a function
>>argument is an expression and a character is always converted to an int in
>>an expression. See K&R page 41 - 42.
     
This is correct.  Actually, this is an understatement:  C does
not have a character type.
     
Wait!  Let me explain what I mean by this.
     
The C language has what I call `expression types' and `storage
types'.  There is a character storage type, but there is no character
expression type.  The following is a list of storage types and
equivalent expression types:
     
    Storage Type        Expression Equivalent
    ------------        ---------------------
    char            int
    unsigned char        unsigned int
    short            int
    unsigned short        unsigned int
    int            int
    unsigned int        unsigned int
    long            long
    unsigned long        unsigned long
    float            double
    double            double
    pointer            pointer
     
(Some C compilers have different flavours of pointer; I believe
the Data General MV series distinguish between `char *' and `other
pointer', as do PR1ME compilers.  One proposed architecture has a
different kind of pointer for each possible size datum.)
     
This peculiarity simplifies the compiler, often at the cost of some
run-time efficiency.  It also leads to several pitfalls.  In general,
if you write what you mean, you should be safe; and if you write
what the compiler does, you should also be safe.  (There is an
advantage to writing what you mean:  A good compiler may be able
to produce better code in such cases.  Unfortunately, there is a
disadvantage as well:  A poor or mediocre compiler will often
produce worse code.)
     
>>I know that some compilers take care of this and allow you to
>>still declare ch as a char. However, I note that K&R always declare
>>ch as an int in their examples. I would suppose that the compiler being
>>used requires the int declaration.
     
Then it is not a C compiler.
     
>>Since the conversion occurs by definition of the language, there is
>>no danger in declaring it an int
     
(other than possible confusion on the part of the programmer)
     
>>and this is commonly done in most C code.
     
As I mentioned in the `soundex debate', I do this myself, with some
reservations.
     
In article <547@chinet.UUCP> rlk@chinet.UUCP (Richard Klappal) writes:
>Balderdash!!!!!
     
Not at all.
     
>K&R declare all chars as ints so that routines that return EOF will
>work correctly regardless of whether chars are signed or unsigned
>in your hardware/software combination.
     
K&R, p. 127:
     
  type(c)    /* return type of ASCII character */
  int c;
  {
    if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
        return(LETTER);
    else if (c >= '0' && c <= '9')
        return(DIGIT);
    else
        return(c);
  }
     
p. 79:
     
  char buf[BUFSIZE];    /* buffer for ungetch */
  int  bufp = 0;    /* next free position in buf */
  ...
  ungetch(c)
  int c;
  {
    if (bufp > BUFSIZE)
        printf("ungetch: too many characters\n");
    else
        buf[bufp++] = c;
  }
     
(To be fair, an exercise on page 80 or so suggests extending ungetch()
to handle ungetch(EOF).)
     
p. 42:
     
  Since a function argument is an expression, type conversion also
  take place when arguments are passed to functions: in particular,
  char and short become int, and float becomes double.  This is
  why we have declared function arguments to be int and double even
  when the function is called with char and float.
     
>Your compiler is broken if it will not work as shown in the example,
     
Agreed.
     
>and if you define the arg as an int in the subroutine, you \'should\'
>cast the char arg to an int in the calling sequence.
     
Now *this* is (to borrow your word) balderdash.  If by this you
mean `for clarity, I think you should', then I will agree; if
you mean `for proper operation, in strict C compilers, you must',
to this I object: it is not so.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	jnet%"karl@haddock" 19-SEP-1986 21:48
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9316
          for JMS@ARIZMIS; Fri, 19-SEP-1986 21:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014472; 16 Sep 86 6:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024325; 16 Sep 86 5:30 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <86900053@haddock>
Date: 12 Sep 86 15:23:00 GMT
Nf-ID: #R:brl-smoke.ARPA:3594:haddock:86900053:000:1735
Nf-From: haddock!karl    Sep 12 11:23:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
BJORNDAS%CLARGRA@WISCVM.WISC.EDU (Sterling Bjorndahl) writes:
>>foo(ch)
>>char ch;  /* Or should this be "int ch;" because it gets promoted? */
     
haddock!karl (Karl Heuer) replies:     | drutx!qwerty (Brian Jones) replies:
>[int is better;] one should never     | >char ch is the correct declaration.
>declare formal arguments of [type     | >The compiler should handle pulling
>char, short, float, or array].  [But] | >the character portion.  Declaring
>your compiler is broken.              | >it 'int' is asking for trouble.
     
Well, now that's cleared up.  :-)
     
Actually, I think I may have spoken too quickly.  It *is* misleading to
declare a float or array formal parameter -- the compiler silently converts
it to a double or pointer declaration -- but char and short aren't affected
the same way, at least not here (SVR2 vax).
     
example:
foo(ch, sh, fl, ar) char ch; short sh; float fl; int ar[10]; { ... }
sizeof(fl)==sizeof(double) not sizeof(float); &fl is "double *" not "float *"
sizeof(ar)==sizeof(int *) not sizeof(int[10]); &ar is "int **" not "int(*)[]"
but, sizeof(ch)==sizeof(char) and &ch is "char *".
     
So maybe it is safe; I can't find a definitive statement in K&R.
     
However, I disagree that "declaring it 'int' is asking for trouble".  It may
or may not undergo sign extension, but that's true of any use of char.  The
actual argument *was* converted from char to int by the caller, so the value
of the (int) formal argument is predictable.  If it's declared "char" it has
a predictable value, but I'm not convinced it has a well-defined type.  In
any case (unless you were doing more than your posting implied) you have a
broken compiler.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"pdg%ihdev.uucp@BRL.ARPA" 20-SEP-1986 00:01
To:	JMS
Subj:	Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1027
          for JMS@ARIZMIS; Sat, 20-SEP-1986 00:01 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/20/86 at 01:50:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015431; 16 Sep 86 7:57 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025781; 16 Sep 86 7:35 EDT
From: "P. D. Guthrie" <pdg%ihdev.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <886@ihdev.UUCP>
Date: 14 Sep 86 21:09:14 GMT
To:       info-c@BRL-SMOKE.ARPA
>Or if you want a simple cpp macro:
>
>#define  isleapyear(year)   ((year)%4)
>
>Bob Devine
Or if you want a complex cpp macro
to return the number of days in a year......
#define num_day(x) ((x)%4 ? (x)%100 ? (x)%400 ? 366 : 355 : 356 : 355)

From:	ARPA%"rgenter@bbn-labs-b.ARPA" 20-SEP-1986 02:09
To:	JMS
Subj:	char vs. int in arg decls

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2204
          for JMS@ARIZMIS; Sat, 20-SEP-1986 02:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/20/86 at 04:02:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a020538; 16 Sep 86 10:40 EDT
Received: from labs-b.bbn.com by SMOKE.BRL.ARPA id a003555; 16 Sep 86 10:34 EDT
To: info-c@BRL-SMOKE.ARPA
cc: chris@maryland.ARPA
Subject: char vs. int in arg decls
Date: 16 Sep 86 10:23:43 EDT (Tue)
From: Rick Genter <rgenter@bbn-labs-b.ARPA>
     Yes, it will work to interchange (int) and (char) as the types of
function arguments, as long as you *never* use &, or *only* work on VAXen
(and similar-endian machines).  At my previous employer we had a late-night
hacker who had written a really nice screen editor.  One day I tried to port
it to the Sun.  Nothing worked (core dumped before clearing the screen).  I
started to track it down, then noticed things like:
        <...>
    add_char_to_line (':');        /* draw border */
        <...>
    add_char_to_line (c)
    {                /* no decl for c, so default to int */
        <...>
        ins_char_in_buffer (& c, & buf);
    }
    ins_char_in_buffer (cp, bufp)
    char *cp;
    BUF *bufp;
    {
        <...>
    }
Needless to say, this kind of coding was sprinkled throughout the source.
Dennis would have liked this guy; I said "lint" to him and he replied "?" :-).
     The moral of the story: say what you mean, even if it *usually* doesn't
matter.
--------
Rick Genter                 BBN Laboratories Inc.
(617) 497-3848                10 Moulton St.  6/512
rgenter@labs-b.bbn.COM  (Internet new)    Cambridge, MA   02238
rgenter@bbn-labs-b.ARPA (Internet old)    linus!rgenter%BBN-LABS-B.ARPA (UUCP)

From:	ARPA%"chris@maryland.ARPA" 20-SEP-1986 02:15
To:	JMS
Subj:	Re:  char vs. int in arg decls

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2374
          for JMS@ARIZMIS; Sat, 20-SEP-1986 02:15 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a027018; 16 Sep 86 16:16 EDT
Received: from mimsy.umd.edu by SMOKE.BRL.ARPA id a015628; 16 Sep 86 16:06 EDT
Received: by mimsy.umd.edu (5.9/4.7) id AA24294; Tue, 16 Sep 86 13:00:59 EDT
Date: Tue, 16 Sep 86 13:00:59 EDT
From: Chris Torek <chris@maryland.ARPA>
Message-Id: <8609161700.AA24294@mimsy.umd.edu>
To: info-c@BRL-SMOKE.ARPA, rgenter@bbn-labs-b.ARPA
Subject: Re:  char vs. int in arg decls
    From: Rick Genter <rgenter@labs-b.bbn.com>
    Yes, it will work to interchange (int) and (char) as the
    types of function arguments, as long as you *never* use &,
    or *only* work on VAXen (and similar-endian machines).
It will work at other times as well.
    I tried to port [code like the below] to the Sun.
        add_char_to_line (':');        /* draw border */
        add_char_to_line (c)
        {            /* no decl for c, so default to int */
            <...>
            ins_char_in_buffer (& c, & buf);
        }
        ins_char_in_buffer (cp, bufp)
        char *cp;
        BUF *bufp;
        {
            <...>
        }
This code is wrong, and lint will say so.  It is wrong not because
':' is an int, and add_char_to_line's parameter is therefore int,
but because add_char_to_line's parameter is declared as an int and
its address (type `int *') is passed to a function expecting type
`char *'.  Were add_char_to_line declared as
    add_char_to_line(c)
        char c;
    {
        ...
        ins_char_in_buffer(&c, &buf);
    }
the code would have been correct (even though the call to
add_char_to_line above passes ':', which has type `int': this is
another place where automatic promotion has odd effects).
    Dennis would have liked this guy; I said "lint" to him and
    he replied "?" :-).
Actually, I believe `?' is due to Kernighan.  (Anyone at You Know
Where care to comment?)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"Wilkinson@HI-MULTICS.ARPA" 21-SEP-1986 22:26
To:	JMS
Subj:	ttychars.h & ttydef.h

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3435
          for JMS@ARIZMIS; Sun, 21-SEP-1986 22:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/22/86 at 00:15:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005363; 22 Sep 86 1:12 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id aa15420; 22 Sep 86 0:56 EDT
Received: from hi-multics.arpa by AOS.BRL.ARPA id a005255; 22 Sep 86 0:54 EDT
Acknowledge-To:  Wilkinson@HI-MULTICS.ARPA
Date:  Sun, 21 Sep 86 23:44 CDT
From:  Wilkinson@HI-MULTICS.ARPA
Subject:  ttychars.h & ttydef.h
To:  info-c@BRL.ARPA
Message-ID:  <860922044422.464750@HI-MULTICS.ARPA>
     
I recently tried to compile the TVX editor on an Intel 286/310 XENIX 3
system.  The makefile.bsd refers to /usr/include/ttychars.h and
ttydef.h.  Neither of these headers are located anywhere on the system.
Does anyone know if the they are regpplaced by another header on a XENIX
system?
          Richard   {Wilkinson@HI-MULTICS.ARPA}

From:	ARPA%"Wilkinson@HI-MULTICS.ARPA" 21-SEP-1986 22:35
To:	JMS
Subj:	net.sources

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3523
          for JMS@ARIZMIS; Sun, 21-SEP-1986 22:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/22/86 at 00:26:52 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005365; 22 Sep 86 1:12 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id ab15420; 22 Sep 86 0:56 EDT
Received: from hi-multics.arpa by AOS.BRL.ARPA id a005257; 22 Sep 86 0:54 EDT
Acknowledge-To:  Wilkinson@HI-MULTICS.ARPA
Date:  Sun, 21 Sep 86 23:48 CDT
From:  Wilkinson@HI-MULTICS.ARPA
Subject:  net.sources
To:  info-c@BRL.ARPA
Message-ID:  <860922044811.920674@HI-MULTICS.ARPA>
     
I have noticed that many entries in INFO-C and other INFO- digests refer
to NET.SOURCES.  Is there any way that a mail address on an ARPA machine
can be connected to NET.SOURCES?
          Richard     {Wilkinson@HI-MULTICS.ARPA}
 PS Is there any other access to the sources form a PC over dial in line?

From:	ARPA%"LINNDR%VUENGVAX.BITNET@wiscvm.ARPA" 21-SEP-1986 22:59
To:	JMS
Subj:	Order of function argument evaluation

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3628
          for JMS@ARIZMIS; Sun, 21-SEP-1986 22:59 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/22/86 at 00:54:11 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005590; 22 Sep 86 1:47 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id ab15600; 22 Sep 86 1:28 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a005400; 22 Sep 86 1:24 EDT
Received: from (LINNDR)VUENGVAX.BITNET by WISCVM.WISC.EDU on 09/18/86
  at 23:11:41 CDT
Date:     Thu, 18 Sep 86 22:19 CST
From:        LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject:  Order of function argument evaluation
To:  info-c@BRL.ARPA
X-Original-To:  info-c@brl.arpa, LINNDR
     
>Does anyone know of a compiler for which the program below does NOT
>produce the output shown?
>       .
>       .       <program deleted>
>       .
>----- PROGRAM OUTPUT ---------------
>2,1,0
>3
>------------------------------------
It seems I can answer my own question; the Sargasso C compiler for the
DEC-10 under TOPS-10 produces
-----
0,1,2
     3
------
     
This sort of behavior is up to the compiler writer, isn't it?
-----------------------------------------------------------------------
David Linn
LINNDR%VUENGVAX.BITNET@WISCVM.WISC.EDU          ! Internet (I think)
...!psuvax1!vuengvax.bitnet!linndr              ! Usenet

From:	ARPA%"LINNDR%VUENGVAX.BITNET@wiscvm.ARPA" 21-SEP-1986 23:58
To:	JMS
Subj:	Evaluation of function arguments (w/ side-effects)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3924
          for JMS@ARIZMIS; Sun, 21-SEP-1986 23:58 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/22/86 at 01:52:37 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005826; 22 Sep 86 2:44 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a015843; 22 Sep 86 2:11 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a005742; 22 Sep 86 2:05 EDT
Received: from (LINNDR)VUENGVAX.BITNET by WISCVM.WISC.EDU on 09/18/86
  at 14:16:15 CDT
Date:     Thu, 18 Sep 86 14:03 CST
From:        LINNDR%VUENGVAX.BITNET@wiscvm.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject:  Evaluation of function arguments (w/ side-effects)
To:  info-c@BRL.ARPA
X-Original-To:  info-c@brl.arpa, LINNDR
     
Does anyone know of a compiler for which the program below does NOT
produce the output shown?
----------------------------------
/* order - program to demonstrate order of function argument evaluation */
/*      David Linn - Vanderbilt University - 1986                       */
main()
{
        int i;
     
        i = 0;
        auxfun(i++,i++,i++);
        printf("%d\n",i);
}
     
auxfun(a,b,c)
{
        printf("%d,%d,%d\n",a,b,c);
}
----- PROGRAM OUTPUT ---------------
2,1,0
3
------------------------------------
     
David Linn
LINNDR%VUENGVAX.BITNET@WISCVM.WISC.EDU          ! Internet (I think)
...!psuvax1!vuengvax.bitnet!linndr              ! Usenet

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 23-SEP-1986 16:35
To:	JMS
Subj:	Re: structure alignment question

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1819
          for JMS@ARIZMIS; Tue, 23-SEP-1986 16:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 17:23:49 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000338; 23 Sep 86 10:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016814; 23 Sep 86 9:36 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: structure alignment question
Message-ID: <7363@sun.uucp>
Date: 17 Sep 86 18:34:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Background:  Our architecture has the following data types and sizes:
> (fairly "standard" 32-bit architecture description, which could very well
> be CCI's Power 6; Harris (no relation) sells this machine under their own
> name)
>
> Question:  Should structures and unions always be aligned to 4-byte
>            boundaries?
> Consider:   Our portable C compiler aligns this structure as follows:
> ...
>         short a;        ->  byte 0
>         union aa
>         {
>            short bb;    ->  byte 4
>            char cc;
>         } dd ;
>         char c;         ->  byte 8
>
> I've been told that on a VAX, however, 'bb' is placed on byte 2 and
> 'c' is placed on byte 4.  Is this true?
     
Yes, at least in the 4.3BSD version of the compiler, although the other
versions are almost certainly not different enough to align the values
differently.
     
> How do other compilers handle this case?
     
Sun's 68000-family compiler does exactly the same thing, although
(obviously) "struct a"s can't be blindly copied between VAXes and Suns.
     
> Which way is "correct"?
     
K&R says:
     
    8.5 Structure and union declarations
     
    ...Each non-field member of a structure begins on an addressing
    boundary appropriate to its type...
     
K&R does not seem to say anything about the addressing boundaries
appropriate to structures or unions in the Reference Manual, but it implies
that the addressing boundary appropriate to a union, at least, is that of
the member with the most restrictive addressing boundary on page 174 of
chapter 8, where it suggests that in order to align a given structure on a
boundary more restrictive than its "natural" boundary, you place it in a
union with an object with the desired alignment boundary.
     
The ANSI C draft seems to say much the same thing, and gives little
additional detail.  (If it's stored somewhere not indexed under "alignment",
let me know; I only looked in the Index under "alignment".)
     
The 4.3BSD VAX C compiler (and, I suspect, all other UNIX VAX C compilers)
follow this rule for structures, as well; if you declare a structure
containing only one member, a "char", the size of the structure will be one
byte and the structure will be aligned only on a byte boundary.
     
In PCC, the minimum alignment requirement of a structure (or union) is given
by the #define constant "ALSTRUCT"; this is 8 (bits) in the VAX PCC and in
our PCC.  I suspect the person who did the compiler for the machine in
question may have gotten confused and figured that if the machine requires
4-byte alignment of "int"s, it also requires 4-byte alignment of "struct"s
and "union"s (the CCI Power 6 does require 4-byte alignment of "int"s, and
2-byte alignment of "short"s), and set ALSTRUCT to 32 (bits), not realizing
that this is a *minimum*, not *maximum* alignment requirement.
     
It may be too late to change it now, given that a lot of code has been
compiled for that machine and a lot of on-disk data structures built using
that alignment.  I'd at least try, though.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 23-SEP-1986 16:35
To:	JMS
Subj:	Re: putw return value

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2140
          for JMS@ARIZMIS; Tue, 23-SEP-1986 16:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 17:43:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000431; 23 Sep 86 10:42 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016847; 23 Sep 86 9:37 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: putw return value
Message-ID: <7364@sun.uucp>
Date: 17 Sep 86 18:42:41 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Question:  What should "putw" return?
>
> Our I/O library returns the error code for the "putw" operation, which is
> usually 0.   In perusing BSD4.2 and ATT5.2.2 source, I see the same
> functionality.
     
Which probably means it predates both of them, and worked that way in the
V7-vintage standard I/O library.  This would indicate it's probably supposed
to.
     
> Yet the man pages seem to indicate that "putw" should return the "word"
> written.
     
The trouble with returning the value written is that if you write the value
-1, this can't be distinguished from EOF (at least on UNIX implementations,
and others where EOF is -1), and unless you *know* that you won't be writing
that value, you have to call "ferror" on that stream to detect errors.
     
> Is there a discrepancy between the code and the documentation?
     
Well, if there isn't, how do you explain the fact that the code and
documentation disagree?  More likely, you meant "There is a discrepancy
between the code and the documentation; which is correct?" to which the
answer is, most likely, "The code, in this case; the code has been that way
for a long time, though several variations of UNIX, and 'fixing' it to agree
with the documentation would cause other problems."
     
> (The Perennial C test suite makes mention in a "bugs" section that the
> VAX 11/750 also returns "0" for putw in the particular test.)
     
Which is a very odd way of putting it; did the people who did that test
suite to work differently on a VAX-11/780, for instance?
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"levy%ttrdc.uucp@BRL.ARPA" 23-SEP-1986 17:31
To:	JMS
Subj:	Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3486
          for JMS@ARIZMIS; Tue, 23-SEP-1986 17:31 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 19:20:50 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029423; 23 Sep 86 10:10 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015875; 23 Sep 86 9:18 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <1193@ttrdc.UUCP>
Date: 16 Sep 86 23:34:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <34@vianet.UUCP>, devine@vianet.UUCP (Bob Devine) writes:
>Dave Lewis writes:
>> leapyear (year)
>> int year;
>> {
>>   if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
>>      return (1);
>>   else
>>      return (0);
>> }
>
>  While this works, it is overkill.  Unless you believe that your
>code will make it to the year 2100, a simple test for divisibility
>by 4 is sufficient.  If you really want an algorithm for all years,
>you then need to also test for years divisible by 4000...
>
...
>
>#define  isleapyear(year)   ((year)%4)
>
>Bob Devine
     
Butbutbut... whattabout code which deals with things that are of concern
over more than a few years' scope, such as positions of the heavenly bodies?
The code needn't last till the year 2100 to want to deal with things that
are going to happen then (only the printouts :-) ).  And what about birth
dates of very old people?
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy

From:	ARPA%"levy%ttrdc.uucp@BRL.ARPA" 23-SEP-1986 17:36
To:	JMS
Subj:	Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3667
          for JMS@ARIZMIS; Tue, 23-SEP-1986 17:35 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 19:27:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029468; 23 Sep 86 10:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015892; 23 Sep 86 9:18 EDT
From: "Daniel R. Levy" <levy%ttrdc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <1194@ttrdc.UUCP>
Date: 16 Sep 86 23:38:21 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <886@ihdev.UUCP>, pdg@ihdev.UUCP (P. D. Guthrie) writes:
>>Or if you want a simple cpp macro:
>>
>>#define  isleapyear(year)   ((year)%4)
>>
>>Bob Devine
>
>Or if you want a complex cpp macro
>to return the number of days in a year......
>
>#define num_day(x) ((x)%4 ? (x)%100 ? (x)%400 ? 366 : 355 : 356 : 355)
                                                       ^^^   ^^^   ^^^
     
Huh?
--
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
       go for it!              allegra,ulysses,vax135}!ttrdc!levy

From:	ARPA%"kpk%gitpyr.uucp@BRL.ARPA" 23-SEP-1986 17:47
To:	JMS
Subj:	Equality vs Assignment

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3762
          for JMS@ARIZMIS; Tue, 23-SEP-1986 17:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 19:36:39 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029523; 23 Sep 86 10:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016191; 23 Sep 86 9:24 EDT
From: kpk%gitpyr.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Equality vs Assignment
Message-ID: <2259@gitpyr.UUCP>
Date: 17 Sep 86 00:23:52 GMT
Keywords: Who has not been bitten
To:       info-c@BRL-SMOKE.ARPA
     
Who among us has not been bitten at least once by writing
     
if (x = 1) ...
     
when he/she meant
     
if (x == 1)
     
What I want to know is
     
Has anyone written a program to scan a C program and issue a warning message
for those lines where an assignment has occured in a conditional statement
(i.e. if, while, the third statement in a for loop)?
     
If anyone has written such a program, why not post it (or at least mail me a
copy)?
     
To any yacc and lex hacks: why not see if you can whip up such a program?

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 23-SEP-1986 17:58
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3926
          for JMS@ARIZMIS; Tue, 23-SEP-1986 17:58 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 19:42:02 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000278; 23 Sep 86 10:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a016728; 23 Sep 86 9:36 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <7362@sun.uucp>
Date: 17 Sep 86 18:03:23 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Balderdash!!!!!
> K&R declare all chars as ints so that routines that return EOF will
> work correctly regardless of whether chars are signed or unsigned
> in your hardware/software combination.
     
This is irrelevant to how *arguments to functions* are declared.  K&R
declares those variables into which "getc" or "getchar" store their values
as "int"s because the value of "getc" (and thus "getchar") *is* an "int".
This also has nothing to do, strictly speaking, with whether "char"s are
signed or unsigned.  In *either* case, storing the value of "getc" into a
"char" and comparing it with EOF will fail.  Assuming that EOF is -1 (as it
is in most, if not all, UNIX implementations of the standard I/O library),
then:
     
    If "char"s are signed, then reading in a character with the
    value '\377' (assuming 8-bit characters; perform appropriate
    translation for other character sizes) and assigning it to a
    "char" variable assigns a value to that variable that will
    be considered equal to -1.  Thus, a program looking for EOF
    will see one, and think it reached the end of the file.
     
    If "char"s are unsigned, then when "getc" encounters the end
    of the file, it will return -1, which when assigned to a "char"
    variable will give that variable a value equal to '\377' (again,
    assuming 8-bit characters; your mileage may vary).  This value
    will not be considered equal to -1, but will be considered
    equal to 255.  Thus, a program looking for EOF will never see it.
     
Declaring to argument to "foo" in the example given in previous postings
will not affect whether the program can properly detect end-of-file, unless
the result of "getc" is being passed to "foo" and "foo" is testing whether
it's an EOF.  If the result of "getc" is being passed to any routine, that
argument to that routine should be declared as "int" since the result of
"getc" is an "int".
     
> Your compiler is broken if it will not work as shown in the example,
> and if you define the arg as an int in the subroutine, you \'should\'
> cast the char arg to an int in the calling sequence.  The automatic
> promotion of char to integer only means that everything will probably
> work if you don't do the casting.
     
No, the automatic promotion of "char" to "int" is 100% equivalent to a
promotion using a "cast".  If you declare:
     
    char c = 'w';
     
then
     
    foo(c);
     
and
     
    foo((int)c);
     
are equivalent - if this isn't ANSI C or there is no function prototype
declarator in scope that declares the argument to "foo" as a "char".  If
this is ANSI C, and there is such a function prototype *declarator* in
scope, then the argument is *not* promoted automatically.  Note the use of
the word "declarator":
     
    void
    foo(ch)
        char ch;
    {
        ...
    }
     
    int
    main(argc, argv)
        int argc;
        char **argv;
    {
        char c = 'w';
     
        foo(c);
        ...
    }
     
will cause the promotion, but replacing the definition of "foo" with
     
    void
    foo(char ch)
    {
        ...
    }
     
will not cause the promotion, because in the first example when "foo" is
used it is declared as "void foo(...)", while in the second example it is
declared as "void foo(char)".
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	jnet%"NJG@CORNELLA" 23-SEP-1986 18:10
To:	JMS
Subj:	Re: wiscnet telnet line-mode revisited; CLIFF@UCBCMSA

Received: From BITNIC(MAILER) by ARIZMIS with RSCS id 4226
          for JMS@ARIZMIS; Tue, 23-SEP-1986 18:10 MST
Received: by BITNIC (Mailer X1.23b) id 3964; Tue, 23 Sep 86 21:07:09 EDT
Received: from CORNELLA(MAL) by BITNIC (Mailer X1.23b) id 3546;
Comment:      Tue, 23 Sep 86 21:02:01 EDT
Received: by CORNELLA (Mailer X1.23b) id 9339; Tue, 23 Sep 86 20:59:13 EDT
Date:         Tue, 23 Sep 86 20:43:59 EDT
Sender:       (NJG@CORNELLA) via List Processor <LISTSERV@BITNIC>
Reply-to:     <NJG@CORNELLA>
X-From:         Nick Gimbrone <NJG@CORNELLA>
From:         NJG@CORNELLA
Subject:      Re: wiscnet telnet line-mode revisited; CLIFF@UCBCMSA
To:           Joel Snyder <JMS@ARIZMIS> (Distribution: IBM-NETS)
In-Reply-To:  Message of Tue, 23 Sep 86  15:18 EDT from <EACUS@CUVMA>
     
It seems from my point of view that the VM of the future is VM/XA/SF.
While I cann't say what this version of VM will support in the future,
I can say that it does not support *CCS services today, nor does it
support ANY linemode access.  It has to be 3270 (in this case via the
passthru LDEV diag) or nothing under today's implementation of this
system.  While tomorrow may hold new and different answers (such as
*CCS), to me today says that Wiscnet, in this environment at least, is
severly limited by this constraint.  The only other alternative in this
environment for incoming services would be SIM3270 like solutions
(volunteers anyone?).

From:	ARPA%"notes%hcx1.uucp@BRL.ARPA" 23-SEP-1986 18:42
To:	JMS
Subj:	putw return value

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4410
          for JMS@ARIZMIS; Tue, 23-SEP-1986 18:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 20:12:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028264; 23 Sep 86 9:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014657; 23 Sep 86 8:55 EDT
From: notes%hcx1.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: putw return value
Message-ID: <102@hcx1.UUCP>
Date: 13 Sep 86 21:15:46 GMT
Sender: notes%hcx1.uucp@BRL.ARPA
Nf-ID: #N:hcx1:5500004:000:539
Nf-From: hcx1!daver    Sep 12 09:34:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
Question:  What should "putw" return?
     
Our I/O library returns the error code for the "putw" operation, which is
usually 0.   In perusing BSD4.2 and ATT5.2.2 source, I see the same
functionality.
     
Yet the man pages seem to indicate that "putw" should return the "word"
written.
     
Is there a discrepancy between the code and the documentation?
     
(The Perennial C test suite makes mention in a "bugs" section that the
VAX 11/750 also returns "0" for putw in the particular test.)
     
Dave Ray -- uucp: {ucf-cs|allegra}!novavax!hrshcx!hcx1!daver

From:	ARPA%"phnch%phuxc.uucp@BRL.ARPA" 23-SEP-1986 18:48
To:	JMS
Subj:	Re: Using SCANF with DOUBLE precision variables...

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 4520
          for JMS@ARIZMIS; Tue, 23-SEP-1986 18:48 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028651; 23 Sep 86 9:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015128; 23 Sep 86 9:03 EDT
From: "N.C. Hauth [Courtney]" <phnch%phuxc.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using SCANF with DOUBLE precision variables...
Message-ID: <65@phuxc.UUCP>
Date: 16 Sep 86 00:15:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Yes, there is a solution to your problem.  You have to use the scanf
with a long float. For example:
     
     
  sscanf(line,"%*1d %1d %6lf\n",&division_1,&dc1);
     
Happy Hunting.
Courtney

From:	edu%"jsm@vax1.ccs.cornell.edu" 23-SEP-1986 20:10
To:	JMS
Subj:	Keyboard redefinition function library

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4878
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028895; 23 Sep 86 9:47 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015685; 23 Sep 86 9:13 EDT
From: Jon Meltzer <jsm@vax1.ccs.cornell.edu>
Newsgroups: net.wanted,net.lang.c,net.micro.pc,net.micro
Subject: Keyboard redefinition function library
Message-ID: <163@vax1.ccs.cornell.edu>
Date: 16 Sep 86 18:26:53 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I'm looking for a toolbox, preferably in C, that will do this:
     
  - display foreign language alphabets (for example, Russian or Greek)
  - redefine the keyboard to allow user input in both the standard
    English alphabet and the alternate alphabets.
     
This is to be linked into a MSDOS application.
     
Please email responses.

From:	ARPA%"roy%amd.uucp@BRL.ARPA" 23-SEP-1986 20:10
To:	JMS
Subj:	COFF documentation

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5296
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000773; 23 Sep 86 10:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018347; 23 Sep 86 9:58 EDT
From: roy carlson <roy%amd.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: COFF documentation
Message-ID: <2987@amd.UUCP>
Date: 17 Sep 86 23:30:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
COFF (Common Object File Format) was documented in Chapter 9 of the
Transition Aids manual that was published at the time of introduction
of System V.  Is it described in the current System V documentation?
Where?
     
So far, eight people at AT&T Customer Service, Bell Laboratories, and
800/828-UNIX have not been able to help me find it.
     
Thanks....   Roy Carlson   ...ihnp4!amdcad!amd!roy

From:	ARPA%"rcd%nbires.uucp@BRL.ARPA" 23-SEP-1986 20:10
To:	JMS
Subj:	Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5498
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:10 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000891; 23 Sep 86 11:00 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018912; 23 Sep 86 10:07 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <573@opus.nbires.UUCP>
Date: 18 Sep 86 05:17:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1193@ttrdc.UUCP>, levy@ttrdc.UUCP (Daniel R. Levy) writes:
> In article <34@vianet.UUCP>, devine@vianet.UUCP (Bob Devine) writes:
[example of leap-year test covering 4, 100, 400]
> >  While this works, it is overkill.  Unless you believe that your
> >code will make it to the year 2100, a simple test for divisibility
> >by 4 is sufficient...
> Butbutbut... whattabout code which deals with things that are of concern
> over more than a few years' scope, such as positions of the heavenly bodies?
     
Butbutbut...the argument to the procedure was an int year, apparently CE.
So if you're worrying about getting it absolutely correct, don't forget the
Gregorian correction!  Leap years are child's play next to that one.
     
No, really, look:  FIRST, decide the domain for the function.  THEN design
the function to work well in that domain.  IF someone tells you that the
function doesn't work for his problem (outside the domain of the function),
tell him that hammers don't work for sawing wood, either.
--
Dick Dunn    {hao,ucbvax,allegra,seismo}!nbires!rcd    (303)444-5710 x3086
   ...Are you making this up as you go along?

From:	ARPA%"notes%hcx1.uucp@BRL.ARPA" 23-SEP-1986 20:11
To:	JMS
Subj:	structure alignment question

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5052
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029262; 23 Sep 86 10:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014646; 23 Sep 86 8:55 EDT
From: notes%hcx1.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: structure alignment question
Message-ID: <101@hcx1.UUCP>
Date: 13 Sep 86 21:15:33 GMT
Sender: notes%hcx1.uucp@BRL.ARPA
Nf-ID: #N:hcx1:5500003:000:881
Nf-From: hcx1!daver    Sep 12 06:51:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
Background:  Our architecture has the following data types and sizes:
     
               byte   -- 1 byte
           short  -- 2 bytes
           int    -- 4 bytes
           long   -- 4 bytes
           *ptr   -- 4 bytes
     
Question:  Should structures and unions always be aligned to 4-byte
           boundaries?
     
Consider:   Our portable C compiler aligns this structure as follows:
     
     struct a
     {
        char b ;        ->  byte 0
        union aa
        {
           short bb;    ->  byte 4
           char cc;
        } dd ;
        char c;         ->  byte 8
     } d;
     
I've been told that on a VAX, however, 'bb' is placed on byte 2 and
'c' is placed on byte 4.  Is this true?  How do other compilers handle
this case?  Which way is "correct"?  If there is sufficient interest,
I will post a summary of responses.
     
Dave Ray  --  uucp:  {ucf-cs|allegra}!novavax!hrshcx!hcx1!daver

From:	ARPA%"franka%mmintl.uucp@BRL.ARPA" 23-SEP-1986 20:11
To:	JMS
Subj:	Re: Calendar Functions

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5631
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000967; 23 Sep 86 11:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018967; 23 Sep 86 10:08 EDT
From: franka%mmintl.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Calendar Functions
Message-ID: <1805@mmintl.UUCP>
Date: 15 Sep 86 18:38:56 GMT
Keywords: Calendars
To:       info-c@BRL-SMOKE.ARPA
     
In article <1229@loral.UUCP> dml@loral.UUCP (Dave Lewis) writes:
>daysinmonth (month, year)
>int month, year;
>{
>  if (month == 2)          /* Is it February?             */
>     if (leapyear (year))  /* If so, is it a leap year?   */
>    return (29);       /* 29 days in Feb in leap year */
>     else
>    return (28);       /* 28 days if not              */
>  else{
>     if (month > 7)        /* Is it August -> December?   */
>    month++;           /* Invert even/odd state if so */
>     if (month & 1)        /* Odd months have 31 days     */
>    return (31);
>     else
>    return (30);       /* Even months have 30 days    */
>  }
>}
     
This is ok, but it is easier to use a table:
     
daysinmonth(month, year)
int month, year)
{
   int monthlengths[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
     
   if (month == 2 && leapyear(year)) {
      return (29);
   } else {
      return monthlengths[month - 1];
   }
}
     
(Comments are left as an exercise for the reader.)
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

From:	ARPA%"rbutterworth%watmath.uucp@BRL.ARPA" 23-SEP-1986 20:11
To:	JMS
Subj:	Re: Equality vs Assignment

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6120
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:11 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 21:56:19 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001731; 23 Sep 86 11:29 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019722; 23 Sep 86 10:21 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Equality vs Assignment
Message-ID: <3234@watmath.UUCP>
Date: 18 Sep 86 19:39:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> Who among us has not been bitten at least once by writing
> if (x = 1) ...
> when he/she meant
> if (x == 1)
> What I want to know is
>
> Has anyone written a program to scan a C program and issue a warning message
> for those lines where an assignment has occured in a conditional statement
> (i.e. if, while, the third statement in a for loop)?
     
There is already such a program:  lint.
Here's the modified section you want from the BSD 4.2 version of
/usr/src/usr.bin/lint/lpass1.c.
     
contx( p, down, pl, pr ) register NODE *p; register *pl, *pr; {
     
    *pl = *pr = VAL;
    if (p->in.type==UNDEF) down=VAL; /* (void) cast */
     
    switch( p->in.op ){
     
    case NOT:
        *pl=down;
    case ANDAND:
    case OROR:
        if (hflag&&(p->in.right->in.op==ASSIGN))
            werror("Possible unintended assignment");
    case QUEST:
        *pr = down;
    case CBRANCH:
        if (hflag&&(p->in.left->in.op==ASSIGN))
            werror("possible unintended assignment");
        break;
     
    case SCONV:
    case PCONV:
    ...

From:	jnet%"karl@haddock" 23-SEP-1986 20:11
To:	JMS
Subj:	Re: enum function bug?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4725
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a028859; 23 Sep 86 9:45 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015666; 23 Sep 86 9:13 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: enum function bug?
Message-ID: <86900054@haddock>
Date: 16 Sep 86 23:03:00 GMT
Nf-ID: #R:sdchema.sdchem.UUCP:299:haddock:86900054:000:1950
Nf-From: haddock!karl    Sep 16 19:03:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
sdchem!tps (Tom Stockfisch) writes:
>I want to pass a pointer to function returning [enum bool] to a function,
>but lint says I'm not doing it right.
     
Cc and lint disagree about what "enum" really means.  Lint calls it a new
datatype, but cc thinks it's just a synonym for "int" in some contexts.
Apparently the distinction is lost somewhere between lint pass 1 and pass 2.
Yes, it's a bug.
     
#if SOAPBOX
I think cc should also treat them as distinct types.  (The easy-going days
of "everything is an int" are over, folks.  Egad, now you have to *declare*
functions, even if you're just passing the result to another function!)
If you need an int context, you should cast the enum into an int.  (Though
switch(enum) should still work, provided all the case labels are enums.)  I
suppose an enum actually specifies an *ordered* set, so "++" and "--" are
acceptable, as well as "+" and "-", but they work as with pointers: enum+int
== enum, enum-enum == int.
     
This proposal would make your "enum bool" less useful, but "typedef int bool"
(which is what I always use) is just as good anyway.
     
The only addition I'd like to make is to allow one to declare an array to be
subscripted by an enum: "double foo[enum color]; foo[RED] = 1.0; ...".  Such
an array would *not* be subscriptable by int (though of course an integral
expression could be cast into enum color and then used as a subscript).  This
would often obviate the need for a constant NCOLORS, and make the code more
palatable to both cc and lint.  A smart compiler could make a special case
for sparse enums (enum color { RED=0, BLUE=100 }), as long as it's guaranteed
that each valid instance of the enum type may be used as a subscript.
     
The idea could be extended to allow any datatype, e.g. "int foo[char]" (which
would subscript from -128 to 127 on a pdp11 or vax), but this is less useful.
#endif /* SOAPBOX */
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 23-SEP-1986 20:11
To:	JMS
Subj:	Re: Bug in 4.2 cc code generator (result type of assignment)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5234
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000545; 23 Sep 86 10:46 EDT
Received: from USENET by SMOKE.BRL.ARPA id a017936; 23 Sep 86 9:52 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Bug in 4.2 cc code generator (result type of assignment)
Message-ID: <7367@sun.uucp>
Date: 17 Sep 86 20:23:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
Fixed - in part - in 4.3.  The code it generates for the first loop, for
comparison; it's the same as in 4.2:
     
L19:
    cvtbl    *-12(fp),r0
    bicl2    $-256,r0
    cvtlb    r0,-13(fp)
    incl    -12(fp)
    cmpb    -13(fp),-5(fp)
    jeql    L20
     
And the code for the second loop:
     
L24:
    movl    -12(fp),r0
    incl    -12(fp)
    cvtbl    (r0),r0
    bicl2    $-256,r0
    cvtlb    r0,-13(fp)
    cmpb    -13(fp),-5(fp)
    jeql    L25
     
Well, at least it's correct this time, but it's *still* less efficient; moving
the pointer into "r0" first is pointless.  Turning on the optimizer doesn't
help; it does collapse the "cvtbl" and "bicl2" into a "movzbl", but it
doesn't figure out that
     
    movl    -12(fp),r0
    incl    -12(fp)
    movzbl    (r0),r0
     
is better done as
     
    movzbl    *-12(fp),r0
    incl    -12(fp)
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"rcd%nbires.uucp@BRL.ARPA" 23-SEP-1986 20:11
To:	JMS
Subj:	Re: enum function bug?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5400
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:11 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a000851; 23 Sep 86 10:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a018895; 23 Sep 86 10:06 EDT
From: Dick Dunn <rcd%nbires.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: enum function bug?
Message-ID: <572@opus.nbires.UUCP>
Date: 18 Sep 86 05:08:59 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900054@haddock>, karl@haddock writes:
> Cc and lint disagree about what "enum" really means.  Lint calls it a new
> datatype, but cc thinks it's just a synonym for "int" in some contexts.
>...
> #if SOAPBOX
> I think cc should also treat them as distinct types.  (The easy-going days
> of "everything is an int" are over, folks...
     
The problem goes a little deeper than this.  Consider that if an enum is
defined in a .h file, and that header file is used in two separate .c
files, you have (by some annoyingly reasonable argument) two separate
types!  [Substitute canonical discussion of name equivalence vs structural
equivalence of types here.]
     
If lint were to make a name-equivalence type check, you couldn't use enums
across modules.  I suspect that it is not currently equipped to do the
structural-equivalence test, although it's not that hard to do since
there's no nesting or recursive structure in enums.  But even then,
explicit assignment of ordinals to enum elements, where the ordinals might
be constant expressions (yes, bleah, but read on...) adds more worms to the
can.  Consider something silly like:
     
----------foo.h:
typedef enum {a=XCONST, b, c} etype;
     
----------gleep.c
#define    YCONST    3
#define    XCONST    YCONST+YCONST
#include "foo.h"
etype xyzzy = b;
     
----------mumble.c
#define    YCONST    3
#define    XCONST    2*YCONST
#include "foo.h"
extern etype xyzzy;
     
Do the types of xyzzy in mumble.c and gleep.c match?  They are provably
both enums with the same type name and the same constituents with the same
values, but...
     
If you admit that name equivalence is inadequate (which I believe) but that
this example carries structural equivalence too far (which I also believe,
I think), then where do you draw the line?
--
Dick Dunn    {hao,ucbvax,allegra,seismo}!nbires!rcd    (303)444-5710 x3086
   ...Are you making this up as you go along?

From:	jnet%"mcg@omepd" 23-SEP-1986 20:12
To:	JMS
Subj:	Aggregate Declarations without Braces

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4967
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:12 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a029237; 23 Sep 86 10:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014561; 23 Sep 86 8:54 EDT
From: Steven McGeady <mcg@omepd>
Newsgroups: net.lang.c
Subject: Aggregate Declarations without Braces
Message-ID: <137@omepd>
Date: 12 Sep 86 18:25:32 GMT
Keywords: ANSI X3J11, aggregate, initializers
To:       info-c@BRL-SMOKE.ARPA
     
     
A question has arisen among some colleagues of mine as to whether the
following lines of C code are valid declarations:
     
    char c[1] = 'a';
    int a[1] = 1;
    int b[2] = 1;
    typedef struct { int a; } fakeint; fakeint i = 1;
     
The following is a message (from me, incidentally), trying to defend
this practice as legal, despite a dramatic lack of (direct) support from
either K&R or X3J11.
     
As pointed out below, this works on PCC (both PCC and PCC-2/QCC, as though
it mattered).
     
Any informed comments on this subject would be welcomed, preferably
directed via mail to me, rather than to the net.  I promise to digest
the responses and post them.
     
S. McGeady
Oregon Microcomputer Engineering
Intel, Corp
     
tektronix!psu-cs!omepd!mcg, sun!verdix!inteloa!omepd!mcg
     
     
---------- Forwarded Message
     
On page 198 of K&R, in section 8.6:
     
    "When the declared variable is an aggregate ... then the
     initializer consists of a brace-enclosed, comma-separated list
     of initializers ...
     
     Braces may be elided as follows.  ... If, however, the initializer
     does not begin with a left brace, then only enough elements from
     the list are taken to account for the members of the aggregate ..."
     
Admittedly this is weak justification (that is, in a context whose applicability
could be argued), but it does establish a precedent for elision of braces.
The only issue is whether one can elide the braces around a single initializer
at the top level.
     
For this I rely on the syntax description:
     
in K&R:
    init-declarator:
        declarator initializer
     
    initializer:
        = expression
        = { initializer-list }
        = { initializer-list , }
     
    initializer-list:
        expression
        initializer , initializer-list
        { initializer-list }
     
This implies that
     
    declarator = expression ;
     
is syntactically legal (The Standard says the same thing in a much more
confusing way.  So we're arguing about semantics of intialization
of aggregates here, not the syntax.  I argue that K&R, in the above
paragraph, does not rule out elision of the outermost set of braces
if the initializer-list is a single element.  I argue further that
the Standard, in introducing the word "shall", and mucking with the
language with respect to elision of braces, has confused the issue
without clearly resolving it.  Finally, I agrue that the lack of mention
of this change from PCC in the Rationale means that X3J11 hasn't thought
of this issue yet.
     
Furthermore, stretching a bit, I can argue that this is very useful.
Take the example:
     
    typedef struct { int a; } fakeint;
     
    ...
     
    fakeint i = 1;
     
This kind of 'conveniance' has precedent in the 'char foo[] = "abcdef";'
shortcut.
     
Whatever else is true, the answer isn't clearly spelled out in either K&R
or the Standard.  PCC allows it, at least some existing code uses it
(even outside our test suite).
     
If there's a good reason why it shouldn't be in there, I will, of course,
entertain the idea of backing it out.  But at this stage I can't think of
anything that leaving it in will break.
     
------------ End of Forwarded Message

From:	edu%"furuta@mimsy.umd.edu" 23-SEP-1986 20:21
To:	JMS
Subj:	[adobe!foley@decwrl.dec.com: Re: dvi2ps, bitmaps and font cachei

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6224
          for JMS@ARIZMIS; Tue, 23-SEP-1986 20:20 MST
Received: from WASHINGTON.ARPA by wiscvm.wisc.edu on 09/23/86 at 22:06:09 CDT
Return-Path: <furuta@mimsy.umd.edu>
Received: from mimsy.umd.edu by WASHINGTON.ARPA with TCP; Mon 22 Sep 86
 17:12:14-PDT
Received: by mimsy.umd.edu (5.9/4.7) id AA00528; Sun, 21 Sep 86 15:07:31 EDT
Date: Sun, 21 Sep 86 15:07:31 EDT
From: Richard Furuta <furuta@mimsy.umd.edu>
Message-Id: <8609211907.AA00528@mimsy.umd.edu>
To: laser-lovers@washington.arpa
Subject: [adobe!foley@decwrl.dec.com: Re: dvi2ps, bitmaps and font cacheing]
ReSent-Date: Tue 23 Sep 86 18:15:58-PDT
ReSent-From: Richard Furuta <Furuta@WASHINGTON.ARPA>
ReSent-To: Laser-Lovers: ;
ReSent-Message-ID: <12241352198.10.FURUTA@WASHINGTON.ARPA>
     
From: adobe!foley@decwrl.dec.com (Matt Foley)
Date: 10 Sep 1986 1833-PDT (Wednesday)
To: Per Westerlund <caip!seismo!enea!chalmers!per@uw-beaver.arpa>
Cc: foley@decwrl.dec.com, furuta@mimsy.umd.edu
Subject: Re: dvi2ps, bitmaps and font cacheing
In-Reply-To: Per Westerlund <decwrl!caip!seismo!enea!chalmers!per@uw-beaver> /
        Mon, 1 Sep 86 17:19:54 -0200.
             <8609011519.AA06949@chalmers.UUCP>
     
- The big bitmaps can be much more compactly represented,
  cf. *gf <-> *pxl. Would it not be possible to send a
  PostScript program that builds the bitmap, prints the
  character and then releases the memory used by the bitmap?
  Alternatively, there could be a similar interpreter in the
  prolog, and a compact description could be sent instead.
     
I am not personally familiar with dvi2ps, but I believe it downloads
TeX characters as PostScript bitmap fonts.  This requires that the
character description data be contained in VM, and indeed you could get
VM overflow with huge fonts.  There are two basic solutions:
1.    don't send the data as font characters, just send an imagemask
properly positioned on the page;
2.    send the data in compressed form, with a /BuildChar procedure
that invokes a decompression routine.  Since the PostScript environment
is interpretted (vs. compiled), this might be a little slow, but it
will work.  However, the fonts produced by dvi2ps probably don't allow
for compressed data.  If you are a PostScript programmer, you could
probably hack their filter and prologue so it would.
     
- Maybe big characters can be represented as outline fonts; it
  should be possible to trace the border pixels of a big
  traditional letter bitmap and make a path out of it. This
  does not work for patterned bitmaps of course.
     
This would be even better, of course.  One of the advantages of Adobe's
approach is the compactness of font data compared to bitmaps.  It also
could be made to work for patterned fills of the characters.  This
would take me a while to explain; email me if you ever have the
pressing need to do so.
     
- What is beeing done on font-cacheing?
  If big bitmaps can be more compactly represented, it should
  almost always be possible to print any single page.
     
It is not the font cache that's filling up, but the VM where the font
DEFINITION is being stored.  The font cache is automatically bypassed
if a character glyph is too big.
     
It is possible to use an ordinary font definition, but not
download the individual character definition until it's needed.  Just
download the "top level" of the font (apprx. 1300 bytes) and do the
'definefont', then when you need the 'A' character, do a save, download
the char data for 'A', invoke '(A) show', then do the corresponding
'restore'.  This would allow you to diddle VM to your heart's content.
The problem is you spend lots of time downloading bit maps repeatedly,
because these very large characters won't be cached so you have to
download their defs each time. But it will work.
     
By the way, a similar approach may be used with ordinary-sized fonts to
fake up a system that appears to let you have a very large number
of fonts present in the printer without taking
up much VM.  The font cache does not obey the save/restore mechanism, so
one can (a) create the top level of the font; (b) do a save;
(c) download the char defs;
(d) 'show' them at the needed point size [possibly into the null
device -- see 'setnulldevice'] so as to force their glyphs into the
font cache; then (e) do the corresponding restore, which recovers the VM
used to store the char data.  The characters are available at the point
size and orientation at which they were cached, because the high-level
font dict is still present in VM, but the char defs are not taking up
any VM.  Of course, this approach completely kills PostScript's usual
ability to arbitrarily scale a font; you also need to be aware that the
use of another font might cause your first font to be flushed out of
the font cache.  If you wish to use this approach, you will probably
want to have a /BuildChar proc that yells for help if asked to print a
char for which it has no def.  Recovery from such an error would be
nearly impossible on a single-channel device; on the other hand, a
system like the Lino100, which has a disk drive, could automatically
load from disk via a different channel, without interfering with data
already in the stdin channel.
     
I'm getting rather esoteric here.  If you have further questions,
please feel free to address them directly to me.
     
[Note to moderator:  Rick, if you think this would be of general
interest to the newsgroup, feel free to post it.]
     
--Matt Foley, Cust. Supt. Eng.
ADOBE SYSTEMS INCORPORATED
decwrl!adobe!foley
"adobe!foley"@glacier.stanford.edu
(415) 852-0271
     
PostScript is a registered trademark of Adobe Systems Incorporated.
     
     

From:	ARPA%"LLACROIX%carleton.edu@CSNET-RELAY.ARPA" 23-SEP-1986 21:28
To:	JMS
Subj:	Re: Re: Missing VMS 4.4 VAXCRT[lg].OLB files

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 7120
          for JMS@ARIZMIS; Tue, 23-SEP-1986 21:28 MST
Received: from SRI-KL.ARPA by wiscvm.wisc.edu on 09/23/86 at 23:12:52 CDT
Received: from CSNET-RELAY.ARPA by SRI-KL.ARPA with TCP; Fri 19 Sep 86
 04:13:26-PDT
Received: from carleton.edu by csnet-relay.csnet id ab17097; 19 Sep 86 4:49 EDT
Date:     Thu, 18 Sep 86 23:48 CDT
From:     Les LaCroix <LLACROIX%carleton.edu@CSNET-RELAY.ARPA>
To:       leichter-jerry@YALE.ARPA, info-vax@SRI-KL.ARPA
Subject:  Re: Re: Missing VMS 4.4 VAXCRT[lg].OLB files
     
In a recent note to jayb%zeus.tek.csnet@csnet-relay.csnet (cc to info-vax)
regarding VAXCRTL object libraries vs the corresponding shraed images,
you state:
     
> There is NO advantage to using the object library, rather than the shareable
> library, except in rather rare cases (linking an image that will work on older
> versions of VMS, for example - and even then, just having the C library in
> object form is often not enough.  Better to ship object files of your code and
> link on the target system if this is the problem.)  Using the shareable images
> has a number of advantages, including smaller images and the fact that images
> pick up bug fixes to the support routines without re-linking.
     
Two small objections here:
     
1) You get smaller images and RTL bug fixes, all w/o relinking.  You also get
an extra image to be activated every time you run your application.  In most
cases that's not worth worrying about.  Then there are those rare times when it
*does* matter.
     
2) In addition to the bug fixing that comes along with VMS updates, it's not
unheard of to see new bugs introduced.  Yes, even from DEC, and yes in the
RTLs.  A product of my employer's was hit with such a problem with VMS 4.4.
Fortunately the problem was only annoying and had no consequential impact
for our customers.  Even more fortunate is the fact that these kinds
of problems are very rare.
     
Conclusion: know your options and the implications, then use the shared
images unless you have a *really* good reason to do otherwise.
     
>     Further, Is there a command to given to  create the .OLB from the .EXE
>     libraries.
> No.  .EXE libraries contain executable code; .OLB's, object code.  You would
> need an inverse to the linker.
     
True, but sometimes you can fake it by creating a Shared Image Library which
contains references to the shared images you want to link against. Your program
still gets linked to the shared images, but you can usually avoid a Linker
Options file.  Unfortunately, there have been documented problems in the past
with shared image libraries which refer to VAXCRTL.EXE.  I don't know if
the problems still exist in VMS 4.4.
     
Les LaCroix                |   csnet:  llacroix@carleton.edu
SPSS, Inc.                 |   uucp:   ...{ihnp4,decvax}!stolaf!ccnfld!llacroix
402 Washington Street      |           ...ihnp4!gargoyle!spsspyr!lacroix
Northfield, MN 55057-2027  |
     
"A dog is a dog until he faces you.  Then he is Mr. Dog." - haitian farmer

From:	jnet%"karl@haddock" 23-SEP-1986 21:52
To:	JMS
Subj:	Re: Char vs. Int

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7560
          for JMS@ARIZMIS; Tue, 23-SEP-1986 21:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/23/86 at 23:41:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001794; 23 Sep 86 11:31 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020081; 23 Sep 86 10:27 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Char vs. Int
Message-ID: <86900057@haddock>
Date: 18 Sep 86 13:31:00 GMT
Nf-ID: #R:brl-smoke.ARPA:3770:haddock:86900057:000:416
Nf-From: haddock!karl    Sep 18 09:31:00 1986
Posted: Thu Sep 18 09:31:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
jl42@andrew.cmu.edu writes:
>I have always been under the impression that a CHAR variable and an INT
>variable were the same in 'C'
     
No, they're not.  An expression of type "char" will be converted to "int"
at the drop of a hat, but they are not identical.  (Neither are arrays and
pointers the same thing, and for much the same reasons.)
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock" 23-SEP-1986 21:58
To:	JMS
Subj:	Re: Calendar Functions (simpler lea

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7655
          for JMS@ARIZMIS; Tue, 23-SEP-1986 21:58 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001839; 23 Sep 86 11:32 EDT
Received: from USENET by SMOKE.BRL.ARPA id a020098; 23 Sep 86 10:27 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler lea
Message-ID: <86900058@haddock>
Date: 18 Sep 86 13:54:00 GMT
Nf-ID: #R:vianet.UUCP:34:haddock:86900058:000:996
Nf-From: haddock!karl    Sep 18 09:54:00 1986
Posted: Thu Sep 18 09:54:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
vianet!devine (Bob Devine) writes:
>Dave Lewis writes:
>>   if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
>
>While this works, it is overkill.  Unless you believe that your
>code will make it to the year 2100, a simple test for divisibility
>by 4 is sufficient.
     
It looks like you're assuming the test is for the current year.  For a
general-purpose algorithm (as per the original request), Dave's code is
correct.  If the input is a 32-bit signed integer measuring seconds since
1970 (a common implementation of time_t), then the range is contained in
(1900,2100) and the simpler algorithm works -- but this is probably not a
good assumption to make; an unsigned long will reach past 2100.
     
>If you really want an algorithm for all years,
>you then need to also test for years divisible by 4000...
     
I believe the quadrimillennium correction was never officially adopted.
It's not accounted for in cal(1).
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"mash%mips.uucp@BRL.ARPA" 23-SEP-1986 22:24
To:	JMS
Subj:	Re: Re: structure alignment question

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8115
          for JMS@ARIZMIS; Tue, 23-SEP-1986 22:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 00:14:48 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002368; 23 Sep 86 12:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022650; 23 Sep 86 11:15 EDT
From: John Mashey <mash%mips.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structure alignment question
Message-ID: <696@mips.UUCP>
Date: 19 Sep 86 08:54:00 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <7363@sun.uucp> guy@sun.uucp (Guy Harris) writes:
>> ...in reply to:
>> Question:  Should structures and unions always be aligned to 4-byte
>>            boundaries? <....example follows:...>
>
>Yes, at least in the 4.3BSD version of the compiler, ....
Actually, some might be aligned to 8-byte boundaries, on machines that
like doubles on such boundaries.
     
>K&R does not seem to say anything about the addressing boundaries
>appropriate to structures or unions in the Reference Manual, but it implies
>that the addressing boundary appropriate to a union, at least, is that of
>the member with the most restrictive addressing boundary on page 174 of
>chapter 8, where it suggests that in order to align a given structure on a
>boundary more restrictive than its "natural" boundary, you place it in a
>union with an object with the desired alignment boundary.
>
>The ANSI C draft seems to say much the same thing, and gives little
>additional detail.  (If it's stored somewhere not indexed under "alignment",
>let me know; I only looked in the Index under "alignment".)
>
Guy is correct, as usual.  The key info is (trickily) found under sizeof:
ANSI C, section C.3.3.4 The sizeof operator, says:
"... When applied to an operand that has structure or union type, the result is
the total nubmer of bytes in such a member considered as a member of an array,
including whatever internal and trailing paddiing might be needed to align each
member in such an array properly.... Another use of the sizeof operator is to
compute the number of members in an array:  sizeof array / sizeof array[0];
     
Note that the net combination requires that:
    a) Any union or structure must be aligned on the most restrictive
    boundary of any of its members, including member structures.
    b) It's size must be rounded up to a multiple of that same size.
Anything else causes the above usage of sizeof to be unrobust in the face of:
    struct { ..... } array[number];
     
Note that for speed, it is usually best to align data items on the most
restrictive boundaries, even if a specific machine implementation doesn't
really require it.  Lots of machines let words be on arbitrary boundaries,
but you pay for it in speed, if not now, then later, as CPUs come
to have wider data paths.  A perfect case is the surprise going from
680[01]s to 68020s: if you let long's be aligned on 2-byte, but not necesarily
4-byte boundaries, and if you want to convert to 68020s without converting
data saved in such format, you lose performance you might have had.
(Of course, some space is saved; in practice, it's seldom large.)
     
Question for the audience: what implementations thought ahead about potential
64-bit buses and aligned doubles on 8-byte boundaries? try this:
main(argc, argv) {
    struct x {
        long i;
        double j;
    } y;
    printf("%x,%x, %d\n", &y.i, &y.j, sizeof y);
}
--
-john mashey    DISCLAIMER: <generic disclaimer, I speak for me only, etc>
UUCP:     {decvax,ucbvax,ihnp4}!decwrl!mips!mash, DDD:      408-720-1700, x253
USPS:     MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086

From:	jnet%"karl@haddock" 23-SEP-1986 22:43
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8420
          for JMS@ARIZMIS; Tue, 23-SEP-1986 22:43 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002454; 23 Sep 86 12:07 EDT
Received: from USENET by SMOKE.BRL.ARPA id a022992; 23 Sep 86 11:19 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <86900059@haddock>
Date: 18 Sep 86 23:27:00 GMT
Nf-ID: #R:brl-smoke.ARPA:3594:haddock:86900059:000:1402
Nf-From: haddock!karl    Sep 18 19:27:00 1986
Posted: Thu Sep 18 19:27:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
chinet!rlk writes:
>In article <2233@gitpyr.UUCP> thomps@gitpyr.UUCP writes:
>>[text deleted --kwh]
>Balderdash!!!!!
     
This is not a very informative comment following a long quote.  Do you
mean that all of the quoted text is balderdash, or just the part you attempt
to refute in the next paragraph?  (I think everything Ken said was correct.)
     
>K&R declare all chars as ints so that routines that return EOF will
>work correctly regardless of whether chars are signed or unsigned
>in your hardware/software combination.
     
That's a valid reason for declaring SOME variables "int" -- namely those
that will be used to hold the result of getchar() et al -- but this has no
relevance to the question at hand.  (And whether char is signed or not is
irrelevant to both questions.)
     
>Your compiler is broken if it will not work as shown in the example,
>and if you define the arg as an int in the subroutine, you \'should\'
>cast the char arg to an int in the calling sequence.  The automatic
>promotion of char to integer only means that everything will probably
>work if you don't do the casting.
     
What does "probably" mean in this context?  If uncasted char is automatically
promoted to int, and the argument is declared int, how can it fail?  Are you
saying that the cast should be present for documentation/aesthetic reasons?
     
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock" 23-SEP-1986 22:47
To:	JMS
Subj:	Re: Help with BDSC float

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8670
          for JMS@ARIZMIS; Tue, 23-SEP-1986 22:47 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002491; 23 Sep 86 12:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023007; 23 Sep 86 11:19 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Help with BDSC float
Message-ID: <86900060@haddock>
Date: 18 Sep 86 23:33:00 GMT
Nf-ID: #R:mit-eddie.MIT.EDU:3211:haddock:86900060:000:785
Nf-From: haddock!karl    Sep 18 19:33:00 1986
Posted: Thu Sep 18 19:33:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
mit-eddie!moore (Andrew Moore) writes:
>My BDS C compiler doesn't want to accept  %6.3f  (example) in printf's.
>Nor does it accept "float" as a data type declaration.  On some compilers,
>I don't have to declare a variable as "float" before using it:
>    printf("Float: %6.3f", (5.0/4.0));
     
I don't understand your last sentence.  Declare what variable?  I presume
you mean that on some compilers, you can write floating-point expressions
without the keyword "float".
     
>...but in BDS, this is not accepted.  How is "float" different in BDS C?
     
The most likely answer is simply that you have a compiler that doesn't
support floating point.  (I presume "double" doesn't work either?)  Talk to
your vendor.
     
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

From:	ARPA%"wyatt%cfa.uucp@BRL.ARPA" 23-SEP-1986 22:49
To:	JMS
Subj:	Re: Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 8793
          for JMS@ARIZMIS; Tue, 23-SEP-1986 22:49 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002554; 23 Sep 86 12:11 EDT
Received: from USENET by SMOKE.BRL.ARPA id a023562; 23 Sep 86 11:29 EDT
From: Bill Wyatt <wyatt%cfa.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <256@cfa.UUCP>
Date: 19 Sep 86 15:55:57 GMT
Posted: Fri Sep 19 11:55:57 1986
To:       info-c@BRL-SMOKE.ARPA
     
[ mass quantities of simple vs. complete leap year calculations arguments ]
>
> No, really, look:  FIRST, decide the domain for the function.  THEN design
> the function to work well in that domain.  IF someone tells you that the
> function doesn't work for his problem (outside the domain of the function),
> tell him that hammers don't work for sawing wood, either.
     
Trouble is, in the real world, your function will be re-used outside its
proper domain, and by someone who has no idea your function is even needed,
much less not suited for his/her application. If the cost of doing it right
is small, then do it right. The trouble with that sentence is the problem of
determining the cost of not doing it right.
--
     
Bill    UUCP:  {seismo|ihnp4}!harvard!talcott!cfa!wyatt
Wyatt   ARPA:  wyatt%cfa.UUCP@harvard.HARVARD.EDU

From:	jnet%"karl@haddock" 23-SEP-1986 22:54
To:	JMS
Subj:	Re: need help with a delcaration

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8912
          for JMS@ARIZMIS; Tue, 23-SEP-1986 22:54 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003089; 23 Sep 86 12:33 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024120; 23 Sep 86 11:41 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: need help with a delcaration
Message-ID: <86900061@haddock>
Date: 19 Sep 86 16:39:00 GMT
Nf-ID: #R:brl-smoke.ARPA:3594:haddock:86900061:000:361
Nf-From: haddock!karl    Sep 19 12:39:00 1986
Posted: Fri Sep 19 12:39:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
umcp-cs!chris (Chris Torek) writes:
>C does not have a character type. ... [It] has what I call `expression
>types' and `storage types'.  There is a character storage type, but there
>is no character expression type.
     
In the conventional terminology: C has no rvalues of type char.
     
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 23-SEP-1986 23:07
To:	JMS
Subj:	Re: Re: structure alignment question

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 9091
          for JMS@ARIZMIS; Tue, 23-SEP-1986 23:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 00:52:43 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003191; 23 Sep 86 12:38 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024383; 23 Sep 86 11:46 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structure alignment question
Message-ID: <7447@sun.uucp>
Date: 19 Sep 86 17:58:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> >Yes, at least in the 4.3BSD version of the compiler, ....
> Actually, some might be aligned to 8-byte boundaries, on machines that
> like doubles on such boundaries.
     
By way of clarification, my "yes" was to "yes, the VAX aligns the 'union'
containing a 'short' and a 'char' on a 2-byte, not a 4-byte, boundary."
Structures need not always be aligned on the most restrictive boundary
required by the architecture or imposed by the compiler on scalar data, but
it must align a structure so that all its members are aligned, so that it is
aligned on the most restrictive boundary of all its members.
     
PCC starts out aligning structures on a "minimum alignment required by all
structures" boundary, and then marches through the member list strengthening
the alignment requirement as necessary.  I presume the reason that the
"minimum alignment required by all structures" is not hardcoded to "one
byte" is that there might be machines that prefer, or require, structures
aligned more stringently.  E.g., a machine might have
"register+displacement" addressing where the displacement is in units of
8-byte quadwords, or the implementor might have decided to speed up
structure assignment by using some trick that can copy data faster if it's
aligned on a quadword boundary.  It was *not* intended for machines with
more stringent restrictions on scalar alignment, as the aforementioned march
handles that problem already.
     
> Note that for speed, it is usually best to align data items on the most
> restrictive boundaries, even if a specific machine implementation doesn't
> really require it.  Lots of machines let words be on arbitrary boundaries,
> but you pay for it in speed, if not now, then later, as CPUs come
> to have wider data paths.
     
Yes, the VAX PCC aligns "int"s and "long"s on 4-byte boundaries, even though
the machine can fetch longwords off such a boundary; there is, I'd bet, a
performance penalty for such a fetch.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	jnet%"karl@haddock" 23-SEP-1986 23:09
To:	JMS
Subj:	Re: Orphaned Response

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 9325
          for JMS@ARIZMIS; Tue, 23-SEP-1986 23:09 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 00:59:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003208; 23 Sep 86 12:39 EDT
Received: from USENET by SMOKE.BRL.ARPA id a024454; 23 Sep 86 11:47 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Orphaned Response
Message-ID: <86900055@haddock>
Date: 16 Sep 86 23:20:00 GMT
Nf-ID: #R:hadron.UUCP:559:haddock:86900055:000:1427
Nf-From: haddock!karl    Sep 16 19:20:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
hadron!jsdy (Joe Yao) writes:
>In article <1761@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
>>[haddock!karl (Karl Heuer) writes:]
>>>For another, the types might be
>>>unknown, if they are arguments in a macro; in this case I would want the
>>>macro to work on void as well as valued expressions.
>>This case is not covered by my suggestion.  I find it hard to imagine doing
>>it, however.
>When would one try to pass a void "value" to anything, whether or
>not it is a macro?  (I agree, that is  v e r y  hard to imagine!)
     
Your comment "whether or not it is a macro" suggests that you are assuming
the macro has function semantics, in which case it would not be useful to
hand it a void expression.  But not all macros have this property; consider
    #define new(T) ((T *)malloc(sizeof(T)))
which expects a type rather than an expression.
     
What I was thinking of (I don't have a specific instance) was a macro whose
return value has the same type as its arguments -- like generic MIN and MAX.
To concoct something that would accept void arguments, you could write
    #define foo(e1,e2) (SOMETHING ? (SOMETHING,(e1)) : (SOMETHING,(e2)))
I suppose.  Of course, the user must be aware that this is a macro, and that
its value is void when its arguments are.  In any case, I agree that it's
not all that likely, but it's not inconceivable.
     
Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint

From:	ARPA%"bert%infoswx.uucp@BRL.ARPA" 24-SEP-1986 00:24
To:	JMS
Subj:	Re: Help with BDSC float

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0378
          for JMS@ARIZMIS; Wed, 24-SEP-1986 00:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 02:13:27 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003453; 23 Sep 86 12:49 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025235; 23 Sep 86 12:04 EDT
From: bert%infoswx.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Help with BDSC float
Message-ID: <5000001@infoswx>
Date: 16 Sep 86 15:08:00 GMT
Nf-ID: #R:mit-eddie.MIT.EDU:3211:infoswx:5000001:000:1229
Nf-From: infoswx.UUCP!bert    Sep 16 10:08:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
About float in BDSC. (I'm talking about the CPM version that I have used)
     
Basically, BDSC does not have float.  There is a library of float
functions available that will allow you to do some floating point
operations with some difficulty.  To use them, you must declare a 5 char
array for each float variable.  You assign it a value with a function.
You play with it with other functions.  Then you can print it with
a special printf routine that you must link in specifically to handle
the %e and %f control strings.  But don't try to use fprintf if you
link the float printf stuff in, it doesn't work on the version I have.
     
examples:
     
char float1[5], float2[5];
buf[30];
     
atof(float1, "10.0");        /* set float to 10.0 */
     
fpadd(float1, float1, atof(float2, "5.0");     /* add 5 to it */
     
fpsub(float1, float1, atof(float2, "2.0");     /* subtract 2 from it */
     
fpmult(float1, float1, float2);            /* multiply it by 5 */
     
fpdiv(float1, float1, float2);            /* divide it by 5 */
     
ftoa(buf, float1);                /* make ascii (%e format) */
     
printf("%f %s\n", float1, buf);                /* print it (%f, %e) */
     
Note that the result is left in the first arg on all the arith operations.
Also, they all return char * to the result.
     
Bert Campbell.

From:	ARPA%"guest%csustan.uucp@BRL.ARPA" 24-SEP-1986 01:23
To:	JMS
Subj:	String input problems in curses

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1077
          for JMS@ARIZMIS; Wed, 24-SEP-1986 01:23 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 03:16:31 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003592; 23 Sep 86 12:51 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025307; 23 Sep 86 12:06 EDT
From: Chris Rhodes <guest%csustan.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: String input problems in curses
Message-ID: <183@csustan.UUCP>
Date: 20 Sep 86 20:49:12 GMT
To:       info-c@BRL-SMOKE.ARPA
     
( eat me. )
     
The following relates to curses on a Pyramid 90x running 4.2bsd:
     
while designing a particular application using curses, the UNIX
terminal control package, I have found that *none* of the string
input functions work - not gets, scanf, or wscanw or any of the
other curses input routines.  Most of these give me a "Bus error
(core dumped)" message (one which I have generally gotten sick of)
but scanf() loses input, e.g.:
     
scanf("%s",buffer);
printf("%s",buffer);
     
prints nothing.
     
I ended up having to do a 'while ( (c = getchar()) != `\n`);'
structure which works, but I fear that I may be doing something
wrong which may cause other mysterious bugs.
     
Does this problem sound familiar with anybody else?  Or is it
just another of those unique, mysterious curses bugs which can
be cured only by removing all traces of the program and spending
a month writing BASIC programs on a RSTS machine?
     
thanks in advance,
     
/*  Chris Rhodes / Shooting Shark
 *  Currently cowering behind lll-crg!csustan!guest
 *  real uucp : lll-crg!csuh!shark -or- lll-crg!ptsfa!harlie!shark
 *  My opinions *are* those of csustan!  Yeah, they made me spokesman, ah,
 */ president of the university!  Yeah, *that's* the ticket!

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 24-SEP-1986 01:30
To:	JMS
Subj:	Re: Re: structure alignment question

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1175
          for JMS@ARIZMIS; Wed, 24-SEP-1986 01:30 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 03:20:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004309; 23 Sep 86 13:12 EDT
Received: from USENET by SMOKE.BRL.ARPA id a025941; 23 Sep 86 12:19 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structure alignment question
Message-ID: <7479@sun.uucp>
Date: 21 Sep 86 22:18:48 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> The last 68000 compiler I used aligned strings on WORD boundaries.
> This would cost one byte per string, half the time. But there was a
> big speed payoff: I could do word operations in my strnlen, strncmp,
> strncpy, and whatever other string processing functions I happened to
> write.
     
Oh, really?
     
    char    string1[] = "foo";
    char    string2[] = "xfoo";
     
    return(strcmp(string1, string2 + 1));
     
If you can do this with straightforward word operations, and not take a
performance hit relative to byte-by-byte copies, you've got a really clever
"strcmp".  (Hint:  my 68010 manual does *NOT* mention any "swap bytes"
instruction, and the 68010 doesn't have a barrel shifter.)
     
Furthermore,
     
    char    string3[128+1];
     
    strcpy(string3, string1);
     
would, if it copied a word at a time, have to deal both with words of the
form
     
    00xx
     
(when it recognizes a word of that form, it should stop *before* copying it
and stuff a zero byte at the end of the target) and of the form
     
    xx00
     
(when it recognizes a word of that form, it should stop *after* copying it).
     
> All this code ported to a Sun-3 no (apparent) problem, but crashed on a
> Sun-2, because the SUN compiler allocated strings in a totally stingy
> 1-byte alignment.
     
It would also have crashed on the first example given above *regardless* of
whether the Sun compiler allocated strings on 1-byte or 2-byte boundaries.
If your routines couldn't handle arguments off byte boundaries, I'm sorry,
but they were *not* correct implementations of the string routines!
*!NOTHING*!  guarantees that the arguments to the string routines always
point to the *first* byte of a string.  Furthermore, nothing guarantees that
"strcat" and "strncat" will always do aligned copies, even if the arguments
always point to the first byte of a string; the reason for this should be
obvious.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"caesar%ge-dab.uucp@BRL.ARPA" 24-SEP-1986 01:34
To:	JMS
Subj:	RE: Equality vs Assignment

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1264
          for JMS@ARIZMIS; Wed, 24-SEP-1986 01:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 03:27:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004542; 23 Sep 86 13:21 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026204; 23 Sep 86 12:25 EDT
From: "Robert J. Caesar Jr." <caesar%ge-dab.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: RE: Equality vs Assignment
Message-ID: <374@ge-dab.UUCP>
Date: 21 Sep 86 15:59:38 GMT
Keywords: = or ==
To:       info-c@BRL-SMOKE.ARPA
     
I don't have a programs, but this might help as a future solution.
In the project I am involved with, we use:
     
#define is    ==
#define isn_t !=
     
This has helped us avoid a lot of headaches. The code reads a
little easier too.
     
if (x is 1)
     
if (y isn_t x)
     
     
--
   Bob Caesar
   General Electric SCSD                      caesar@static.dab.ge.com
   PO Box 2500 Room 4336                      (904) 258-3043
   Daytona Beach, Florida 32015            ...!mcnc!ge-rtp!ge-dab!caesar

From:	ARPA%"atbowler%watmath.uucp@BRL.ARPA" 24-SEP-1986 01:40
To:	JMS
Subj:	Functions that never return

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1337
          for JMS@ARIZMIS; Wed, 24-SEP-1986 01:40 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004579; 23 Sep 86 13:22 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026595; 23 Sep 86 12:34 EDT
From: "Alan T. Bowler [SDG]" <atbowler%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Functions that never return
Message-ID: <3274@watmath.UUCP>
Date: 20 Sep 86 08:56:43 GMT
Posted: Sat Sep 20 04:56:43 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <86900032@haddock> you write:
>
>Note: In my earlier posting I came to the tentative conclusion that the "dead
>function" concept (a function which never returns, e.g. exit) would probably
>not be sufficiently useful to be worth adding a new builtin type.  I haven't
>changed my mind; I just want to point out some possibilities.
>
There are library functions "exit", "longjmp", "abort" that never
return.  Most implementations will have quite a few more,
and using these users will normally construct a number of others.
A larger program is very likely to have several error handlers
that print a message, do some cleanup and longjmp back to
a good restart point.
   On the observation that this is a "goto" type of action
why not just recycle the "goto" keyword and allow it in function
type declarations. e.g.
    extern goto exit(int);
     
1) It does not require a new keyword.
2) It is compatible with the existing language
3) It is reasonably obvious what it means
4) The compiler gets the optimizing hint it needs
   without requiring a flow analysis that goes outside the
   function boundaries (i.e. you don't have to sacrifice
   separate compilation to have an optimising compiler take
   advantage of it).
5) On a similar note it gets rid of the damned
   /*NOTREACHED*/
   by associating the property of not returning with
   the function instead of with every call to the function.

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 24-SEP-1986 01:53
To:	JMS
Subj:	Re: COFF documentation

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1452
          for JMS@ARIZMIS; Wed, 24-SEP-1986 01:53 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 03:36:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004617; 23 Sep 86 13:24 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026662; 23 Sep 86 12:36 EDT
From: guy%sun.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: COFF documentation
Message-ID: <7468@sun.uucp>
Date: 20 Sep 86 04:54:43 GMT
Posted: Sat Sep 20 00:54:43 1986
To:       info-c@BRL-SMOKE.ARPA
     
> COFF (Common Object File Format) was documented in Chapter 9 of the
> Transition Aids manual that was published at the time of introduction
> of System V.  Is it described in the current System V documentation?
> Where?
>
> So far, eight people at AT&T Customer Service, Bell Laboratories, and
> 800/828-UNIX have not been able to help me find it.
     
Well, if eight people working for various arms of AT&T can't find it, it
seems like it's time for a shakeup.  I found it with no trouble; at least
for S5R2 on the VAX and the iAPX286, it's in the "UNIX(TM) System V -
Release 2.0 Support Tools Guide", April 1984, 307-108, Issue 2, under the
heading of (surprise!) "The Common Object File Format".  Maybe they've
misplaced it since then.  If so, it's *definitely* time for a shakeup....
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"eectrsef%titan.uucp@BRL.ARPA" 24-SEP-1986 02:03
To:	JMS
Subj:	Re: Expression sequencing query

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 1596
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:03 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 03:52:04 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004663; 23 Sep 86 13:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a026717; 23 Sep 86 12:39 EDT
From: " SA User Serv." <eectrsef%titan.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Expression sequencing query
Message-ID: <111@titan.UUCP>
Date: 19 Sep 86 18:54:27 GMT
Keywords: Bugs
Posted: Fri Sep 19 14:54:27 1986
To:       info-c@BRL-SMOKE.ARPA
     
In article <760@oakhill.UUCP> tomc@oakhill.UUCP (Tom Cunningham) writes:
>    /* a = b + b + b */
>    a = ((b=1),b) + ((b=2),b) + ((b=3),b)
>
>I expected the result to be 6.  With the Microsoft C compiler and the
>compiler on the Sun 3, the result is 9.  Apparently the parenthetical
>assignments are all getting done before the comma and addition.  Any
>thoughts on this?
>
Tom, I agree, the result should be 6, as defined by K&R, but I have tried
it on a Cyber 180/830 running NOS VE, and get 9, also AT&T's 3B5
System V, gets 9, But A copy of the Small-C Compiler that I have ported
comes up with a 6.  Does this seam to imply that Small-C is a better
(more accurate) compiler, than those that AT&T produces?  I find it
totally unaccepable that AT&T can not produce a working C compiler.
I would like everyone to test it on as many machines as prossible, to
see if we can find as least ONE other besides Small-C, that works.
     
Mike Stump  ucbvax!hplabs!csun!csunb!beusemrs

From:	ARPA%"lindsay%tl-vaxa.uucp@BRL.ARPA" 24-SEP-1986 02:08
To:	JMS
Subj:	Re: functions that don't return

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1727
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:08 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:00:56 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004694; 23 Sep 86 13:26 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027053; 23 Sep 86 12:44 EDT
From: Don Lindsay <lindsay%tl-vaxa.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: functions that don't return
Message-ID: <28@tl-vaxa.UUCP>
Date: 20 Sep 86 02:30:46 GMT
Posted: Fri Sep 19 22:30:46 1986
To:       info-c@BRL-SMOKE.ARPA
     
There has been some discussion about functions that never return (e.g exit).
It was suggested that if a compiler could be told about this, then it
could generate better code.
     
In fact, these functions sometimes DO return (and in that case, the compiler
had better have allowed for that).
     
For example, a storage allocator may decide to exit, because his caller has
reached some limit. But, the developer of this storage allocator wishes to
write a test program, and she wants the test program to exercise this
feature. The test program can be more powerful, and more convenient, and easier
to document and use, if it can make the "exit" routine return !
     
Similarly, a program may detect an unusual condition, and call a handler
for it. It is more general if it is the handler which decides whether or
not to return. (Perhaps one would link in different handlers under different
circumstances.) It is quite common for people to write over-specified
programs, where the mainline "knows" what kind of handler is out there.
The existence of a new function type would mostly encourage such limited
thinking.
     
Don Lindsay

From:	ARPA%"franka%mmintl.uucp@BRL.ARPA" 24-SEP-1986 02:12
To:	JMS
Subj:	Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1792
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:12 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:05:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005096; 23 Sep 86 13:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027291; 23 Sep 86 12:49 EDT
From: Frank Adams <franka%mmintl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <1821@mmintl.UUCP>
Date: 18 Sep 86 22:06:20 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <886@ihdev.UUCP> pdg@ihdev.UUCP (55224-P. D. Guthrie) writes:
>Or if you want a complex cpp macro
>to return the number of days in a year......
>
>#define num_day(x) ((x)%4 ? (x)%100 ? (x)%400 ? 366 : 355 : 356 : 355)
     
If you want a macro which gives the right answer, you might instead try:
     
#define num_day(x) ((x)%4 ? (x)%100 ? (x)%400 ? 366 : 365 : 366 : 365)
     
Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108

From:	ARPA%"chris%umcp-cs.uucp@BRL.ARPA" 24-SEP-1986 02:20
To:	JMS
Subj:	Re: Re: structure alignment question

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1867
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:20 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:11:28 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005141; 23 Sep 86 13:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027524; 23 Sep 86 12:54 EDT
From: Chris Torek <chris%umcp-cs.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structure alignment question
Message-ID: <3527@umcp-cs.UUCP>
Date: 21 Sep 86 20:11:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <1705@mcc-pp.UUCP> tiemann@mcc-pp.UUCP (Michael Tiemann) writes:
>... The last 68000 compiler I used aligned strings on WORD boundaries.
>This would cost one byte per string, half the time. But there was
>a big speed payoff: I could do word operations in my strnlen,
>strncmp, strncpy, and whatever other string processing functions
>I happened to write. ... all this "fast" code actually runs slower
>than a "dumb" byte-copy model [on a Sun-3], because the 68020 faults
>itself to death reading in 32-bit words on odd boundaries, and
>doesn't run at all on a Sun-2 because the 68010 can read odd words.
     
(Does the 68020 really fault?  I thought it just did two bus accesses.)
     
It is not difficult to do copies in word mode iff the strings
are aligned:
     
    | Sun mnenonics
     
    | /*LINTLIBRARY*/
    | strcpy(to, from) char *to, *from; { *to = *from; return (to); }
    | /*UNTESTED!*/
        ENTRY(strcpy)
    TO    =    a0        | I think this works
    FROM    =    a1
        movl    sp@(4),TO    | to
        movl    sp@(8),FROM    | from
    | I forget if this is legal.  If not, copy to d0 first.
        btst    #0,TO        | test for odd destination
        bnes    odd0        | handle odd dst, unknown src
        btst    #0,FROM        | test for odd source
        bnes    hardway        | handle even dst, odd src
     
    | both addresses are even; do a fast strcpy
    fastcopy:
        movw    FROM@+,d0    | grab entire word
        movw    d0,d1        | need to test high byte first
        lsrw    #8,d1        | throw out low byte
        beqs    fastend        | if high byte zero, go terminate dst
        movw    d0,TO@+        | copy entire word
        tstb    d0        | and see if we are now done
        bnes    fastcopy    | do more if not
        movl    sp@(4),d0    | set return value
        rts            | and return
    fastend:
        movql    #0,d0
        movb    d0,TO@        | terminate destination string
        movl    sp@(4),d0    | set return value
        rts            | and return
     
    odd0:
        btst    #0,FROM        | test for odd source
        beqs    hardway        | handle odd dst, even src
        movb    FROM@+,TO@+    | copy one byte to make even
        bnes    fastcopy    | and do rest with fast copy
        movl    sp@(4),d0    | set return value
        rts            | and return
     
    | one address is even, the other odd, so do it a byte at a time.
    hardway:
        movl    TO,d0        | set return value
    hardloop:
        movb    FROM@+,TO@+    | copy ...
        bnes    hardloop    | until we copy a null
        rts            | return
     
I wonder, though, if this is truly faster.  Should not a movb/bnes
pair run in loop mode?  (Perhaps not; `dbcc' loops do, though, and
one could use a dbra surrounded by a bit of extra logic.)  Machine
dependent `fast' code is often CPU dependent as well, and one must
be prepared to modify marked inner loops when moving among implem-
entations of one architecture.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:    seismo!umcp-cs!chris
CSNet:    chris@umcp-cs        ARPA:    chris@mimsy.umd.edu

From:	ARPA%"tiemann%mcc-pp.uucp@BRL.ARPA" 24-SEP-1986 02:27
To:	JMS
Subj:	Re: Re: structure alignment question

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 1982
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:27 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:18:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005174; 23 Sep 86 13:56 EDT
Received: from USENET by SMOKE.BRL.ARPA id a027914; 23 Sep 86 13:00 EDT
From: Michael Tiemann <tiemann%mcc-pp.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structure alignment question
Message-ID: <1706@mcc-pp.UUCP>
Date: 22 Sep 86 14:31:39 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <7479@sun.uucp>, guy@sun.uucp (Guy Harris) writes:
> > The last 68000 compiler I used aligned strings on WORD boundaries.
> > This would cost one byte per string, half the time. But there was a
> > big speed payoff: I could do word operations in my strnlen, strncmp,
> > strncpy, and whatever other string processing functions I happened to
> > write.
>
> Oh, really?
>
>     char    string1[] = "foo";
>     char    string2[] = "xfoo";
>
>     return(strcmp(string1, string2 + 1));
>
> If you can do this with straightforward word operations ...
> [ ... USW ... ]
> *!NOTHING*!  guarantees that the arguments to the string routines always
> point to the *first* byte of a string.  Furthermore, nothing guarantees that
> "strcat" and "strncat" will always do aligned copies, even if the arguments
> always point to the first byte of a string; the reason for this should be
> obvious.
> --
>     Guy Harris
>     {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
>     guy@sun.com (or guy@sun.arpa)
     
What I meant was... There are times when I *can* (can-to can-to can-to)
guarantee that I am refering to the first byte of a string. Sure,
when I am doing SUB-string operations I have to be prepared to
pay the price, but if I happen only to want to do STRING operations,
where I *always* refer *only* to the string as a whole, then it
sure would be nice to be rewarded for passing that extra knowledge
on to my compiler.
     
When I don't know what I'm dealing with, I use strcmp, strcat, etc,
(and I expect them do make pessimistic decisions).
I wrote my own C routines "fmove", "fzero" which are like
"bcopy" and "bzero", except I only call them when I know I'll
be using word aligned things. Also, "fcmp" depends on the fact that a
word-aligned string is terminated by a null word (too much to
ask of a compiler to do that: possible (2*sizeof(int)-1 byte overhead),
but if they're two of MY strings, I call it.
     
The point is, a word aligned string does not seem to be too much
to ask for, and the performance improvement IS noticable:
Lets be hypothetical for a moment:
     
int lookup(s)
     char *s;
{
    int where;
     
    switch (*(int *)s) {
      case 0x41424300:        /* "abc" */
    return ABC;
      case 0x78797a00:        /* "xyz" */
    return XYZ;
      default:
    /* must look up in symbol table... */
    do { ... };
    return where;
    }
}
     
Keep your reserved words < 4 characters and off you go!
No flames about "portability": these were handled by a little
emacs function (generates hex and ascii comment for short strings),
and each emacs (VAX, SUN, whatever) has its own version.
     
"A little knowledge is a dangerous thing"... programmers should
*never* learn about machine architectures: they will only want to
write fast code...
     
I hope that this time I have clarified my position: everybody can
now say I'm wrong (of course I am) or right.
     
Michael
tiemann@mcc.com
     
"I'm that C programmer your mother warned you about"

From:	ARPA%"hoffman%hdsvx1.uucp@BRL.ARPA" 24-SEP-1986 02:32
To:	JMS
Subj:	C preprocessor wanted

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2084
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:32 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:23:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006340; 23 Sep 86 14:41 EDT
Received: from USENET by SMOKE.BRL.ARPA id a000293; 23 Sep 86 13:46 EDT
From: hoffman%hdsvx1.uucp@BRL.ARPA
Newsgroups: net.wanted.sources,net.lang.c
Subject: C preprocessor wanted
Message-ID: <562@hdsvx1.UUCP>
Date: 21 Sep 86 20:47:01 GMT
To:       info-c@BRL-SMOKE.ARPA
     
We have gotten quite addicted to using the C-preprocessor ("CPP") for
pre-processing of non-C files.  It's a great way to turn a clumsy
language into something readable.  But our C compiler may soon be
replaced by a compiler in which the preprocessor phase cannot be
called separately.  So we will probably wind up writing our own
version of it.  But I hope that someone in net land can save me this
trouble.
     
I would be very happy to receive any C source programs which either
entirely or partially implement the #define and #include statements.
(#ifdef and others are nice, but we don't need them.)  But it has to
be in C -- this is a VMS, not a UNIX implementation, so don't assume
the existence of any UNIX-special functions.
     
Thanks in advance.
     
--
 Richard Hoffman                | "Oh life is a wonderful cycle of song,
 Schlumberger Well Services     |     A medley of extemporanea.
 hoffman%hdsvx1@slb-doll.csnet  | And Love is a thing that can never go wrong
 PO Box 2175, Houston, TX 77252 | ... And I am Marie of Roumania." --D. PARKER

From:	jnet%"karl@haddock" 24-SEP-1986 02:34
To:	JMS
Subj:	Re: structure alignment question

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2154
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:34 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:24:47 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005265; 23 Sep 86 14:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028589; 23 Sep 86 13:14 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: structure alignment question
Message-ID: <86900062@haddock>
Date: 22 Sep 86 13:15:00 GMT
Nf-ID: #R:hcx1:5500003:haddock:86900062:000:881
Nf-From: haddock!karl    Sep 22 09:15:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
>In article <1705@mcc-pp.UUCP> tiemann@mcc-pp.UUCP (Michael Tiemann) writes:
>>The last 68000 compiler I used aligned strings on WORD boundaries. ...
>>There was a big speed payoff: I could do word operations in [strncpy, etc.]
     
Wrong!  Even if strings are word-aligned, substrings (e.g. "p+1") will not
be.  (Unless the chars themselves are word-aligned, in which case your space
penalty is a factor of two instead of a half byte.)
     
umcp-cs!chris (Chris Torek) writes:
>It is not difficult to do copies in word mode iff the strings are aligned:
>[example of a strcpy() that considers four alignment cases]
     
Even if the strings are word-aligned, you have to test for a null *byte*
(not a zero word); my guess is that the extra manipulation inside the loop
will make it slower than a byte-by-byte copy.
     
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

From:	jnet%"karl@haddock" 24-SEP-1986 02:42
To:	JMS
Subj:	Re: Re: Calendar Functions (simpler

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 2258
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:31:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005326; 23 Sep 86 14:02 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028611; 23 Sep 86 13:15 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Re: Calendar Functions (simpler
Message-ID: <86900063@haddock>
Date: 22 Sep 86 13:22:00 GMT
Nf-ID: #R:cfa.UUCP:256:haddock:86900063:000:336
Nf-From: haddock!karl    Sep 22 09:22:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
cfa!wyatt (Bill Wyatt) writes:
>If the cost of doing it right is small, then do it right.
     
I knew someone who wrote a calendar program, complete with quadrimillennium
correction, in assembly language on a machine that was scheduled to be
junked in a month!
     
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

From:	ARPA%"gwyn@BRL.ARPA" 24-SEP-1986 02:47
To:	JMS
Subj:	Re:  putw return value

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2434
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:47 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:35:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010045; 23 Sep 86 17:31 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a007152; 23 Sep 86 17:10 EDT
Date:     Tue, 23 Sep 86 17:07:25 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       notes%hcx1.uucp@BRL.ARPA
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  putw return value
Message-ID:  <8609231707.aa09483@VGR.BRL.ARPA>
     
There have been various versions of putw() on UNIX systems.
Some returned the word written or EOF on failure, which was
ambiguous.  Somebody then decided that putw() should return
0 on success, EOF on failure.  However, the implementation
didn't follow the new spec.  SVR3 has it that putw() should
return ferror() or EOF on failure.  I think this is the
same as 0 or EOF.  My feeling is that you should ignore the
return value of putw() since there's no telling what it
will be next week, and use ferror() to detect an error.

From:	jnet%"karl@haddock" 24-SEP-1986 02:51
To:	JMS
Subj:	Re: String input problems in curses

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2586
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:51 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:39:59 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005367; 23 Sep 86 14:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028631; 23 Sep 86 13:15 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: String input problems in curses
Message-ID: <86900065@haddock>
Date: 22 Sep 86 14:09:00 GMT
Nf-ID: #R:csustan.UUCP:183:haddock:86900065:000:1286
Nf-From: haddock!karl    Sep 22 10:09:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
csustan!guest (Chris Rhodes) writes:
>while designing a particular application using curses, the UNIX
>terminal control package, I have found that *none* of the string
>input functions work - not gets, scanf, or wscanw or any of the
>other curses input routines.
>I ended up having to do a "while ( (c = getchar()) != '\n');"
>structure which works, but I fear that I may be doing something
>wrong which may cause other mysterious bugs.
     
I don't know if it's the same on 4.2bsd, but in SysV curses it isn't really
safe to use stdio directly -- you should use the curses getch() function
instead of getchar().  But you say wscanw() etc. are also failing?
     
Assuming it isn't a curses bug (if so, you'd think someone else would have
found it by now -- it looks pretty serious!), I'd guess that you've used an
identifier that accidentally collides with a global identifier from the
library.  (I had a similar problem with a program that had a global variable
named "time".)  Try using lint, if you have a decent lint library for curses.
     
>Most of these give me a "Bus error (core dumped)" message (one which I have
>generally gotten sick of)
     
Have you considered examining the core dump?  That's what it's for!
     
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

From:	ARPA%"gwyn@BRL.ARPA" 24-SEP-1986 02:54
To:	JMS
Subj:	Re:  COFF documentation

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2667
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:54 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:45:15 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a010575; 23 Sep 86 17:53 EDT
Received: from brl-vgr.arpa by SMOKE.BRL.ARPA id a007376; 23 Sep 86 17:31 EDT
Date:     Tue, 23 Sep 86 17:29:32 EDT
From:     Doug Gwyn (VLD/VMB) <gwyn@BRL.ARPA>
To:       roy carlson <roy%amd.uucp@BRL.ARPA>
cc:       info-c@BRL-SMOKE.ARPA
Subject:  Re:  COFF documentation
Message-ID:  <8609231729.aa09974@VGR.BRL.ARPA>
     
COFF is described in Chapter 11 of the "UNIX System V Release 3
Programmer's Guide", Select No. 307-225.

From:	jnet%"karl@haddock" 24-SEP-1986 02:59
To:	JMS
Subj:	Re: functions that don't return

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 2741
          for JMS@ARIZMIS; Wed, 24-SEP-1986 02:59 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:48:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005433; 23 Sep 86 14:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028645; 23 Sep 86 13:16 EDT
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: functions that don't return
Message-ID: <86900066@haddock>
Date: 22 Sep 86 14:38:00 GMT
Nf-ID: #R:tl-vaxa.UUCP:28:haddock:86900066:000:2151
Nf-From: haddock!karl    Sep 22 10:38:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
     
tl-vaxa!lindsay (Don Lindsay) writes:
>There has been some discussion about functions that never return (e.g exit).
>It was suggested that if a compiler could be told about this, then it
>could generate better code.
>
>In fact, these functions sometimes DO return (and in that case, the compiler
>had better have allowed for that).
     
Hogwash.  "Functions that never return" and "functions that sometimes DO
return" describe disjoint sets.  Functions genuinely in the latter set (e.g.
pre-ANSI abort()) are not under consideration here.
     
>For example, a storage allocator may decide to exit, because his caller has
>reached some limit.  But, the developer of this storage allocator wishes to
>write a test program, and she wants the test program to exercise this
>feature.  The test program can be more powerful, and more convenient, and
>easier to document and use, if it can make the "exit" routine return!
     
What if the function that calls exit() doesn't fall into a return?  (E.g.
"if (p == NULL) exit(1); *p = ..." will bomb if exit() doesn't exit.)  And
if you supersede exit() with a function that returns, how do you get out of
the program?  Send yourself a signal?
     
>Similarly, a program may detect an unusual condition, and call a handler
>for it. It is more general if it is the handler which decides whether or
>not to return. (Perhaps one would link in different handlers under different
>circumstances.) It is quite common for people to write over-specified
>programs, where the mainline "knows" what kind of handler is out there.
>The existence of a new function type would mostly encourage such limited
>thinking.
     
On the contrary, it would encourage the author to document (via declaration)
what the specification is.  It's the author's right to insist on a handler
that doesn't return, if there's no appropriate default handler.  (A storage
allocator normally does have an appropriate default handler: "return (NULL)")
     
You might as well be arguing that "void" is a bad idea because it encourages
people to write functions that don't return an error check.
     
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

From:	ARPA%"ELIEL%BROWNVM.BITNET@wiscvm.ARPA" 24-SEP-1986 03:07
To:	JMS
Subj:	Re: Equality vs Assignment

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2896
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:07 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 04:53:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a012342; 24 Sep 86 1:01 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a011662; 24 Sep 86 0:38 EDT
Received: from (MAILER)BROWNVM.BITNET by WISCVM.WISC.EDU on 09/23/86 at
  23:38:08 CDT
Received: by BROWNVM (Mailer X1.23) id 2370; Wed, 24 Sep 86 00:38:20 EDT
Date:         Wed, 24 Sep 86 00:28:49 EDT
From:           "Eliel Mamousette, II" <ELIEL%BROWNVM.BITNET@wiscvm.ARPA>
Subject:      Re: Equality vs Assignment
To:  info-c@BRL-SMOKE.ARPA
In-Reply-To:  Your message of 17 Sep 86 00:23:52 GMT
     
This is a good question, although I think that for CMS/SP users, using yacc
or lex may be a bit overboard when XEDIT provides the "all" command that
would let one easily scan for that kind of error.  I suppose that a macro
to do this before compiling would be easy to write.  As I don't have time
right now, let me outline what I mean:
    in CW EXEC :
         "XEDIT "fn ft/* h or c */" (PROFILE chk_equ"
          if rc ^= 0 then exit /* flag indicating desire to continue or no*/
          else CW ....
    chk_equ XEDIT would have something like this :
         "all /for/ && /=/ "
            some search code...
         "all /while/ && /=/ "
            some more..., etc, etc.
Let me know if any one has the time to do it so that I can get a copy!
     
also, if any one knows of versions of yacc and/or lex for the CMS/SP environ-
ment, please let me know as well!
   have a day,
             eliel

From:	ARPA%"guido%mcvax.uucp@BRL.ARPA" 24-SEP-1986 03:25
To:	JMS
Subj:	Re: enum function bug?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3148
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:25 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 05:16:12 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005511; 23 Sep 86 14:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028800; 23 Sep 86 13:19 EDT
From: Guido van Rossum <guido%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: enum function bug?
Message-ID: <7079@boring.mcvax.UUCP>
Date: 22 Sep 86 21:56:29 GMT
Posted: Mon Sep 22 23:56:29 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
In article <572@opus.nbires.UUCP> rcd@nbires.UUCP (Dick Dunn) writes:
>[example with enum {a= 3+3, b, c} in one file and enum {a= 2*3, b, c}
>in another]
>
>If you admit that name equivalence is inadequate (which I believe) but that
>this example carries structural equivalence too far (which I also believe,
>I think), then where do you draw the line?
     
In my eyes, in the example you give the two types are clearly
structurally equivalent.  After all, the two expressions have to be
constant expressions, which is a well-defined term (in C!).  I propose
the following rule for enum equivalence:
     
    Two enumerated types are equivalent if they have the same 'tag'
    (or no tags), and define the same set of enumeration constants
    with the same associated value for each constant.
     
(This will find even enum {a=2, b=1, c=0} and enum {c, b, a} equivalent!)
     
By the way, I agree with the proposed ANSI standard which defines that
enums are equivalent to ints!  This is the only suitable way to do it
*in C*, even though for any other language, to be designed newly, enums
should be distinct types.  I also agree with Lint checking enum
equivalence -- but there should be a way to turn it off, since I believe
that lint should not issue any errors (warnings are ok) for strictly
ANSI-conforming C programs.
--
    Guido van Rossum, CWI, Amsterdam <guido@mcvax.uucp>

From:	ARPA%"guido%mcvax.uucp@BRL.ARPA" 24-SEP-1986 03:28
To:	JMS
Subj:	Re: Calendar Functions

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3258
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:28 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005622; 23 Sep 86 14:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028808; 23 Sep 86 13:19 EDT
From: Guido van Rossum <guido%mcvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions
Message-ID: <7080@boring.mcvax.UUCP>
Date: 22 Sep 86 22:16:42 GMT
Keywords: Calendars
Posted: Tue Sep 23 00:16:42 1986
Apparently-To: rnews@mcvax
To:       info-c@BRL-SMOKE.ARPA
     
Wouldn't Jim Cottrell love this:
     
    #define leapyear(y) !((y)&3)
     
    daysinmonth(m, y) {
        if (m == 2) return 28 + leapyear(y);
        return 30 + ((1&m) ^ (m>7));
    }
     
Seriously, I believe that the original code, which applied the same rule
here showed a discrepancy between its seemingly clear coding style
(explaining every simple statement with a comment) and the 'trick' in
the algorithm (invert the parity of the month for months > 7).
     
In my eyes the solution which uses a table is the cleanest.

From:	ARPA%"apn%nonvon.uucp@BRL.ARPA" 24-SEP-1986 03:33
To:	JMS
Subj:	Re: Using SCANF with DOUBLE precision variables...

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 3403
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:33 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006054; 23 Sep 86 14:30 EDT
Received: from USENET by SMOKE.BRL.ARPA id a028881; 23 Sep 86 13:20 EDT
From: apn <apn%nonvon.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using SCANF with DOUBLE precision variables...
Message-ID: <108@nonvon.UUCP>
Date: 22 Sep 86 20:52:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3672@brl-smoke.ARPA>, DAVE%UWF.BITNET@WISCVM.WISC.EDU writes:
> I have been wanting to read in some real numbers, preferably thru SCANF, but I
> get nothing but 0.000 returned when i try to put the result of a SCANF in a
 var
> declared as DOUBLE.  The only thing that I could think of was either writing
 my
> own algorithm, or reading the number in as FLOAT and storing it in the DOUBLE
     
     
    What about using atof to read in the float ?

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 24-SEP-1986 03:42
To:	JMS
Subj:	Re: Re: structure alignment question

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3486
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:41 MST
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a006224; 23 Sep 86 14:37 EDT
Received: from USENET by SMOKE.BRL.ARPA id a029299; 23 Sep 86 13:28 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structure alignment question
Message-ID: <7503@sun.uucp>
Date: 22 Sep 86 20:07:55 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> (Does the 68020 really fault?  I thought it just did two bus accesses.)
     
"fault" was a poor choice of words on his part; it already means something,
namely a trap.  The '020 doesn't fault, it just does two bus accesses.
     
>     | strcpy(to, from) char *to, *from; { *to = *from; return (to); }
>     | /*UNTESTED!*/
     
When tested with some simple test cases (even->even, odd->even, even->odd,
odd->odd), it worked.
     
>     TO    =    a0        | I think this works
     
It does.
     
>     | I forget if this is legal.  If not, copy to d0 first.
>         btst    #0,TO        | test for odd destination
     
It's not, and I modified it to do so.
     
> I wonder, though, if this is truly faster.  Should not a movb/bnes
> pair run in loop mode?
     
Nope.  Only "dbCC" loops run in loop mode.
     
> (Perhaps not; `dbcc' loops do, though, and one could use a dbra surrounded
> by a bit of extra logic.)
     
Yes.  The following, courtesy of John Gilmore and Vaughan Pratt, is what is
actually used in the (3.2 version of) "strcpy", etc.:
     
    moveq    #-1,d1        | maximum possible (16-bit) count
hardloop:
    movb    FROM@+,TO@+    | copy...
    dbeq    d1,hardloop    | until we copy a null or the count is -1
    bne    hardloop    | if not-null, continue copying with count
                | freshly initialized to -1
     
Now for the numbers.  A test program was built to do a large number of
copies in a loop, and to do the same loop with no body; the times were
subtracted and the result was divided by the number of iterations.  The
program was run with strings of length 2, 10, and 100.  All strings were
"malloc"ed, so they started on word boundaries (the program tested this,
just to make sure).  The results:
     
Byte-by-byte copy, using "movb"/"dbcc" loop (standard 3.2 "strcpy), Sun-2
(10 MhZ 68010, no caches, zero wait states):
     
    250000 copies of 2 bytes took 5.720000 seconds
    0.000023 seconds/call
     
    50000 copies of 10 bytes took 1.760000 seconds
    0.000035 seconds/call
     
    5000 copies of 100 bytes took 0.860000 seconds
    0.000172 seconds/call
     
New strcpy, same Sun-2:
     
    250000 copies of 2 bytes took 8.440000 seconds
    0.000034 seconds/call
     
    50000 copies of 10 bytes took 3.120000 seconds
    0.000062 seconds/call
     
    5000 copies of 100 bytes took 1.880000 seconds
    0.000376 seconds/call
     
Standard strcpy, Sun-3/75 (16.67 MhZ 68020, no caches other than the on-chip
256-byte instruction cache, 1.5 wait states):
     
    250000 copies of 2 bytes took 1.780000 seconds
    0.000007 seconds/call
     
    50000 copies of 10 bytes took 0.720000 seconds
    0.000014 seconds/call
     
    5000 copies of 100 bytes took 0.500000 seconds
    0.000100 seconds/call
     
New strcpy, same Sun-3/75:
     
    250000 copies of 2 bytes took 2.800000 seconds
    0.000011 seconds/call
     
    50000 copies of 10 bytes took 0.960000 seconds
    0.000019 seconds/call
     
    5000 copies of 100 bytes took 0.520000 seconds
    0.000104 seconds/call
     
Standard strcpy, Sun-3/200 (25 MhZ 68020, off-chip write-back cache, 0 wait
states):
     
    250000 copies of 2 bytes took 1.060000 seconds
    0.000004 seconds/call
     
    50000 copies of 10 bytes took 0.480000 seconds
    0.000010 seconds/call
     
    5000 copies of 100 bytes took 0.260000 seconds
    0.000052 seconds/call
     
New strcpy, same Sun-3/200:
     
    250000 copies of 2 bytes took 1.420000 seconds
    0.000006 seconds/call
     
    50000 copies of 10 bytes took 0.520000 seconds
    0.000010 seconds/call
     
    5000 copies of 100 bytes took 0.320000 seconds
    0.000064 seconds/call
     
These numbers were quite reproducible.
     
The moral(s) of the story:
     
    1) Loop mode, on the 010, is a big win.  (The byte-by-byte
       "strcpy" runs in loop mode on the 010, the other one
       doesn't; the other one takes about twice as long.)
     
    2) The instruction cache, on the 020, is a big win.  (The 020
       versions don't differ by as much, and the other one seems
       to be catching up as the strings get longer, which didn't
       happen on the 010.)
     
    3) With realistic string lengths, and 68K-family machines
       offered by Sun, at least, the plain vanilla byte-by-byte
       copy is the right way to do things, even with word-aligned
       strings.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"yost%bty.uucp@BRL.ARPA" 24-SEP-1986 03:46
To:	JMS
Subj:	Abusing `curses' WINDOW structure

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 3725
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:46 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 05:41:21 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013336; 24 Sep 86 6:04 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014131; 24 Sep 86 5:30 EDT
From: Brian Yost <yost%bty.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Abusing `curses' WINDOW structure
Message-ID: <314@bty.UUCP>
Date: 20 Sep 86 05:19:49 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I have a question concerning termcap -vs- terminfo implementations
of the curses library.
     
I'm writing a program which uses the curses library, and need to
include a "print screen" type of utility.  Rather than reproducing
my display logic in order to print a text file image, I was thinking
of simply copying the screen from stdscr->_y directly into my textfile
(adding newlines where appropriate).  Something along these lines:
     
    PrintScr(f, win)
    FILE *f;
    WINDOW *win;
    {
        register short i, j;
     
        for (i = 0; i < win->_begy; i++)
            fputc('\n', f);
     
        for (i = 0; i < win->_maxy; i++) {
            for (j = 0; j < win->_begx; j++)
                fputc(' ', f);
            for (j = 0; j < win->_maxx; j++)
                fputc(win->_y[i][j], f);
            fputc('\n', f);
        }
        fflush(f);
    }
     
Now, my machine uses termcap, and this seems to work OK.  The question
is, is the WINDOW structure different in the terminfo implementation?
And if so, can the routine above be rewritten and made to work?
     
Please reply by mail, and thanks.
     
Brian Yost         {clyde,topaz}!infopro!bty!yost
     
``This is a sic (sic) joke.''

From:	ARPA%"jsdy%hadron.uucp@BRL.ARPA" 24-SEP-1986 03:52
To:	JMS
Subj:	Re: Char vs. Int

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3817
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:52 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 05:46:33 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013351; 24 Sep 86 6:05 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014240; 24 Sep 86 5:34 EDT
From: "Joseph S. D. Yao" <jsdy%hadron.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Char vs. Int
Message-ID: <576@hadron.UUCP>
Date: 23 Sep 86 05:47:24 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <3770@brl-smoke.ARPA> jl42@andrew.cmu.edu (Jay Mathew Libove) writes:
>I have always been under the impression that a CHAR variable and an INT
 variable
>were the same in 'C'- yet I now see:
>In the sequence:
> ...
>char ch is the correct declaration.  ...
>        .  Declaring it 'int' is asking for trouble.
>
>Why is it asking for trouble to declare ch as INT when K&R says they are the
>same?
     
Simple.  It doesn't and they aren't.  K&R 2.2: char is a byte, one
character; int is the machine's natural integer (and examples).
K&R 2.7 mentions chars' automatic conversion, in arithmetic and
arguments, into ints.  (The need for conversion, of course, implies
the difference between the two.)  This is repeated in CRef 2.6,
4., 6.1, 6.6.
--
     
    Joe Yao        hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
            jsdy@hadron.COM (not yet domainised)

From:	ARPA%"colin%vu-vlsi.uucp@BRL.ARPA" 24-SEP-1986 03:56
To:	JMS
Subj:	Re: enum function bug?

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 3908
          for JMS@ARIZMIS; Wed, 24-SEP-1986 03:56 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 05:49:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013407; 24 Sep 86 6:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014327; 24 Sep 86 5:37 EDT
From: Colin Kelley <colin%vu-vlsi.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: enum function bug?
Message-ID: <365@vu-vlsi.UUCP>
Date: 23 Sep 86 17:04:06 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <103@hcx1.UUCP> notes@hcx1.UUCP writes:
>
>struct st { int c ; } ;
>int func (b);
>   int b;
>{
>}
>main()
>{
>   struct st s;
>   func (&s);
>}
This is obviously wrong, since ints are not pointers!  But what I thought
you were going to try was
     
main()
{
    struct st s;
    func (s);
}
     
That is, call func() passing it the whole structure as if it were an int,
since we all _know_ the structure just consists of one int anyway, right!
PLEASE DON'T DO THIS!!!  Of course it won't get by lint, but quite a few
programmers wind up doing it because it works on so many machines.  Well,
it doesn't work at all on a Pyramid, where structures are passed differently
than ints.
     
Someone here got bitten by this attempting to port smp (a symbolic math
package) to our Pyramid.  The bozo programmer had declared a union containing
all possible pointers, but then declared the formal parameter just as a pointer
to an int.  "What", you say, "commercial code which doesn't even pass lint?"
That's what I said too!  Yuck...
     
            -Colin Kelley ..{cbmvax,pyrnj,psuvax1}!vu-vlsi!colin

From:	ARPA%"cg%myrias.uucp@BRL.ARPA" 24-SEP-1986 04:00
To:	JMS
Subj:	Re: Equality vs Assignment

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 4069
          for JMS@ARIZMIS; Wed, 24-SEP-1986 04:00 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 05:54:36 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a013434; 24 Sep 86 6:09 EDT
Received: from USENET by SMOKE.BRL.ARPA id a014604; 24 Sep 86 5:47 EDT
From: Chris Gray <cg%myrias.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Equality vs Assignment
Message-ID: <270@myrias.UUCP>
Date: 18 Sep 86 19:48:29 GMT
Keywords: Who has not been bitten
To:       info-c@BRL-SMOKE.ARPA
     
The proper place for this check is of course as a warning issued by the C
compiler. It's not all that hard - it took me about 30 lines of code in the
compiler (ANSI draft based) that I've done. It's a check I felt was quite
important, since I've been bitten by it too many times (I program in other
languages besides C, where '=' IS a comparison).
     
        Chris Gray (...alberta!myrias!cg)

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 24-SEP-1986 05:13
To:	JMS
Subj:	Re: Re: structure alignment question

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 4930
          for JMS@ARIZMIS; Wed, 24-SEP-1986 05:13 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/24/86 at 06:59:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a014207; 24 Sep 86 7:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a015780; 24 Sep 86 7:32 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: structure alignment question
Message-ID: <7534@sun.uucp>
Date: 23 Sep 86 18:01:19 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> What I meant was...
     
Then why the hell didn't you *say* that?  What you *did* say was
     
    "...I could use do word operations in my strnlen, strncmp,
    strncpy, and whatever other string processing functions I
    happened to write."
     
which sure sounds to *me* like you were doing word operations in the
standard string operations.  If you weren't referring to them, you shouldn't
have called them "my strnlen, ..."; you should have called them "my string
processing functions", and perhaps emphasized that they were *not*
replacements for the standard ones.
     
> Also, "fcmp" depends on the fact that a word-aligned string is
> terminated by a null word
     
As do the string copy and string length routines, unless you're individually
checking each byte of each word that you move.
     
> The point is, a word aligned string does not seem to be too much
> to ask for,
     
Yes, it is, considering you can do it yourself.  Just declare all your
strings to be unions of arrays of "char"s and a "short".  If you want to
initialize the string, you can probably get away with declaring it to be an
integral number of words long - if you include the extra padding word, the
compiler will even do you the favor of making that word all-zero.  If you
use ANSI C, you can even initialize the union by declaring the string to be
its first member.
     
Remember, ANSI C does *not* guarantee, in any way, that strings are aligned
on any boundary more strict than a byte boundary.  As such, you're going to
have to do this sort of thing anyway, unless you "know" how the compiler
works.  Yes, it means you have to type more, but that's life.
     
> "A little knowledge is a dangerous thing"... programmers should
> *never* learn about machine architectures: they will only want to
> write fast code...
     
Could you please point out where *anybody* stated their position this way?
Don't just assume that this was somebody's motivation; one of the biggest
source of errors in this business seems to be people assuming they "know"
why something was done, or how it works internally, or....
     
Sometimes that kind of tweaking is a good idea, and sometimes it just makes
work for you or, more likely, the guy who inherited your code when it comes
time to port it to a new architecture.  I'm tempted, at times, to use Barney
Frank's phrase and call it the programming equivalent of "crack"; it gives a
short-term high, but has bad long-term consequences.  If you're going to do
that sort of thing, 1) make sure you *really* need it, and can't get the
same performance improvement using more portable code, 2) wrap it in #ifdefs
so that people know it's there (and don't have to go through too much
trouble to compile a version for a particular machine), and 3) provide a
portable version so people can at least get it to work on a new machine
fairly quickly.
     
> I hope that this time I have clarified my position: everybody can
> now say I'm wrong (of course I am) or right.
     
You're wrong.  You don't need to have the compiler put strings on word
boundaries in order to be able to put your specialized kind of string on
word boundaries.
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"guy%sun.uucp@BRL.ARPA" 25-SEP-1986 03:41
To:	JMS
Subj:	Re: Abusing `curses' WINDOW structure

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 1523
          for JMS@ARIZMIS; Thu, 25-SEP-1986 03:41 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/25/86 at 05:23:32 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005625; 25 Sep 86 6:13 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010968; 25 Sep 86 5:32 EDT
From: Guy Harris <guy%sun.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Abusing `curses' WINDOW structure
Message-ID: <7565@sun.uucp>
Date: 24 Sep 86 06:42:28 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> I'm writing a program which uses the curses library, and need to
> include a "print screen" type of utility.  Rather than reproducing
> my display logic in order to print a text file image, I was thinking
> of simply copying the screen from stdscr->_y directly into my textfile
> (adding newlines where appropriate). ...
> Now, my machine uses termcap, and this seems to work OK.  The question
> is, is the WINDOW structure different in the terminfo implementation?
> And if so, can the routine above be rewritten and made to work?
     
"Abusing" is right!  Assuming you "know" what an unadvertised data structure
of a package looks like is a great way to get into trouble.
     
Yes, the window structure is different, although that sort of thing will
sort of work.  Don't do it, though.  There is a macro "winch" that returns
the "character" at the current position on the screen.  Use that instead.
"character" is in quotes, because it masks out the character attributes in
the 4BSD "curses" but not the S5 "curses".  You should mask the result of
that operation with 0177 if you just want the character.  (Note that your
sample code would not work properly for characters in standout mode; the raw
data in the screen buffer has high bits set if the character has an
attribute turned on.)
     
This stuff is documented both in the 4.2BSD and the S5 "curses"
documentation.  Please, people, before you decide you have no choice but to
sneak around the back door of a facility, check out the documentation - in
painful detail, if need be - first!
--
    Guy Harris
    {ihnp4, decvax, seismo, decwrl, ...}!sun!guy
    guy@sun.com (or guy@sun.arpa)

From:	ARPA%"drw%cullvax.uucp@BRL.ARPA" 25-SEP-1986 07:36
To:	JMS
Subj:	Re: Re: Expression sequencing query

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5219
          for JMS@ARIZMIS; Thu, 25-SEP-1986 07:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/25/86 at 09:26:45 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007391; 25 Sep 86 7:58 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012379; 25 Sep 86 7:32 EDT
From: Dale Worley <drw%cullvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Expression sequencing query
Message-ID: <353@cullvax.UUCP>
Date: 24 Sep 86 20:08:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> In article <760@oakhill.UUCP> tomc@oakhill.UUCP (Tom Cunningham) writes:
> >    /* a = b + b + b */
> >    a = ((b=1),b) + ((b=2),b) + ((b=3),b)
> >
> >I expected the result to be 6.  With the Microsoft C compiler and the
> >compiler on the Sun 3, the result is 9.  Apparently the parenthetical
> >assignments are all getting done before the comma and addition.  Any
> >thoughts on this?
     
Harbison&Steele (7.11) makes it clear that an implementation must
evaluate one argument of a binary operator completely before starting
evaluation of the other argument.  Thus, the result should be 6.  I
don't know what the ANSI standard says.
     
Dec VAX Ultrix gives 9.
     
Lattice C 3.00 for MS-DOS gives 7!!!  (Yes, that's "7", not a typo!)
     
Dale

From:	ARPA%"kpk%gitpyr.uucp@BRL.ARPA" 25-SEP-1986 07:42
To:	JMS
Subj:	Equality/Assignment

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5095
          for JMS@ARIZMIS; Thu, 25-SEP-1986 07:42 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/25/86 at 09:22:00 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007545; 25 Sep 86 8:01 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012565; 25 Sep 86 7:35 EDT
From: "Kevin P. Kleinfelter" <kpk%gitpyr.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Equality/Assignment
Message-ID: <2273@gitpyr.UUCP>
Date: 21 Sep 86 22:16:32 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
A little while ago, I posted a request for a program to check for
possible confusion of "=" and "==".  Several people requested that
I post/mail such a program when found.
     
I received a very nice program which performed the required check, however
it also checked for consistent indentation (in a manner inconsistent with
my preferred style).
     
After a little thought, I wrote the following program.  It isn't very
smart, but it is about as simple a program as I can imagine to solve the
problem.
     
Cut the remainder of this message into the 3 files indicated.
Run "lex" on the ".l" file, and run "cc" on the ".c" file (and of course,
on lex's output).
     
Note: The version of lex that I use is public domain, and a little different
from Unix lex.  You may have to fiddle with "yyline" or other lex details to
get it to work properly.  If you have any problems, mail them to me, and I'll
see if I can help.
     
================= equalch.c =================================================
/* main program to check for use of "=" in a C program when "==" intended */
#include "equalchk.h"
extern int yyline;
     
main ()
{
   int token;
   int comment_in_progress = 0;
   int paren_nesting_level = 0;
     
   yyline = 1;
   while(token=yylex()) {
      switch(token) {
         case StartComment:
            if (comment_in_progress) {
               printf("%d WARNING: nested comment\n",yyline);
            }
            comment_in_progress = 1;
            break;
         case EndComment:
            comment_in_progress = 0;
            break;
         case LeftParen:
            if (comment_in_progress) {
               break;
            }
            paren_nesting_level++;
            break;
         case RightParen:
            if (comment_in_progress) {
               break;
            }
            if (paren_nesting_level <= 0) {
               printf("%d ERROR: unmatched right parenthesis\n",yyline);
               break;
            }
            paren_nesting_level--;
            break;
         case Equal:
            if (paren_nesting_level > 0) {
               printf("%d WARNING: possible misuse of \"==\"\n",yyline);
            }
            break;
      }
   }
}
================ equalchk.h ================================================
     
/* defines for including by equalch.lxi for C ==/= checker */
#define StartComment 300
#define EndComment 301
#define LeftParen 302
#define RightParen 303
#define Equal 304
     
================ equalchk.l =================================================
     
     
%{
#include "equalchk.h"
extern int yylval;
extern int yyline;
%}
%%
"/*"                    {yylval=StartComment;return(StartComment);}
"*/"                    {yylval=EndComment;return(EndComment);}
"("                     {yylval=LeftParen;return(LeftParen);}
")"                     {yylval=RightParen;return(RightParen);}
"=="                    {;}
"="                     {yylval=Equal;return(Equal);}
[\012]                  {yyline++;}
[\001-\177]             {;}
%%

From:	ARPA%"henry%utzoo.uucp@BRL.ARPA" 25-SEP-1986 09:54
To:	JMS
Subj:	Re: Calendar Functions (simpler leap year calculation)

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7643
          for JMS@ARIZMIS; Thu, 25-SEP-1986 09:54 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/25/86 at 11:45:41 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008152; 25 Sep 86 8:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012798; 25 Sep 86 7:40 EDT
From: Henry Spencer <henry%utzoo.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <7136@utzoo.UUCP>
Date: 25 Sep 86 00:03:37 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> ...If you really want an algorithm for all years,
> you then need to also test for years divisible by 4000...
     
No, there is no 4000-year correction.  There's 4 and 400 and that's it
at present.  Some twiddling will eventually become necessary, but it
won't be anything as simple and uniform as leap millenia -- the function
we are trying to approximate is not linear on that time scale.
--
                Henry Spencer @ U of Toronto Zoology
                {allegra,ihnp4,decvax,pyramid}!utzoo!henry

From:	ARPA%"david%ztivax.uucp@BRL.ARPA" 26-SEP-1986 00:12
To:	JMS
Subj:	Re: Re: Expression sequencing query - (nf)

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 7116
          for JMS@ARIZMIS; Fri, 26-SEP-1986 00:12 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/26/86 at 02:02:29 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008176; 25 Sep 86 8:19 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012845; 25 Sep 86 7:42 EDT
From: david%ztivax.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Re: Expression sequencing query - (nf)
Message-ID: <8200006@ztivax.UUCP>
Date: 23 Sep 86 11:35:00 GMT
Nf-ID: #R:unido:-11100:ztivax:8200006:000:72
Nf-From: ztivax!david    Sep 23 12:35:00 1986
Posted: Tue Sep 23 13:35:00 1986
To:       info-c@BRL-SMOKE.ARPA
     
On Ultrix V1.2 (4.3bsd, more or less), the answer is...
     
NINE!  oops...

From:	ARPA%"devine%vianet.uucp@BRL.ARPA" 26-SEP-1986 00:45
To:	JMS
Subj:	Re: Calendar Functions (simpler lea

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7402
          for JMS@ARIZMIS; Fri, 26-SEP-1986 00:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/26/86 at 02:19:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008472; 25 Sep 86 8:25 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012954; 25 Sep 86 7:45 EDT
From: Bob Devine <devine%vianet.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler lea
Message-ID: <37@vianet.UUCP>
Date: 24 Sep 86 22:36:04 GMT
To:       info-c@BRL-SMOKE.ARPA
     
haddock!karl (Karl W. Z. Heuer) writes:
[ that my suggestion of only checking if the year is divisible by
four assumes "the test is for the current year" and that "For a general
purpose algorithm (as per the original request), Dave's code is correct."]
     
  Not quite right.  I said just testing by use of "year % 4" is perfectly
fine for most uses (this is sort of like generic products.)  However, if
you want to test for years outside the range of 1901-2099 it doesn't work.
The UNIX value returned by the time() system call only covers the years
1970 +/- 67 years which falls nicely in the range.  The time() call is
unlikely to change.  If your system doesn't do it this way or you need a
larger range, don't use the simple test!
     
  A general purpose algorithm must also take care of years before the Gregorian
calendar system was adopted by a country.  Any KGB agents out there that
are reading this be sure to handle the years before 1918 differently :-)
So, the posted general purpose algorithm is not comprehensive in its
handling of years.  My initial posting simply indicated that if you are
not going to comprehensive, at least be a little faster.
     
> I believe the quadrimillennium correction was never officially adopted.
> It's not accounted for in cal(1).
     
  I'll check into the official rules; 'cal' is not a definite source.
The Gregorian calender is about 1/2 minute too long compared to the solar
calendar which was quite close considering it was done by a 16th century
astronomer.  That means that there needs to be a day added in, oh, about
3,000 years.  Be sure to mark the date :-)
     
     
Bob Devine

From:	ARPA%"STROBL%DBNGMD21.BITNET@wiscvm.ARPA" 26-SEP-1986 04:02
To:	JMS
Subj:	Re: Re: Expression sequencing query

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 0587
          for JMS@ARIZMIS; Fri, 26-SEP-1986 04:02 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/26/86 at 05:56:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a007836; 26 Sep 86 6:47 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a006548; 26 Sep 86 6:02 EDT
Received: from (MAILER)DBNGMD21.BITNET by WISCVM.WISC.EDU on 09/26/86
  at 05:01:51 CDT
Date:    Fri, 26 Sep 86 11:59 CET
To:  info-c@BRL-SMOKE.ARPA
From:      Wolfgang Strobl <STROBL%DBNGMD21.BITNET@wiscvm.ARPA>
Subject: Re: Re: Expression sequencing query
     
> > >    /* a = b + b + b */
> > >    a = ((b=1),b) + ((b=2),b) + ((b=3),b)
> ...
> Lattice C 3.00 for MS-DOS gives 7!!!  (Yes, that's "7", not a typo!)
     
DeSmet 2.15 (PCDOS), Microsoft 2.03 (PCDOS) and Lattice 2.10F (MVS) all
give 7.

From:	ARPA%"C90630JG%WUVMD.BITNET@wiscvm.ARPA" 26-SEP-1986 23:27
To:	JMS
Subj:	expression sequencing bugs

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5856
          for JMS@ARIZMIS; Fri, 26-SEP-1986 23:26 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/27/86 at 01:17:51 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a024777; 27 Sep 86 2:12 EDT
Received: from brl-aos.arpa by SMOKE.BRL.ARPA id a000855; 27 Sep 86 1:53 EDT
Received: from wiscvm.arpa by AOS.BRL.ARPA id a024692; 27 Sep 86 1:55 EDT
Received: from (MAILER)WUVMD.BITNET by WISCVM.WISC.EDU on 09/25/86 at
  22:02:52 CDT
Received: by WUVMD (Mailer X1.23b) id 3702; Thu, 25 Sep 86 14:03:34 CST
Date: 25 September 1986 14:00:01 CDT
From:    C90630JG%WUVMD.BITNET@wiscvm.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
To:  INFO-C@BRL.ARPA
MMDF-Warning:  Parse error in original version of preceding line at BRL.ARPA
Subject: expression sequencing bugs
     
In article <760@oakhill.UUCP> tomc@oakhill.UUCP (Tom Cunningham) writes:
>    /* a = b + b + b */
>    a = ((b=1),b) + ((b=2),b) + ((b=3),b)
>
>I expected the result to be 6.  With the Microsoft C compiler and the
>compiler on the Sun 3, the result is 9.  Apparently the parenthetical
>assignments are all getting done before the comma and addition.  Any
>thoughts on this?
>
Tom, I agree, the result should be 6, as defined by K&R, but I have tried
it on ......................
I would like everyone to test it on as many machines as prossible, to
see if we can find as least ONE other besides Small-C, that works.
     
Mike Stump  ucbvax!hplabs!csun!csunb!beusemrs
     
I would like to report that the Computer Innovations C86 C complier
on the IBM-PC produces the correct answer.
     
Jonathen Goldberg
c90630jg@wuvmd.bitnet

From:	ARPA%"00R0DHESI%bsu.csnet@csnet-relay.ARPA" 27-SEP-1986 02:04
To:	JMS
Subj:	Significant deficiency in C

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 7644
          for JMS@ARIZMIS; Sat, 27-SEP-1986 02:04 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/27/86 at 03:54:10 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a025258; 27 Sep 86 4:42 EDT
Received: from relay.cs.net by SMOKE.BRL.ARPA id a001706; 27 Sep 86 4:34 EDT
Received: from bsu by csnet-relay.csnet id ac01337; 26 Sep 86 5:06 EDT
Date:     Wed, 24 Sep 86 09:01 EST
From:     Rahul Dhesi <00R0DHESI%bsu.csnet@csnet-relay.ARPA>
To:       info-c@BRL-SMOKE.ARPA
Subject:  Significant deficiency in C
     
That C promotes all values of type char to int before using them in an
expression may on the face of it seem to simplify expression evaluation and the
semantics of the language, but it also makes the implementation grossly
inefficient in some cases.  Experimenting with Lempel-Ziv compression that also
involved calculating a CRC, I found that code compiled by Microsoft C was as
much as 10 times slower than hand-crafted assembly code (this on an 8088 CPU)
even when macros were liberally used instead of functions.
     
Inspecting critical loops in the generated code, I was shocked to find that the
compiler was doing what it could to make things fast, but it was hindered by
the requirement that char types be promoted to int before being used in an
expression.  The 8088 CPU has 16-bit registers that are made up of pairs of
8-bit registers and each 8-bit register can be separately used for 8-bit
operations, making character-oriented code extremely efficient.  But the
compiler was forced to treat such code as int-oriented code (ints being 16 bits
in this implementation).  Hand-crafted assembly code, where the programmer
knows whether or not 16 bits will be ultimately needed, isn't similarly
restricted.
     
I think this is a significant deficiency in C.  Is ANSI doing anything to
eliminate this or decrease its effect?  Considering that the vast majority of
UNIX tools do text processing in 7-bit units, one would think that somebody
would have done something by now.  Is a potential doubling or tripling of
text processing speed not significant enough to be worth redefining a
programming language for?
     
Perhaps the problem is that UNIX and C have traditionally been implemented only
on machines (e.g. PDP-11, VAX-11/7xx) in which using an 8-bit register always
automatically tied up a 16-bit or larger register, and nobody ever imagined
that we would be running C programs on cheap microprocessors with 8-bit
registers.
     
Rahul Dhesi
dhesi%bsu@csnet-relay.ARPA
...!seismo!csnet-relay.ARPA!bsu!dhesi

From:	ARPA%"brett%wjvax.uucp@BRL.ARPA" 28-SEP-1986 03:04
To:	JMS
Subj:	Re: Promotion of integral types

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 5289
          for JMS@ARIZMIS; Sun, 28-SEP-1986 03:04 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 04:55:55 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001825; 28 Sep 86 5:52 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010433; 28 Sep 86 5:34 EDT
From: Brett Galloway <brett%wjvax.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Promotion of integral types
Message-ID: <761@wjvax.wjvax.UUCP>
Date: 26 Sep 86 17:19:45 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <271@myrias.UUCP> cmt@myrias.UUCP (Chris Thomson) writes:
>In article <3422@umcp-cs.UUCP> Chris Torek writes:
>
>>     Storage Type        Expression Equivalent
>>     ------------        ---------------------
>>     char            int
>>     unsigned char        unsigned int
>>     short            int
>>     unsigned short        unsigned int
>>     int            int
>> [more types]
>It is interesting to note that K&R does not say that unsigned char or
>unsigned short get promoted to unsigned int; it says that they get promoted
>to integer (on page 183), which is a bit vague.  Harbison & Steele says
>very clearly what is said above.  The ANSI Draft (1986.07.09 version) says
>very clearly that unsigned char and unsigned short are promoted to int,
>since the values can all be represented in an int (assuming sizeof(int)
>is greater than sizeof(short), which is usually true).
>
>What to do?  Frankly, I prefer the ANSI approach, but it does represent a
>silent change from what H&S (and Chris Torek) perceive to be standard
>practice.  For some reason, it is not flagged as such in the rationale
>document; it isn't even discussed there.
     
I disagree.  One cannot assume that sizeof(int) > sizeof(short).
--
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

From:	ARPA%"rbutterworth%watmath.uucp@BRL.ARPA" 28-SEP-1986 03:33
To:	JMS
Subj:	Re: Promotion of integral types

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5527
          for JMS@ARIZMIS; Sun, 28-SEP-1986 03:33 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 05:17:25 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001879; 28 Sep 86 6:15 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010371; 28 Sep 86 5:32 EDT
From: Ray Butterworth <rbutterworth%watmath.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Promotion of integral types
Message-ID: <3405@watmath.UUCP>
Date: 26 Sep 86 18:27:47 GMT
To:       info-c@BRL-SMOKE.ARPA
     
> It is interesting to note that K&R does not say that unsigned char or
> unsigned short get promoted to unsigned int; it says that they get promoted
> to integer (on page 183), which is a bit vague.  Harbison & Steele says
> very clearly what is said above.  The ANSI Draft (1986.07.09 version) says
> very clearly that unsigned char and unsigned short are promoted to int,
> since the values can all be represented in an int (assuming sizeof(int)
> is greater than sizeof(short), which is usually true).
>
> What to do?  Frankly, I prefer the ANSI approach, but it does represent a
> silent change from what H&S (and Chris Torek) perceive to be standard
> practice.  For some reason, it is not flagged as such in the rationale
> document; it isn't even discussed there.
     
There is one major problem with the ANSI proposal.
     
When doing comparisions, if the two types aren't identical after
the usual conversions and one of them is unsigned, the comparison
is done as unsigned.  e.g. "(-1) >= ui" for all unsigned ints ui.
(In particular, "(-1)>sizeof(anything)" is always true if size_t is
unsigned long or unsigned int.)
     
This can be somewhat surprising, but one can learn to live with it
once the principle is understood.  The real problem occurs with
shorts and unsigned shorts.  Consider the comparison "neg1>=us",
where "neg1" is an int with value -1 and "us" is any unsigned short.
If sizeof(unsigned short)<sizeof(int), the "us" is promoted to
an int and the comparison is done between ints and the result is
always false.  But if sizeof(unsigned short)==sizeof(int), "us"
is promoted to unsigned int, "neg1" is converted to unsigned int,
and the comparison is always true.
     
Now this is not only surprising, it means that comparing an
unsigned short with an int (or a constant) can give different
results depending upon the machine one is using.  How many
people are going to keep this in mind while writing their code?

From:	ARPA%"mwm@eris.ucb-vax.ARPA" 28-SEP-1986 03:45
To:	JMS
Subj:	Re: Re: Expression sequencing query

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 5694
          for JMS@ARIZMIS; Sun, 28-SEP-1986 03:45 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 05:35:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001881; 28 Sep 86 6:16 EDT
Received: from USENET by SMOKE.BRL.ARPA id a010389; 28 Sep 86 5:32 EDT
From: Mike Meyer <mwm@eris.ucb-vax.ARPA>
Newsgroups: net.lang.c
Subject: Re: Re: Expression sequencing query
Message-ID: <1340@jade.BERKELEY.EDU>
Date: 26 Sep 86 09:27:59 GMT
Sender: usenet@jade.ucb-vax.ARPA
To:       info-c@BRL-SMOKE.ARPA
     
In article <353@cullvax.UUCP> drw@cullvax.UUCP (Dale Worley) writes:
>> In article <760@oakhill.UUCP> tomc@oakhill.UUCP (Tom Cunningham) writes:
>> >    /* a = b + b + b */
>> >    a = ((b=1),b) + ((b=2),b) + ((b=3),b)
>> >
>> >I expected the result to be 6.  With the Microsoft C compiler and the
>> >compiler on the Sun 3, the result is 9.  Apparently the parenthetical
>> >assignments are all getting done before the comma and addition.  Any
>> >thoughts on this?
>
>Harbison&Steele (7.11) makes it clear that an implementation must
>evaluate one argument of a binary operator completely before starting
>evaluation of the other argument.  Thus, the result should be 6.  I
>don't know what the ANSI standard says.
     
My reading of the ANSI hardcopy is that it doesn't say. I thought H&S
was a description, not a definition.
     
>Dec VAX Ultrix gives 9.
     
As do VAX 4.2 and 4.3.
     
>Lattice C 3.00 for MS-DOS gives 7!!!  (Yes, that's "7", not a typo!)
     
Some messy - and almost believable - arguments can be made that the
value of that expression is "implementation dependent". Rather than do
that, I'll just point out that *ANY* time++ you have a single
statement that changes a variable, then uses the variable in a
different place, you're asking for trouble. For that particular
expression, I'd expect the following, with increasing surprise as you
move down the list:
     
    6
    3, 9
    4, 5, 7, 8
    other integers representable on the machine
    NANs of various flavors
    dropped cores.
     
    <mike
     
     
++ Except for those cases that are in different operands of a logical
operator, as the evaluation order on those is known.

From:	ARPA%"SYSYKL%HUJImd.BITNET@wiscvm.ARPA" 28-SEP-1986 03:57
To:	JMS
Subj:	Calender functions and Nautical Almanac

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 5861
          for JMS@ARIZMIS; Sun, 28-SEP-1986 03:57 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 05:52:46 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a001851; 28 Sep 86 6:04 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a010222; 28 Sep 86 5:20 EDT
Received: from (SYSYKL)HUJIMD.BITNET by WISCVM.WISC.EDU on 09/28/86 at
  04:20:26 CDT
Received: from HUJIVMS by HBUNOS (HUmail 2.4);
          Sun, 28 Sep 86 11:18:07 +0200
Received: from HUJIMD by HUJIVMS (HUyMail-2M); Sun, 28 Sep 86 11:17:00
  +0200
Date:     Sun,  28 Sep 86 11:10 +0200
From:       Melnik Yehezkel <SYSYKL%HUJImd.BITNET@wiscvm.ARPA>
To:  info-c@BRL-SMOKE.ARPA
Subject:  Calender functions and Nautical Almanac
     
Does anyone have program that can calculate GHA and Dec. for sun and Aries?
Thanks Yehezkel.
     

From:	ARPA%"moore@mit-eddie.ARPA" 28-SEP-1986 10:19
To:	JMS
Subj:	Help with file I/O

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8621
          for JMS@ARIZMIS; Sun, 28-SEP-1986 10:19 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 11:17:35 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002510; 28 Sep 86 12:06 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012346; 28 Sep 86 11:30 EDT
From: "Andrew M. Moore" <moore@mit-eddie.ARPA>
Newsgroups: net.lang.c
Subject: Help with file I/O
Message-ID: <3333@mit-eddie.MIT.EDU>
Date: 27 Sep 86 16:28:57 GMT
To:       info-c@BRL-SMOKE.ARPA
     
     
     
   The "FILE" declaration in my BDS C compiler doesn't seem to be
recognized.  Any hints on how to deal with file I/O?
     
Andrew Moore
arpa MOORE%MIT-EECS@MIT-MC.ARPA
uucp ...mit-eddie!moore
 bbs 617/479-9208 [300/1200]
  us Box 121, North Quincy, MA  02171

From:	ARPA%"steiny%scc.uucp@BRL.ARPA" 28-SEP-1986 10:23
To:	JMS
Subj:	Re: Promotion of integral types

Received: From WISCVM(SMTPUSR2) by ARIZMIS with RSCS id 8944
          for JMS@ARIZMIS; Sun, 28-SEP-1986 10:23 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 11:42:30 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002530; 28 Sep 86 12:18 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012459; 28 Sep 86 11:32 EDT
From: steiny%scc.uucp@BRL.ARPA
Newsgroups: net.lang.c
Subject: Re: Promotion of integral types
Message-ID: <740@scc.UUCP>
Date: 27 Sep 86 18:09:15 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <271@myrias.UUCP>, cmt@myrias.UUCP (Chris Thomson) writes:
> It is interesting to note that K&R does not say that unsigned char or
> unsigned short get promoted to unsigned int; it says that they get promoted
> to integer (on page 183), which is a bit vague.
     
    Well, actually they do not mention unsigned char being as there
was no such thing in Version VI or even many Version VII systems.  In
fact the system I am using right now, an Interdata 8/32 with Wollongong
Edition VII does not have either unsigned char or unsigned long.
     
    What they say is that chars might sign extend and might not depending
on the machine, which is even more confusing.
     
--
scc!steiny
Don Steiny @ Don Steiny Software
109 Torrey Pine Terrace
Santa Cruz, Calif. 95060
(408) 425-0382

From:	ARPA%"matt%oddjob.uucp@BRL.ARPA" 28-SEP-1986 10:24
To:	JMS
Subj:	debugging/logging macros

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 8440
          for JMS@ARIZMIS; Sun, 28-SEP-1986 10:24 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 10:57:42 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a002485; 28 Sep 86 11:55 EDT
Received: from USENET by SMOKE.BRL.ARPA id a012539; 28 Sep 86 11:35 EDT
From: Matt Crawford <matt%oddjob.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: debugging/logging macros
Message-ID: <1498@oddjob.UUCP>
Date: 28 Sep 86 04:13:02 GMT
To:       info-c@BRL-SMOKE.ARPA
     
The way net.sources is going, I should write a 4KB man page for
this and shar it up and post it there!
     
I like the following logging/debugging macro
     
#ifndef LOGLEVEL
#define LOGLEVEL 0
#endif
     
#define LOG(n)    if ( (n) > LOGLEVEL ) ; else fprintf
     
use it like this:
     
  LOG(1)(stderr, "LISM model server starting at %s\n", tstamp());
     
You could instead make LOGLEVEL a variable and catch a signal to
toggle it.
_____________________________________________________
Matt        University    crawford@anl-mcs.arpa
Crawford    of Chicago    ihnp4!oddjob!matt

From:	ARPA%"KLH@SRI-NIC.ARPA" 28-SEP-1986 15:45
To:	JMS
Subj:	Re: Re: Expression sequencing query

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 2035
          for JMS@ARIZMIS; Sun, 28-SEP-1986 15:44 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/28/86 at 17:36:44 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a003609; 28 Sep 86 18:26 EDT
Received: from sri-nic.arpa by SMOKE.BRL.ARPA id a015346; 28 Sep 86 17:53 EDT
Date: Sun 28 Sep 86 14:54:16-PDT
From: Ken Harrenstien <KLH@SRI-NIC.ARPA>
Subject: Re: Re: Expression sequencing query
To: info-c@BRL-SMOKE.ARPA
cc: KLH@SRI-NIC.ARPA
In-Reply-To: <1340@jade.BERKELEY.EDU>
Message-ID: <12242626198.14.KLH@SRI-NIC.ARPA>
     
Someone asked what other compilers produced for the expression:
    a = ((b=1),b) + ((b=2),b) + ((b=3),b);
     
I just tried it on KCC, the PDP-10 C compiler that I and others have
developed (not a commercial product, but available).  It returns 6.
Of course, if it didn't I would have fixed it!
    As a general observation on questions of this nature, I would
expect that compilers written since the publication of H&S have been
much better (cleaner, more consistent, more predictable, etc) than
their predecessors, because H&S is a much, MUCH better guide than K&R.
Unfortunately for future implementors, the ANSI draft is more like K&R
than H&S...
-------

From:	ARPA%"vaughan%orion.uucp@BRL.ARPA" 29-SEP-1986 05:36
To:	JMS
Subj:	Re: Using SCANF with DOUBLE precision variables...

Received: From WISCVM(SMTPUSER) by ARIZMIS with RSCS id 6718
          for JMS@ARIZMIS; Mon, 29-SEP-1986 05:36 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/29/86 at 04:59:05 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004976; 29 Sep 86 5:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019678; 29 Sep 86 5:32 EDT
From: Robert Vaughan <vaughan%orion.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using SCANF with DOUBLE precision variables...
Message-ID: <22@orion.UUCP>
Date: 25 Sep 86 21:57:14 GMT
To:       info-c@BRL-SMOKE.ARPA
     
>> I have been wanting to read in some real numbers, preferably thru SCANF
>> ...
>> declared as DOUBLE.  (...)
     
Well, go ahead! K&R, page 149 gives the key to reading in double precision
number using the scanf family:
    "the conversion characters e or f may be preceeded by l (letter l)
     to indicate that .. a pointer to double rather than float is
     expected"
The code would look like
     
double foo;
     
    scanf("%lf",&foo);
     
After having my code bomb several times (unfortunately, I was not as lucky
as you - instead of zeroes, I got core dumps), I discovered this little
gem in K&R.

From:	ARPA%"kneller%ucsfcgl.uucp@BRL.ARPA" 29-SEP-1986 05:38
To:	JMS
Subj:	Re: Using SCANF with DOUBLE precision variables...

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6978
          for JMS@ARIZMIS; Mon, 29-SEP-1986 05:38 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/29/86 at 05:17:58 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a005034; 29 Sep 86 6:14 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019735; 29 Sep 86 5:33 EDT
From: Don Kneller%Langridge <kneller%ucsfcgl.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: Using SCANF with DOUBLE precision variables...
Message-ID: <9939@cgl.ucsf.edu.ucsfcgl.UUCP>
Date: 29 Sep 86 07:18:50 GMT
To:       info-c@BRL-SMOKE.ARPA
     
In article <22@orion.UUCP> vaughan@orion.UUCP (Robert Vaughan) writes:
>>> I have been wanting to read in some real numbers, preferably thru SCANF
>>> ...
>>> declared as DOUBLE.  (...)
>
>double foo;
>
>    scanf("%lf",&foo);
>
Except, of course, in the infinite wisdom of Silicon Graphics whose
floats and doubles are the same size so one must use %f for both.  The
"justification" is that they have yet another floating point type called
long float with gets the %lf format.  It's painfully nonportable.  Sigh.
--
    Don Kneller
UUCP:    ...ucbvax!ucsfcgl!kneller
ARPA:    kneller@cgl.ucsf.edu
BITNET:    kneller@ucsfcgl.BITNET

From:	ARPA%"gnu%hoptoad.uucp@BRL.ARPA" 29-SEP-1986 05:50
To:	JMS
Subj:	Re: enum function bug?

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 6774
          for JMS@ARIZMIS; Mon, 29-SEP-1986 05:50 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/29/86 at 04:59:20 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a004971; 29 Sep 86 5:50 EDT
Received: from USENET by SMOKE.BRL.ARPA id a019658; 29 Sep 86 5:31 EDT
From: John Gilmore <gnu%hoptoad.uucp@BRL.ARPA>
Newsgroups: net.lang.c
Subject: Re: enum function bug?
Message-ID: <1148@hoptoad.uucp>
Date: 29 Sep 86 05:08:03 GMT
To:       info-c@BRL-SMOKE.ARPA
     
I think the definitive word on this has been said already:
     
Date:  8 Nov 1982 0216-PST (Monday)
From: decwrl!decvax!harpo!npoiv!alice!research!dmr
Subject: enums
Newsgroups: net.lang.c
     
There has been a lot of grousing about the uselessness of the enum type
in C, most of it justified under the circumstances.  The circumstances
are that all versions of PCC that I know of are buggy in their treatment
of this type.
     
Enums were intended to be entirely equivalent to ints; just a way, really,
of defining names for constants understood by the compiler and subject
to the normal scope rules.
     
There was a clear choice here: enums as utterly separate collections of atoms,
more or less as in Pascal, or as ways of naming integers.  I chose the
latter after some waffling.  Unfortunately, some of the waffle batter
got mixed in with PCC and has stayed there.
     
        Dennis Ritchie
--
John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   jgilmore@lll-crg.arpa
             May the Source be with you!

From:	ARPA%"BJORNDAS%CLARGRAD.BITNET@wiscvm.ARPA" 29-SEP-1986 07:18
To:	JMS
Subj:	re: order of evaluation

Received: From WISCVM(SMTPUSR1) by ARIZMIS with RSCS id 9213
          for JMS@ARIZMIS; Mon, 29-SEP-1986 07:18 MST
Received: from BRL-AOS.ARPA by wiscvm.wisc.edu on 09/29/86 at 08:33:23 CDT
Received: from brl-smoke.arpa by AOS.BRL.ARPA id a008422; 29 Sep 86 9:24 EDT
Received: from wiscvm.wisc.edu by SMOKE.BRL.ARPA id a022465; 29 Sep 86 8:29 EDT
Received: from (BJORNDAS)CLARGRAD.BITNET by WISCVM.WISC.EDU on 09/29/86
  at 07:29:38 CDT
Date: 29 SEP 86 00:09-PST
From:  BJORNDAS%CLARGRAD.BITNET@wiscvm.ARPA
To:  INFO-C@BRL-SMOKE.ARPA
Subject: re: order of evaluation
     
The expression a = ((b=1,b) + (b=2,b) + (b=3,b)) evaluates correctly
to 6 on the ALCOR C compiler running on a TRS-80 Model 4, TRSDOS 6.2.
(This is also the broken compiler which prompted my earlier question about
chars being promoted to ints in function calls, lest I feel too proud :-).)
     
Sterling Bjorndahl, Claremont Graduate School
BJORNDAS @ CLARGRAD on BITNET
