Questions tagged [constant-expressions]

Use this tag for question about expressions whose value is known at compile time.

Filter by
Sorted by
Tagged with
6 votes
2 answers
255 views

How useful is the traditional const in addition to constexpr and rvalue references?

In C++, there are two newly created features related to const: constexpr and rvalue references. (IMHO rvalue reference is not ...
user23013's user avatar
  • 2,238
4 votes
6 answers
522 views

How can memory addresses be compile-time constants?

In C the memory address of a statically allocated object or a function is considered compile-time constant. For example this is valid code: ...
user16217248's user avatar
  • 7,535
6 votes
1 answer
182 views

LSP for a language with a lot of compile-time execution

I'm currently designing a language with a heavy focus on compile-time code execution. In particular, all types will be handled as regular compile-time values (similar to the Zig language). This ...
abel1502's user avatar
  • 2,497
11 votes
2 answers
1k views

Why is it so difficult to implement the first Futamura projection?

The Futamura projections are a series of three transformations that can be performed on interpreters, compilers, and compiler-compilers respectively. These transformations rely on a specializer which ...
Corbin's user avatar
  • 724
22 votes
2 answers
4k views

Why is it so hard to evaluate functions with constant arguments at compile-time?

I noticed C23 has constexpr but only for variables, not for functions. While C++ does, this would allow a function to be defined in such a way that if the function ...
user1345541's user avatar