Skip to content

Commit

Permalink
Lambdas (#3848)
Browse files Browse the repository at this point in the history
This document proposes a path forward to add lambdas to Carbon. It
further proposes augmenting function declarations to create a more
continuous syntax between the two categories of functions. In short,
both lambdas and function declarations will be introduced with the `fn`
keyword. The presence of a name distinguishes a function declaration
from a lambda expression, and the rest of the syntax applies to both
kinds. By providing a valid lambda syntax in Carbon, migration from from
C++ to Carbon will be made easier and more idiomatic. In C++, lambdas
are defined at their point of use and are often anonymous, meaning
replacing them solely with function declarations would create an
ergonomic burden compounded by the need for the migration tool to select
a name.

Associated discussion docs:

* [Lambdas Discussion
1](https://docs.google.com/document/d/1rZ9SXL4Voa3z20EQz4UgBMOZg8xc8xzKqA1ufPQdTao/)
* [Lambdas Discussion
2](https://docs.google.com/document/d/14K_YLjChWyyNv3wv5Mn7uLFHa0JZTc21v_WP8RzC8M4/)
* [Lambdas Discussion
3](https://docs.google.com/document/d/1VVOlRuPGt8GQpjsygMwH2B7Wd0mBsS3Qif8Ve2yhX_A/)
* [Lambdas Discussion
4](https://docs.google.com/document/d/1Sevhvjo06Bc6wTigNL1pK-mlF3IXvzmU1lI2X1W9OYA/)

---------

Co-authored-by: Chandler Carruth <[email protected]>
Co-authored-by: Richard Smith <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2024
1 parent 50bce0c commit 864c832
Showing 1 changed file with 710 additions and 0 deletions.
Loading

0 comments on commit 864c832

Please sign in to comment.