idi527
In erl shell I can paste <x.y.z> and it would be parsed as a PID. From http://erlang.org/doc/man/shell.html:
The shell can parse commands with pids (<0.60.0>), ports (port<0.536>), references (#Ref<0.1662103692.2407792644.214210>), and external functions (fun<a.b.1>), but the command fails unless the corresponding pid, port, reference, or function can be created in the running system.
But in iex I seem to have to use pid/1,3, ref/1,4 functions, and I don’t know how to deal with ports (currently I use Port.list/0 but there’s probably a nicer approach) … Does anyone know if there is any format for pids, refs, ports, etc that iex can parse?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
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
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex











Showing Posts 1 to 8- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
OvermindDL1
That’s the format it uses.
A Port is just a PID for note.
idi527
So there is no way to use something like
<0.21.32>to get#PID<0.21.32>? That is, without having to use a function? Just copy-pasting#PID<0.21.32>back into the iex would be great.Thanks! But how can I use it? I see ports as
[#Port<0.0>, #Port<0.2>, #Port<0.4>], and I can’t usepid(0, 0)orpid("0.0").OvermindDL1
I think ports are considered ‘external pids’ (like pids on a remote system), so you can’t use the
pidfunctions on those. Why not assign it to something?idi527
Sometimes I just don’t have this ability, so I default to
Port.list/0which is a bit annoying if there are many open ports. Unless the approach I showed above with copy-pasting is impossible due to some inner workings of iex,something like
port/2(similar toref/4andpid/3) would be nice to have.OvermindDL1
I think it would be possible to make such a function, wouldn’t be perfectly performant but if run from iex that wouldn’t really matter, just add something like
def port(a, b), do: Enum.find(Port.list(), &(inspect(&1) == "#Port<#{a}.#{b}>"))to your iex helpers, like in a.iex.exsfile that contains something like:dch
The way I do this is to store the last fews transaction (e.g. in Phoenix or Plug) into a ConCache, and then I can retrieve the original item from Cache. For long-running things, I pull them out of the Application.env or possibly a given GenServer state. It’s almost always for debugging, so the other option is to use tracing to collect the raw data as either function call parameters going in, or as return values on the way back.
idi527
In my case I look up the ports with
:sys.get_state, then usePort.listto get the position of the port, and thenEnum.atto actually get the port … @OvermindDL1’s approach would save me one step, but still, just copy pasting#Port<0.2043>from:sys.get_stateoutput and into iex would be great. What I wonder about is if there is a way to make iex recognize#Port<...>,#PID<...>, and#Reference<...>as not comments, but port, pid, and reference respectively.wojtekmach
As @michalmuskala wrote in a feature request we can currently do: