News for hackers. Stuff that matters.
Re:Rust 1.45 by cuddlybacon on Thursday July 16, 2020 @06:02PM (#23864304)
> C Macros are lacking because they are very primitive, e.g. they have not type system. They are also hardly turing complete. Its extremely hard to write a meaningful algorithm in them.

I think this may be why I'm having a hard time appreciating them. Probably half the macros I see could just be a function call. The majority of those that don't are hiding a conditional return or goto, which I find to be a net negative.

I'll probably have to use a language with good macros before I can appreciate them.

Re:Rust 1.45 by kibwen on Thursday July 16, 2020 @07:39PM (#23865162)
> Probably half the macros I see could just be a function call.

Yes, that particular breed of C macros would likely manifest in Rust as people just defining a new function. In Rust, you tend to see macros in places where "just make a new function" doesn't suffice for whatever reason; for example, maybe you need to define a dozen different structs that only differ by the type of one field, so instead of actually defining the struct a dozen times, you could just define the struct inside the macro and then `define_my_struct!(u8); define_my_struct!(u16);` and so on.

You also can't use Rust macros to "redefine" other unrelated pieces of code, so that's one less thing to worry about.

Re:Rust 1.45 by cuddlybacon on Thursday July 16, 2020 @08:39PM (#23865656)
Your define_my_struct! actually seems useful. Thanks for that example.