# Implicit modules and script style plugins

**URL:** <https://forum.elixirforum.com/t/implicit-modules-and-script-style-plugins/60663>\
**Category:** Questions\
**Tags:** metaprogramming, ast\
**Created:** [December 31, 2023, 11:30pm UTC](https://forum.elixirforum.com/t/implicit-modules-and-script-style-plugins/60663 "2023-12-31T23:30:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkbbwr](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jkbbwr/32/20182_2.png) [@jkbbwr](https://forum.elixirforum.com/u/jkbbwr)\
**Post date:** [December 31, 2023, 11:30pm UTC](https://forum.elixirforum.com/t/implicit-modules-and-script-style-plugins/60663/1 "2023-12-31T23:30:23Z")

</div>

I want to work on a DSL that looks very similar to unit tests, define some steps but the steps are linked

```elixir
step "step 1" do
    IO.puts("hi")
end

step "step 2", depends: ["step 1"] do
    IO.puts("bye")
end

```

Forcing a user to define a module at the top feels possibly distracting.

Two questions, one how should I go about loading an exs at runtime and calling it (I assume `Code.compile_file`

Second more important question, how might I go about dynamically generating a module or infering one maybe from the filename.

---

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/32/31980_2.png) [@zachdaniel](https://forum.elixirforum.com/u/zachdaniel)\
**Post date:** [January 1, 2024, 12:18am UTC](https://forum.elixirforum.com/t/implicit-modules-and-script-style-plugins/60663/2 "2024-01-01T00:18:19Z")

</div>

Dynamically generating modules is easier than you’d expect,

```elixir
def make_module(stuff) do
  Module.create(derived_module_name(stuff), quote do
    # your module body goes here
  end,
  Macro.Env.location( __ENV__ ))
end

```

As for running a `.exs` file, I think your best bet would be `Code.eval_file/2`. Also, depending on what you’re looking to do, you may want to look into `Reactor`: [README — reactor v1.0.2](https://hexdocs.pm/reactor/readme.html), as it may do what you’re looking to do already. And for defining the DSL you may look into `Spark`: [Spark — spark v2.7.2](https://hexdocs.pm/spark/get-started-with-spark.html), which is a DSL building toolkit. Still sorely under-documented, but very feature rich. If you’re willing to read the tests to figure out how it works, then you’ll be A-ok. It’s very battle tested.

---

<div class="post-metadata">

**Author:** ![jkbbwr](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jkbbwr/32/20182_2.png) [@jkbbwr](https://forum.elixirforum.com/u/jkbbwr)\
**Post date:** [January 1, 2024, 10:44pm UTC](https://forum.elixirforum.com/t/implicit-modules-and-script-style-plugins/60663/3 "2024-01-01T22:44:18Z")

</div>

Id probably still have to wrap the content of the `.exs` file so I might end up using some sort of string eval.
