From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: Generic default parameters
Date: Mon, 13 May 2002 10:03:57 -0400
Date: 2002-05-13T14:04:00+00:00 [thread overview]
Message-ID: <aboh4g$6eo$1@nh.pace.co.uk> (raw)
In-Reply-To: slrnadq3j5.1cf.randhol+abuse@kiuk0156.chembio.ntnu.no
The original issue was one of bringing in a "Count Of List Elements" type as
a generic parameter. You have to bring in the element type because you can't
know what that should be in advance. However, you *might* want to say
"Unless Otherwise Directed Make The Count Of List Elements Be 'Natural'" -
the reason being that for a large number of simple cases, you may never want
anything more specialized than Natural - so you don't want the extra work of
specifying it in the instantiation. Yet you want the ability to override the
default from time to time if for some reason you *do* want a more
specialized type. Example:
generic
type Element_Type is private ;
type Element_Count is range <> => Natural ; -- or whatever syntax
package Lists is.....
and then....
package My_Simple_Lists is new Lists (Element_Type => Some_Type);
(Here I got a list that will be counted up with Natural)
package
My_Really_Strongly_Typed_Lists
is new
Lists (
Element_Type => Apple_Type,
Element_Count =>
Apple_Counter_Not_To_Be_Confused_With_Apple_Cart_Pushers_Counters);
The idea is to let the obsessive-compulsives get what they want without
bumming out the laid-back, chilling dudes for whom Natural is good enough.
:-)
From here, I might imagine a case where for a more complex generic parameter
list, I might have half of the parameters have defaults the other half are
"must supply" parameters. Think of when you might have a function or
procedure in which you have default values for parameters. Same thing.
MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas www.pacemicro.com
Enabling the digital revolution
e-Mail: marin.condic@pacemicro.com
"Preben Randhol" <randhol+abuse@pvv.org> wrote in message
news:slrnadq3j5.1cf.randhol+abuse@kiuk0156.chembio.ntnu.no...
>
> I'm not sure I understand. If you have 5 parameters and only two can
> have a default then I don't see why giving the generic defaults would
> help. To me it sounds like making generics less strongly typed/more
> dynamic, but probably I misunderstand you :-)
>
next prev parent reply other threads:[~2002-05-13 14:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-10 14:22 Generic default parameters Thomas Wolf
2002-05-10 16:38 ` Preben Randhol
2002-05-10 16:50 ` Marin David Condic
2002-05-11 9:29 ` Simon Wright
2002-05-13 15:03 ` Hyman Rosen
2002-05-11 12:28 ` Preben Randhol
2002-05-13 14:03 ` Marin David Condic [this message]
2002-05-13 14:49 ` Hyman Rosen
2002-05-10 19:04 ` Hyman Rosen
2002-05-11 12:23 ` Preben Randhol
2002-05-11 13:49 ` Larry Kilgallen
2002-05-13 14:06 ` Marin David Condic
2002-05-10 19:27 ` Randy Brukardt
2002-05-11 12:32 ` Preben Randhol
2002-05-10 22:14 ` Stephen Leake
2002-05-13 7:49 ` Thomas Wolf
2002-05-13 8:49 ` Dmitry A. Kazakov
2002-05-13 14:00 ` Stephen Leake
2002-05-13 15:21 ` Dmitry A. Kazakov
2002-05-13 16:42 ` Stephen Leake
2002-05-14 10:24 ` Dmitry A. Kazakov
2002-05-14 14:02 ` Stephen Leake
2002-05-15 10:08 ` Dmitry A. Kazakov
-- strict thread matches above, loose matches on Subject: below --
2002-05-14 4:57 Grein, Christoph
2002-05-14 10:23 ` Dmitry A. Kazakov
2002-05-14 11:03 Grein, Christoph
2002-05-14 12:01 ` Dmitry A. Kazakov
2002-05-14 14:05 ` Stephen Leake
2002-05-15 8:44 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox