Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site ihdev.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!ihdev!rjv From: rjv@ihdev.UUCP (ron vaughn) Newsgroups: net.lang.c Subject: Re: passing arrays by value Message-ID: <227@ihdev.UUCP> Date: Thu, 16-May-85 11:48:50 EDT Article-I.D.: ihdev.227 Posted: Thu May 16 11:48:50 1985 Date-Received: Fri, 17-May-85 01:29:50 EDT References: <226@ihdev.UUCP> Distribution: net Organization: AT&T Bell Laboratories Lines: 33 *** EGASSEM RUOY HTIW ENIL SIHT ECALPER *** i said earlier: >quick and simple: in c i wanted to pass an array by value. oops. hmmmm. i've already received a few letters saying "are you sure you mean by value??" i should have explained, i was doing the classic "knights tour" problem, using branch and bound techniques. classic b&b differs from regular ol' backtracking, it builds a big tree, and keeps a local version of the board at EACH node in the tree. hence each recursive call to place a knight on the board must pass the board by value. on the other hand, with most backtracking you can keep one version of the board and work with it only. these comments on b&b and backtracking algorithms are generalizations. there are exceptions, b&b can be forced to use pass by reference, but pass by value is much cleaner. (who cares about memory...) it is kind of interesting to compare C to, say, pascal, where you use "var" (or whatever, i hate pascal) to explicitly state you want pass by reference. from a user viewpoint, pascal makes sense, you tell it how you are passing. in C it looks like everything is passed by value (so you wind up passing &thing to get pass by reference) except for arrays, which apparently can't be passed by value. this *almost* makes sense... does this really matter? am i still missing something?? is there a reason arrays are special -- the "array IS a pointer" argument, perhaps?? is the array==pointer at the heart of C and thinking anything else a valid reason for public flogging??? keep those cards and letters coming, ron vaughn ...!ihnp4!ihdev!rjv