Does "source()" redefine things?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Does "source()" redefine things?

Bruno Berstel
Hi all,

I'm facing the following problem. I have a small file with two scripted
methods. The file is named "foo.bsh" and here is its contents:

    load_task(filename) {
      print("Loading file " + filename);
      task = new Task(filename);
    }

    void foo() {
      print("foo");
    }

I load these two methods using

    source("foo.bsh");

and it works. Then I want to go further and do more stuff in the
"load_task" method. I modify my file so that it contents the following code:

    load_task(filename) {
      print("Loading file " + filename);
      task = new Task(filename);
      print("Done");
    }

    void foo() {
      print("foo");
    }

I then reload the script using

    source("foo.bsh");

and to my surprise it seems that my modification has not been taken into
account. (Yes, I saved my Emacs buffer.) That is, the "load_task" method
does not print "Done". Furthermore, I modified the file this way (note
the modifications in both methods):

    load_task(filename) {
      print("Loading file " + filename);
      task = new Task(filename);
      print("Really done");
    }

    void foo() {
      print("bar");
    }

I then reload the script using "source()": the "load_task" method still
behave as originally, but the "foo" method prints "bar". :-(

I'm stuck here, since as you can imagine, having to restart a new
interpreter after each change in a script kind of defeats the purpose of
using BeanShell...

Any help appreciated,
    Bruno.

I'm using BeanShell 2.0b4 (from the Console if that matters).



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Does "source()" redefine things?

Daniel Wunsch
On Thursday 01 September 2005 15:22, Bruno Berstel wrote:

> I then reload the script using "source()": the "load_task" method still
> behave as originally, but the "foo" method prints "bar". :-(

this bug has been introduced with version 2.0b4.
go back to 2.0b2 or use "String filename" instead
of just "filename".

daniel



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users