On Jul 26, 2:04=A0am, "Luis Lavena" <luislav... / gmail.com> wrote:
> On Sat, Jul 26, 2008 at 5:09 AM, Tanaka Akira <a... / fsij.org> wrote:
> > In article <3454c9680807250054i70db563duf44b42d92ba41... / mail.gmail.com=
>,
> > =A0"Vladimir Sizikov" <vsizi... / gmail.com> writes:
>
> >> 1. RubyGems uses it to invoke #{RUBY_ENGINE}.rb file with
> >> customizations, specific for particular implementation
>
> > I'm not sure what the customizations to be done.
>
> One example is the gem stub files generated by RubyGems that need to
> be changed to reflect the name of the executable for jRuby (jruby.bat)
> at least in Windows.
>
> I've seen and dealt with many regexp that just evaluate /java/ for
> RUBY_PLATFORM and I need to perform customization for it (like using a
> .jar file instead of a C extension).
>
> >> 2. Different implementations have different specifics, like JRuby can
> >> 'require' a JAR file and need different activerecord drivers, etc.
> >> There are also some JRuby-specific libraries that only make sens for
> >> JRuby, and the whole Java Integration layer. So, folks need to figure
> >> out when they run with JRuby and when they not.
>
> > Why don't just try "some feature"?
>
> >...
>
> > is much better becuase it works well with other engines if
> > it provide zlib.
>
> This is for gems or packages that are both compatible (or intend to
> be) with the different implementations. Is not about the rescue of a
> missing feature.
>
> One example is jruby on Windows cannot perform a series of socket
> related functions, while on posix platform it can. So limit your code
> to only RUBY_PLATFORM =3D~ /java/ doesn't work.
>
> So under jRuby there is no way to know the underlying OS because they
> rely on RUBY_PLATFORM to make it looks like java. The same will happen
> with Rubinius when it works on Windows or IronRuby when it build in
> Mono.
>
> Right now, besides query RUBY_PLATFORM, you also need:
>
> defined?(JRUBY_VERSION) or defined?(Rubinius) to deal with specfic
> code for those cases... (dunno about IronRuby).
>
> What about an unified way that doesn't pollute the already complicated
> RUBY_PLATFORM?
>

RUBY_ENGINE is needed to definitively identify the implementation on
which the code is running. This information needs to be simple and
unambiguous, not tacked onto some other information. When there was a
single implementation, this was not needed, but there are now multiple
implementations.

The RubySpec project needs this information and other code certainly
will. Whether folks use the value of RUBY_ENGINE in conditionals for
requiring code is up to them. They may have a good need to do so.

Also, the name is very clear and descriptive: engine, noun: a thing
that is the agent or instrument of a particular process. RUBY_ENGINE
=3D=3D the thing that makes your Ruby code run.

Cheers,
Brian