-
Notifications
You must be signed in to change notification settings - Fork 145
Create FS-1152-For-loop-with-accumulation.md #807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@T-Gro Review wanted |
|
They should be treated both as valid, I don't think there is a big difference. |
|
@T-Gro You mean to treat |
|
But treating |
|
As a user of F#, I'd be concerned with the fact that this proposal is overloading the It seems a bit surprising that the It might be a more clear design if these two differences could be both represented separately in some way:
Maybe it's better to allow the programmer to opt in to either decision independently rather than force-bundling both concepts together? Use the |
|
@omcnoe If you really think about it, the traditional |
|
@Happypig375 More exactly, the traditional |
This is true and has been there a long time but I haven't seen this done. It doesn't make any sense to me because going into technical details is not important for viewing reviewing a high-level suggestion, unless the suggestion itself is highly technical in nature (e.g. may not work unless various technical aspects align) or has specific technical uncertainties that are important for evaluating it. These are extremely rare. I think we should qualify the readme with that info. In this case, what is this RFC supposed to show? Are there technical questions that are uncertain from the suggestion that it resolves that are essential for evaluating the suggestion? |
|
@charlesroddie The original suggestion reads as this
Obviously there are a lot of questions surrounding this - what is After careful design as done in this RFC, the result now becomes
All the design choices and justifications are to be included in this RFC for a comprehensive evaluation on the validity of this suggestion, being concrete trumps being ambiguous. This is why making an RFC can also help convince approval. Also, I don't get why you are complaining about procedures instead of the actual suggestion - it seems not to be constructive behaviour especially when paired with the 👎 reaction on the top post, as seen not just in this PR, but also in other issues, where the 👎 reaction persists despite a proper reply. |
I do think that the language design process makes sense and I therefore believe it is ok if somebody points to it. |
|
In my opinion this construct would make it more complex for newcomers to understand code, intransparent about what is actually executed underneath (Seq.fold, List.fold, a for loop with a mutable variable?) and I don't see how it makes code shorter or easier to read. A for loop with a mutable variable is a few characters longer and familiar to most people. Folds are also more transparent in my opinion and can be used in pipe-chains. |
|
@Happypig375 did establish that folds aren't an edge case by any stretch -- in fact, it's the third most common HOF after Granted, To me, the main downside of using a mutable is that, especially as beginners, we're being encouraged to use Likewise, the downside of folds, especially for beginners, is that they require memorizing a lot of seemingly arbitrarily ordered arguments: Virtually the only situation you'd ever reach for the Finally, this is a relatively minor point, but if you're trying to draft up a loop or HOF application for a complicated algorithm, you might first try a fold and find that it isn't sufficient. I think both beginners and advanced users alike have this experience routinely. In those situations, refactoring the function argument to an HOF is not as intuitive as adding or removing things to/from a loop. |
|
Just to clarify, I didn‘t mean to say that folds are not common, I meant to say that the places where you actually benefit from this syntax (meaning shorter or more readable code) seem pretty far fetched to me. The „don‘t use mutables“ argument is actually pretty bad since mutable variables inside a function body don’t harm anyone. Global mutables and mutable objects kill functional programming, not some accumulator variable. |
|
I wouldn't argue that it's shorter. F# doesn't really go out of its way to make code shorter. It may or may not be more readable to an experienced user either. The main point is that it can help with adoption if users don't have to go through the whole journey of "Wow, folds are pretty overwhelming, can't I just use a loop? Oh I guess I can but can I do it without using a mutable since I'm trying to practice immutability right now? Oh okay I guess I can use |
|
I don’t see how this should be beginner friendly, you use an imperative construct (a loop) which in its body returns a value which is initialized by using |
|
Although it's in a different form, intuitively, it feels a lot like the The main problem with CEs, which has been pointed out in the RFC, is that they're notoriously difficult to debug. |
Comprehensive evaluation doesn't make sense before summary evaluation. High level first then details and that has always been the approach. If an unambiguous summary isn't possible that should be explained in the summary and some attempt made to communicate it. The concrete problems created is that time is wasted reviewing details - it's other people's time but sometimes reviews are requested and people may feel they have to review the details. My role is only to keep an eye out that any technical discussion here doesn't bypass a high level process of community review of the language suggestion, resulting in features getting into F# which are fully technically specified but which are not good overall additions to the language. |
|
Thank you for putting together this detailed RFC. The level of detail provided was genuinely helpful in understanding both the motivation behind the proposal and the various technical options considered. It's clear that significant thought and effort went into this document. After careful consideration, I've decided to close this PR for now. The reasoning is captured in the discussion thread, where I've marked the suggestion as "Probably not". As noted there, this doesn't preclude revisiting the idea in the future should circumstances change—whether through new compelling use cases, shifts in the ecosystem, or renewed community interest and consensus. Thank you again for your contribution to the F# language design process. |
rendered RFC