Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9303129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:24:47+00:00 2026-06-18T23:24:47+00:00

I have an application with can be extended with Ruby. Scripts can be created

  • 0

I have an application with can be extended with Ruby. Scripts can be created in the application itself and are reloaded every time they are edited. So, when the user adds a method to a class, it takes effect immediately. I can’t just execute the modified file, as if the user removes a method, it shall unexist. The only option is to clear the state of the interpreter and reload all scripts again. But Ruby protects itself against restarting: (eval.c)

void ruby_init(void)
{
    int state = ruby_setup();
    if (state) {
        error_print();
        exit(EXIT_FAILURE);
    }
}

int ruby_setup(void)
{
    static int initialized = 0;
    int state;

    if (initialized)
        return 0;
    initialized = 1;

    /* ... */

    return state;
}

I also think calling ruby_init() multiple times can cause issues with the stack position that ruby keeps track of and break the GC. Restarting the whole application is not an option as it has a GUI interface. Also keeping all ruby stuff in a separated process would be painful because a Qt interface to insert new GUI elements on the application is exposed. Another option is to keep track somehow of all defined methods, classes, constants, etc and undef them before reexecuting the code. Is there a simple way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T23:24:48+00:00Added an answer on June 18, 2026 at 11:24 pm

    Yes, there is! (I think) (This requires that you use some Ruby code to load the other Ruby code):

    $current_env = nil
    
    def reload(code)
      $current_env = Module.new
      $current_env.module_eval(code)
    end
    

    Yes, it’s that simple. Whenever you need to access things from the plugin, just access $current_env as a module:

    $current_env::ExtensionClass.extension_thing
    

    The old classes things that are replaces when reload is called become inaccessible, in addition to being deallocated next time the GC gets around.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have an extended User model called UserProfile. This user can
I have created an application where I had extended an Activity and got the
I have a C++ Windows application that can be extended by writing C++ plugins,
I am developing a Math application which can be extended by writing python scripts.
I have an application that can filter a datagridview based on date using a
I have an application that can be viewed with landscape and portrait mode. I'm
I have an application that can potentially have hundreds of memory mapped, i.e., mmap()
In C++, a console application can have a message handler in its WinMain procedure,
I have an application where users can store items. Now each type of account
I have an application where I can launch a modal dialog box over a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.