comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <mcNOSPAM@mckae.com>
Subject: Re: basic ada question
Date: Mon, 22 Aug 2005 08:28:43 -0500
Date: 2005-08-22T08:28:43-05:00	[thread overview]
Message-ID: <bfa4d$4309d30e$49955f2$19914@ALLTEL.NET> (raw)
In-Reply-To: <m2ek8phe27.fsf@grendel.local>

Simon Wright wrote:

> I sometimes find myself using a mixed style,
> 
>                Invalidate (Current_Item (Using),
>                            If_For_Instance =>
>                              Instance_Base_P (For_The_Instance));

I find the mixed style particularly valuable in situations where Boolean 
arguments are used.  For example, if I had the procedure declaration:

   procedure Do_Something(To_This_Instance   : in Item_Type;
                          First_Time_Through : in Boolean);

Invocations of this procedure could look like:

    Do_Something(Current_Instance, True);

Correct, but that "True" doesn't tell you a whole lot.  You could
define your own two-value enumeration, with enumerals First and
Not_First, but all you really need in that procedure is just plain
old Boolean.  You could also subtype Boolean, use renames clauses on,
or define constants for, True and False, but that's just more code
that could easily distract the reader, when all you really need is
an invocation like this:

    Do_Something(Current_Instance, First_Time_Through => True);

Within the procedure's implementation, the context and appropriateness
of the Boolean argument is apparent, and the invocation of it using
named notation for the Boolean parameter pulls some of that context into
the caller for increased clarity.

-- Marc A. Criley
-- McKae Technologies
-- www.mckae.com
-- DTraq - XPath In Ada - XML EZ Out



  parent reply	other threads:[~2005-08-22 13:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-19 16:35 basic ada question Randy
2005-08-19 17:55 ` Adrian Knoth
2005-08-19 20:22   ` Simon Wright
2005-08-19 21:13     ` Adrian Knoth
2005-08-22 13:28     ` Marc A. Criley [this message]
2005-08-19 21:43   ` Randy
2005-08-19 22:03     ` Adrian Knoth
2005-08-20  3:30   ` Jeffrey R. Carter
2005-08-20 14:28     ` Robert A Duff
2005-08-21 17:37     ` Steve
2005-08-21 21:45       ` Randy
2005-08-22 13:41         ` Steve
2005-08-23  1:47           ` Steve
2005-08-23 17:24             ` Martin Krischik
2005-08-23 21:32               ` Adrian Knoth
2005-08-24 16:41                 ` Martin Krischik
2005-08-20  6:36   ` [OT] Randy
2005-08-20 12:58     ` [OT] Larry Kilgallen
2005-08-20 19:48       ` [OT] Randy
2005-08-20 20:25         ` [OT] Adrian Knoth
2005-08-20 21:55           ` [OT] Way out in Left field Randy
2005-08-20 22:44           ` [OT] Randy
2005-08-20 21:27     ` [OT] TEST Randy
2005-08-20 22:52       ` Frank J. Lhota
2005-08-20 23:00         ` Randy
2005-08-20 22:31 ` [ot] test Randy
2005-08-20 22:39 ` Randy
replies disabled

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