kpanic
Hi,
I discovered by accident last week this:
Example:
quote do %{hello: "test"}.hello() end == quote do %{hello: "test"}.hello end
true
I get that the AST is the same – with parens or the absence of parens, however why this is an allowed syntax?
Thanks
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
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 everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
It is simply because the language allows functions without parameters to be called without the parens. In your case
.hello()is canonical Elixir while.hellois just a convenience shorthand syntax.kpanic
Sure, but here we are accessing a map that would return a binary in this case.
For functions it might make sense when arity is 0, however I guess this behaviour might generate confusion since
When we access
hellowe expect the value back and not a pleonastic()function callmichalmuskala
The AST for both things is exactly the same. There’s no way for the compiler to differentiate between the two:
kpanic
Thank you michal, I undestand that the AST is the same. See initial post regarding map access.
Since you are saying that the compiler does not differentiate, I guess we should live with that.
However having in code redundant parentheses (when accessing a map value) seems confusing to me.
is not a function call.
OvermindDL1
Eh, technically it is a function call, it lowers down to become
:maps.get(:hello, %{hello: "test"}). On the beam VM there is no such thing as a map extraction operator like., rather you can extract only by matching out the value via a hardcoded key or by calling the built in internal functions in the:mapsmodule, and Elixir lowers to them.kpanic
Thanks for elaborating @OvermindDL1
However it think that it might be confusing from the syntax perspective. In the end that’s what I mean.
For example:
Not sure if I am too “picky” on this one
LostKobrakai
Here’s the macro that’s being called: Kernel.SpecialForms — Elixir v1.20.2
From the syntax perspective you’re calling
greeting/0ontestquite similar to e.g.which calls
alive?/0onmod. The AST alone just knows aboutmodthe variable, but does not know if the variable will be a map or a alias or whatever.kpanic
@LostKobrakai sure and thanks for the pointers, however don’t you find confusing that accessing to a map/struct and putting a
()is the same as not putting it?As a dev, especially after long hours of work, one may wonder if:
this is a function that a dev defined somewhere or just accessing a map/struct
Maybe is it just me that find this confusing?

gregvaughn
I suspect this is a transitory concern. I suspect you’re coming from an OO world (like most) where it is common to call methods on objects. As a functional language, Elixir has no methods at all. It’s functions. This
.syntax just looks like a method/member access, but it’s really a function. Once you’ve spent more time with Elixir and internalized this information, the confusion should subside.OvermindDL1
Not just you, but sometimes that ambiguity lets you override things too. At one time we had tuple calls too that worked like
{SomeModule, whatever, else, you, want}and if you didblah = {SomeModule, whatever, else, you, want}then didblah.bloop(42)then it ended up callingSomeModule.bloop(42, {SomeModule, whatever, else, you, want}), which was crazy useful for emulating first-class modules on the BEAM, but thanks to recent developments that is now broken…Yep, exactly this.
Conceptually this: