Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!gatech!emory!arnold From: arnold@emory.uucp (Arnold D. Robbins {EUCC}) Newsgroups: comp.lang.c Subject: Re: *\"LDA\" ok? Message-ID: <2211@emory.uucp> Date: Wed, 26-Aug-87 13:34:00 EDT Article-I.D.: emory.2211 Posted: Wed Aug 26 13:34:00 1987 Date-Received: Fri, 28-Aug-87 06:20:06 EDT References: <8877@brl-adm.ARPA> <8088@mimsy.UUCP> <87@splut.UUCP> Reply-To: arnold@emory.UUCP (Arnold D. Robbins {EUCC}) Organization: Emory University Computing Center Lines: 43 There has been considerable discussion about C's strings and the fact that the lack of string operands is a hindrance. Several years ago I suggested a string operator, but I got little response. Here's my idea again. Add a new symbol for use in comparison, assignment, and argument declarations and functions calls that pass arrays *by value*, say "`". It would be used analogously to * in pointer declarations/use. Array comparison: if (`x == `y) if (`x == `"LDA") Function declaration: int foo (char `arg); /* requires dope vector */ x = foo (`x); char (`junk[5])(); /* function returning array! (length 5) */ Array assignment: `x = `y; There would have to be a number of new rules relating to arrays of the same type but of different length, and using arrays of different types. In particular, it would probably be necessary to special case array of char so that even if two arrays are of different length, all operations would work as if the str* functions had been called, i.e. terminating on a 0 byte. The advantages of this proposal is that it adds something many people feel has long been missing (array operations, passing arrays by value), but without overloading an existing operator or breaking any current code. The disadvantages are that function calls would now require the use of dope vectors, and assigments and comparisons would be compound operations (i.e. a hidden loop); so what looks like a simple, quick operation (like comparing two integers) could be a very long, slow operation. Function call/return times also could increase. Well, so much for throwing out ideas. Any comments? -- Arnold Robbins ARPA, CSNET: arnold@emory.ARPA BITNET: arnold@emory UUCP: { decvax, gatech, sun!sunatl }!emory!arnold ONE-OF-THESE-DAYS: arnold@emory.mathcs.emory.edu