30 Sep 19:16
Clarified references, shortcut notation
edA-qa <edA-qa <at> disemia.com>
2004-09-30 17:16:15 GMT
2004-09-30 17:16:15 GMT
Okay, looking at the types more and more I get a clear picture of how they all related to each other and their usage. I will try to give that picture here. Firstly, in C2 all variables comprise two parts, the instance and the reference (I intentionally use this word). Instances can exist: -on the stack -in the heap -elsewhere (not yet defined) References are of the types: -shared ref to instance in heap -local ref to instance on stack -value ref to instance on stack -ref to instance anywhere Notes: -when all shared refs to items in the heap go out of scope, the instance is marked for removal/deleted -when stack space for a stack instance goes out of scope, the instance is removed/deleted -a value ref is the same as a local ref, except that it may not be rebound (this limitation is to prevent the losing of an instance) -in this discussion, a pointer is being ignored, as I believe it can be implemented as a non-fundamental type Notation: //creates an instance in heap, and returns a shared reference new T(); //declares a shared reference, uninitialized bound to null (the following are all the same) T^ sharedRef; T shared^ sharedRef; T^ sharedRef = null; //binds a heap instance sharedRef @= otherSharedRef; //creates an instance on the stack, and a value reference which is bound to this instance T value; //declares a local reference (unitialized bound to null) T local^ localRef; T local^ localRef = null; //binds a local ref to a stack instance localRef @= value; localRef @= otherLocalRef; //declares an any reference (unitiialized bound to null) T any^ anyRef; T any^ anyRef = null; //binds an any ref to a stack instance, and heap instance anyRef @= value; anyRef @= localRef; anyRef @= sharedRef; -- -- edA-qa mort-ora-y Idea Architect http://disemia.com/ ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl
RSS Feed