RFC: `for...in` construct

Hello,

Here’s an RFC I drafted for adding a for...in construct to the language. Feedback is welcome here :slight_smile:

Some reservations were already voiced here, and acknowledged in the RFC.

I was hoping it adds comprehensions/LINQ to OCaml but it’s a syntax sugar for iter. :slight_smile:

1 Like

This could be done nicely with a ppx no?

for…in could also be done “nicely” with ppx then

2 Likes

To a lesser extent (I think) but yes. I mean I’d be happy with comprehension in OCaml too, but questions about “which data structure” does one build, and how do you specify that are unclear to me.

I’m not going to draft more than one RFC at a time, but feel free to do so if you have a clear idea of implementation

List and array comprehensions are already present in OxCaml, if you’re interested (I haven’t used them myself, but they’re documented here).

5 Likes

Nice! Didn’t know about that feature of OxCaml, thank you :slight_smile:
I wonder if the mechanism can be transparently extended to other data structure (e.g. any data structure that can be filter_mapped)