Hi! This is a proposal for an additional macrocall syntax which will parse past newlines until an end
is encountered. The idea is to have a syntax which allows using a macro more akin to reserved keyword blocks such as function
, struct
, etc., without requiring manual use of begin ... end
. The syntax proposed here uses @@
because this is currently a syntax error, but better alternatives may exist.
As an example, suppose I want to save three characters when defining functions, so I define the macro:
macro fun(signature, lines...)
quote
function $(signature.args[1])($(signature.args[2:end]...))
$(lines...)
end
end |> esc
end
Then with the new syntax rule, the following would be a valid macrocall:
@@fun f(x)
y = x^2
return y
end
and equivalent to
@fun f(x) y = x^2 return y
A more useful example might be something like:
macro loop(before, condition, body, after)
quote
$before
while $condition
$body
end
$after
end |> esc
end
resulting in the following macrocall:
@@loop
begin
x = 1
y = 10
end
x < y
x += 1
println(x)
end
being equivalent to:
@loop begin
x = 1
y = 10
end begin
x < y
end begin
x += 1
end begin
println(x)
end
Of course, these are simplified examples to illustrate the main idea, and actual macros which make use of this syntax would presumably add a lot of boilerplate around the transformed expressions.