From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f7a9613bbc2bd8c9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-13 18:01:25 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed1.bredband.com!bredband!diablo.netcom.net.uk!netcom.net.uk!newsfeed.icl.net!psiuk-p2!psiuk-p3!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Generic default parameters Date: Mon, 13 May 2002 10:03:57 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: References: NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 1021298640 6616 136.170.200.133 (13 May 2002 14:04:00 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 13 May 2002 14:04:00 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:23987 Date: 2002-05-13T14:04:00+00:00 List-Id: 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" 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 :-) >