-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Currently, even though macro expansion is done during the parse phase of the compiler it does not fully inline the production because if the ending of macro is an if
block a following else
block is not paired up with it.
I have been told that this is intended, though I believe that it is rather strange behaviour, because if someone was to output the --extended=pretty
output of the compiler from said macro expansion it would look like the else block should match up.
Motivation:
If this was allowed then macro writers would have a very nice and clean way to have an optional fallout case that is syntactically nice to look at.
Example:
Lets say you want to write an initialiser for an object that relies on some item but have the option for a default value that is written by the user, with the else block you could write the following:
let item = init_foo!{ parms } else { Foo::new(15) };
Here the initialisation might go ahead normally but if not there is a custom default value.