From: Wayne Vucenic Date: 2005-09-27T13:33:47+09:00 Subject: Re: Ruby and CLR interactions ------=_Part_21305_26774523.1127795624941 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi John, I think I understand your concern. Suppose I have a file called clrstuff.rb, which uses the CLR shim. The apartment model gets set up correctly, and everything works fine. Now someone writes a file, foo.rb, which uses win32ole, then does a "require 'clrstuff'". But win32ole may have set up an incompatible apartmen= t model before 'clrstuff' gets invoked, which causes problems for 'clrstuff'. Is this basically the problem? I believe your proposal is to put some info on the required configuration into foo.rb.config. I assume you're proposing a separate file to handle the case where we're unwilling/unable to simply make the changes directly to foo.rb. It seems like this would work, and I can't right off think of a substantially different approach. It's unfortunate that the configuration file needs to be attached to foo.rb rather than to clrstuff.rb. This way when the file bar.rb comes along which uses win32ole and then requires ' foo.rb', we'll also need a bar.rb.config. I'd like to suggest a slight modification/generalization to your proposal. I'd suggest supporting two files, with names like foo.rb.pre and foo.rb.pos= t. Both files contain ordinary Ruby code, but ".pre" is run before foo.rb and ".post" is run after. .pre can be used to do what your .config file would do. .post would be useful when foo.rb contains a buggy method and for whatever reason I can't change foo.rb. Then I can redefine the problematic method in .post. Wayne On 9/26/05, John Lam wrote: > > Hi Wayne, > > >> I'm really glad to see that someone is working on a shim for CLR 2.0! > > Me too :) > > >> Would doing something like this as the first 2 lines in the .rb file > work? > >> require 'clrshim' > >> setSTA > > The problem is that require 'rubyshim' would have to be guaranteed to be > the > first line of code in a *program*. I'm not sure at all how I can make tha= t > guarantee given the semantics of require. > > So hence my thinking around doing a platform-specific change to the Ruby > runtime to check for a configuration file. > > -John > > ------=_Part_21305_26774523.1127795624941--