From: Ryan Davis Date: 2002-09-11T08:12:00+09:00 Subject: Re: RubyInline 1.0.4 Released! (fwd) On 2002-09-10T17:15:25, Pat Eyler wrote: > From: Pat Eyler > To: ruby-talk ML > maybe someone would like to post a code sample of Inline::C from ruby? Here is the snippet from example.rb: def fastfact(*args) inline args, <<-END int i, f=1; for (i = FIX2INT(argv[0]); i >= 1; i--) { f = f * i; } return INT2FIX(f); END end Basically, this is the body of the function you'd have to write if you were to write a "real" extern. This gets extracted, compiled, linked into a .so, required/loaded, and run in the first call to this method. The second call to this method (in the same runtime) just runs the optimized version. Another call in another runtime would jump to the require/loaded stage unless the script had been edited since last compile.