# \#modules

**URL:** https://forum.elixirforum.com/tag/modules/1468.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [Unexpected behaviours when generating functions through metacoding](https://forum.elixirforum.com/t/unexpected-behaviours-when-generating-functions-through-metacoding/60791)

<div class="topic-metadata">

**Author:** [@aquamat](https://forum.elixirforum.com/u/aquamat)\
**Replies:** 2\
**Last updated:** [January 5, 2024, 6:26pm UTC](https://forum.elixirforum.com/t/unexpected-behaviours-when-generating-functions-through-metacoding/60791 "2024-01-05T18:26:55Z")

</div>

Hello! For my first post to the forum that has helped me a great deal as I have become involved with this language and ecosystem. I have some code that allows me to test if an email address looks like it is from a free…

---

## [Getting a list of modules within a macro -- returns :undefined](https://forum.elixirforum.com/t/getting-a-list-of-modules-within-a-macro-returns-undefined/55729)

<div class="topic-metadata">

**Author:** [@OrontaMedu](https://forum.elixirforum.com/u/OrontaMedu)\
**Replies:** 1\
**Last updated:** [May 21, 2023, 12:26pm UTC](https://forum.elixirforum.com/t/getting-a-list-of-modules-within-a-macro-returns-undefined/55729 "2023-05-21T12:26:34Z")

</div>

Similar to Question on :application.get\_key(:my\_app, :module) Why will the 1st call return :undefined, whereas the 2nd will do a list of modules? defmodule App123.ModLoad do defmacro \_\_using\_\_(opts) do quote bin…

---

## [Global pseudonym for module](https://forum.elixirforum.com/t/global-pseudonym-for-module/55087)

<div class="topic-metadata">

**Author:** [@phgrey](https://forum.elixirforum.com/u/phgrey)\
**Replies:** 4\
**Last updated:** [April 7, 2023, 8:29am UTC](https://forum.elixirforum.com/t/global-pseudonym-for-module/55087 "2023-04-07T08:29:30Z")

</div>

have module A.B. And another module A.C is the same. do not want to copy. is there a way to create GLOBAL pseudonym? smth like alias A.B as: A.C but not inside the module, site-wide. the reason: i have some API as a re…

---

## [Ecto Changeset validate\_confirmation function is undefined](https://forum.elixirforum.com/t/ecto-changeset-validate-confirmation-function-is-undefined/54288)

<div class="topic-metadata">

**Author:** [@chrisdel101](https://forum.elixirforum.com/u/chrisdel101)\
**Replies:** 3\
**Last updated:** [March 3, 2023, 1:19am UTC](https://forum.elixirforum.com/t/ecto-changeset-validate-confirmation-function-is-undefined/54288 "2023-03-03T01:19:37Z")

</div>

This related to my other question, but I’m asking a new one for clarity. Using the built-in validation\_confirmation I’m getting: undefined function validate\_confirmation/4. It’s an Ecto(?) function, so I’m stumped on…

---

## [Calling function from within same module it's declared is undefined/is not available](https://forum.elixirforum.com/t/calling-function-from-within-same-module-its-declared-is-undefined-is-not-available/54198)

<div class="topic-metadata">

**Author:** [@chrisdel101](https://forum.elixirforum.com/u/chrisdel101)\
**Replies:** 10\
**Last updated:** [March 1, 2023, 4:17pm UTC](https://forum.elixirforum.com/t/calling-function-from-within-same-module-its-declared-is-undefined-is-not-available/54198 "2023-03-01T16:17:08Z")

</div>

Redoing this to be more clear: Question How can I call a function inside a module? File: test.exs defmodule MyModule do def sum(a, b) do a + b end MyModule.sum(1,1) # or sum(1,1) end elixir test.exs : \*…

---

## [Importing custom functions for use in config.exs/releases.exs/runtime.exs](https://forum.elixirforum.com/t/importing-custom-functions-for-use-in-config-exs-releases-exs-runtime-exs/50621)

<div class="topic-metadata">

**Author:** [@mbklein](https://forum.elixirforum.com/u/mbklein)\
**Replies:** 2\
**Last updated:** [September 28, 2022, 9:53pm UTC](https://forum.elixirforum.com/t/importing-custom-functions-for-use-in-config-exs-releases-exs-runtime-exs/50621 "2022-09-28T21:53:32Z")

</div>

I have a complex app configuration that I’ve made much simpler via a custom module. I don’t want to implement it as a config provider because I have to use it during development as well. But trying to access it from conf…

---

## [Problem with function to dynamically define modules](https://forum.elixirforum.com/t/problem-with-function-to-dynamically-define-modules/49796)

<div class="topic-metadata">

**Author:** [@edmundobiglia](https://forum.elixirforum.com/u/edmundobiglia)\
**Replies:** 2\
**Last updated:** [August 26, 2022, 12:30pm UTC](https://forum.elixirforum.com/t/problem-with-function-to-dynamically-define-modules/49796 "2022-08-26T12:30:36Z")

</div>

Hi there! I’m trying to create a function that dynamically defines a module based on the passed argument, like so: defmodule Test do def define\_module(module\_name, value) do defmodule module\_name do def run,…

---

## [Quote, defmacro and modules](https://forum.elixirforum.com/t/quote-defmacro-and-modules/44069)

<div class="topic-metadata">

**Author:** [@riccardomanfrin](https://forum.elixirforum.com/u/riccardomanfrin)\
**Replies:** 2\
**Last updated:** [November 24, 2021, 8:06pm UTC](https://forum.elixirforum.com/t/quote-defmacro-and-modules/44069 "2021-11-24T20:06:48Z")

</div>

I’m trying to understand how macros and module definitions interact with each others and I’m having few cases which I don’t understand. The below example has some pseudo doctest to show my doubts. What I need is to supp…

---

## [Initialising structs and incrementing value for each new struct](https://forum.elixirforum.com/t/initialising-structs-and-incrementing-value-for-each-new-struct/43107)

<div class="topic-metadata">

**Author:** [@kouluelixir](https://forum.elixirforum.com/u/kouluelixir)\
**Replies:** 8\
**Last updated:** [October 15, 2021, 6:12pm UTC](https://forum.elixirforum.com/t/initialising-structs-and-incrementing-value-for-each-new-struct/43107 "2021-10-15T18:12:34Z")

</div>

I am a beginner making a code with module. Employee module has a struct and a function. Employees have names, id’s, salaries and jobs. I have gotten updating jobs and salaries to work. I still need for the employee id t…

---

## [Live view: passing form to nested live component breaks redirection](https://forum.elixirforum.com/t/live-view-passing-form-to-nested-live-component-breaks-redirection/41334)

<div class="topic-metadata">

**Author:** [@nidu](https://forum.elixirforum.com/u/nidu)\
**Replies:** 0\
**Last updated:** [July 29, 2021, 4:15pm UTC](https://forum.elixirforum.com/t/live-view-passing-form-to-nested-live-component-breaks-redirection/41334 "2021-07-29T16:15:23Z")

</div>

Hello, I’m trying to make a live view app with a form that has a nested live component. page\_live.ex -\> form\_component.ex -\> nested\_component.ex (Repro repo is available here https://github.com/nidu/live-view-redirect…

---

## [Three semi-obscure Elixir features](https://forum.elixirforum.com/t/three-semi-obscure-elixir-features/38627)

<div class="topic-metadata">

**Author:** [@marick](https://forum.elixirforum.com/u/marick)\
**Replies:** 1\
**Last updated:** [April 1, 2021, 8:38am UTC](https://forum.elixirforum.com/t/three-semi-obscure-elixir-features/38627 "2021-04-01T08:38:08Z")

</div>

I wrote about some Elixir features that are not that often useful, but I think are still good to know about: the process dictionary, handling calls to undefined functions, and Macro.decompose\_call This is in the context…

---

## [Best practise for configuring Ecto.Repo for an open source module?](https://forum.elixirforum.com/t/best-practise-for-configuring-ecto-repo-for-an-open-source-module/35634)

<div class="topic-metadata">

**Author:** [@mikl](https://forum.elixirforum.com/u/mikl)\
**Replies:** 1\
**Last updated:** [November 18, 2020, 2:46pm UTC](https://forum.elixirforum.com/t/best-practise-for-configuring-ecto-repo-for-an-open-source-module/35634 "2020-11-18T14:46:23Z")

</div>

I’m working on a yet-to-be-released module for dealing with dual-entry accounting in Elixir/Phoenix apps, and due to its nature, this features a lot of database interaction. What is the best way to allow the implementin…

---

## [Compiling and loading modules dynamically](https://forum.elixirforum.com/t/compiling-and-loading-modules-dynamically/32170)

<div class="topic-metadata">

**Author:** [@aesmail](https://forum.elixirforum.com/u/aesmail)\
**Replies:** 9\
**Last updated:** [September 18, 2020, 2:33pm UTC](https://forum.elixirforum.com/t/compiling-and-loading-modules-dynamically/32170 "2020-09-18T14:33:53Z")

</div>

I have a bit of an unconventional situation. I have an app that generates files at runtime. Those files contain valid elixir code (modules basically). I need to compile them and load them at runtime. I am able to do mo…

---

## [Capitalization of filenames](https://forum.elixirforum.com/t/capitalization-of-filenames/33308)

<div class="topic-metadata">

**Author:** [@roostercrab](https://forum.elixirforum.com/u/roostercrab)\
**Replies:** 2\
**Last updated:** [July 23, 2020, 11:26pm UTC](https://forum.elixirforum.com/t/capitalization-of-filenames/33308 "2020-07-23T23:26:12Z")

</div>

Hello, I am trying to teach Elixir to some intro to programming students, and they had a strange experience when running a simple program that wouldn’t work until they capitalized the filename like the module. We are a…

---

## [Setting a module attribute from a function in a different module](https://forum.elixirforum.com/t/setting-a-module-attribute-from-a-function-in-a-different-module/31719)

<div class="topic-metadata">

**Author:** [@joey\_the\_snake](https://forum.elixirforum.com/u/joey_the_snake)\
**Replies:** 3\
**Last updated:** [May 22, 2020, 6:29am UTC](https://forum.elixirforum.com/t/setting-a-module-attribute-from-a-function-in-a-different-module/31719 "2020-05-22T06:29:30Z")

</div>

I have 2 modules, one of them has a function that returns a list and the other one is using that function to create a module attribute. Is this a safe operation in Elixir? I’m not sure if it’s guaranteed that the first …

---

## [Is it detrimental for the BEAM to create many modules](https://forum.elixirforum.com/t/is-it-detrimental-for-the-beam-to-create-many-modules/24310)

<div class="topic-metadata">

**Author:** [@lud](https://forum.elixirforum.com/u/lud)\
**Replies:** 3\
**Last updated:** [July 29, 2019, 10:04pm UTC](https://forum.elixirforum.com/t/is-it-detrimental-for-the-beam-to-create-many-modules/24310 "2019-07-29T22:04:50Z")

</div>

For an app, I would like to implement a command pattern, a la Commanded. I would like to know if there could be downsides to creating a different module (with a defstruct inside) for each command. Say 200.

---

## [Module attributes: when must they be unique?](https://forum.elixirforum.com/t/module-attributes-when-must-they-be-unique/21429)

<div class="topic-metadata">

**Author:** [@fireproofsocks](https://forum.elixirforum.com/u/fireproofsocks)\
**Replies:** 5\
**Last updated:** [April 5, 2019, 3:21pm UTC](https://forum.elixirforum.com/t/module-attributes-when-must-they-be-unique/21429 "2019-04-05T15:21:51Z")

</div>

While looking over the source code for a library I’m using, I noticed that there were several times that the same module attribute (@params) was defined in the same module – the author was using this as a way to define d…
