Does Elixir support introspection to show available features?

Consider this snippet from Phoenix Programming :

defmodule Rumbl.VideoController do use Rumbl.Web, :controller def index(conn, _params) do videos = Repo.all(Video) render(conn, "index.html", videos: videos) end end 

index uses the render function that it receives from the import called use Rumbl.Web, :controller .

I know that other functions have been imported. But does Elixir provide a way to list them?

Can I list the available functions for the current scope in Elixir?

+4
source share
1 answer

You can get this information from the __ENV__ macro. Documentation is present for the Macro.Env struct , which is returned.

The most interesting fields from this structure for you will be functions and macros , which contain a list of currently available functions and macros along with the module from which they were created.

+9
source

Source: https://habr.com/ru/post/1238465/


All Articles