Okay, now that I have a better understanding of the limitations on macros,
I have a couple more questions.
First, the first limitation stated in the tutorial says that the parser is
greedy. However, a lot of the ambiguities referred to in the second
limitation would be eliminated if the parser wer
On Wednesday, 20 February 2013, Paul Stansifer wrote:
>
> Any idea why? () could be considered an expression, but it's not in an
>> expression position, and a lot of things could be considered expressions
>> and don't do this.
>>
> The local ambiguity errors exist for the internal reason that the
> Any idea why? () could be considered an expression, but it's not in an
> expression position, and a lot of things could be considered expressions
> and don't do this.
>
The local ambiguity errors exist for the internal reason that the Rust
parser `fail`s (I guess now it `die!`s) when it gets a pa
On Tue, Feb 19, 2013 at 6:43 PM, Paul Stansifer wrote:
> Alternation already exists, at least at the outer level:
>
> macro_rules! alt_example(
> ( cons($e1:expr, $e2:expr) ) => ( ... )
> ( mt() ) => ( ... )
> )
>
> Of course, making use of it for something other than a whole macro
> invoc
Alternation already exists, at least at the outer level:
macro_rules! alt_example(
( cons($e1:expr, $e2:expr) ) => ( ... )
( mt() ) => ( ... )
)
Of course, making use of it for something other than a whole macro
invocation requires the use of a helper macro, which can be tricky if the
hel
Okay, that makes sense. I figured it was probably just non-trivial to
implement, but I figured I'd ask. Something else I was wondering about was
the lack of alternation or option (0:1 repetition) syntax. I was writing a
macro that would expand to a match, replacing short form patterns with
their lo
It's just a matter of not having implemented it yet. Each new macro
invocation location unfortunately requires modifying the AST, which affects
all the code that is interested in that part of the AST. It's not a huge
amount of work, but it does inflict lots of "can't happen" error cases on
unrelate
I was fiddling around with macros when I noticed that they don't work in a
pattern position (such as on the LHS of => in a match). Just for
curiosity's sake, I was wondering whether there was a particular reason for
this, or if it just hadn't been implemented / wasn't worth implementing.
The motiva