8

For a long time I wanted to have the possibility in Swift to copy instances of value types by just changing the value of one property (member variable).
Something like Kotlin's copy function.

And now that Swift has macros (like Rust), I made a macro for that! 😄

https://github.com/WilhelmOks/...

Comments
  • 2
    Yo dog. I heard you like macros. So I put macros in your macros, so you can be confused while you're confused.

    Beats DSLs though.

    Domain Specific Languages, not Dick Sucking Lips.
  • 1
    @Wisecrack Let me tell you that I absolutely hate C/C++/Objective-C macros.

    Swift macros are much better. The main goal is to reduce error prone boilerplate. So, the code can get even less confusing and safer.
  • 1
    @Lensflare I look at templating and macros and just think of it as bandaid solution to features that should have been included in a language to begin with.

    Only exception I can see to this are the ones that let you add syntax that modifies the AST, so you can add language features over time, instead of having to modify the syntax directly.

    Shit, did I just describe a DSL? I think I just described a DSL.
  • 1
    @Wisecrack kind of. Some potential language features would be very specific to a domain or use case. And adding them all to the language would bloat the language. So macros are a nice way to let devs make their own extensions and features to the language. And use them selectively via plugins.
Add Comment