C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Paper on Interfaces (5 Pages)

From: Breno Guimarães <brenorg_at_[hidden]>
Date: Fri, 24 Feb 2023 06:43:03 -0300
Oh, I was thinking in the other direction. I thought it was beautiful to
not have a new keyword and clearly state "i have this lockable which is
really a binary_semaphore, but has these extra methods" and I think it's
unambiguous syntax (so would be more easily accepted)

But yes, it's way too soon to talk about syntax.

Em sex., 24 de fev. de 2023 06:38, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> escreveu:

> On Fri, Feb 24, 2023, Breno Guimarães wrote:
> >
> > What about
> >
> > using lockable_bisem = std::binary_semaphore {
> > void lock() { acquire(); }
> > Void unlock() { release(); }
> > };
>
>
> I'm open to other syntaxes. Of course the word 'interface' is probably
> used in a lot of code as the name of a type or a variable, so it would
> have to be something like "_Interface" or "__interface".
>
> In the syntax you give above, Breno, I would want to be a tiny bit
> more verbose to indicate we're creating an interface, maybe something
> like:
>
> using new interface [ lockable_bisem = std::binary_semaphore ] {
> void lock() { acquire(); }
> void unlock() { release(); }
> };
>
> so then 'interface' could be an "identifier with special meaning"
> instead of a keyword, meaning we could still have:
>
> typedef int interface;
>
> using new interface [ lockable_bisem = std::binary_semaphore ] {
> void lock() { acquire(); }
> void unlock() { release(); }
> };
>
> I do want to have a verbose word in there something like "interface"
> or "facade" or "veneer". I am quite a pedantic and verbose person in
> general but I really want it to be obvious at first glance what the
> code is doing, especially since "using" can already do a few different
> things.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-02-24 09:43:16