[RFC] Operators GET, SET and CLEAR for L bits
Mohammad-Reza Nabipoor
mnabipoor@gnu.org
Wed Jan 28 23:17:15 GMT 2026
Hi Jose.
On Wed, Jan 28, 2026 at 11:48:18AM +0100, Jose E. Marchesi wrote:
>
> > Hello people!
> >
> > I propose to add the following operators (to apply to L bits) to the
> > extended standard prelude:
> >
> >
> > prio SET = 7, CLEAR = 7;
> >
> > op SET = (bits b, int n) bits:
> > if n >= 1 AND n <= bits_width
> > then b OR 2r1 SHL (n-1)
> > else b
> > fi;
> >
> > op CLEAR = (bits b, int n) bits:
> > if n >= 1 AND n <= bits_width
> > then b AND NOT (2r1 SHL (n-1))
> > fi;
> >
I like the idea of SET and CLEAR dyadic operators!
> > prio GET = 4;
> >
> > op GET = (bits b, int n) bool:
> > if n >= 1 AND n <= bits_width
> > then ABS (b AND n) /= 0
> > fi;
>
> Note GET is not needed, because the standard operator ELEM does exactly
> that:
>
> flags ELEM flag_with
>
Cool!
>
> but it counts from the left! i.e. it gives you the boolean corresponding
> to the ith boolean starting from the left :)
Yeah! Casting to []bool is also does that. Unfortunately (esp. for me) RR authors
were big-endian people :(
>
> Also I now realize we still have to implement the bitspack standard
> procedures..
>
Good outcome!
More information about the Algol68
mailing list