-
Notifications
You must be signed in to change notification settings - Fork 21
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
Better improvement for cexpr "do!" translation rule #592
Comments
@tpetricek I have poor english so please help me at this issue :) Off topic: |
I kind a stumbled upon the same problem some time ago. My observations were kind of different back than. Please see the UserVoice from that time. As far as I can see your use case is a sequential CE, can you try to remove the |
Thanks @mexx . I read #19 and UserVoice, shame my builder not related seq CE (Async, TaskBuilder like) :( I want: let result = opt {
let mutable remains = 10
while remains > 0 do
remains <- remains - 1
return 123 // I want to exit (But cause compilation error) But I have to writing: let result = opt {
let mutable remains = 10
while remains > 0 do
remains <- remains - 1
yield 123 // must use yield This code fragment very misreading by "yield" because yield means "iterate value and continue (next continuation)". I feel bad code complementary.... |
I'm going to close this suggestion, it hasn't seen many comments requesting similar things since first created. |
Better improvement for cexpr "do!" translation rule
We can improve cexpr "do!" translation rule.
Existing F#'s do! with no continuation rule is:
This rule contains "expr has Return()".
But it has to Zero() than Return().
I'm thinking about how to full (naturally) statements support inside of cexpr block,
existing F#'s rule has different and weak both normal expr and cexpr.
Details 1 of 3
It simple physical way tested for:
Output: I saw along the rules.
Details 2 of 3
If OptBuilder can capable while?
Difficulty of while implementation is how exit local blocks by "return" and "return!".
I read Tomas's article good demonstrate how to implement imperative cexpr builder.
The imperative builder indicates "is exiting now" marked as "Option.Some".
My sample code contains partial result record and has exiting flag likely Tomas's:
Output: I saw along the rules too.
Or do! with continuation translation rule applied (Results with Zero()) enable comment line:
That's OK.
Details 3 of 3
But if I append while support in this code:
Output: Oh I surprised why applied only once?!? I don't returned inside cexpr block?!
But if enable WriteLine:
This is OK. I feel a sense of incompatibility... it's really natural behavior than before's.
Thinking why cexpr translation rule cause this problem:
What's or How the "return" behavior, I think long time but not clear...
@bleis-tift gives me cexpr rule complementary problem hints:
Only do! means "return ()".
I feel fix problem simply if change F#'s cexpr do! non-continuation rule.
I propose how to fix this problem:
Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F# are ...
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S?
AsyncBuilder cannot contains return behavior (Hmm, I don't know until just now...)
Related suggestions:
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
The text was updated successfully, but these errors were encountered: