From: tmoran@acm.org
Subject: Re: Specialization of generics
Date: Mon, 04 Jun 2001 01:04:07 GMT
Date: 2001-06-04T01:04:07+00:00 [thread overview]
Message-ID: <b8BS6.59935$%i7.46092561@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 46ba9d66.0106031617.c802df3@posting.google.com
>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.
next prev parent reply other threads:[~2001-06-04 1:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-04 0:17 Specialization of generics John Pitney
2001-06-04 1:04 ` tmoran [this message]
2001-06-04 10:23 ` Ehud Lamm
2001-06-04 14:51 ` Ted Dennison
2001-06-04 16:16 ` Ehud Lamm
2001-06-04 17:28 ` Brian Rogoff
2001-06-04 19:21 ` Ehud Lamm
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox