[SUGGESTION] Compiletime / runtime separation or constexpr, consteval, template<> sickness. #644
Replies: 6 comments 9 replies
-
I don't think we need to mark all compile time things with |
Beta Was this translation helpful? Give feedback.
-
I'm a fan of the unified |
Beta Was this translation helpful? Give feedback.
-
There's no The way to require that an expression |
Beta Was this translation helpful? Give feedback.
-
Why don't we use Cpp1 keywords? fnc1: () constexpr -> i32 = 10;
fnc2: () consteval -> i32 = 10; |
Beta Was this translation helpful? Give feedback.
-
I agree, why complicate and change the meaning of const when we already have keywords in cpp1
On 4 November 2023 15:12:12 Abhinav00 ***@***.***> wrote:
I don't think there's const return types required in any cases. Your other suggestion is similar to what I was thinking for consteval functions.
Here's an example from wiki
consteval { // run this block of code at compile time
if WIN32 != "" || WinVersion > 0 {
-> { use this code }
} else {
-> { use that code }
}
}
So, I think consteval functions can be simply written as:
func : () -> return_type = consteval {
//your code
}
—
Reply to this email directly, view it on GitHub<#644 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AALUZQKGGSLZIQOU2LTWDZTYCZLMTAVCNFSM6AAAAAA65QCWB6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TINZUG4YDS>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I strongly disagree. <> syntax is one thing that bites hard in cpp1. Take for example such simple and common task as converting runtime time code to complie time or back. It will require lot of shuffling and intervening with symblols, instead of just slapping keyword. Compare for example with Zig lang where you write runtime, comptime and build system in one language instead of 3. |
Beta Was this translation helpful? Give feedback.
-
Just to share my idea of
constexpr
.C++ has a strict separation between runtime and compiletime. All about compiletime was assisted with
<>
characters syntax beforeconstexpr
.And I have no idea why
constexpr
was introduced. It was easier to embrace<expression>
with<>
to specify that it is strict compile time.<i>: int
defines compile time variable,i.e. translates to
constexpr int i
Forces
<expression>
to be compile-time, i.e. translates toBeta Was this translation helpful? Give feedback.
All reactions