begin marker #17837
Replies: 0 comments 4 replies
-
This is starting to look dangerously close to Pascal! function E(x: real): real;
function F(y: real): real;
begin
F := x + y
end;
begin
E := F(3) + F(4)
end; |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Another underserved use case, as noted at That is, you want The marker could be Which is the linked ticket on
alternatively
|
Beta Was this translation helpful? Give feedback.
-
People like me keep asking for early return support. A begin block could support early returns as "guard" syntax, such as we are used to in pattern matches and for comprehensions.
I guess that is one guard, but that is better than none. I just refactored a In fact, it was so annoying, I accidentally did it twice on different branches. |
Beta Was this translation helpful? Give feedback.
-
A long function definition might consist of many short local functions followed by a function body.
An optional
begin
marker would help locate where the body starts. Often this is marked with a comment.An alternative idea is to allow additional indentation of the prefix of definitions:
That expression is currently badly indented.
Possible restrictions on such syntax might include that only method defs are allowed (or lazy val or templates); the idea is that evaluation begins at the begin.
A related feature request is to make function result value more perspicacious:
That syntax would allow naming the body:
but burdens
end
with runtime semantics.Alternatives are
value.tap(f)
andtry body finally f
as a way to say "here's the result and additional side effects".Also Begin the Beguine with Thomas Hampson.
Beta Was this translation helpful? Give feedback.
All reactions