With a bit of fiddeling you can use every kind of bracket to basically make function calls in c++

Here are the links to the snippets, all compile and run

Rust: https://godbolt.org/z/bM3d7bG14

OCaml: https://godbolt.org/z/17oMv83zx

C++: https://godbolt.org/z/9Y3WfoE1W

you are viewing a single comment's thread
view the rest of the comments
[–] 2 points 7 hours ago (1 child)

To be fair, with Rust macros anything goes. There was an example where someone demoed descriping rust structs and enums nested as xml with a macro to parse it.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 5 hours ago

    That's inside the macro though. Whatever you parse inside the macro is defined by the creator of the macro. The macro invocation itself is defined by the rust language.

    Rust allows you to use any bracket because it doesn't know what the macro is supposed to do.

    Some macros work like functions:

    println!("Hello world");
    

    Some macros work like array declarations:

    let v = vec![1,2,3];
    

    And some macros work like a code scope:

    select!{
     a => myfunc(),
     b => my_other_func()
    }
    

    Since rust doesn't know what your macro does, it just lets the user choose whatever the user sees more fitting for that specific macro invocation.

  • source
  • parent