diff options
author | Samuel Lidén Borell <samuel@kodafritt.se> | 2025-08-31 23:23:12 +0200 |
---|---|---|
committer | Samuel Lidén Borell <samuel@kodafritt.se> | 2025-08-31 23:23:12 +0200 |
commit | 04ef304ec44329971885a3a25fa58eadf9251aaf (patch) | |
tree | 5e57ace217120b564022e93e863512cdf4486ad6 /notes | |
parent | f241350e7db6682dac502f48241b6f9576356169 (diff) | |
download | slul-try2-main.tar.gz slul-try2-main.tar.bz2 slul-try2-main.zip |
Diffstat (limited to 'notes')
-rw-r--r-- | notes/multiline_exprs.txt | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/notes/multiline_exprs.txt b/notes/multiline_exprs.txt new file mode 100644 index 0000000..34af72a --- /dev/null +++ b/notes/multiline_exprs.txt @@ -0,0 +1,110 @@ +Syntax 1: Parentheses +--------------------- + + int func_ret = (do_stuff + x + y + z) + + []int array = [ + 1 + 2 + 3 + ] + + +Syntax 2: `with` for functions +------------------------------ + + int func_ret = do_stuff with + arg1 = x + arg2 = y + arg3 = z + end + + []int array = [ + 1 + 2 + 3 + ] + + # Or, using `with` for even for arrays: + []int array = with + 1 + 2 + 3 + end + + +Syntax 3: With line continuations at end +---------------------------------------- + +Note that the last line shouldn't have any `\` (which is a bit unintuitive) + + int func_ret = do_stuff \ + x \ + y \ + z + + # Should line continuations be required in this case? + []int array = [ \ + 1 \ + 2 \ + 3 \ + ] + + +Syntax 4: With line continuations at start +------------------------------------------ + +This would require look-ahead in the parser. Also, code editors won't be +able to auto-indent :( + + int func_ret = do_stuff + | x + | y + | z + + # Should line continuations be required in this case? + []int array = [ + | 1 + | 2 + | 3 + | ] + +Syntax 5: Special long-line block +--------------------------------- + + longline + int func_ret = do_stuff + x + y + z + end + + # Should a lone-line block be required in this case? + longline + []int array = [ + 1 + 2 + 3 + ] + end + +Syntax 6: Line-continuation-start and line-continuation-end +----------------------------------------------------------- + +I find this quite intuitive. But I don't think it's used by any other +programming language: + + + int func_ret = do_stuff ... + x + y + z ; + + []int array = [ ... + 1 + 2 + 3 + ] ; |