Re: Power operator fails in ordinal range definition

Hairy Pixels via fpc-pascal <[email protected]>
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <CAGsUGtmRFXEe7W4pNcsjH8f1+VWaMz_11Y11nB_QkXXJ8yDpgg@mail.gmail.com>
 On Nov 14, 2024 at 8:11:53 PM, Sven Barth via fpc-pascal <
[email protected]> wrote:

> Because it wasn't deemed necessary that the compiler itself provides this
> operator.
>

You can use it to create ordinal types from bytes using a generic. I was
trying to do something like this. If you do other operations on constants
it makes to include powers too. Of course you can solve this a number of
other ways too but I preferred this one.

type
  SomeInt<const A, B: Byte> = record
    header: 0..(256**A) - 1;
    footer: 0..(256**B) - 1;
  end;

SomeInt<4, 3>

Regards,
    Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.