# Save and restore namespace

**URL:** https://discourse.julialang.org/t/save-and-restore-namespace/87120
**Category:** New to Julia
**Created:** [September 12, 2022, 9:22am UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120 "2022-09-12T09:22:40Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [September 12, 2022, 9:22am UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/1 "2022-09-12T09:22:40Z")

</div>

Hi  
I am trying to generate a form using gtk in module; the problem arise when I (de)generate two form because the data of the second form obfuscates that of the first.  
I only have two alternatives in mind:

- save the namespace
- passing a namespace to the modue function  
Are these solutions possible?  
Thanks

---

<div class="post-metadata">

### Author: ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)
#### Post date: [September 12, 2022, 2:57pm UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/2 "2022-09-12T14:57:51Z")

</div>

Hi,  
Having some (minimal, runnable) code would help a lot in understanding the issue clearly.

---

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [September 13, 2022, 7:30am UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/3 "2022-09-13T07:30:34Z")

</div>

Thanks  
How attach the code (two scripts of over 500 lines)?  
I know why the program faults, is because I can’t instantiate two copy of the module.  
regards

---

<div class="post-metadata">

### Author: ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)
#### Post date: [September 13, 2022, 10:56am UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/4 "2022-09-13T10:56:30Z")

</div>

Make a copy of the scripts, then try and remove all the parts of it that are not essential to this issue. Keep just the minimal parts that produce the same error when you run it, and post that code.

There’s more tips about providing useful info while asking questions, in this thread: “[make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)”.

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [September 13, 2022, 2:58pm UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/5 "2022-09-13T14:58:14Z")

</div>

I’m slightly confused what you mean. You have teo forms you built with Gtk, but there are name collisons? Maybe just use each form within a module to have separate namepsaces for each.

---

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [September 13, 2022, 4:01pm UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/6 "2022-09-13T16:01:00Z")

</div>

Thanks  
I know where is the “error” at bottom a very essential of I am doing.  
The second call of the form obviously replaces the data, for this I am asking if I can force a new namespace at every call.

```julia
function answer(data)
println(data["Condor"])
end
module formgen
export formGen
function formGen(frm,answer)
    println(" ***$frm***")
    global callBack = answer
    wdgx = split(frm," ";keepempty=false)
    data = Dict()
    for i = 1:length(wdgx)
        println("$i: ",wdgx[i])
        data[wdgx[i]] = i
    end
        callBack(data)
end
end
println("First call")
formgen.formGen("El Condor",answer)
println("Second call")
formgen.formGen("Star FormGen",answer)

```

---

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [September 13, 2022, 4:05pm UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/7 "2022-09-13T16:05:18Z")

</div>

Thanks Mkitti  
your answer confirms to me that it is possible to have the same module acting on different namespaces, however i have no idea how to do this.

---

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [September 13, 2022, 4:06pm UTC](https://discourse.julialang.org/t/save-and-restore-namespace/87120/8 "2022-09-13T16:06:52Z")

</div>

Thanks Mkitti  
your answer confirms to me that it is possible to have the same module acting on different namespaces, however i have no idea how to do this.

![condor.gif](https://global.discourse-cdn.com/julialang/original/3X/f/3/f3eee9e1535df7932bb5f92a53ace7697c0235dc.gif)
