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,8029f6524ed823f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-03 18:04:08 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshub2.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Specialization of generics References: <46ba9d66.0106031617.c802df3@posting.google.com> X-Newsreader: Tom's custom newsreader Message-ID: Date: Mon, 04 Jun 2001 01:04:07 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 991616647 24.7.82.199 (Sun, 03 Jun 2001 18:04:07 PDT) NNTP-Posting-Date: Sun, 03 Jun 2001 18:04:07 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:8051 Date: 2001-06-04T01:04:07+00:00 List-Id: >the generic is instantiated in a different way if the generic formal >parameters match some condition? For example? You could of course include a boolean constant as a parameter and then have an "if" select which of two code sequences to run. >One application I could think of >would be for an image package to handle 1-bit images in a compact way. You might want to use tagged types. For instance, in Claw.Bitmaps there's: type Basic_DIBitmap_Type is abstract new Root_DIBitmap_Type with ... then various actual types of bitmaps are, eg, type Mono_DIBitmap_Type (Height, Byte_Width : Claw.Int) is new Basic_DIBitmap_Type (Height, Byte_Width) with record ... type VGA_DIBitmap_Type (Height, Width : Claw.Int) is new Basic_DIBitmap_Type (Height, Width) with record ... and then the various routines whose implementation is specific to the color depth are defined, eg, function Get_Size (Bitmap: in Mono_DIBitmap_Type) return Claw.Size_Type; -- Return the size in pixel counts of the bitmap. function Get_Size (Bitmap: in VGA_DIBitmap_Type) return Claw.Size_Type; -- Return the size in pixel counts of the bitmap. etc.