digitalmars.D - Abstract syntax tree manipulation
- Suminda Dharmasena (4/4) Apr 21 2013 Hi,
- Jacob Carlborg (8/11) Apr 21 2013 The original idea with the "macro" keyword was to introduce AST macros.
- Tofu Ninja (4/18) Jan 24 2014 This is amazing, its not 100% perfect but it hits all the main
- Jacob Carlborg (6/8) Jan 24 2014 I don't know. Dropbox says the file was created 2013 in February. I've
- MrSmith (3/11) Jan 25 2014 Is this avaliable as some sort of preprocessor?
- Jacob Carlborg (4/6) Jan 25 2014 No, unfortunately it's not available in any form.
- Suminda Dharmasena (1/1) Jun 16 2014 Any progress on Macros?
- Tofu Ninja (3/17) Jan 24 2014 My favorite part was the statement macros and the attribute
- Elie Morisse (3/17) Jan 26 2014 This would be a perfect and much classier replacement for mixins
- Belzurix (38/42) Apr 21 2013 Hi!
- Jacob Carlborg (5/15) Apr 21 2013 There's also Nemerle which lets you create new syntax for your AST macro...
- Araq (16/31) Apr 22 2013 Term rewriting macros can be turned off on both local and global
- Suminda Dharmasena (2/2) Jan 23 2014 Also Redex Racket / Racket can give some inspiration.
Hi, Since macro is reserved perhaps D can introduce AST manipulating macros. Suminda
Apr 21 2013
On 2013-04-21 09:57, Suminda Dharmasena wrote:Hi, Since macro is reserved perhaps D can introduce AST manipulating macros. SumindaThe original idea with the "macro" keyword was to introduce AST macros. Although nothing has happened yet. People have been talking about it from time to time but no one has had a real proposal. I've got this: https://dl.dropboxusercontent.com/u/18386187/ast_macros.html But I haven't turned it into a DIP (D Improvement Proposal) yet. -- /Jacob Carlborg
Apr 21 2013
On Sunday, 21 April 2013 at 10:13:43 UTC, Jacob Carlborg wrote:On 2013-04-21 09:57, Suminda Dharmasena wrote:This is amazing, its not 100% perfect but it hits all the main things I want out of a macro system. How long ago did you come up with this?Hi, Since macro is reserved perhaps D can introduce AST manipulating macros. SumindaThe original idea with the "macro" keyword was to introduce AST macros. Although nothing has happened yet. People have been talking about it from time to time but no one has had a real proposal. I've got this: https://dl.dropboxusercontent.com/u/18386187/ast_macros.html But I haven't turned it into a DIP (D Improvement Proposal) yet.
Jan 24 2014
On 2014-01-24 11:20, Tofu Ninja wrote:This is amazing, its not 100% perfect but it hits all the main things I want out of a macro system. How long ago did you come up with this?I don't know. Dropbox says the file was created 2013 in February. I've created a DIP out of this: http://wiki.dlang.org/DIP50 -- /Jacob Carlborg
Jan 24 2014
On Friday, 24 January 2014 at 13:22:53 UTC, Jacob Carlborg wrote:On 2014-01-24 11:20, Tofu Ninja wrote:Is this avaliable as some sort of preprocessor? Looks really amazing!This is amazing, its not 100% perfect but it hits all the main things I want out of a macro system. How long ago did you come up with this?I don't know. Dropbox says the file was created 2013 in February. I've created a DIP out of this: http://wiki.dlang.org/DIP50
Jan 25 2014
On 2014-01-25 13:15, MrSmith wrote:Is this avaliable as some sort of preprocessor? Looks really amazing!No, unfortunately it's not available in any form. -- /Jacob Carlborg
Jan 25 2014
On Sunday, 21 April 2013 at 10:13:43 UTC, Jacob Carlborg wrote:On 2013-04-21 09:57, Suminda Dharmasena wrote:My favorite part was the statement macros and the attribute macros. I want this so much.Hi, Since macro is reserved perhaps D can introduce AST manipulating macros. SumindaThe original idea with the "macro" keyword was to introduce AST macros. Although nothing has happened yet. People have been talking about it from time to time but no one has had a real proposal. I've got this: https://dl.dropboxusercontent.com/u/18386187/ast_macros.html But I haven't turned it into a DIP (D Improvement Proposal) yet.
Jan 24 2014
On Sunday, 21 April 2013 at 10:13:43 UTC, Jacob Carlborg wrote:On 2013-04-21 09:57, Suminda Dharmasena wrote:This would be a perfect and much classier replacement for mixins in most situations.Hi, Since macro is reserved perhaps D can introduce AST manipulating macros. SumindaThe original idea with the "macro" keyword was to introduce AST macros. Although nothing has happened yet. People have been talking about it from time to time but no one has had a real proposal. I've got this: https://dl.dropboxusercontent.com/u/18386187/ast_macros.html But I haven't turned it into a DIP (D Improvement Proposal) yet.
Jan 26 2014
On Sunday, 21 April 2013 at 07:57:51 UTC, Suminda Dharmasena wrote:Hi, Since macro is reserved perhaps D can introduce AST manipulating macros. SumindaHi! As far as I can remember, macros have been deferred to D3 because it has mixins and templates, so one can easily manipulate code in D. However, it's been long time since there was serious discussion about the implementation details. I'm happy to see that the topic emerged again just before DConf - maybe the discussion will continue there. Several non-lispy languages introduced macros long ago so the developers may learn from others mistakes and they will avoid the pitfalls. These languages include Groovy, Scala, Nimrod and Rust. The Rust implementation is much like text substituation when used, so one can easily learn it in an hour. Its syntax is a little distinct from the base language, and there has been a problem with lexing it according to a past issue: https://github.com/mozilla/rust/issues/2755 It's still unfinished, there are some limitations. ( although it's been always hard to debug them ) Have a look at: http://static.rust-lang.org/doc/0.6/tutorial-macros.html and also see the language manual ( at http://rust-lang.org ) Beyond AST macros, Nimrod ( http://nimrod-code.org ) has text substituation mechanisms called templates - much like C macros or templates in C++ and D. It also has term rewriting macros. In my opinion, Nimrod is a language where a lot of features can produce dirty code ( although some of them are very well done and they are extremely powerful tools ), and it's the developer's choice to use the features for the right purposes ( especially true with term rewriting ). So obfuscation is just as easy in that language as in C++ or Perls before version 6 despite the fact that its sysntax is derived from Python. I can't say much about Scala and Groovy, but their syntax for defining macros doesn't use as cryptic symbols as Nimrod. For example I couldn't find out for first time what is nnk the nnk prefix in the nnkInfix symbol. Zsombor
Apr 21 2013
On 2013-04-21 12:36, Belzurix wrote:Hi! As far as I can remember, macros have been deferred to D3 because it has mixins and templates, so one can easily manipulate code in D. However, it's been long time since there was serious discussion about the implementation details. I'm happy to see that the topic emerged again just before DConf - maybe the discussion will continue there. Several non-lispy languages introduced macros long ago so the developers may learn from others mistakes and they will avoid the pitfalls. These languages include Groovy, Scala, Nimrod and Rust.There's also Nemerle which lets you create new syntax for your AST macros. http://nemerle.org/wiki/index.php?title=Macros -- /Jacob Carlborg
Apr 21 2013
Beyond AST macros, Nimrod ( http://nimrod-code.org ) has text substituation mechanisms called templates - much like C macros or templates in C++ and D. It also has term rewriting macros.Nimrod's templates do operate on the AST too, they don't perform text substitution.In my opinion, Nimrod is a language where a lot of features can produce dirty code ( although some of them are very well done and they are extremely powerful tools ), and it's the developer's choice to use the features for the right purposes ( especially true with term rewriting ).Term rewriting macros can be turned off on both local and global levels to ensure they don't affect semantics. You can also exclude a TR macro symbol explicitly in an "import" statement (import module except broken_tr_macro) should the transformation turn out to be buggy.So obfuscation is just as easy in that language as in C++ or Perls before version 6 despite the fact that its sysntax is derived from Python.The idea that a statically typed language with checked exceptions and an effect system (both features which didn't make it into 0.9.0 though) is somehow less maintainable than Python with its dynamism everywhere is absurd.I can't say much about Scala and Groovy, but their syntax for defining macros doesn't use as cryptic symbols as Nimrod. For example I couldn't find out for first time what is nnk the nnk prefix in the nnkInfix symbol.Admittedly the macros API has been rushed out and the nnk prefixes are ugly. However there are addons that improve on the API. The core API will be improved too but it needs some transition path as unfortunately quite some code now depends on it. ;-)
Apr 22 2013
Also Redex Racket / Racket can give some inspiration. Also perhaps Nimrod can get a D back end?
Jan 23 2014