Do you mean `struct.field` would be a function call? Or `struct.field()` would desugar to something else? And what about setters, how would calling them look like? Maybe I’m to hang up on the syntax but I’m really curious what you’re thinking about.
FWIW you can make it so that this runs arbitrary call put_in(alice[:email], “al...@example.com”) By defining get_and_update/3 on your struct. > On 8 Jul 2025, at 18:48, Thiago Majesk Goulart <thiagomgoul...@gmail.com> > wrote: > > This is more of a question than a proposal, and I don't actually know how > viable it would be in reality. But today we can implement the access > behaviour for structs, which can be really (really, really) useful in cases > where you are dealing with rich data types. > > I don't remember if this has been discussed in the forums before, so I would > like to know if expanding on the syntax sugar to have accessors has ever been > considered. > > Maybe having something like a put/2 callback is a bit out of the scope for > the access behaviour itself, and I'm sure this would pose some design > challenges, like how to resolve for struct's static access and so on. > > Anyways, I'm curious if the core team has considered something like this or > if there are any plans to pursue a version of this in the future. My best. > > -- > 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 > <mailto:elixir-lang-core+unsubscr...@googlegroups.com>. > To view this discussion visit > https://groups.google.com/d/msgid/elixir-lang-core/f7e3c66d-7de7-4d32-9df3-96d019b65ed2n%40googlegroups.com > > <https://groups.google.com/d/msgid/elixir-lang-core/f7e3c66d-7de7-4d32-9df3-96d019b65ed2n%40googlegroups.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 visit https://groups.google.com/d/msgid/elixir-lang-core/753FB9B1-4B0F-457E-8728-35D4107CC2CC%40wojtekmach.pl.