[ruby-core:64851] [ruby-trunk - Feature #10214] new functions for compare of symbols in C API

From: hanmac@...
Date: 2014-09-08 09:06:08 UTC
List: ruby-core #64851
Issue #10214 has been updated by Hans Mackowiak.


i need to check it, is the VALUE object the same pointer for symbols with same content? (because some might be static and the other dynamic, so == of the VALUE might not work)

i think thats only the case if the ID object is greated first before the dynamic symbol is maked in ruby

in a case where a symbol is created dynamicly and then a static symbol is created with the same content
i dont think the VALUE pointer of them would be the same (and i also need to check what happen to the dynamic symbol, because i dont think its getting static but it might become a pinned one)

----------------------------------------
Feature #10214: new functions for compare of symbols in C API
https://bugs.ruby-lang.org/issues/10214#change-48719

* Author: Hans Mackowiak
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
currently i often use Symbols as enums in my bindings, 
have something like this with comparing symbols by their ID

~~~
if(SYMBOL_P(sym))
{
  if(rb_intern("name") == SYM2ID(sym))
    return ENUM_NAME;
}
~~~

now with dynamic symbols and other ones, its problematic because with that i always foce a dynamic symbol to become static or pinned (that what SYM2ID does)

so imo there need to be better ways to comare is an ID and a VALUE-sym or two VALUE-syms and check if they have the same content (hm because comparing two VALUE with == might/does not work) 



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next