beno
Is this feasible somehow?
Foo.bar() #=> "bar"
Bar.foo() #=> "foo"
Context.perform do
Foo.bar() #=> "context_bar"
Bar.foo() #=> "context_foo"
end
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
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 new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
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
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
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
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex











Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
I’d never recommend doing different things in different contexts without explicitly passing in the context, but there are a number of ways, passing in hidden data in the process dictionary, making perform be a macro that does different things to calls, etc… There are lots and lots of different way, almost all of them are not suggested.
If you have a more specific complete example that we could fill in a few bits for you, then we can show you, but again, not recommended. ^.^
benwilson512
This looks like a classic X Y problem (http://xyproblem.info/). What are you trying to accomplish in general?
There are a few options that look like that, each is a bit different in what it entails.
Each of these works differently, and is used for different purposes. We need to know about what you’re trying to accomplish broadly speaking so that we can direct you in the right way.
beno
It is the second case, I am working on a database driver named xarango. I am looking to see if I can use the same API for direct calls (producing HTTP request/responses) and calls inside a transaction (producing javascript code to be run on the server). But based on my insights so far I think I need a dedicated API for transaction calls.
OvermindDL1
Actually that might be a good case for using the process dictionary. If the transaction call happens in another process (whether the repo process itself or a new one) the transaction call can decorate the process by setting a key in the process dictionary, then your calls can just test for that.
I’m still not a fan of differences in operation based on state like that, but as long as it acts the same inside and outside the transaction, it makes sense.
beno
Thank you for your suggestion.
Process.put/2andProcess.get/1indeed look like they provide the ‘global state’ I could use.I would have to store a fairly complex and frequently accessed
%Transaction{}struct in there though, since I need to concatenate subsequent transaction results and execute them as a whole. Besides all this becoming a bit un-functional, are there any (perhaps performance) objections to this?OvermindDL1
Not at all functional (maybe could be considered some implicit ‘this’ maybe?), but it should be fast enough as when structs are changed then anything unchanged is handed over straight, only changed parts and the parts that contain them are recreated.
Do note, the process dictionary is very fast, generally only used as an optimization thing, or for doing non-functional stuff like this. ^.^
gon782
Obligatory further reading on the process dictionary in Erlang mention.
beno
I think I will just make a dedicated Transaction API after all. This keeps me on the functional straight and narrow and gives me optimal flexibility for when the nasty details appear.