Re: [rust-dev] Why there's this asymmetry in defining a generic type/function/method and calling it?

2014-11-18 Thread Paul Stansifer
If not, then the expression doesn't seem to be ambiguous, but I can see, that writing the parser would be more tedious. So is this the reason, an easier parser implementation and therefore most likely faster parsing of code? It's not so much the speed of the parser that is the matter, but

Re: [rust-dev] AST transforming syntax extension

2013-09-19 Thread Paul Stansifer
(note that you should wrap your second RHS in `{}` in order to avoid hitting the following bugs: https://github.com/mozilla/rust/issues/8012 https://github.com/mozilla/rust/issues/4375) I had misunderstood your original question: now I see that, by operate on, you meant that you wanted to run the

Re: [rust-dev] AST transforming syntax extension

2013-09-19 Thread Paul Stansifer
Originally I *did* want to operate on AST, because I couldn't get macro system to parse more than the first statement when I was writing my rules like this: ( $head:stmt ; $($rest:*stmt*);+ ) = ( $head ; stmt_list!( $($rest);+ ) ); Apparently interpolated statements cannot be re-parsed

Re: [rust-dev] How to use concat_idents! properly

2013-03-04 Thread Paul Stansifer
I'm afraid it's not primarily a parsing issue; it has to do with the Rust implementation, in particular that the same AST type holds pre-expanded code (potentially containing macro invocations) and post-expanded code (in which macro invocations must not be present). Changing the identifier type to

Re: [rust-dev] How to use concat_idents! properly

2013-03-04 Thread Paul Stansifer
that the macro system has improved, but it's still no small project, and I wouldn't blame anyone for vetoing making such a large change to the Rust AST out of a generally precautionary attitude. Paul Glenn On Mar 4, 2013, at 9:17 AM, Paul Stansifer wrote: I'm afraid it's not primarily

Re: [rust-dev] opinions about splicing macros / other items?

2013-02-25 Thread Paul Stansifer
#2 had never occurred to me. I think I lean toward it, since it has the potential to be a simpler implementation. (And you could even use it to clean up the crufty can't-happen errors that I introduced when I made fold able to fold into zero items.) Paul

Re: [rust-dev] I wanted a dollar but you gave me a ... dollar?

2013-02-22 Thread Paul Stansifer
Rust syntax expects a literal number in the `[T * n]` construct; from the parser's point of view, what it receives is an expression, without any information that it is a number. (There are internal reasons for this, but it also makes the behavior of `$` more consistent; for example, preventing

Re: [rust-dev] Pattern macros?

2013-02-20 Thread Paul Stansifer
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 parse

Re: [rust-dev] Pattern macros?

2013-02-19 Thread Paul Stansifer
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

Re: [rust-dev] Pattern macros?

2013-02-18 Thread Paul Stansifer
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 unrelated

Re: [rust-dev] [RFC] Functions/methods with generated names

2013-02-15 Thread Paul Stansifer
Your analysis is solid; those are the main options, as far as I can tell. TL;DR: Advantages and disadvantages! Implementation concerns! Smurfs! Third option somewhat preferred by me! - I agree that macros-in-identifier-position is appealing linguistically, but it's a bit tricky for internal

Re: [rust-dev] How to get code of snapshot compiler

2012-10-23 Thread Paul Stansifer
The code in the Rust repo *is* the code for the snapshot compiler. Since the Rust compiler is written in Rust, everyone has to download a binary version of the compiler in order to compile their own copy. In the distant past, there existed an Ocaml compiler for Rust, which was how the process was

[rust-dev] a new Rust macro syntax

2011-08-17 Thread Paul Stansifer
Patrick proposed a new syntax for macro invocations. Summary from https://github.com/graydon/rust/wiki/Syntax-extension: Expr → # Path BalancedLexemes BalancedLexemes → ( BalancedLexemes * ) BalancedLexemes → [ BalancedLexemes * ] BalancedLexemes → { BalancedLexemes * } BalancedLexemes →

Re: [rust-dev] macro-by-example syntax

2011-07-26 Thread Paul Stansifer
Thanks!   #macro(zip_or_unzip) alt {     case ([[x, ...], [y, ...]]) { [[x, y], ...]] }     case ([[xx, yy], ...]) { [[xx, ...], [yy, ...]] }   } I know, it's more verbose, but (a) it doesn't repeat itself, (b) it re-uses an existing construct rather than create a new one. I think I