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.

Reply via email to