# What is the idiomatic way to undo a gensym?

**URL:** <https://discourse.julialang.org/t/what-is-the-idiomatic-way-to-undo-a-gensym/15354>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 22, 2018, 7:32pm UTC](https://discourse.julialang.org/t/what-is-the-idiomatic-way-to-undo-a-gensym/15354 "2018-09-22T19:32:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [September 22, 2018, 7:32pm UTC](https://discourse.julialang.org/t/what-is-the-idiomatic-way-to-undo-a-gensym/15354/1 "2018-09-22T19:32:10Z")

</div>

I’ve never seen `gensym` before today, but is there an idiomatic way to undo the operation?

For example,

```julia
> gensym("Core.println")
Symbol("##Core.println#701")

```

I guess one way would be to regex it:

```julia
> match(r"(?<=##)[^#]*(?=#)", String(gensym("Core.println"))).match
"Core.println"

```

But that seems about as hacky as this question?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 22, 2018, 7:34pm UTC](https://discourse.julialang.org/t/what-is-the-idiomatic-way-to-undo-a-gensym/15354/2 "2018-09-22T19:34:42Z")

</div>

What problem are you trying to solve?

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [September 22, 2018, 7:42pm UTC](https://discourse.julialang.org/t/what-is-the-idiomatic-way-to-undo-a-gensym/15354/3 "2018-09-22T19:42:38Z")

</div>

In JLD2, there’s a line that tries to make a convert call:

- [JLD2.jl/data.jl at ae0345682a3b1d256a81de2957623b64ffb405b1 · JuliaIO/JLD2.jl · GitHub](https://github.com/simonster/JLD2.jl/blob/ae0345682a3b1d256a81de2957623b64ffb405b1/src/data.jl#L675)

However, this seems to break for abstract types (at least when within an array).

On inspection, it shows that the object, `x`:

- is of type `JLD2.ReconstructedTypes.##Fussy.Reactor#739`
- and not of `Fussy.Reactor`

I was trying to do a diff on the `fieldnames` of the object stored in JLD2 and the current `Fussy.Reactor`

// if you could do this, then you might have a better chance of converting the object

* * *

**edit:** the `T` in the function is `Fussy.AbstractReactor` – which is abstract and therefore has no fields

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 22, 2018, 8:11pm UTC](https://discourse.julialang.org/t/what-is-the-idiomatic-way-to-undo-a-gensym/15354/4 "2018-09-22T20:11:56Z")

</div>

Sounds like you want to prevent gensym from being called in the first place. (Macro hygiene error?)
