Thread overview | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 26, 2015 DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
http://wiki.dlang.org/DIP78 - Proposal for a macro system without syntactical extensions to the language. Hence it doesn't allow arbitrary syntax. |
May 26, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Tuesday, 26 May 2015 at 20:23:11 UTC, Kagamin wrote: > http://wiki.dlang.org/DIP78 - Proposal for a macro system without syntactical extensions to the language. Hence it doesn't allow arbitrary syntax. If this proposal is considered, it is required to propose to look at the implementation of macros in Nemerle. Many believe that it is in Nemerle macros implemented the most successful compared to other modern languages. Of course, the most successful macros are implemented in Lisp, but the syntax of the language is poor :) Some information here: http://www.nemerle.org/About Great article about macros Nemerle, but in Russian: http://rsdn.ru/article/nemerle/NemerleStingFormating.xml Of course, it is necessary to look at Rust and Nim, but macros Nemerle implemented better. I also think that the D needed macros, but I sure would not want to see the lite version of the macros. If implemented, then at least to the end and complete! Or not to implement macros in general... Although if you create something in between lite and full version of the macro, then I think it would be a big plus for D, so entirely without macros somehow uncomfortable. Some mixins little. Sometimes I think that D do not need these macros, and sometimes it seems to me that they are severely lacking.Although the competition is also necessary to consider the other languages that have at least some macros, such as, Nim/Rust. In general, D needs some macros. |
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On 2015-05-26 22:23, Kagamin wrote: > http://wiki.dlang.org/DIP78 - Proposal for a macro system without > syntactical extensions to the language. Hence it doesn't allow arbitrary > syntax. I'm not sure how this is different for DIP50. I can see the obvious differences in the syntax how to declare a macro and so on. But otherwise they look very similar. -- /Jacob Carlborg |
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Wednesday, 27 May 2015 at 06:54:56 UTC, Jacob Carlborg wrote:
> I'm not sure how this is different for DIP50. I can see the obvious differences in the syntax how to declare a macro and so on. But otherwise they look very similar.
I believe 78 allows a simpler implementation and requires less changes to the language, though I'm not sure if frontend can get it done on a purely semantical level: similar techniques like mixins and static if rely on syntax. Maybe a macro should be called with a special syntax, e.g. myAssert!(a==b);
|
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie | On Tuesday, 26 May 2015 at 23:47:41 UTC, Dennis Ritchie wrote:
> If this proposal is considered, it is required to propose to look
> at the implementation of macros in Nemerle. Many believe that it
> is in Nemerle macros implemented the most successful compared to
> other modern languages. Of course, the most successful macros are
> implemented in Lisp, but the syntax of the language is poor :)
The problem with declarative macro system is that you would need to learn yet another language. Possibly turing-complete. And a declarative turing-complete language is an overkill both for usage and implementation. Imperative macros get it done in an intuitive way in the existing language.
|
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Wednesday, 27 May 2015 at 08:14:36 UTC, Kagamin wrote:
> The problem with declarative macro system is that you would need to learn yet another language. Possibly turing-complete. And a declarative turing-complete language is an overkill both for usage and implementation. Imperative macros get it done in an intuitive way in the existing language.
Yes, declarative macros can destroy an imperative language, because they can change the syntax of the language beyond recognition. Ie macrosystem will be more powerful than the language itself. Unfortunately, Nemerle, Scala and turned :)
But, in my opinion, there should be options to combine declarative macros with imperative languages. You just need to properly limit these macros to a certain moment.
Is not it possible to combine in the desired degree of declarative macros with imperative languages?
|
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie | On Wednesday, 27 May 2015 at 09:31:33 UTC, Dennis Ritchie wrote:
> Is not it possible to combine in the desired degree of declarative macros with imperative languages?
The point is to streamline ast creation. I think, helper methods can be provided by phobos in, say, std.macros to simplify ast creation for common constructs. Well, in a way libraries are a form of DSL...
|
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Wednesday, 27 May 2015 at 09:40:35 UTC, Kagamin wrote:
> The point is to streamline ast creation. I think, helper methods can be provided by phobos in, say, std.macros to simplify ast creation for common constructs. Well, in a way libraries are a form of DSL...
std.macros it may, this is the right way! At least, it would suit me :)
|
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Tuesday, 26 May 2015 at 20:23:11 UTC, Kagamin wrote: > http://wiki.dlang.org/DIP78 - Proposal for a macro system without syntactical extensions to the language. Hence it doesn't allow arbitrary syntax. I really like how powerful and easy to use are AST macros in nim. IMO, if D gets such, it would become the language with the best meta-programming abilities D -> :D Here's a nice presentation about them: http://www.infoq.com/presentations/nimrod |
May 27, 2015 Re: DIP78 - macros without syntax extensions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On 2015-05-27 10:06, Kagamin wrote: > I believe 78 allows a simpler implementation and requires less changes > to the language, though I'm not sure if frontend can get it done on a > purely semantical level: similar techniques like mixins and static if > rely on syntax. DIP50 would require a minimal amount of syntax change, the only thing is prefixing a function with the "macro" keyword. DIP78 on the other hand, it's not so easy to see that a function declaration is actual a macro declaration. In that case I would prefer the "macro" keyword. It's already a reserved, for exactly this purpose, so it will be backwards compatible. I would say that neither of the DIP's contain a lot of detail. So it's hard to know which one is more complex. In DIP50 there's quite a lot of optional/bonus features. To me, implementing only the minimal requirements look very similar to DIP78. One thing that would be more complex in DIP50 would be the "Context" class. Although I'm not sure if that's needed in DIP78 as well. > Maybe a macro should be called with a special syntax, > e.g. myAssert!(a==b); I have thought of that too. But I haven't been able to come up with a syntax that looks good and doesn't conflict with any existing syntax/symbol. The above syntax is already used for template instantiation. -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation