From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Distinguishing type names from other identifiers
Date: 1998/01/28
Date: 1998-01-28T00:00:00+00:00 [thread overview]
Message-ID: <Pine.BSF.3.96.980128085901.28109A-100000@shell5.ba.best.com> (raw)
In-Reply-To: mheaney-ya023680002701982151030001@news.ni.net
On Tue, 27 Jan 1998, Matthew Heaney wrote:
> In article <Pine.BSF.3.96.980127125056.10823A-100000@shell5.ba.best.com>,
> Brian Rogoff <bpr@shell5.ba.best.com> wrote:
> >and I never have collisions between type and variable names. In generic
> >code, choosing specific names (as Matthew Heaney suggested, I think)
> >becomes much harder, the code is generic after all. This convention also
> >makes it easy to write source analysis tools which get type names by
> >simple lexical analysis, and, IMO, is easy on the eyes. I agree, it is
> >redundant, but then so are comments, readable names, the distinction in
> >Ada between functions and procedures ;-), ...
>
> In practice, names for generic types aren't any harder either. The
> convention I use is something like
>
> generic
> type Stack_Item is private;
> with function "=" (L, R : Stack_Item) return Boolean is <>;
> package Stacks is
>
> type Root_Stack is abstract tagged null record;
>
> function Top (Stack : Root_Stack) return Stack_Item;
> ...
> end Stacks;
That's a very nice convention, but as you acknowledge below, its really no
different from _Type, since you add a redundant qualifier "Stack_" to the
name.
> Here's one case where I'd concede that the _Type convention makes sense,
> because you want to emphasize the inchoate character of the formal type.
> But I pretty much use the adjective+noun convention for formal types too,
> for consistency.
That seems reasonable to me. I'd have no problem adopting this, even if I
prefer "_Type" ;-). I would also use _Func, _Proc, for access to function
and procedure, and _Class (for classwide types); I think that's about it.
In Beidler's Scranton data structure suite a far more elaborate naming
scheme is used, but its too much for my tastes. GNAT code is more like
yours, except less verbose, i.e., more abbreviations. I can live with
that, though obviously I prefer the style I'm describing.
> Another example is importing an active iterator as a generic formal type:
>
> generic
> Max_Depth : in Positive;
> package Stacks.Bounded is
>
> type Bounded_Stack is new Root_Stack with private;
> ...
> generic
> type Source_Stack is new Root_Stack with private;
>
> type Source_Stack_Iterator (Stack : access Source_Stack'Class) is
> new Root_Stack_Iterator with private;
>
> procedure Generic_Copy
> (From : access Source_Stack'Class;
> To : in out Bounded_Stack);
>
> end Stacks.Bounded;
This is also OK, but I still don't see why you find the redundant _Type
to be "noise" and the redundant _Stack, not-noisy. I find qualifiers like
_Stack worse, since qualified package names already have that information.
What's your thinking on this?
> Boy oh boy, I really, really wish we had access constant parameters and
> discriminants. Oh well.
Yeah well. I wish hard for out mode function params, but it ain't gonna
happen. Its really nice to have a language thats not changing all the
time too! When the next Ada 200X thread starts, we'll all have a chance.
-- Brian
next prev parent reply other threads:[~1998-01-28 0:00 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-01-07 0:00 Two simple language questions Chip Richards
1998-01-07 0:00 ` Dale Stanbrough
1998-01-07 0:00 ` Tucker Taft
1998-01-07 0:00 ` Matthew Heaney
1998-01-10 0:00 ` Two simple language questions (plural types) Michael F Brenner
1998-01-10 0:00 ` Robert Dewar
1998-01-10 0:00 ` Matthew Heaney
1998-01-10 0:00 ` Robert Dewar
1998-01-12 0:00 ` Anonymous
1998-01-12 0:00 ` Brian Rogoff
1998-01-12 0:00 ` Matthew Heaney
1998-01-12 0:00 ` Brian Rogoff
1998-01-13 0:00 ` Robert Dewar
1998-01-13 0:00 ` Distinguishing type names from other identifiers Nick Roberts
1998-01-13 0:00 ` Matthew Heaney
1998-01-14 0:00 ` Stephen Leake
1998-01-24 0:00 ` Matthew Heaney
1998-01-15 0:00 ` Anonymous
1998-01-24 0:00 ` Matthew Heaney
1998-01-24 0:00 ` Martin M Dowie
1998-01-24 0:00 ` Martin M Dowie
1998-01-24 0:00 ` Pred Nick Roberts
1998-01-25 0:00 ` Distinguishing type names from other identifiers Matthew Heaney
1998-01-15 0:00 ` Aaro Koskinen
1998-01-17 0:00 ` Martin M Dowie
1998-01-17 0:00 ` Martin M Dowie
1998-01-25 0:00 ` Matthew Heaney
1998-01-25 0:00 ` Brian Rogoff
[not found] ` <n5rs5FAStOz0Ew2+@dowie-cs.demon.co.uk>
1998-01-26 0:00 ` Brian Rogoff
1998-01-27 0:00 ` Martin M Dowie
1998-01-27 0:00 ` Brian Rogoff
1998-01-27 0:00 ` Matthew Heaney
1998-01-28 0:00 ` Brian Rogoff [this message]
1998-01-28 0:00 ` Matthew Heaney
1998-01-29 0:00 ` Brian Rogoff
1998-01-30 0:00 ` Mats Weber
1998-01-28 0:00 ` Martin M Dowie
1998-01-11 0:00 ` Two simple language questions (plural types) Brian Rogoff
1998-01-07 0:00 ` Two simple language questions Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
1998-01-13 0:00 Distinguishing type names from other identifiers Adam Beneschan
1998-01-14 0:00 ` Brian Rogoff
1998-01-15 0:00 ` Michael F Brenner
1998-01-15 0:00 ` Nick Roberts
1998-01-16 0:00 ` Robert Dewar
1998-01-16 0:00 ` Michael F Brenner
1998-01-16 0:00 ` Robert Dewar
1998-01-16 0:00 ` Robert Dewar
1998-01-16 0:00 ` Brian Rogoff
1998-01-17 0:00 ` nabbasi
1998-01-18 0:00 ` Robert Dewar
1998-01-21 0:00 ` Philip Brashear
1998-01-20 0:00 ` Benoit Jauvin-Girard
1998-01-20 0:00 ` Robert Dewar
1998-01-14 0:00 tmoran
1998-01-14 0:00 ` Robert Dewar
1998-01-14 0:00 ` Brian Rogoff
1998-01-14 0:00 ` nabbasi
1998-01-15 0:00 ` Brian Rogoff
1998-01-25 0:00 tmoran
1998-01-25 0:00 ` Brian Rogoff
1998-01-26 0:00 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox