comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: actual for variable name must be variable compiler error
Date: Tue, 30 Sep 2014 07:47:31 -0700 (PDT)
Date: 2014-09-30T07:47:31-07:00	[thread overview]
Message-ID: <fc2b46b3-27f0-45e6-adc3-ea28dfaf4d22@googlegroups.com> (raw)
In-Reply-To: <m0cte9$58d$1@dont-email.me>

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 that.  There have been lots of times where I've seen the header of a procedure/function with its parameters and with documentation that describes the parameters, 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/functions that were far too long to begin with.  I suppose that modifying an "in" parameter 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 anyway).

                                    -- Adam



  parent reply	other threads:[~2014-09-30 14:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29  0:48 actual for variable name must be variable compiler error Stribor40
2014-09-29  2:50 ` Jeffrey Carter
2014-09-29 10:39 ` Brian Drummond
2014-09-29 19:37   ` Simon Clubley
2014-09-29 21:33     ` Georg Bauhaus
2014-09-30  0:27       ` Simon Clubley
2014-09-30 12:09         ` Peter Chapin
2014-09-30 13:17         ` Dennis Lee Bieber
2014-09-30 19:48           ` Simon Clubley
2014-09-30 14:47         ` Adam Beneschan [this message]
2014-09-29 14:27 ` Denis McMahon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox