comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name?
Date: Mon, 24 Dec 2012 14:58:12 +0200
Date: 2012-12-24T14:58:12+02:00	[thread overview]
Message-ID: <ajr1r4FisghU1@mid.individual.net> (raw)
In-Reply-To: <lylicny8i4.fsf@pushface.org>

On 12-12-24 13:50 , Simon Wright wrote:
> Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
> 
>> Or do you mean to ask if it was a mistake in the definition of
>> Ada.Numerics.Real_Arrays.Solve to give the second formal parameter the
>> name "X", given that "X" is a common name in client code?
> 
> This is certainly a style issue. The second parameter has been 'X' ever
> since it was introduced in v4 of ai-00296 in June 2003[1]. I would
> probably have chosen 'B', but there may well be mathematical texts that
> would take the approach adopted in the ARM.

There may indeed.

> It's very common for mathematical code to adopt terse naming, in line
> with the way mathematicians seem to work,

Agreed. Writing long names in chalk on a black-board (or with ink on a
white-board) is cumbersome and one quickly runs out of space.

> and I find it hard to think of
> sensible names for these parameters.

One problem is that even the subprogram name "Solve" is not according to
good practice. Firstly, an imperative verb like "Solve", should name a
procedure, not a function. For a function, a noun should be used, for
example "Solution". Secondly, "Solve" and "Solution" are really far too
general; the name should be more specific, for example
"Linear_Inverse_Image".

A more specific subprogram name could in turn suggest sensible names for
the parameters, for example "Map" for the matrix Solve.A, and "Value"
for Solve.X.

The overly general names "Solve" or "Solution" suggest parameter names
like "Problem" or "Equation", which are not so good.

> But it ought to be possible for
> client code to be more explicit (unless, of course, the algorithm to be
> implemented was specified by one of the above-referenced mathematicians!)

I have had the pleasure ;-) of implementing some computations specified
by mathematicians (well, control-theory specialist, really). The
mathematical symbols in the given equations were (as typical)
semi-fractal collections of indices and sub-indices surrounding some
base symbol on all (well, most) corners, in different alphabets (latin,
greek, etc.). The Ada identifiers logically became monsters like
"alpha_sub_i_sub_kappa".

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  reply	other threads:[~2012-12-24 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-23 22:28 X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name? Gustaf Thorslund
2012-12-24  8:33 ` Niklas Holsti
2012-12-24 11:50   ` Simon Wright
2012-12-24 12:58     ` Niklas Holsti [this message]
2012-12-24 21:25     ` Gustaf Thorslund
2012-12-24 20:42   ` Gustaf Thorslund
2012-12-24 20:10 ` jpwoodruff
replies disabled

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