Date: Mon, 28 Apr 2025 10:22:01 -0400
On Mon, Apr 28, 2025 at 9:56 AM Marcin Jaczewski <
marcinjaczewski86_at_[hidden]> wrote:
> pon., 28 kwi 2025 o 15:48 Arthur O'Dwyer via Std-Proposals <
> std-proposals_at_[hidden]> napisał(a):
> >
> > Now, the big problem with this is that just knowing that `b`'s value is
> known to the compiler at compile-time — a boolean yes/no answer — doesn't
> give the programmer access to what numeric value the compiler thinks it has!
> > So we still can't write, e.g.,
> > uint64_t myLog(uint64_t a, uint64_t b)
> > {
> > if consteval (b) {
> > std::array<int, b> subresults; // ERROR, the expression `b` did
> not magically become a constant expression in here... unless you propose
> that it should, which is a whole new can of worms
> > // Optimized implementation with b known
> > return ...;
> > }
> > // Generic implementation
> > }
>
> Even more:
> ```
> if consteval (b) {
> return std::array<int, b>{};
> }
> ```
> How do we even handle this? Function would effectively change its type
> based on values you pass to it.
>
Right, that's a good example of the whole new can of worms that would
result from making my example not-an-"ERROR".
One might say that the feature that is *possible* is not *useful*, while
the feature that is *useful* is not *possible*.
–Arthur
marcinjaczewski86_at_[hidden]> wrote:
> pon., 28 kwi 2025 o 15:48 Arthur O'Dwyer via Std-Proposals <
> std-proposals_at_[hidden]> napisał(a):
> >
> > Now, the big problem with this is that just knowing that `b`'s value is
> known to the compiler at compile-time — a boolean yes/no answer — doesn't
> give the programmer access to what numeric value the compiler thinks it has!
> > So we still can't write, e.g.,
> > uint64_t myLog(uint64_t a, uint64_t b)
> > {
> > if consteval (b) {
> > std::array<int, b> subresults; // ERROR, the expression `b` did
> not magically become a constant expression in here... unless you propose
> that it should, which is a whole new can of worms
> > // Optimized implementation with b known
> > return ...;
> > }
> > // Generic implementation
> > }
>
> Even more:
> ```
> if consteval (b) {
> return std::array<int, b>{};
> }
> ```
> How do we even handle this? Function would effectively change its type
> based on values you pass to it.
>
Right, that's a good example of the whole new can of worms that would
result from making my example not-an-"ERROR".
One might say that the feature that is *possible* is not *useful*, while
the feature that is *useful* is not *possible*.
–Arthur
Received on 2025-04-28 14:22:14