I am learning Elixir, up to chapter 7 PragProg book, and after thinking about the immutability and other items, I was thinking it was not generally possible to create a circular reference in the Elixir Maps/Tuples/Lists, etc.. Where A -> B -> C -> A.
Without going into really trying to trick the system, is this true?
Due to the immutability, there is a chicken-egg problem creating circulars. In fact, there is nothing done by Elixir to prevent it; it just comes out of the box within the immutability.
Proof: Since C
in your chain links A
on creation, A
must exist in advance; A
in turn links B
hence B
must exist even before; B
links C
, requiring C
to exist, but it is not yet created. QED.
One can not simply refer an unexisting Term*, and can not modify the existing one, therefore, it is impossible in Elixir.
* please read the discussion in comments on wording here and why Term
was finally chosen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With