# \#module

**URL:** https://discourse.julialang.org/tag/module/151.md?match_all_tags=true&page=3&tags%5B%5D=module

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 4

---

## [Combining two co-dependent modules into a single program](https://discourse.julialang.org/t/combining-two-co-dependent-modules-into-a-single-program/61881)

<div class="topic-metadata">

**Author:** [@Niall](https://discourse.julialang.org/u/Niall)\
**Replies:** 20\
**Last updated:** [May 28, 2021, 3:33pm UTC](https://discourse.julialang.org/t/combining-two-co-dependent-modules-into-a-single-program/61881 "2021-05-28T15:33:43Z")

</div>

I’m struggling to understand how to combine modules at the moment, and am clearly missing something crucial. I have a module that uses another module, and also a method that calls another method of the same name but diff…

---

## [Is it possible to make conditional changes in a TimeArray (TimeSeries) object entries?](https://discourse.julialang.org/t/is-it-possible-to-make-conditional-changes-in-a-timearray-timeseries-object-entries/61231)

<div class="topic-metadata">

**Author:** [@shubh\_b](https://discourse.julialang.org/u/shubh_b)\
**Replies:** 2\
**Last updated:** [May 16, 2021, 12:17pm UTC](https://discourse.julialang.org/t/is-it-possible-to-make-conditional-changes-in-a-timearray-timeseries-object-entries/61231 "2021-05-16T12:17:34Z")

</div>

Here is a TimeArray object ta as using TimeSeries dt = \[Date("2011-12-07"), Date("2012-04-06"), Date("2012-07-07")\] par1 = \[11, 12, 14\] par2 = \[21, 22, 24\] ta = TimeArray((dt = dt, par1 = par1, par2 = par2), timestamp…

---

## [Why do we need to prefix module name with Julia function sometimes to make it work?](https://discourse.julialang.org/t/why-do-we-need-to-prefix-module-name-with-julia-function-sometimes-to-make-it-work/60949)

<div class="topic-metadata">

**Author:** [@shubh\_b](https://discourse.julialang.org/u/shubh_b)\
**Replies:** 1\
**Last updated:** [May 11, 2021, 1:19pm UTC](https://discourse.julialang.org/t/why-do-we-need-to-prefix-module-name-with-julia-function-sometimes-to-make-it-work/60949 "2021-05-11T13:19:21Z")

</div>

As example, here is a DateTime object declared below using Dates module: julia\> using Dates julia\> dt = DateTime(2021, 05, 11, 18, 21, 50) 2021-05-11T18:21:50 We can find the Hour value of dt simply using hour() funct…

---

## [In what order are \`\_\_init\_\_\` functions called?](https://discourse.julialang.org/t/in-what-order-are-init-functions-called/60492)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 1\
**Last updated:** [May 4, 2021, 7:52am UTC](https://discourse.julialang.org/t/in-what-order-are-init-functions-called/60492 "2021-05-04T07:52:05Z")

</div>

If a module C contains using A using B I know that C.\_\_init\_\_ is called last. But is there any promise about the order of A.\_\_init\_\_ and B.\_\_init\_\_?

---

## [\[Julia usage / metaprogramming\] How to evaluate a module's function with function's name as a string?](https://discourse.julialang.org/t/julia-usage-metaprogramming-how-to-evaluate-a-modules-function-with-functions-name-as-a-string/60031)

<div class="topic-metadata">

**Author:** [@erwanlecarpentier](https://discourse.julialang.org/u/erwanlecarpentier)\
**Replies:** 10\
**Last updated:** [April 26, 2021, 2:17pm UTC](https://discourse.julialang.org/t/julia-usage-metaprogramming-how-to-evaluate-a-modules-function-with-functions-name-as-a-string/60031 "2021-04-26T14:17:25Z")

</div>

Hi! Inside a function, I would like to evaluate a module’s function based on two inputs: 1) the module itself and 2) the function’s name as a string. Here is the code: module A function foo() println("This is A.foo…

---

## [Multiple dispatch and modules](https://discourse.julialang.org/t/multiple-dispatch-and-modules/59700)

<div class="topic-metadata">

**Author:** [@lambdakappatheta](https://discourse.julialang.org/u/lambdakappatheta)\
**Replies:** 8\
**Last updated:** [April 24, 2021, 2:36am UTC](https://discourse.julialang.org/t/multiple-dispatch-and-modules/59700 "2021-04-24T02:36:48Z")

</div>

After watching Stefan Karpinski’s talk called The Unreasonable Effectiveness of Multiple Dispatch I started wondering how multiple dispatch and modules fit together. To put it simply, if type A is defined in module a an…

---

## [Passing functions as default arguments to functions in sibling modules](https://discourse.julialang.org/t/passing-functions-as-default-arguments-to-functions-in-sibling-modules/58769)

<div class="topic-metadata">

**Author:** [@MattWillFlood](https://discourse.julialang.org/u/MattWillFlood)\
**Replies:** 1\
**Last updated:** [April 7, 2021, 6:02pm UTC](https://discourse.julialang.org/t/passing-functions-as-default-arguments-to-functions-in-sibling-modules/58769 "2021-04-07T18:02:03Z")

</div>

Hi Guys :slightly\_smiling\_face: Is there a way to pass a function from a submodule (saved in a separate file) as a default argument to a sibling function? :thinking: As an example, say that my module is structured as f…

---

## [\`Using\` doesn't work inside custom module](https://discourse.julialang.org/t/using-doesnt-work-inside-custom-module/58742)

<div class="topic-metadata">

**Author:** [@Sunny](https://discourse.julialang.org/u/Sunny)\
**Replies:** 2\
**Last updated:** [April 7, 2021, 10:52am UTC](https://discourse.julialang.org/t/using-doesnt-work-inside-custom-module/58742 "2021-04-07T10:52:00Z")

</div>

I want to export a function from a custom module that uses some package inside itself, but it works in a unexpected way for me module A export f using StatsBase f(x) = StatsBase.sample(\[x,0\]) end using .A f(1) Output …

---

## [Getting the name of a Struct / Scoping Issues with Custom Structs](https://discourse.julialang.org/t/getting-the-name-of-a-struct-scoping-issues-with-custom-structs/58706)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 3\
**Last updated:** [April 6, 2021, 8:56pm UTC](https://discourse.julialang.org/t/getting-the-name-of-a-struct-scoping-issues-with-custom-structs/58706 "2021-04-06T20:56:55Z")

</div>

Hi there, I have a scoping issues, and did not manage to find a solution on my own. I was hoping that someone more knowledgeable might have a quick solution for this: I define an abstract type AbstractModel in a modul…

---

## [Organisation of a diverse library in submodules using Reexport and ForceImport](https://discourse.julialang.org/t/organisation-of-a-diverse-library-in-submodules-using-reexport-and-forceimport/57377)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 0\
**Last updated:** [March 17, 2021, 12:50pm UTC](https://discourse.julialang.org/t/organisation-of-a-diverse-library-in-submodules-using-reexport-and-forceimport/57377 "2021-03-17T12:50:35Z")

</div>

I have a Machine Learning library with different stuff that I am keeping organised in submodules. I use submodules because (1) They actually make “logical” sense to classify them in submodules; (2) They integrate nicely …

---

## [Making code and packages available to workers inside module](https://discourse.julialang.org/t/making-code-and-packages-available-to-workers-inside-module/56311)

<div class="topic-metadata">

**Author:** [@Nikos\_Gianniotis](https://discourse.julialang.org/u/Nikos_Gianniotis)\
**Replies:** 4\
**Last updated:** [March 2, 2021, 11:49am UTC](https://discourse.julialang.org/t/making-code-and-packages-available-to-workers-inside-module/56311 "2021-03-02T11:49:43Z")

</div>

Dear forum, my title explains to some extend what I am trying to achieve. To make it hopefully clearer, I have written the following minimal code as an example. First, I create an ordinary script (scriptA.jl) where the…

---

## [How to implement "dependent constants" in a module](https://discourse.julialang.org/t/how-to-implement-dependent-constants-in-a-module/55766)

<div class="topic-metadata">

**Author:** [@triceert](https://discourse.julialang.org/u/triceert)\
**Replies:** 8\
**Last updated:** [February 24, 2021, 3:14pm UTC](https://discourse.julialang.org/t/how-to-implement-dependent-constants-in-a-module/55766 "2021-02-24T15:14:11Z")

</div>

So from what I learned in Julia so far, constants make everything faster. So if I have a script that calculates a value that is dependent on the input of the script but then stays constant throughout the script (e.g. a D…

---

## [Best practice for managing package hierarchy](https://discourse.julialang.org/t/best-practice-for-managing-package-hierarchy/55822)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 7\
**Last updated:** [February 23, 2021, 10:38am UTC](https://discourse.julialang.org/t/best-practice-for-managing-package-hierarchy/55822 "2021-02-23T10:38:02Z")

</div>

What’s the best practice for the management of a package and its modules? Please take a look at the following example. In this example, module A is a kind of a Base module, and module B is a corresponding module. Also…

---

## [Recommended development workflow in VSCode](https://discourse.julialang.org/t/recommended-development-workflow-in-vscode/55348)

<div class="topic-metadata">

**Author:** [@marty0801](https://discourse.julialang.org/u/marty0801)\
**Replies:** 12\
**Last updated:** [February 21, 2021, 1:11pm UTC](https://discourse.julialang.org/t/recommended-development-workflow-in-vscode/55348 "2021-02-21T13:11:12Z")

</div>

I’m trying to move from Juno to VSCode, but I’m having trouble getting introspection to work well with my code setup. In Juno, I made local modules available by push!ing to LOAD\_PATH. This post indicates that this is not…

---

## [Importing modules after having included them in the Main module](https://discourse.julialang.org/t/importing-modules-after-having-included-them-in-the-main-module/54836)

<div class="topic-metadata">

**Author:** [@Valery](https://discourse.julialang.org/u/Valery)\
**Replies:** 4\
**Last updated:** [February 8, 2021, 3:11pm UTC](https://discourse.julialang.org/t/importing-modules-after-having-included-them-in-the-main-module/54836 "2021-02-08T15:11:23Z")

</div>

Hi all, I want to import some modules containing variables and functions for my project. Down below is a simplified version of my Main module (forward / in Linux). Why does such an error occur ? module Main include("M…

---

## [So if I have module A defining a struct, then with "using" import the struct to mo](https://discourse.julialang.org/t/so-if-i-have-module-a-defining-a-struct-then-with-using-import-the-struct-to-mo/54704)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 2\
**Last updated:** [February 6, 2021, 4:41am UTC](https://discourse.julialang.org/t/so-if-i-have-module-a-defining-a-struct-then-with-using-import-the-struct-to-mo/54704 "2021-02-06T04:41:25Z")

</div>

So if I have module A defining a struct, then with “using” import the struct to module B, and define a function on that struct. Then in module C “using” import both module A and B. When I try to run the function on the s…

---

## [Scoping issues with Macro in Module](https://discourse.julialang.org/t/scoping-issues-with-macro-in-module/54383)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 3\
**Last updated:** [February 1, 2021, 5:43pm UTC](https://discourse.julialang.org/t/scoping-issues-with-macro-in-module/54383 "2021-02-01T17:43:55Z")

</div>

Hi everyone, I need to create a mutable struct where I do not know the number of fields a priori. I could alternatively just use a NamedTuple for this, but in this case the struct is preferable to me. I can do this wond…

---

## [Passing constant configuration values to modules](https://discourse.julialang.org/t/passing-constant-configuration-values-to-modules/28551)

<div class="topic-metadata">

**Author:** [@aahaselgrove](https://discourse.julialang.org/u/aahaselgrove)\
**Replies:** 7\
**Last updated:** [January 28, 2021, 3:33pm UTC](https://discourse.julialang.org/t/passing-constant-configuration-values-to-modules/28551 "2021-01-28T15:33:25Z")

</div>

I am working on a numerical optimisation project with Julia in a Jupyter notebook. My current workflow is to define the problem size with some global constants at the top of the notebook (eg. const N = 20), which are the…

---

## [Confused about intent of using/import (docs)](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834)

<div class="topic-metadata">

**Author:** [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Replies:** 5\
**Last updated:** [January 26, 2021, 3:16pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834 "2021-01-26T15:16:06Z")

</div>

I was reading the (new v1.7) docs on modules (Standalone using and import): Specifically: Possibly the most common way of loading a module is using ModuleName. This loads the code associated with ModuleName, and brin…

---

## [Load functions from files dynamically without including them in global scope](https://discourse.julialang.org/t/load-functions-from-files-dynamically-without-including-them-in-global-scope/51248)

<div class="topic-metadata">

**Author:** [@akhil\_teja](https://discourse.julialang.org/u/akhil_teja)\
**Replies:** 1\
**Last updated:** [December 4, 2020, 12:47pm UTC](https://discourse.julialang.org/t/load-functions-from-files-dynamically-without-including-them-in-global-scope/51248 "2020-12-04T12:47:23Z")

</div>

I want to dynamically include functions from files based on condition. Below code gives you an Idea. File1.jl function foo() println("In File1.jl") end File2.jl function foo() println("In File2.jl") end Mai…

---

## [Is there a way to make a submodule "open"](https://discourse.julialang.org/t/is-there-a-way-to-make-a-submodule-open/49641)

<div class="topic-metadata">

**Author:** [@mhinsch](https://discourse.julialang.org/u/mhinsch)\
**Replies:** 21\
**Last updated:** [November 12, 2020, 12:33am UTC](https://discourse.julialang.org/t/is-there-a-way-to-make-a-submodule-open/49641 "2020-11-12T00:33:59Z")

</div>

The scenario: I am writing a DSLish set of macros that create a few functions that again call code the user has provided verbatim (in the macro call), so something like this: @mymacro Bla myfun1() myfun2() end …

---

## [How do I find which module exported a given method or variable?](https://discourse.julialang.org/t/how-do-i-find-which-module-exported-a-given-method-or-variable/49422)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 5\
**Last updated:** [November 2, 2020, 3:28pm UTC](https://discourse.julialang.org/t/how-do-i-find-which-module-exported-a-given-method-or-variable/49422 "2020-11-02T15:28:47Z")

</div>

How do I find which module exported a given method or variable? Background: I have a script MyScript.jl which works I made MyModule that encapsulates some of it’s functions, and call them from MyScript2.jl MyModule.…

---

## [Design of related modules wrt pkg](https://discourse.julialang.org/t/design-of-related-modules-wrt-pkg/48708)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 1\
**Last updated:** [October 21, 2020, 2:37pm UTC](https://discourse.julialang.org/t/design-of-related-modules-wrt-pkg/48708 "2020-10-21T14:37:31Z")

</div>

tldr: regarding use of pkg, are these two examples both doing the same thing (one parent pkg exports functions from all the others)? is there case where one might instead do: each child pkg uses functions from a common…

---

## [Module import vs using](https://discourse.julialang.org/t/module-import-vs-using/48707)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 5\
**Last updated:** [October 21, 2020, 9:30am UTC](https://discourse.julialang.org/t/module-import-vs-using/48707 "2020-10-21T09:30:38Z")

</div>

I’m confused by this table in the docs. The last column is identical for rows 1,3 (import MyModule and using MyModule), which seems inconsistent with the previous paragraph: import also differs from using in that f…

---

## [Dynamic Imports and User Defined Interfaces in Julia](https://discourse.julialang.org/t/dynamic-imports-and-user-defined-interfaces-in-julia/48274)

<div class="topic-metadata">

**Author:** [@gyrfalcon](https://discourse.julialang.org/u/gyrfalcon)\
**Replies:** 4\
**Last updated:** [October 14, 2020, 2:16am UTC](https://discourse.julialang.org/t/dynamic-imports-and-user-defined-interfaces-in-julia/48274 "2020-10-14T02:16:38Z")

</div>

Hello! I am a newcomer to Julia and I am trying to recreate something that I worked a bit on in Python in Julia, because I think Julia will be the better language overall for numerical performance. However, I am trying t…

---

## [SparseMatrixCSC definition in function](https://discourse.julialang.org/t/sparsematrixcsc-definition-in-function/46766)

<div class="topic-metadata">

**Author:** [@jmurga](https://discourse.julialang.org/u/jmurga)\
**Replies:** 4\
**Last updated:** [September 17, 2020, 10:20am UTC](https://discourse.julialang.org/t/sparsematrixcsc-definition-in-function/46766 "2020-09-17T10:20:56Z")

</div>

Hi everyone! I’m developing a module within several functions. I found some troubles with the type definition at some inputs functions. I don’t know why but I cannot use SparseMatrixCSC type as the input type. After bu…

---

## [Importing SharedArray module](https://discourse.julialang.org/t/importing-sharedarray-module/44953)

<div class="topic-metadata">

**Author:** [@trathi](https://discourse.julialang.org/u/trathi)\
**Replies:** 1\
**Last updated:** [August 21, 2020, 2:43am UTC](https://discourse.julialang.org/t/importing-sharedarray-module/44953 "2020-08-21T02:43:31Z")

</div>

I understand that we need @everywhere before any functions or modules that we want to make available to all the processes. My question is if need to have @everywhere before importing the SharedArrays module as well, i.e…

---

## [Passing a function to an eval in my module](https://discourse.julialang.org/t/passing-a-function-to-an-eval-in-my-module/44955)

<div class="topic-metadata">

**Author:** [@koosp](https://discourse.julialang.org/u/koosp)\
**Replies:** 4\
**Last updated:** [August 14, 2020, 10:11pm UTC](https://discourse.julialang.org/t/passing-a-function-to-an-eval-in-my-module/44955 "2020-08-14T22:11:08Z")

</div>

I made a module which had a function, that calls another function inside of it to compute partial derivatives. I tested it with Base functions like exp, sin and so on and it worked, it still works. I also tested it with …

---

## [Best way of \`using\` without bring names into scope?](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272)

<div class="topic-metadata">

**Author:** [@afbarnard](https://discourse.julialang.org/u/afbarnard)\
**Replies:** 7\
**Last updated:** [August 4, 2020, 4:54pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272 "2020-08-04T16:54:16Z")

</div>

Is there a way to use a module without bringing its names into scope? I don’t need to extend any methods. Specifically, using A brings type Foo into scope, but other code already defines Foo, so there is a name ambiguit…

---

## [Variable not defined in module](https://discourse.julialang.org/t/variable-not-defined-in-module/43147)

<div class="topic-metadata">

**Author:** [@Lewis\_Liu](https://discourse.julialang.org/u/Lewis_Liu)\
**Replies:** 5\
**Last updated:** [July 15, 2020, 9:46pm UTC](https://discourse.julialang.org/t/variable-not-defined-in-module/43147 "2020-07-15T21:46:05Z")

</div>

module TestN1 sum=1 for i in 1:10 sum += i end end The code above doesn’t work. Is something wrong？ Julia version 1.4.2.

[Previous page](https://discourse.julialang.org/tag/module/151.md?match_all_tags=true&page=2&tags%5B%5D=module)

[Next page](https://discourse.julialang.org/tag/module/151.md?match_all_tags=true&page=4&tags%5B%5D=module)
