Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <68f811a783d637cd497edb406367fcbbdb5e7288@i2pn2.org>
Deutsch   English   Français   Italiano  
<68f811a783d637cd497edb406367fcbbdb5e7288@i2pn2.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.nk.ca!rocksolid2!i2pn2.org!.POSTED!not-for-mail
From: fir <fir@grunge.pl>
Newsgroups: comp.lang.c
Subject: Re: enum sets
Date: Thu, 29 Aug 2024 16:18:03 +0200
Organization: i2pn2 (i2pn.org)
Message-ID: <68f811a783d637cd497edb406367fcbbdb5e7288@i2pn2.org>
References: <vaoclb$3lfbf$1@dont-email.me> <3be5b29ade1ce269874ab1ef8abf1bd666a7fc9c@i2pn2.org> <vaptfo$3vten$1@dont-email.me> <0ce67f893035672e67fa53b167e543535077df04@i2pn2.org> <65c6c0f42bad7039d830f931c518057b24feda16@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 29 Aug 2024 14:18:07 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="148813"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
In-Reply-To: <65c6c0f42bad7039d830f931c518057b24feda16@i2pn2.org>
X-Spam-Checker-Version: SpamAssassin 4.0.0
Bytes: 5698
Lines: 132

fir wrote:
> fir wrote:
>> Thiago Adams wrote:
>>> On 29/08/2024 10:09, fir wrote:
>>>> Thiago Adams wrote:
>>>>> I am wondering how useful would be to have enum sets.
>>>>>
>>>>> Let´s say you have a function that accepts only monospaced fonts.Then
>>>>> you can use enum monospaced_font_type. Or a switch case where you need
>>>>> to check all and only monospaced_font_type.
>>>>>
>>>>> But at same type you can store at same object monospaced_font_type or
>>>>> font_type.
>>>>>
>>>>> enum font_type
>>>>> {
>>>>>      enum monospaced_font_type
>>>>>      {
>>>>>          CASCADIA_FONT,
>>>>>      },
>>>>>      ARIAL_FONT
>>>>> };
>>>>>
>>>>> This could be arranged in any way.
>>>>>
>>>>>
>>>> reading yet once i dont know what you want
>>>>
>>>> i guess you maybe say what i understand as kinda "micro dictionary"
>>>>
>>>
>>>
>>> It does not use bits. Each enumerator will have a sequential number like
>>> it is today.
>>>
>>> When the same enumerator is used twice the number does not change.
>>>
>>> Sample:
>>>
>>> enum font_type
>>> {
>>>       enum monospaced_font_type
>>>       {
>>>           CASCADIA_FONT,
>>>       },
>>>
>>>       ARIAL_FONT,
>>>
>>>       enum modern_monospaced_font_type
>>>       {
>>>           CASCADIA_FONT,
>>>       },
>>>   };
>>>
>>>
>>>
>>> CASCADIA_FONT is 0
>>> ARIAL_FONT is 1
>>>
>>>
>>>
>>> The implementation could work like this:
>>>
>>> Each enum has a set of "parent enums."
>>>
>>> A cast or conversion from one enum to another will trigger a warning if
>>> the target type is not in the parent set.
>>>
>>> For instance, casting from enum monospaced_font_type to enum font_type
>>> is fine because the parent set of enum monospaced_font_type is { enum
>>> font_type }.
>>>
>>> Each enumerator will also have its own parent set, representing the
>>> enums it belongs to. For example, CASCADIA_FONT belongs to { enum
>>> monospaced_font_type, enum font_type } .
>>>
>>> Therefore, converting an enumerator to any enum in its parent set is
>>> acceptable; otherwise, a warning will be issued.
>>>
>>> In a switch case for an enum type, we must ensure that all enumerators
>>> of that type are present.
>>>
>>> For example, in a switch statement for enum font_type, we need to check
>>> that all enumerators with enum font_type in their parent set are
>>> included.
>>>
>>>
>> ok i guess i undestand what you talkin about
>>
>> you want a list of enums say from 0 to 1703 ordinally on binary level
>> but but you also want to compiler build a table to which group it belong
>> but not encode it as bits
>>
>> if so if you want to repeat given emon in more groups than you need to
>> not give it new walue instead given enum would have two walues
>>
>> it can be done and gives something like more typesafety but the
>> microdictionary is imo much more interesting idea - as those dictionary
>> things are in a way fundamental in programming
>
> overaly i would said this is good idea - but its generalisation: much
> better (could said weird i never thought concretely on this
> microdictionaries though i dropped thinking on C for months completely)

i could say i once used something that resembles this dictionary this is 
gamma table

unsigned char gamma_table[256] =
{
  51,54,60,63,      68,70,73,77,      82,83,84,86,     88,90,92,95,
  98,99,100,101,   102,103,104,106,   108,109,110,111, 113,115,117,120,
  122,122,123,124, 124,125,126,127,  128,129,130,131,  132,133,134,136,
  137,137, 138,139, 140,141,142,143, 144,145,146,147,  148,150,152,153,

  154,154,154,155, 155,155,156,156,  157,157,158,158, 159,159,160,160,
  161,161,161,162, 162,163,163,164,  164,165,166,167, 168,169,170,171,
  172,172,173,173, 174,174,175,175,  176,176,177,177, 178,178,179,179,
  180,180,181,181, 182,182,183,183,  184,185,186,187, 188,189,190,191,

  192,192,192,193, 193,193,194,194,  194,195,195,196, 196,197,197,198,
  198,198,198,199, 199,199,200,200,  201,201,202,202, 203,204,205,206,
  207,207,207,208, 208,208,209,209,  210,210,211,211, 212,212,213,214,
  214,214,214,215, 215,215,216,216,  217,217,218,219, 220,221,222,223,

  224,224,224,225, 225,225,225,226,  226,226,227,227, 228,228,229,229,
  230,230,230,231, 231,231,232,232,  233,233,234,234, 235,235,236,237,
  238,238,238,239, 239,239,240,240,  241,241,242,242, 243,243,244,245,
  246,246,246,247, 247,247,248,248,  249,249,250,251, 252,253,254,255


};

but definig it as such microdictionarry seem to be probably better idea