From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.230.133 with SMTP id sy5mr41626376obc.22.1412088452573; Tue, 30 Sep 2014 07:47:32 -0700 (PDT) X-Received: by 10.50.122.2 with SMTP id lo2mr102546igb.4.1412088452476; Tue, 30 Sep 2014 07:47:32 -0700 (PDT) Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!a13no6055180igq.0!news-out.google.com!rp1ni8527igb.0!nntp.google.com!a13no6055177igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 30 Sep 2014 07:47:31 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: actual for variable name must be variable compiler error From: Adam Beneschan Injection-Date: Tue, 30 Sep 2014 14:47:32 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:189253 Date: 2014-09-30T07:47:31-07:00 List-Id: On Monday, September 29, 2014 5:27:56 PM UTC-7, Simon Clubley wrote: > However, I want to make it clear I don't write production code like > that. If an in parameter needs modifying in a C program it gets copied > into a local variable and worked on there. Modifying an in parameter > in the way it's done in my example just feels so very wrong to me even > when the language lets you do it... It's definitely caused problems for me, in Pascal, which also lets you do t= hat. There have been lots of times where I've seen the header of a procedu= re/function with its parameters and with documentation that describes the p= arameters, and then I look toward the end of the procedure/function and see= a use of the parameter, and assume it's the value that got passed in--only= to find out later during testing that the "local copy" got changed earlier= . Often I've found that I needed to make a change in that part of the code= and I really needed the original value, but it wasn't stored anywhere. To= be honest, though, this has mostly been a problem with procedures/function= s that were far too long to begin with. I suppose that modifying an "in" p= arameter might be OK in a very short function, shorter than 10 lines. But = longer than that, and I think you risk causing the same kind of confusion I= 've had problems with (of course, you should consider breaking it down anyw= ay). -- Adam