Multi-Line Statements


#1

How do you multi-line statements in this language?
I want to create a macro which will take quite the input and it will be unreadable if the user is forced to put it all in one line.


#2

You can use begin blocks. This is very common with macros:

@foo begin
    bar
    baz
end

Passes one argument (the begin block) to the macro @foo.


#3

That is not helpful if you don’t want the content of the begin block to be scoped away. Which often is the case.

Is there any good reason for a macro, that expects 3 statements and does not find all 3 expression on the same line to look for them on the next line.


#4

begin end blocks do not affect the scope in Julia, though the scoping behavior of macros is subtle (as is the case in any language). If you are looking for ways to pass arguments to macros you have several options

If you want to specify arguments on multiple lines you can do

@mac(arg1, arg2,
     arg3, arg4)

You can also do as @mbauman suggested, be aware that in that case the begin end block is a single argument and is a simple data structure called an expression Expr.