Last update August 15, 2008

Doc Comments / Phobos /
Object



object    

Table of contents of this page
object   
Comments   
Missing Items   
Object.print   
printf   
Typeinfo and polymorphism   
ClassInfo   
Links   

Comments    

Add your comments here...

This part is confusing:

bool opEquals(Object o);

    Returns !=0 if this object does have the same contents as obj. 

Why not specify a bool return value instead of !=0 (Returns true if equals).

Missing Items    

I don't see any reason why these alias shouldn't be listed as part of the documentation:

  • alias string;
  • alias wstring;
  • alias dstring;

Object.print    

The Object.print method is absent from the documentation. I think it'd be best to match the code with docs by removing it from object.d. (Since it's not even documented, I'll bet no one has ever used this "feature".)

printf    

The documention doesn't mention extern(C) int printf(char *, ...), it should probably be removed from object.d. (Since it's not documented, this "feature" might have not been used by anyone.)

Typeinfo and polymorphism    

Sometimes (like in a variadic function) you have a TypeInfo?, and want to determine if that TypeInfo? represents a particular class or any of it's subclasses. This tip comes from Jarret Billingsley:
TypeInfo ti = _arguments[i];
TypeInfo_Class tic = cast(TypeInfo_Class)ti;

if(tic)
{
    ClassInfo ci = tic.info;

    for( ; ci !is null; ci = ci.base)
        if(ci == Foo.classinfo)
        {
            // it's derived, do what you will
        }

    if(ci is null)
    {
        // we got to the base without finding Foo,
        // it's not derived from Foo
    }
}

ClassInfo    

Please add some more information about ClassInfo. Something like:

ClassInfo classinfo;

    .classinfo for this interface (not for containing class) 

.classinfo.name allows you to get the name of a class as a string. For example:

void main ( char [] [] args ) {

	A a = new A;
	printf("%.*s", a.classinfo.name); //prints "A"
}

Links    


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: August 15, 2008 3:45 (diff))