C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 24 Feb 2023 09:38:43 +0000
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.

Received on 2023-02-24 09:38:55