>>>>> "n" == nobu nokada <nobu.nokada / softhome.net> writes:

n> At Mon, 18 Aug 2003 18:23:45 +0900,
n> ts wrote:
>> 
>> There is an inconsistance between rb_const_defined_at() and
>> rb_const_get_at() 

n> Do you mean this?

 Not really this  (I've added comment in the source :-)))

int
rb_const_defined_at(klass, id)
    VALUE klass;
    ID id;
{
    VALUE value;

    if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) {
	if (value == Qundef && NIL_P(autoload_file(klass, id)))
	    return Qfalse;
	return Qtrue;
    }
   /*
      here rb_const_defined_at() can look in rb_cObject
   */
    if (klass == rb_cObject) {
	return rb_const_defined(klass, id);
    }
    return Qfalse;
}


VALUE
rb_const_get_at(klass, id)
    VALUE klass;
    ID id;
{
    VALUE value;

    while (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) {
	if (value == Qundef) {
	    rb_autoload_load(klass, id);
	    continue;
	}
	return value;
    }
    /*
       rb_const_get_at() don't do the same thing
       it give an error, rather than trying to look in rb_cObject
    */
    return const_missing(klass, id);
}


 What is the right way to do ?


Guy Decoux