diff options
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 + ] ; |