moacirbishopcamata
Good morning to the Elixir team.
Please excuse me if I’m commenting in the wrong place; please indicate where I should discuss this.
I would like to know if it’s possible to add the ‘:=’ operator for binding assignments and keep the ‘=’ operator for pattern matching.
This would make teaching the features of Elixir/Erlang easier (as a language promoter).
Thank you very much for your attention.
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
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
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
roflbobl
Can you give an example of what you mean?
You can already do stuff like this:
hauleth
But there is no such thing as “binding assignment operator” in Elixir. There is only pattern matching (with potential rebinding). So I do not really get how these operators would differ.
andyleclair
Pattern-matching IS binding assignments, there’s no difference. An example:
If you are a “language promoter” with the goal of teaching Elixir, you should probably spend some more time writing it, so you’re comfortable with how the language works.
al2o3cr
I’m not following what’s gained by distinguishing these two uses of
=. Can you provide some examples?moacirbishopcamata
Thank you for your feedback.
I asked this question because my team and I come from non-functional languages.
I am learning and really enjoying the practicality and ergonomics of Elixir and the capabilities of Erlang/OTP.
Without a doubt, I must and need to improve my understanding of the language further.
I thought that differentiating ‘Pattern matching’ from ‘binding assignments/rebinding’ would be simpler for understanding the Functional Paradigm, which is the heart of functional languages.
It was not my intention to modify the language into something meaningless.
I greatly appreciate the answers.
sodapopcan
At first I also had a hard time accepting that there was no difference between pattern matching and assignment, especially when you’re told
=is not “assign” but “match” and then get an example offoo = "bar" # "bar"The guides have been improved a bit since I initially read them by immediately showing the “inverse” expression:
1 = xis an brow-raiser for newbies but I think they must get some idea that it’s a special case to put a variable on the right hand side or something? I’m only guessing, but I find that showing them this last example really tends to drive it home that=really indeed not an assignment operator:I always explain it as assignment being a side effect of matching. I know that’s sorta overloading a term, but it seems to help in the beginning, lol.
derek-zhou
Think of it this way: ‘=’ is binding assignment within a pattern matching. There is no pattern matching without binding operator because it would be a useless thing to do, other than being an assertion. If you must, you can wrap a scope around it to avoid pollution: