hst337
iex> map = %{x: 1}
iex> map.x
1
iex> map.x()
1
Why would anyone use the map.x() syntax for getting map value? I’d suggest deprecating it since it is misleading. Elixir compiler can add IO.warn to map clause when this happens in runtime
Trending in Proposals: Ideas
We are seeing a lot of warning logs like this:
navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachallaun
Isn’t this just a constraint of parsing/syntax? In your example, it’s not possible to know whether
map.x()is a key lookup on a map, or a function call on a module, until runtime. I don’t believe this could ever be a compile-time warning. (I also generally disagree that it’s misleading/etc. even though I agree thatmap.x()is uncommon.)sbuttgereit
In this case
mapwould be a variable, not an atom. Variables and atoms should be distinguishable at compile time, no?zachallaun
While I could be mistaken, I don’t believe the distinction you’re making actually exists. Consider this function:
This will work if you pass a module with an
x/0exported or a map.sbuttgereit
Good point. Though this is a call to variable whose value is an anonymous function and not a functional call on a module… still sounds like a complicating matter To be fair, that could also be a reason for desiring the proposal since
thing.x()the variable pointing to an anonymous function and thething.x()a variable that is a map could both produce results… we could talk about likeliness, but not impossible either.[EDIT: Nevermind… ignore the above… there are clearly nuances here I’m not correctly considering.]
josevalim
@hst337 it is already deprecated when we detect it is a map at compilation time:
We have been planning on adding a runtime deprecation for a while and there is an open issue tracking this.
hst337
This is the “misleading” I am talking about
It is impossible to know for sure, but compiler is already able to check the types and warn when
map.field()is called whenmapis amap. Plus, runtime warning is okay too.Great! I am sorry, I didn’t check the issue tracker