From: Tanner Burson Date: 2005-09-27T23:49:09+09:00 Subject: Re: Ruby and CLR interactions ------=_Part_9550_13027330.1127832545631 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/26/05, Wayne Vucenic wrote: > > 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 > apartment > 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.post. > Both files contain ordinary Ruby code, but ".pre" is run before foo.rb an= d > ".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 problemati= c > method in .post. > Wayne I'm not sure I fully understand the problem here, but wouldn't an easier solution be to create a wrapper shell script that did nothing but : ruby -rclrshim $1 and call it rubyclr or something? That would guarantee that the first file required is always your clrshim (when its needed) and would in fact let you call call other people's scripts, unmodified. Just my $.02 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 b= e > > the > > first line of code in a *program*. I'm not sure at all how I can make > that > > guarantee given the semantics of require. > > > > So hence my thinking around doing a platform-specific change to the Rub= y > > runtime to check for a configuration file. > > > > -John > > > > > > -- =3D=3D=3DTanner Burson=3D=3D=3D tanner.burson@gmail.com http://tannerburson.com <---Might even work one day... ------=_Part_9550_13027330.1127832545631--