Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

New feature for C++ core language: Interfaces

34 views
Skip to first unread message

Frederick Virchanza Gotham

unread,
Feb 24, 2023, 4:27:55 AM2/24/23
to

Yesterday I posted a paper to the mailing list for proposals for the C++ Standard. You can download the latest draft of my paper from:

http://www.virjacode.com/download/interface_latest_draft.pdf

Here's an excerpt of the syntax:

interface lockable_bisem : std::binary_semaphore
{
void lock(void) noexcept(false) { acquire(); }
void unlock(void) noexcept(false) { release(); }
};

And a excerpt of the explanation:

Downcasting at compile-time from a Base class to a Derived class works fine when the following two criteria are met:
1) The Derived class does not add any additional member objects
2) The Derived class does not define or override any virtual functions
When these two criteria are met, it is always safe to downcast at compile-time from Base to Derived.
In these circumstances, the Derived class is free to:
a) Define a non-virtual function with a new name that doesn’t exist in the Base class
b) Define a non-virtual function to override a non-virtual function of the same name in the Base class

Richard

unread,
Feb 24, 2023, 11:02:22 AM2/24/23
to
[Please do not mail me a copy of your followup]

Frederick Virchanza Gotham <cauldwel...@gmail.com> spake the secret code
<d16b34b7-e2f6-4aa2...@googlegroups.com> thusly:

>
>Yesterday I posted a paper to the mailing list for proposals for the C++
>Standard. You can download the latest draft of my paper from:
>
> http://www.virjacode.com/download/interface_latest_draft.pdf
>
>Here's an excerpt of the syntax:
>
> interface lockable_bisem : std::binary_semaphore
> {
> void lock(void) noexcept(false) { acquire(); }
> void unlock(void) noexcept(false) { release(); }
> };

Nit: writing (void) is a C-ism and is completely unnecessary in C++
where functions are always prototyped.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
0 new messages