comp.lang.ada
 help / color / mirror / Atom feed
From: "Dr. Adrian Wrigley" <amtw@linuxchip.demon.co.uk.uk.uk>
Subject: Re: generic function and overloading
Date: Thu, 18 Oct 2007 18:58:06 GMT
Date: 2007-10-18T18:58:06+00:00	[thread overview]
Message-ID: <pan.2007.10.18.19.00.34.353900@linuxchip.demon.co.uk.uk.uk> (raw)
In-Reply-To: 1192688972.967825.31130@t8g2000prg.googlegroups.com

On Thu, 18 Oct 2007 00:28:38 -0700, eliben wrote:

> Hello,
> 
> I have a few "hardware" types, for example uint16 and uint32. And I
> want to write a functions that will set or clear bits of such types.
> For example:
> 
> function Bit_Set(word: uint16; bitn: natural) return uint16;
> 
> function Bit_Set(word: uint16; bitn: natural) return uint16 is
>   mask: uint16 := 2**bitn;
> begin
>   return word or mask;
> end Bit_Set;

Have you checked that packed arrays of booleans aren't
suitable?  usually you need type like this for interfacing
with other languages (eg C) - but then you use the types
in the appropriate Interfaces packages.  And you might
use such a type when writing directly to a hardware
register on a particular peripheral or bus.  But overall
its very rare that you need to write the code you're asking for!
--
Adrian




  parent reply	other threads:[~2007-10-18 18:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-18  7:28 generic function and overloading eliben
2007-10-18  8:18 ` Jean-Pierre Rosen
2007-10-18  9:31 ` Dmitry A. Kazakov
2007-10-18  9:33   ` Dmitry A. Kazakov
2007-10-18 10:32 ` Georg Bauhaus
2007-10-18 11:07 ` Stephen Leake
2007-10-18 11:30 ` Stefan Lucks
2007-10-18 15:58 ` Robert A Duff
2007-10-18 20:20   ` Simon Wright
2007-10-18 21:23     ` Robert A Duff
2007-10-19  5:19       ` Simon Wright
2007-10-19 13:59         ` Robert A Duff
2007-10-18 18:58 ` Dr. Adrian Wrigley [this message]
2007-10-18 22:30   ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox