From 74192d6a32c05b4cf58ed920ba23c27608b6e545 Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Sun, 28 Apr 2024 04:47:06 +0800 Subject: [PATCH] docs/diary/2024-04-28-code-block-and-return.md --- docs/diary/2024-04-28-code-block-and-return.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 docs/diary/2024-04-28-code-block-and-return.md diff --git a/docs/diary/2024-04-28-code-block-and-return.md b/docs/diary/2024-04-28-code-block-and-return.md new file mode 100644 index 00000000..78b0208f --- /dev/null +++ b/docs/diary/2024-04-28-code-block-and-return.md @@ -0,0 +1,17 @@ +--- +title: code block and return +author: Xie Yuheng +date: 2024-04-28 +--- + +关于 code block 与 return,我能想到下面几种设计方案: + +- (1) 放弃 code block 作为 expression,直接模仿 JS 语法。 + +- (2) code block 作为 expression,此时不能用明显的 return, + 应该设计为最后一个 expression 作为 implicit return value。 + 因为 return 与 early return 相冲突。 + - 并且这里没有更好的语法关键词选择, + `yield` `give` 等等都不太好。 + +我选择方案 (2)。