12 Sep 15:51
Local and global object referencing model of C2
Slawomir Lisznianski <slisznianski <at> c2-lang.org>
2004-09-12 13:51:02 GMT
2004-09-12 13:51:02 GMT
[Working Draft, for public review]
There are three main ways you can refer to a class instance T:
* As the object itself-- by value T
* As the memory address of the object-- by pointer T*
* With an alias to the object-- by reference T&
C2 upholds the stack and heap stores of C++ but encourages the object
by-reference model. Pointers are primarily used for array traversals and
calls to C libraries. In C2, automatic objects are called local objects,
whereas heap objects are referred to as global objects. C2 defines heap
as garbage-collectable store, with garbage-collector to be of a
non-compacting, conservative type. Additionally, with qualifiers read
right-to-left:
If T represents an object of type T, 'T&' declares reference to global T
and 'T local&' declares a reference to local T.
A variable declared to be a 'T&', that is reference to global T, shall
be initialized by operator new of type T or from another reference to
global T or derived from T.
Double ampersand (&&) designates a reference to global or local object.
This type of reference is called an "any-store" reference.
A cv-qualified local object can be assigned to a cv-qualified 'T local&'
or 'T&&' reference variable.
A cv-qualified heap object can be assigned to a cv-qualified 'T&', 'T&&'
(Continue reading)
These guys came up with one
more : T%
what I do like about C2 is that stack or heap objects can be ref'd
through T^. In CLI each one is a different type and users have to pin
handles to get regular references or pointers. thats somewhat confusing.
Rajesh
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here:
RSS Feed