Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Address of array Message-ID: <3440@sun.uucp> Date: Thu, 3-Apr-86 13:31:55 EST Article-I.D.: sun.3440 Posted: Thu Apr 3 13:31:55 1986 Date-Received: Sat, 5-Apr-86 11:15:00 EST References: <750@abic.UUCP> <2600043@ccvaxa> Organization: Sun Microsystems, Inc. Lines: 25 > struct and array pass-by-value and return - a moderate view: > Structures should always be passed by reference. Usually you only need > to look at fields, and if you need scratch space then you should declare > local variables. (Modify this for structs that fit in small packages, > like struct { short x,y; }). For efficiency reasons yes, they should be passed by reference in many circumstances. However, the language already supports call-by-value, and it can be convenient in many other circumstances, so use or non-use of call-by-value should be a matter of programming style, not of language definition. > Structure and array assignment, and comparison for equality, without buffer > copies is a good thing. You are aware, of course, that comparison for equality of structures, assuming it were added to the language, could not be implemented by a "string compare" instruction or code sequence? Such a sequence would compare the padding bytes between structure members; there is no guarantee that those bytes are ever initialized, so two structures whose values are equal may not contain identical bit patterns. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.arpa (yes, really)