Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Module with state - how to implement?

$
0
0

I would like to have a module with state: when I’m working in the repl, I load the module and its state is “empty”; as I use the module’s constructors to instantiate variables of a certain type defined in that module, the module should keep track of those variables (for example, by keeping a list of all such variables; you can assume variables of this type never go out of scope). My question is: how to implement this?

I know that each module has its global scope, so at first I thought that maybe the module could instantiate the container to keep track of variables instantiate by the module’s constructors, but I read in performance tips that you should avoid global variables.

17 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles