Re: [Gauche-devel] Thinking again about parameters in the VM
R7RS Scheme scripting engine
Status: Beta
Brought to you by:
shirok
From: Kirill Z. <k....@me...> - 2012-01-14 04:08:13
|
One way would be to create a global table that holds all parameters ever initialized (per module, I suppose, since the module system is global as well) paired with their initial values. Then the parameter getter procedure can be modified to check, on ref error, if the "same" parameter exists in the table, and if so, to initialize a new parameter of the same name in its own local storage using the initial value stored in the table. This would only fire for parameter ref errors, and we're assuming here that most programs are at least well formed enough to not rely on or exhibit parameter ref errors frequently. The only thing that's probably bad is that now parameter creation is serialized... I'm not sure how much of a handicap it is in practice. Thoughts? On 2012-01-13, at 10:52 PM, Kirill Zorin wrote: >> From private correspondence with Shiro: > > "[An] error happens when a parameter is created *after* some > threads are already running, and the parameter is used > in those threads that were already running. One possible > scenario is like this: > > - We have thread A and thread B running. > - Thread A calls (use rfc.http) for the first time. > This loads http.scm and creates parameters. > Thread B isn't aware of those parameters. > - Thread B *dynamically* loads some file, say, foo.scm, > which contains (use rfc.http). This time http.scm has > already been loaded, so it's no-op. > - Thread B calls some function defined in foo.scm, > which in turn makes http call. The call accesses > parameters defined in http.scm, but they are not > visible from B, hence the error. > > This won't happen typically, since usually the modules > used by the program is statically stated in `use' form; > so when a thread starts running, all the necessary parameters > are already created. > > However, if a module is dynamically loaded (via explicitly > by 'load', or implicitly by autoload), the above scenario > can happen. > > [...] > > The parameter system is awkward anyway, so I need some > fundamental fix for this." > > > Transferring this here to get more thoughts and have some kind of information trail. > > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Mar 27 - Feb 2 > Save $400 by Jan. 27 > Register now! > http://p.sf.net/sfu/rsa-sfdev2dev2 > _______________________________________________ > Gauche-devel mailing list > Gau...@li... > https://lists.sourceforge.net/lists/listinfo/gauche-devel |