Alias, import and defdelegate are a mess?

is a sigil really a plus for that purpose

Sigils is a one way to ‘shortcut’ something, another way is a function with one-letter name (as @josevalim pointed). As I understand, sigils are more preferable to do a compile-time work.

+1 - try to explain a whole problem - it looks like you are trying to solve your problem with a wrong way

I forgot the unquote

@josevalim in fact there is 8 combinaisons:
function or macro, unquoted or not, local or remote.
For pedagogic purpose:

it’s never possible without unquote:
remote function: cannot invoke remote function Shortcuts.remote/1 inside a match
local function: cannot find or invoke local local/1 inside match.
remote macro: cannot invoke remote function Macro.escape/1 inside a match expanding macro: Shortcuts.remote/1
local macro: cannot invoke remote function Macro.escape/1 inside a match expanding macro: Test.local/1

With unquote it’s not possible locally:
local function: undefined function local/1
local macro: undefined function local/1

Remote function and macro work fine.
BTW I need an other module for a simple shortcut, I don’t like that.

The concrete realization of e in comments above depends on your needs, thats because we are asking you about your whole problem. I think, you don’t need Macro.escape at all. For example to match on map keys solution may looks like this:

defmodule Test do
  defmacrop e(kv) do
    quote do
      %{unquote_splicing(kv)}
    end
  end

  def me(e(a: 10)), do: :a_key_10
  def me(e(a: 20)), do: :a_key_20
  def me(e(b: _)),  do: :b_key
end

then in iex:

iex(3)> Test.me(%{a: 10})
:a_key_10
iex(4)> Test.me(%{a: 20})
:a_key_20
iex(5)> Test.me(%{b: :any})
:b_key
4 Likes

My problem is to match on map values :innocent:

I legit cannot figure out how to import one module into another. This is the future :joy::joy::joy:

Importing is done via the import call. It will enable you to call functions from the imported module in your current scope without having to qualify them by the module.

So after import Enum, you can write map(list, &(&1+1)) instead of having to write Enum.map(list, &(&1+1)).

importing is rarely really necessary, and unless building an EDSL should be avoided.