On Fri, 16 Aug 2024 at 17:18, Larry Garfield <la...@garfieldtech.com> wrote:

> On Fri, Aug 16, 2024, at 6:35 AM, Alexandru Pătrănescu wrote:
> > Hi Nick,
> >>
> >> Is there any interest in having enums as class constants?
> >>
> >> I'm often finding cases where I would like to have an enum inside of a
> >> class, but don't want a free-floating enum that's basically like
> >> another class.
> >>
> >
> > ...<snip>...
> >
> >>
> >> class SSHClient {
> >>
> >>    public const enum CommandResult
> >>    {
> >>        case Success;
> >>        case Failure;
> >>        case Unknown;
> >>        case Timeout;
> >>    }
> >>
> >>    // ...
> >> }
> >>
> >>
> >> // Usage:
> >>
> >> SSHClient::CommandResult::Success
> >
> >
> > I feel this topic could be maybe more broad and be called "nested
> > classes" that are already supported in multiple languages: Java, Swift,
> > Python, C#, C++, JavaScript, etc.
> <snip>
>
> I agree with Alexandru.  Since enums are 90% syntactic sugar over classes,
> "inner enums" would be 80% of the way to "inner classes".  And I would be
> in favor of inner classes. :-)  There's a lot of potential benefits there,
> but also a lot of edge cases to sort out regarding visibility, what is
> allowed to extend from what, etc.  But that would support inner enums as
> well.
>
> Based on <snip>....
>
> --Larry Garfield
>

Hello Larry,
I feel obliged to remind about the 80/20 rule where the last 20% of
progress ends up being 80% of all the work. And from the discussion it's
already looking like there are some major questions and caveats and engine
problems that are gonna rear their ugly heads. I'm more in favour starting
with somewhat self-contained features and steadily work to expand on them
as people put the effort into it. The same as was done with the type
system. You can lay the proper foundation now, so it's not blocking future
expansion, but I really do not think full embedded classes are gonna be a
short endeavor - probably multiple years if not half a decade going by
prior record on features of this size.
-- 

Arvīds Godjuks
+371 26 851 664
arvids.godj...@gmail.com
Telegram: @psihius https://t.me/psihius

Reply via email to