comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: Re: N best things about Ada?
Date: Mon, 12 Jul 2010 14:06:59 -0700
Date: 2010-07-12T14:06:59-07:00	[thread overview]
Message-ID: <i1g05i$ae7$1@speranza.aioe.org> (raw)
In-Reply-To: a3e716cc-8be2-4d1c-99db-e827f0ad1f1f@x21g2000yqa.googlegroups.com

On 7/12/2010 7:05 AM, Shark8 wrote:
> People have mentioned packages, non-textual-substitution generics, and
> such.
> But one thing that could come in handy is the named parameters, and it
> is something I like; one of those "little things."
>
> "Circle( Radius =>  23, X =>  28, Y =>  14 );" will always be more
> readable than "Circle( 23, 28, 14 );" plus, there's the added benefit
> that 1) changes in parameter-ordering will not impact calls of this
> sort,&  2) the users of the functions/procedures can place the more
> pertinent parameters [to their task] more prominently [e.g. first].

Yes.

One way to simulate the above when using languages that do not have 
named parameters but do have records or struct, is by passing a record, 
and stick the parameters in the record as fields.

The caller will read the parameters out by the _name_ of the record field.

So, one can change a position of a field in the record, and the called 
function do not have to change, since it is reading the data by the 
field name.

It is not as good as named parameters, but one way around it.

This worked in Matlab, which is interpreted. One nice side benefit is 
that if one has large number of parameters in the call, they now all 
collapse to just one parameter (the record) which holds everything.

One might have to compile everything in other stronger typed static 
languages? but the called function code should not have to change.

--Nasser




  parent reply	other threads:[~2010-07-12 21:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09  0:52 N best things about Ada? usenet
2010-07-09  1:23 ` Britt Snodgrass
2010-07-13 19:05   ` Pascal Obry
2010-07-13 19:26     ` Nasser M. Abbasi
2010-07-14  1:12       ` BrianG
2010-07-14  3:00         ` Britt Snodgrass
2010-07-14  3:52           ` Shark8
2010-07-14 19:08         ` Simon Wright
2010-07-09  2:19 ` Jeffrey R. Carter
2010-07-09  3:08 ` anon
2010-07-09  8:29   ` tonyg
2010-07-10  5:14     ` anon
2010-07-09  9:18 ` Alex R. Mosteo
2010-07-09 11:52 ` John McCormick
2010-07-09 17:27   ` (see below)
2010-07-12 14:05 ` Shark8
2010-07-12 15:13   ` Robert A Duff
2010-07-12 16:14     ` Shark8
2010-07-12 19:44     ` Simon Wright
2010-07-12 21:06   ` Nasser M. Abbasi [this message]
2010-07-13 16:18 ` Warren
2010-07-13 17:21   ` Georg Bauhaus
2010-07-13 17:34     ` Warren
2010-07-13 17:51   ` Jeffrey R. Carter
2010-07-14 18:46     ` Georg Bauhaus
2010-07-14  4:11 ` usenet
2010-07-17  1:18 ` Gautier write-only
replies disabled

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