I have asked this question on Slack, no solutions from there, so putting it up here.
The situation is,
Let’s say I’ve typed in the iex shell alias Asdf.Qwer, but actually what I need now is simply Qwer , I have no way to clear Asdf.Qwer because alias Qwer just again gives me Asdf.Qwer . So am I forever stuck with that? Or is there a way to reset/delete aliases
In other words, Qwer is now forever referring to Asdf.Qwer because of my mistype, and there is no way to delete/say that I don’t want this anymore. Or is there?
(P.S. an unrelated question, is the source code of Elixir Forum available as open source somewhere? It’s a great interface and I admire it very much.)
Thanks, but I don’t want to clear all variable bindings I have currently declared so far and am working on something. (Otherwise just ctrl-C twice out from the shell and coming in back again would have been done.)
Reason I’m asking is to see whether this possibility is already there, just that I don’t know the way how-to.
And Erlang’s shell did have an f() / f(variable) function that cleared the binding (for all/a variable), so I just want to find out if there’s something along the same idea in Iex.
Hmm, funny, it seems that you can overwrite alias in some cases and can’t in other cases. I’ve played with this:
iex> alias Asdf.Qwer
Asdf.Qwer
iex> Qwer
Asdf.Qwer
# still not working
iex> alias Qwer
Asdf.Qwer
iex> alias Qwer, as: Qwer
Asdf.Qwer
# this works?
iex> alias Foo, as: Qwer
Foo
iex> Qwer
Foo
# this also works
iex> alias Bar.Qwer
Bar.Qwer
iex> Qwer
Bar.Qwer
# funnily, this seemed to work at first glance (but really doesn't)
iex> alias Elixir.Qwer
Qwer # refers Qwer, yeay!
iex> Qwer
Bar.Qwer # it reverts, the alias doesn't work.
Thanks guys. Just saw the replies as I’ve been away for the holidays.
@bobbypriambodo’s tests and attempts did make sense but ultimately discovered that it couldn’t behave as expected or intended; I tried and confirmed that too.
# originally already before this `alias Asdf.Qwer`
iex(42)> Qwer
Asdf.Qwer
iex(43)> alias Elixir.Qwer, as: Qwer
Qwer
iex(44)> Qwer
Asdf.Qwer
iex(45)> alias Foo, as: Qwer
Foo
iex(46)> Qwer
Foo
iex(47)> Elixir.Qwer
Qwer
iex(48)> alias Elixir.Qwer, as: Qwer
Qwer
iex(49)> Qwer
Foo
So logging as a bug does appear to make the most sense. Thanks again everybody!!