How do you make anonymous module w/ variables?

question

#1

Doing some real hacky stuff.

I want to make an anonymous module with variables.

Kind of pseudocode, I want:

module ()
    foo = 404
end

Where I’m at (in real code) is:

cur_anon = Module()

// this returns: anonymous


#2

eval(cur_anon, :(....................))

Note that not everything will work in such a module (serialization etc) it shouldn’t segfault though if you are just defining variables and running “simple” code in it. It might also not be GC’d.


#3

Playing devil’s advocate, what work would need to be done to get serialization and GC working?

Also, are there ways to manually add items to the GC stack?


#4

GC will work. There will just be a lot of things cached referencing to it that keep it alive.

Unclear what do you mean or want.


#5

Is this true for all modules?

I meant how do you go about forcing a clear/deregister/unassign (whatever the word is for deallocating disk space) towards an anon module


#6

Yes.

FWIW, adding things to the GC stack preserves it. (And it was what you want to preserve that I was asking about). No you cannot lie to the GC.


#7

Alright. Thanks for the info!

I was just seeing how far I could go with the idea