Latest #metaprogramming Threads 
Imagine a conductor forced to relearn musical notation every time a new instrument joins the orchestra. Violin—one system of writing. Cel...
New
I’ve been heavily working with macros for more than 10 years already and I always used kinda ad-hoc code to expand/debug/test those when ...
New
In Phoenix apps, the web module provides this “re-dispatch into methods” technique for use (see __using__):
defmodule ExampleWeb.Router ...
New
I saw this LinkedIn post:
*Can your programming language do this?
This is a macro in Clojure called `dotrace`. When you surround a pie...
New
What’s the type to use for a function that returns a quote?
For example:
@spec f() :: what_goes_here
def f() do
quote do
code
e...
New
Hello, so I was wondering if something like newtypes is possible in Elixir and found something that does it but I THINK (correct me if I’...
New
I have a module for which I want to create a function rule_ids/0 at compile time. The code collects the rule ids at compile time from the...
New
I have a problem, where i have a macro the calls another function. I want to be able to add optional guards to my macro, and call the nes...
New
Warning: Calling this function inside a macro is considered bad practice as it will attempt to evaluate runtime values at compile time. M...
New
In file 1:
defmodule Utils.Struct do
# this is for importing definitions when "use Utils.Struct" is called
defmacro __using__(_opts...
New
This Week's Trending
This Month's Trending
This Year's Trending
Hi there,
After reading @ericmj response here (Using unquote outside of quote block - #6 by ericmj) about “unquote fragments”, I still c...
New
Hello,
I just extracted the boilerplate management code that I used to work with in previous years:
It is yet another generic input d...
New
I saw this LinkedIn post:
*Can your programming language do this?
This is a macro in Clojure called `dotrace`. When you surround a pie...
New
I’ve been heavily working with macros for more than 10 years already and I always used kinda ad-hoc code to expand/debug/test those when ...
New
Imagine a conductor forced to relearn musical notation every time a new instrument joins the orchestra. Violin—one system of writing. Cel...
New
In Phoenix apps, the web module provides this “re-dispatch into methods” technique for use (see __using__):
defmodule ExampleWeb.Router ...
New
Last Three Year's Trending
I can’t seem to pass an anonymous function as an option to a Plug. I am using plug_hmouse which from the documentation takes an option di...
New
Can Elixir code detect whether it is executing at compile time? I would like to write something like the following macro:
defmacro foo()...
New
I know this has been asked before, but I still can’t get it to work. I have code like this…
def case_stmt(input) do
[c1, c2, c3, c4] =...
New
Note: There are a few folks I’d really love to hear from, time permitting. Pinging in case the title isn’t catchy enough :slight_smile: @...
New
I would like to add a function to my project that is available throughout all modules without aliasing/importing it. How should I go abou...
New
I’m trying to build a protocol and a test suite to implement different adapters (impls of the protocol).
I tried to use a CaseTemplate, ...
New
I am trying to hook into the @doc deprecated: "message" annotation using __on_definition__.
defmodule ExampleCompiler do
def __on_defi...
New
After reading Metaprogramming Elixir, and the hexdocs on metaprogramming and macros, I was wondering how this ties into macros we use eve...
New
I’m developing a Supabase client for Elixir with complete support for all their services, like:
storage
auth
realtime
UI (live view)
S...
New
I’m doing some questionable meta-programming, and could use your help!
I’m using Macro.prewalk to traverse some source code, with the go...
New
I have a module utils,which is supposed to be used by MOdule A, B,C,D… and so on. The issue is utils modules have lot of constants, const...
New
I’m not very used to macros/compile time manipulation, but I will explain what I want to achieve and would like to know if it’s possible ...
New
I have a system that has thousands of run-time generated modules, some of which I want to cache for future reloading.
Ordinarily, the BE...
New
With the following code:
defmodule Foobar do
defmacro b(arg) do
arg
|> String.split("\n")
|> IO.inspect()
end
d...
New
I’m in the process of creating some reusable test modules using a macro:
defmodule SharedTestCase do
defmacro define_tests(do: block) ...
New
Trending Over Three Years
Hi there,
How I can build queries with dynamic fields assignment in Ecto?
I try to do next thing:
import Ecto.Query
field = :id
value ...
New
Hi,
I have been coding with Elixir for 9+ months and I encountered several time the concept of quotes and each time, I think “ok, today ...
New
I have a bunch of functions in a module, that I’d like to dynamically add to a __using__ macro:
defmodule A do
defmacro __using__(_opt...
New
I’m improving some documentation in Elixir, and in order to do so, I need to dynamically build a list of atoms, but without using string...
New
parameterized pipe in elixir: |n>
edit: negative index in |n> and mixed usage with |> are supported
example:
use ParamPipe
...
New
Hi community!
What is the correct way to implement the __using__ macro with an option that changes the way generated functions behave? O...
New
Hi everyone, I was toying around with macros today and I reached a stagnation point. After trying multiple approaches I started to think ...
New
I’m trying to do something similar to wath ecto does when defining schemas. Basically the idea is:
defmodule Test do
use TableBuilder
...
New
I have three identical methods in my module, that do (almost) exactly the same thing. Instead of repeating the function definitions, I am...
New
Elixir newbie here working on a stemmer for a document indexing engine. The stemming algorithm has dozens of steps with many tests per s...
New
I’m struggling with overriding hygiene during manual manipulation of AST with Macro.postwalk. In short, I want to provide a syntax for in...
New
I want to programmatically generate input objects from introspecting my schema, but I can’t figure out the metaprogramming to do so.
Ess...
New
Hi all,
I’ve been playing with Specify lately and I’m trying to get the @type module attribute like the @doc one, so as to link to that ...
New
defmodule Bar do
@after_compile __MODULE__
defmacro __before_compile__(_env) do
IO.inspect("#{__MODULE__}.__before_compile__")
...
New
Easiest to ask this in code…
defmodule Foo do
use Tagger
tag(:red)
end
defmodule Bar do
use Tagger
tag(:blue)
end
Then at runt...
New
Latest on Elixir Forum
Get money off!
The Pragmatic Bookshelf
35% off any eBook
Manning Publications
45% off any item
ElixirCasts
10% off for life
The Pragmatic Studio
20% off any course
AppSignal
10% off for 12 months
Honeybadger
10% off for 12 months
Simply use coupon code "devtalk.com" or "elixirforum" at checkout!
Filter by Type:
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #podcasts
- #code-sync
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








