Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #139281

Re: Range-aware modulo operator -%

From "Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Newsgroups comp.lang.c, comp.lang.c++
Subject Re: Range-aware modulo operator -%
Date 2018-12-31 09:04 -0500
Organization Liberty Software Foundation
Message-ID <q0d7ja$tgl$1@dont-email.me> (permalink)
References (1 earlier) <tGoVD.88490$Ck1.46277@fx18.am4> <q057a5$1pr$1@dont-email.me> <rfrVD.120946$gU6.41087@fx33.iad> <q05lng$k1l$1@dont-email.me> <A9xVD.313699$_35.734@fx46.iad>

Cross-posted to 2 groups.

Show all headers | View raw


On 12/28/2018 5:08 PM, Richard Damon wrote:
> On 12/28/18 12:16 PM, Rick C. Hodgin wrote:
>> How many new symbols have I created, or implemented in CAlive?
> 
> Looking over the past 6 months of messages, I see suggested:
> 
> min/max: \/  /\  \/=  /\=
> swap:    ><
> shortcut indirect: ~> which later became ~~
> modulus:  -%

The swap operator wasn't my idea.  I just happen to think it's
an excellent idea.  I also introduced ><= as a follow-up, one
which operates standalone and conveys more meaning than simply
the "a >< b;" syntax on a stand-alone line, but it is otherwise
synonymous when used in stand-alone.  When ><= is used in-flight,
it doesn't just swap the values for the remainder of the expres-
sion, but rather permanently update the target variables.

     https://groups.google.com/d/msg/comp.lang.c/S0Y0yfuY8bk/JcW-H8p6AQAJ

> and that doesn't count syntax changes like a < b < c

I have also introduced the underscore-bang operator:  _!

     https://groups.google.com/d/msg/comp.lang.c/TerqLu1Rvg4/bD4xkKizBgAJ

It was added to augment legacy systems with new struct / class
information the new additions to the app are aware of, but old
code is not.  It allows traditional uses of prior structures,
such as dynamically linked external modules which have not been
recompiled and are not aware of the new fields, to still operate
properly while allowing the code that has been recompiled to use
the new features.  It doesn't work on legacy arrays, but does
work apart from that, such as single instance structures that
need to convey more cargo than their finite size allows.  By
passing the pointer, the pre and post portions remain visible
to apps that are aware of it.  And the _ptr! syntax indicates
it's being conveyed with pre and/or post data.

I've added predicates:

     // Old way:
     if (units > 1) qty /= units;

     // As a predicate
     ((units > 1)) qty /= units;

I've added the /% divide-modulo operator, which operates to
obtain the divide value and remainder in one op:

     // Old way:
     divide_value = a / b;
     remainder    = a % b;

     // Using divide-modulo
     divide_value = a /% b : remainder;

I've introduced the @ character for use when passing a variable
to indicate it's being passed by reference.

I've introduced the ability to perform a bit rotate operation
using <<< and >>>, which include <<<= and >>>= as well as the
ability to rotate a sub-portion using start#length syntax, as
in <<7#4<< to begin rotating at the 7th bit and extend for 4
bits to the 7th,8th,9th,10th bit.

     x <<<= 5;           // Rotate the bits in x 5 positions
     y >>>= 5 : carry;   // Rotate the bits in y right 5 pos-
                         // itions, and rotate not just in y,
                         // but rotate each bit through the
                         // carry variable.

I've added mated ctors / dtors, so that when something is in-
stantiated with a particular constructor it calls the associated
destructor, which can then also call an explicitly named one by
using the constructor's name, as ~name().

     class Xyz
     {
         Xyz(void) name1
           { /* ctor code */ }
         ~ { /* dtor code */ }

         Xyz(int a) name2
           { /* ctor code */ }
         ~ { /* dtor code */ }
     };

I've added associated pre {} and post {} blocks to everything:

     pre {
         // Code here

     } if (x == 5) {
         // Code here

     } post {
         // Code here
     }

