comp.lang.ada
 help / color / mirror / Atom feed
From: Bill Findlay <yaldnif.w@blueyonder.co.uk>
Subject: Re: highest bit, statically determined
Date: Sun, 30 Sep 2012 00:38:33 +0100
Date: 2012-09-30T00:38:33+01:00	[thread overview]
Message-ID: <CC8D4509.1E319%yaldnif.w@blueyonder.co.uk> (raw)
In-Reply-To: 506769fb$0$6580$9b4e6d93@newsspool3.arcor-online.net

On 29/09/2012 22:36, in article
506769fb$0$6580$9b4e6d93@newsspool3.arcor-online.net, "Georg Bauhaus"
<rm.dash-bauhaus@futureapps.de> wrote:

> On 29.09.12 21:16, Bill Findlay wrote:
> 
> functionfirst_1_bit
> 
> :-)
> 
>> I can now confirm that with GNAT GPL 2012 at -O3 it does inline and fold,
>> but I now see that you want the result to be static as well as the operand,
>> and this does not achieve that.
> 
> Daringly, I have tried to steal the idea and try a comparison (out of
> curiosity, not for the static thing). GCC performs simple tail call
> elimination (explaining the Shift parameter)!
> 
>     function First_1_Bit_A (y : octet; Shift : Integer := 0)  return Natural
> is
>     begin
>        if y >= 2**4  then
>           if y >= 2**6 then
>              return Shift + 7 + Boolean'Pos (y >= 2**7);
>           else
>              return Shift + 5 + Boolean'Pos (y >= 2**5);
>           end if;
>        else
>           if Y = 0 then
>              return 0;
>           else
>              return First_1_Bit_A (y * 2**4, Shift => -4);
>           end if;
>        end if;
>     end First_1_Bit_A;

These bogus parameters, used to pretend that data is not intrinsically
variable, are as objectionable as using goto statements to synthesize while
loops, IMNSHO.

> Don't know if that's as readily adaptable to other word sizes, but it might
> make the functionist happier. ;-)

Fortunately, I have no interest in keeping functionists (or the adherents of
any other religion) happy. 8-)

-- 
Bill Findlay
with blueyonder.co.uk;
use  surname & forename;





  parent reply	other threads:[~2012-09-29 23:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-29 17:34 highest bit, statically determined Georg Bauhaus
2012-09-29 18:11 ` Pascal Obry
2012-09-29 18:59   ` Georg Bauhaus
2012-09-29 19:18     ` Georg Bauhaus
2012-09-29 18:57 ` Bill Findlay
2012-09-29 19:16   ` Bill Findlay
2012-09-29 21:36     ` Georg Bauhaus
2012-09-29 22:06       ` Georg Bauhaus
2012-09-29 23:38       ` Bill Findlay [this message]
2012-09-30 15:01       ` Vadim Godunko
2012-11-04 20:45     ` Yannick Duchêne (Hibou57)
2012-11-04 22:00       ` Bill Findlay
2012-09-30 15:39 ` Anatoly Chernyshev
2012-09-30 18:36   ` Shark8
2012-10-01  8:07   ` Georg Bauhaus
2012-10-01  8:11     ` Georg Bauhaus
2012-10-01  8:52     ` Anatoly Chernyshev
2012-10-01 21:30       ` Georg Bauhaus
2012-10-01 22:55         ` Shark8
2012-10-01 23:25           ` Georg Bauhaus
2012-10-02 11:03         ` Brian Drummond
2012-10-03  9:30           ` kalvink65
2012-10-03 18:54             ` Georg Bauhaus
2012-10-04  7:46               ` Georg Bauhaus
2012-10-04  8:25           ` Stephen Leake
2012-10-04 10:01       ` kalvin.news
2012-10-05  7:50         ` Anatoly Chernyshev
2012-10-05  8:38           ` Anatoly Chernyshev
replies disabled

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