I missed that. Changing this requires changing the grammar in a backwards incompatible way, which is a no-no.
On Tue, Sep 13, 2022 at 22:57 Austin Ziegler <halosta...@gmail.com> wrote: > That’s option 2, and I don’t think it looks readable, which is why I’ve > raised this. > > Like I said, I know *why* this is happening. I’m asking if something more > readable can be done. > > -a > > On Tue, Sep 13, 2022 at 4:50 PM José Valim <jose.va...@dashbit.co> wrote: > >> Put parens around if and it should work. Otherwise the do/end block binds >> to the module attribute. I will make sure we have a good error message for >> it. >> >> On Tue, Sep 13, 2022 at 22:31 Austin Ziegler <halosta...@gmail.com> >> wrote: >> >>> I’d like to propose a refinement to the way that `@attr` values get set. >>> If I want an attribute to have different values at compile-time, I have >>> four options (these are *not* ideally formatted): >>> >>> ```elixir >>> @option1 if(Mix.env() == :test, do: "Option 1") >>> @option2 (if Mix.env() == :test do >>> "Option 2" >>> end) >>> >>> option3 = if Mix.env() == :test do >>> "Option 3" >>> end >>> @option3 option3 >>> >>> if Mix.env() == :test do >>> @option4 "Option 4" >>> else >>> @option4 nil >>> end >>> ``` >>> >>> These are all, in my opinion, obfuscated.g >>> >>> What I *want* to do is: >>> >>> ```elixir >>> @option5 if Mix.env() == :test do >>> "Option 5" >>> end >>> ``` >>> >>> But that doesn’t work because of the way that the `@` special form works >>> (`@/1`). >>> >>> Is it possible to either (a) modify the `@` form to accept an >>> *expression* instead of expecting a single value, or (b) come up with a >>> different way of expressing this? I’m not sure if it’s possible, but maybe >>> `@attr = expr`? >>> >>> I’m not really sure where I’d start exploring it, but it could be >>> interesting to explore if this is something that would be considered. >>> >>> -a >>> -- >>> Austin Ziegler • halosta...@gmail.com • aus...@halostatue.ca >>> http://www.halostatue.ca/ • http://twitter.com/halostatue >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "elixir-lang-core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to elixir-lang-core+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQuhJP_vdUXy%3DJUxN5KZLrKYncC1XJPHJBYsopYRiXO%2BZg%40mail.gmail.com >>> <https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQuhJP_vdUXy%3DJUxN5KZLrKYncC1XJPHJBYsopYRiXO%2BZg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to elixir-lang-core+unsubscr...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BYHOGKky-Tq_ZfdJVKPm1V%3DrXX8UzphKdoohWi4rNNOg%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BYHOGKky-Tq_ZfdJVKPm1V%3DrXX8UzphKdoohWi4rNNOg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Austin Ziegler • halosta...@gmail.com • aus...@halostatue.ca > http://www.halostatue.ca/ • http://twitter.com/halostatue > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQuWjCtUMWd9KEsAUNA2fBbBLWfhKPaP%3D6j59wrqTK6XOA%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQuWjCtUMWd9KEsAUNA2fBbBLWfhKPaP%3D6j59wrqTK6XOA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KVTQVBG0kAdbSubQwy_o_nOvTRzdMZkZQ9ctH99-FciQ%40mail.gmail.com.