How to use Auto_, ItemClass_ and ThisClass_?

It feels a bit optimistic to ask this considering the response my previous question has gotten so far, but I’ll give the rack another turn.

As per the subject, how can we make use of Auto_, ItemClass_ and ThisClass_ in our code?

I’ve seen allusions to them being used for generic programming, but little explanation of how we can use them to do generic programming for our own classes/objects?

Edit: Just wanted to add a bit of background to explain some of where I’m coming from.

I’ve tried using Auto_, but it seems that all that happens, is that I make a data member Auto_, then everything that would use that data member must be Auto_. Auto_ has no constructor, and nothing can be converted to Auto_. So Auto_ is a dead-end.

I’ve tried using ItemClass_, but it seems like a data member of ItemClass_ is considered to be Object, and trying to treat that data member as another type is an error. So ItemClass_ is a dead-end, could just use Object instead and achieve the same thing.

I haven’t tried ThisClass_ yet, it seems to me that it simply refers to the class it is used in the scope of; perhaps if Auto_ or ItemClass_ or some other generic/template programming were being used, I could see a use for it, but thus far, I have not.

I could really use some explanation and/or examples here, because at the moment, it all seems so pointless.

This is straight from the code if you haven’t seen them yet:

//---------------------------------------------------------------------------------------
// `Auto_` - generic/reflective class used when the actual type is to be inferred by use
// of the parameter, return value, temporary, etc. - it is never actually used directly
// as a class.  When a class type is omitted `Auto_` is used as a note to the parser to
// try to determine the type. `Auto_` is used rather than `None` since `None` can be a
// valid class in some circumstances.
//
// Its name has a trailing underscore `_` to indicate that it is generic/reflective and
// to set it apart from other classes.
//---------------------------------------------------------------------------------------
// The generic/reflective class `ItemClass_` refers to the class type of the items/
// elements of the class scope that uses it in its members - such as items in the List
// class.  It is never actually used directly as a class - only as an alias to another
// class type and as such does not have any members in its native directory.
//
// Its name has a trailing underscore `_` to indicate that it is generic/reflective and
// to set it apart from other classes.

Good examples illustrating the use of ItemClass_ can be found in most/all of the List implementation methods. If you find List in the :sk: IDE classes and just start browsing through the methods in the members pane you’ll find several that have :sk: implementations along with some whose implementation was moved to C++ but the original :sk: implementation was left as a comment.

//---------------------------------------------------------------------------------------
// The generic/reflective class `ThisClass_` refers to the class type of the current
// class scope that uses it in its members.  It is never actually used directly as a
// class - only as an alias to another class type and as such does not have any members
// in its native directory.
//
// Its name has a trailing underscore `_` to indicate that it is generic/reflective and
// to set it apart from other classes.

Probably the most used implementation of this is Actor's instances_from although you can find it well used in List, Enum and Actor implementations. It might be helpful to just grep through the Plugins/SkookumScript/Scripts folder if you want to search out some.

As a side-note, I’ve never once used Auto_ in my years of :sk:.

Thank you for the info. :slight_smile:

I actually did look at the source code and the List methods prior to making my original post, but like said there, I encountered issues with each thing I tried.

Regarding Auto_, I was hoping it would help resolve the issue in my other thread (Generic programming question); basically, I’d like to create a class that provides static typing based on some parameters in a manner similar to what List does. It’s possible I’m approaching that the wrong way, though, as I don’t really have any experience with SkookumScript.