• Re: enums (was Re: if else is not readable)

    From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c,comp.lang.python on Sat Sep 19 01:33:14 2026
    From Newsgroup: comp.lang.c

    On Sun, 6 Sep 2026 16:42:55 +0100, bart wrote:

    Such enums already exist, but with some restrictions: they must be a
    valid C identifier, so no embedded spaces for example:

    enum {
    sjhbshj,
    ala,
    bala,
    something
    };

    There is no limit on length, and variables containing such enums
    don't need to be 64 or even 32 bits; 8 bits will usually do.

    But you also need to list them in advance.

    A bit limiting in capabilities, compared to, say, enums in C++, Java
    or Python.

    PythonrCOs enums are particularly powerful. TheyrCOre not some separate category of type built into the language, instead, theyrCOre just
    classes that inherit from a base class provided in a standard library
    module. So you can use multiple inheritance and subclassing with them,
    which you canrCOt in those other languages.

    And that standard library module doesnrCOt actually do anything you
    canrCOt do in your own Python code.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann \@johann@myrkraverk.invalid to comp.lang.c,comp.lang.python on Sat Sep 19 16:18:36 2026
    From Newsgroup: comp.lang.c

    On 9/19/2026 9:33 AM, Lawrence DrCOOliveiro wrote:
    On Sun, 6 Sep 2026 16:42:55 +0100, bart wrote:

    Such enums already exist, but with some restrictions: they must be a
    valid C identifier, so no embedded spaces for example:

    enum {
    sjhbshj,
    ala,
    bala,
    something
    };

    There is no limit on length, and variables containing such enums
    don't need to be 64 or even 32 bits; 8 bits will usually do.

    But you also need to list them in advance.

    A bit limiting in capabilities, compared to, say, enums in C++, Java
    or Python.

    PythonrCOs enums are particularly powerful. TheyrCOre not some separate category of type built into the language, instead, theyrCOre just
    classes that inherit from a base class provided in a standard library
    module. So you can use multiple inheritance and subclassing with them,
    which you canrCOt in those other languages.

    And that standard library module doesnrCOt actually do anything you
    canrCOt do in your own Python code.

    And the advantages are what, exactly? Why do you leave this off like
    a cliffhanger?
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2