C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::recurse

From: Oliver Hunt <oliver_at_[hidden]>
Date: Fri, 16 May 2025 17:08:53 -0700
> On May 15, 2025, at 6:10 AM, Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> wrote:
>

Other folk commented on earlier issues, you’re essentially wanting a way to refer to the current callee by a standard symbol wherever you want. That’s not particularly hard, but that’s an entire language feature to replace `function_name` with `standard_token`. The only place this would be conceivably needed is if you have a recursive lambda in a context it doesn’t have a name. That could be resolved by allowing naming of lambda expressions.

My main question is for the following

>
> Perhaps, in the case of nested lambdas, we could even specify a number
> to std::recurse to specify which function to re-enter. Looking at the
> above code snippet:
>
> std::recurse<0> = Re-enter the immediate function (might be a lambda)
> std::recurse<-1> = Re-enter the enclosing function (might be a lambda)
> std::recurse<-2> = Re-enter the enclosing enclosing function (and so on...)

How would this work?

You’re wanting to call a function, but calling a function requires knowing the type of that function, but you cannot know who is calling you yet because you haven’t finished compiling the function, let alone the functions that might call it.

—Oliver


> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-05-17 00:09:08