It encapsulates code associated with the inner thing.  Works
with anything that can be in a block.  Can also be explicitly
moved to using pre; or post;, or you can name them and call
the one explicit one if you have more than one defined using
the pre name; and post name; syntaxes.

Using a post block allows for easy structured exit from a
multi-nested inner loop.

-----
Many features in CAlive.  They are all well into development,
including most of the newer ones over the past couple months.

-- 
Rick C. Hodgin

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 21:09 -0500
  Re: Range-aware modulo operator -% Richard Damon <Richard@Damon-Family.org> - 2018-12-27 21:34 -0500
    Re: Range-aware modulo operator -% "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2018-12-28 05:37 +0100
    Re: Range-aware modulo operator -% James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-29 16:04 -0500
      Re: Range-aware modulo operator -% Richard Damon <Richard@Damon-Family.org> - 2018-12-29 19:13 -0500
  Re: Range-aware modulo operator -% Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-12-28 03:05 +0000
    Re: Range-aware modulo operator -% Robert Wessel <robertwessel2@yahoo.com> - 2018-12-27 21:31 -0600
      Re: Range-aware modulo operator -% Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-12-28 04:20 +0000
    Re: Range-aware modulo operator -% James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 19:32 -0800
      Re: Range-aware modulo operator -% Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-12-28 04:18 +0000
  Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2018-12-28 12:29 +0000
    Re: Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-28 08:10 -0500
      Re: Range-aware modulo operator -% Richard Damon <Richard@Damon-Family.org> - 2018-12-28 10:25 -0500
        Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2018-12-28 15:56 +0000
          Re: Range-aware modulo operator -% Richard Damon <Richard@Damon-Family.org> - 2018-12-28 17:26 -0500
            Re: Range-aware modulo operator -% Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2018-12-28 23:45 +0100
        Re: Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-28 11:44 -0500
        Re: Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-28 12:16 -0500
          Re: Range-aware modulo operator -% Richard Damon <Richard@Damon-Family.org> - 2018-12-28 17:08 -0500
            Re: Range-aware modulo operator -% Tim Rentsch <txr@alumni.caltech.edu> - 2018-12-28 15:01 -0800
            Re: Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-31 09:04 -0500
              Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2018-12-31 18:07 +0000
                Re: Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-31 14:22 -0500
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2018-12-31 21:05 +0000
                Re: Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-31 16:32 -0500
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2018-12-31 23:43 +0000
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2018-12-31 16:44 -0800
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2019-01-01 01:06 +0000
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2018-12-31 19:06 -0800
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2019-01-01 11:32 +0000
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2019-01-01 12:48 -0800
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2019-01-01 23:54 +0000
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2019-01-01 16:09 -0800
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2019-01-02 00:49 +0000
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2019-01-01 17:53 -0800
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2019-01-02 02:36 +0000
                Leader Kiki is not going to like this... (Was: Range-aware modulo operator -%) gazelle@shell.xmission.com (Kenny McCormack) - 2019-01-02 08:36 +0000
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2019-01-02 00:38 -0800
                Re: Range-aware modulo operator -% rbowman <bowman@montana.com> - 2019-01-01 22:40 -0700
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2019-01-02 12:12 +0000
                Re: Range-aware modulo operator -% gazelle@shell.xmission.com (Kenny McCormack) - 2019-01-01 01:53 +0000
                Re: Range-aware modulo operator -% Richard Damon <Richard@Damon-Family.org> - 2018-12-31 16:57 -0500
                Re: Range-aware modulo operator -% Bart <bc@freeuk.com> - 2018-12-31 22:33 +0000
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2018-12-31 13:34 -0800
                Re: Range-aware modulo operator -% Richard Damon <Richard@Damon-Family.org> - 2018-12-31 16:43 -0500
                Re: Range-aware modulo operator -% Keith Thompson <kst-u@mib.org> - 2018-12-31 15:20 -0800
  Re: Range-aware modulo operator -% Eduardo <abdulai60@gmail.com> - 2018-12-28 07:18 -0800
    Re: Range-aware modulo operator -% "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-28 11:45 -0500

csiph-web