fireproofsocks

fireproofsocks

Printing references as strings?

I’m just discovering make_ref/0 and I’m wondering how to print them as a string… I have poked through the source code, but I don’t see any way to see inside the reference values.

Marked As Solved

hauleth

hauleth

Yeah, sorry, it should be :erlang.ref_to_list/1.

Also Liked

hauleth

hauleth

Much stronger than make_ref/0 (64 bits vs 122 bits, which with birthday collision will provide 1010 difference factor in possible collisions). And generating UUID can be done also outside of the BEAM, which is clearly a win for me.

ityonemo

ityonemo

Don’t expect to. A reference is just a marker to a “place and time”. They’re usually otherwise empty values that are “guaranteed” to be unique. Now, sometimes they are coopted by the vm to refer to “something” but by and large they aren’t references like references in the JVM.

For example, let me send a call to another process. When the response comes back, it should somehow refer to the initial call, so that this response isn’t structurally confused for a callback for some other call (that maybe got dropped and thus orphaned). The thing that the call sends, which should be packaged with the response, so that it can be can referred back to correctly is a reference.

hauleth

hauleth

make_ref()
|> :erlang.ref_to_list()
|> List.to_string()
hauleth

hauleth

Remember that references are meant to be unique only within single cluster, there is no guarantee for global uniqueness of the reference, in contrast to UUID.

hauleth

hauleth

Elixir and Erlang libraries mostly use binaries for storing UUID which IMHO makes most sense.

Where Next?

Popular in Questions Top

LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement