dotnet / dotnet/csharplang

[Proposal]: `tail return` recursive calls

Open
#8,991 0 comments 0 reactions 1 assignee Claimed by @jcouv View on GitHub
Proposal champion
Dominant language
C#
Stars
12.7k
Forks
1.1k
Avg merge
11h 1m
Merged PRs (30d)
3

Description

# `tail return` recursive calls

* Specification: In the discussion for now
* Discussion: https://github.com/dotnet/csharplang/discussions/8990

## Summary
[summary]: #summary

There are a number of instances where it may be clearer to express your algorithm via recursion, especially tail recursion, but unfortunately all recursion in C# currently requires O(n) space for just the call stack, meaning that your algorithm cannot take less than O(n) space.

It is proposed that C# provide a new statement form and a new expression form to allow tail-recursive calls to consume O(1) space.

## Design meetings

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.