1. Michael Granger
  2. ruby-pg
  3. Issues

Issues

Issue #101 invalid

Add support for Rubinius by removing MRI-specific encoding API calls

Anonymous created an issue

The rb_enc_alias function is not exposed in MRI's encoding.h. There is no Ruby equivalent of this C function. It should be considered an implementation detail.

The rb_enc_replicate function is exposed in encoding.h and there is a Ruby equivalent to this C function.

Can rb_enc_replicate be used in place of rb_enc_alias?

The use of ENCODING_GET_INLINED is MRI implementation-specific. There are perfectly valid Encoding APIs like rb_enc_get(obj) and rb_enc_get_index(obj). Even the use of the index I would argue is depending on an MRI implementation detail, but Rubinius supports the index API in the C-API. rb_enc_get_index is going to call ENCODING_GET_INLINED and the overhead of one more C function call cannot outweigh the value of implementation-agnostic code.

Please consider using rb_enc_get_index instead.

Thanks, Brian

Comments (8)

  1. Anonymous

    Also note that rb_enc_alias is actually a local symbol. Your #ifdef to use rb_enc_alias as a last resort would segv on loading the shared library if it were used at compile time.

    The rb_encdb_alias function is exposed, but I would strenuously argue that it is just as much of an MRI implementation detail.

    Thanks, Brian

  2. Michael Granger repo owner

    While I'd ideally like to support alternative interpreters like Rubinius and JRuby, the fact of the matter is that doing so requires additional time, code complexity, and testing.

    If you (or someone else) is willing to be the champion of whatever platform/interpreter/database feature you're advocating, I'd be happy to include you in the discussion of future changes in exchange for patches and testing under your preferred configuration.

    I'd also appreciate it if you'd:

    1. Create an account on bitbucket to open tickets so I know you're actually interested in participating, and
    2. Phrase your tickets in terms of symptoms rather than proscribing a remedy (e.g., "Add support for Rubinius" (or whatever) rather than "rb_enc_alias is an internal MRI function"). The latter doesn't describe a problem, it's just a statement with an implied value judgement.

    Anyway, thanks for the ticket/s.

  3. Log in to comment