Date: Mon, 2 Jun 2025 08:50:59 +0200
If I understand your proposal correcly, helped by clarifications asked by
many, it is the following:
- A function marked with one or more `assure(x)` is compiled in multiple
different variants, one for each combination of assures.
- Calling such a function can be marked by one or more such `assure(x)`
expressions, which calls the variant that matches the assurances it gives.
With the idea that if your caller guarantees it's not negative, you can use
the fast code path, and if they cannot it's the slow path. Similarly, you
could imagine a sqrt(complex) that has a faster implementation if it's only
a real argument, with a similar assure(c.im == 0) added.
Basically, overloading on runtime argument guarantees.
Is that correct?
On Mon, Jun 2, 2025 at 7:14 AM SD SH via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Yeah, you're right. We should think of a way to find entry point, such as
> processing assure before compiling codes so that compiler can generate
> entry points.
> If the function is not inlined? The optimization will be invaild.
> Optimizing without inline is the main work of assure.
>
> ------------------------------
> *发件人:* Std-Proposals <std-proposals-bounces_at_[hidden]> 代表 Simon
> Schröder via Std-Proposals <std-proposals_at_[hidden]>
> *发送时间:* 2025年6月2日 12:59
> *收件人:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *抄送:* Simon Schröder <dr.simon.schroeder_at_[hidden]>
> *主题:* Re: [std-proposals] 回复: 回复: A Proposal about A New Keyword assure
>
>
> On Jun 2, 2025, at 6:55 AM, SD SH via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>
> - Store entry points?
>
> No. Caller just finds the case it need.
>
>
> How is the caller supposed to know if it does not see the function
> definition? I would claim this is the common case. Mostly inline functions
> are visible to the caller and the optimizer does already the right thing as
> mentioned before.
>
> The function declaration would need a way to specify which assures are
> valid.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
many, it is the following:
- A function marked with one or more `assure(x)` is compiled in multiple
different variants, one for each combination of assures.
- Calling such a function can be marked by one or more such `assure(x)`
expressions, which calls the variant that matches the assurances it gives.
With the idea that if your caller guarantees it's not negative, you can use
the fast code path, and if they cannot it's the slow path. Similarly, you
could imagine a sqrt(complex) that has a faster implementation if it's only
a real argument, with a similar assure(c.im == 0) added.
Basically, overloading on runtime argument guarantees.
Is that correct?
On Mon, Jun 2, 2025 at 7:14 AM SD SH via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Yeah, you're right. We should think of a way to find entry point, such as
> processing assure before compiling codes so that compiler can generate
> entry points.
> If the function is not inlined? The optimization will be invaild.
> Optimizing without inline is the main work of assure.
>
> ------------------------------
> *发件人:* Std-Proposals <std-proposals-bounces_at_[hidden]> 代表 Simon
> Schröder via Std-Proposals <std-proposals_at_[hidden]>
> *发送时间:* 2025年6月2日 12:59
> *收件人:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *抄送:* Simon Schröder <dr.simon.schroeder_at_[hidden]>
> *主题:* Re: [std-proposals] 回复: 回复: A Proposal about A New Keyword assure
>
>
> On Jun 2, 2025, at 6:55 AM, SD SH via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>
> - Store entry points?
>
> No. Caller just finds the case it need.
>
>
> How is the caller supposed to know if it does not see the function
> definition? I would claim this is the common case. Mostly inline functions
> are visible to the caller and the optimizer does already the right thing as
> mentioned before.
>
> The function declaration would need a way to specify which assures are
> valid.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-06-02 06:51:12