Daily downloads in decline

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 12 10:26:49 PDT 2015


On Thursday, 11 June 2015 at 16:33:04 UTC, Dennis Ritchie wrote:
> It is possible that Walter and Andrei against macro because of 
> this:
>
> macro_rules! o_O {
>     (
>         $(
>             $x:expr; [ $( $y:expr ),* ]
>         );*
>     ) => {
>         &[ $($( $x + $y ),*),* ]
>     }
> }
>
> fn main() {
>     let a: &[i32]
>         = o_O!(10; [1, 2, 3];
>                20; [4, 5, 6]);
>
>     assert_eq!(a, [11, 12, 13, 24, 25, 26]);
> }
>
> It looks disgusting! ;)

This baffles me. It seems that language designer always need to 
fuck up macros either by:
  - Creating a new API to spawn AST, which become a burden on the 
compiler development (bonus point if you expose compiler 
internal).
  - Creating a new syntax, preferably completely inscrutable so 
you can pretend you are a guru while using it.

There is a good way to express AST in a language, and this is how 
you do it for everything else in the program : you use the damn 
language syntax and grammar.

On that one, LISP get it right, except that its general lack of 
grammar and syntax (really, it is not that LISP has a lot of (), 
it is that everything else has been removed) end up creating a 
new set of problems.

It is just this const expr vs CTFE, one has now to learn a new 
language to do computation at compile time (const expr) when 
using the same language (CTFE) reduce the burden on the dev and 
compiler writer.


More information about the Digitalmars-d mailing list