https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782018-11-24T20:42:56ZRuby Issue Tracking SystemRuby master - Feature #15338: Provide way for C extensions to query if global variable is definedhttps://bugs.ruby-lang.org/issues/15338?journal_id=751562018-11-24T20:42:56Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><blockquote>
<p><a href="https://bugs.ruby-lang.org/issues/15338" class="external">https://bugs.ruby-lang.org/issues/15338</a></p>
</blockquote>
<blockquote>
<p>Let's introduce third function <code>rb_gv_defined</code> to complement <code>rb_gv_get</code> and <code>rb_gv_set</code>.</p>
</blockquote>
<blockquote>
<p>PS: At the moment I'm doing <code>if (RTEST(rb_eval_string("defined?($XX) && $XX"))) { ... }</code> but<br>
there's got to be a better way, right?</p>
</blockquote>
<p>I prefer we avoid adding more bloat to the public C API unless<br>
it's a performance critical case. This doesn't seem<br>
performance-critical to me.</p> Ruby master - Feature #15338: Provide way for C extensions to query if global variable is definedhttps://bugs.ruby-lang.org/issues/15338?journal_id=751652018-11-25T09:32:32Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>As for the implementation, this <code>rb_gv_defined</code> will add new ID just by asking if the gv is defined.</p>