News for hackers. Stuff that matters.
Re:Rust 1.43 by ashtonkem on Thursday April 23, 2020 @11:59AM (#22957371)
In general as a rust programmer you'll end up consuming orders of magnitudes more macros than you'll ever write; from what I've seen macros are more commonly written in libraries to make their use smoother, and my experience in other Macro heavy languages was similar (Clojure, SBCL).

But as others said, the point is boilerplate reduction. You can write a macro that'll automate that process away. A lot of examples are about automatically implementing certain behaviors for structs, such as equality, but you'll also see extensive macro use in ORM libraries that can generate a lot of runtime code off of a smaller table definition macro.

Anything with an explanation point is a macro invocation, by the way.

Re:Rust 1.43 by justwalt on Thursday April 23, 2020 @12:33PM (#22957786)
“Anything with an explanation point is a macro invocation, by the way.”

Can you explain what this means, exactly?

Re:Rust 1.43 by steveklabnik on Thursday April 23, 2020 @12:37PM (#22957838)
This is a function invocation:

    foo(bar)
This is a macro invocation:

    foo!(bar)
It's done this way because macros can have much more complex things inside the ()s than functions can. This helps both humans and computers parse such things.
Re:Rust 1.43 by jack1243star on Thursday April 23, 2020 @12:38PM (#22957849)
Not OP, I think they mean the exclamation mark (!)
Re:Rust 1.43 by ashtonkem on Thursday April 23, 2020 @05:27PM (#22961674)
TIL that “exclamation point” is region specific. Exclamation mark sounds subtly wrong to my ear.
Re:Rust 1.43 by wtetzner on Monday April 27, 2020 @12:13PM (#22997194)
I thought the confusion was that you wrote "explanation point" instead of "exclamation point".
Re:Rust 1.43 by lalaithion on Thursday April 23, 2020 @12:38PM (#22957841)
foo(x, y, z) is a function. foo!(x, y, z) is a macro.
Re:Rust 1.43 by ccktlmazeltov on Thursday April 23, 2020 @12:41PM (#22957877)

    println!("something")

that's a macro
Re:Rust 1.43 by gnosek on Thursday April 23, 2020 @12:39PM (#22957859)
Exclamation mark. e.g.

    println!("hello, world");
or

    todo!();
are macro invocations.
Re:Rust 1.43 by staticassertion on Thursday April 23, 2020 @01:37PM (#22958542)
Macros:

#[Foo] struct Bar {}

baz!()

cat!{}

blah![]

Re:Rust 1.43 by hinkley on Thursday April 23, 2020 @02:06PM (#22958945)
exclamation point?
Re:Rust 1.43 by ashtonkem on Thursday April 23, 2020 @05:27PM (#22961670)
TIL that “Exclamation point” is region specific. Other people call it exclamation marks.
Re:Rust 1.43 by hinkley on Thursday April 23, 2020 @06:44PM (#22962419)
Top level says “explanation point” and apparently didn’t ever reread after getting odd sounding questions.
Re:Rust 1.43 by ashtonkem on Thursday April 23, 2020 @07:30PM (#22962855)
Uhh, I think you’re referring to me.

I didn’t bother to clarify, since 5 people jumped in to explain, and I felt it was redundant.