Hallo Ivanko,

Du schriebst am Mon, 11 Nov 2013 14:34:40 +0500:

> For non-2^N ranging.

For this yone could consider to allow subrange types as basde types for bit
fields also - so you get "the better" of both things:
 - you can specify the needed / wanted number of bits _and_
 - you can specify the numeric range the bitfield should denote
   (as long as you allowed for sufficiently many bits)

My previous egregious example

  Register = RECORD
               Field_1: 0..77;
               Field_2: 1..3;
               Field_3: 5..25;
               Field_4: 111..112;
               Field_5: -2..-1;
             END;

might thus be specified like this:

TYPE
  Basevalue = 0..77;
  Selector =  1..3;
  FiveStep = 5, 10, 15, 20, 25;  { or just 5..25; }
  { maybe allow for incompletely populated subranges as well? }
  HighEnd = 111..112;
  LowEnd = -2..-1;

  Register = RECORD
               Field_1: Basevalue: 7;
               Field_2: Selector:  2;
               Field_3: FiveStep:  5;
               Field_4: HighEnd:   1;
               Field_5: LowEnd:    1;
             END;

Surely not the simplest of things to implement for a compiler, but very
clearly stating the intentions of the programmer. Now, if the values are
checked for range also (at least at compile time, a sfar as possible), the
language might become one of the safest to use that exist, without
sacrificing versatility.

-- 
-- 
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
-----------------------------------------------------------
Mit freundlichen Grüßen, S. Schicktanz
-----------------------------------------------------------



------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to