[Mono-list] Making templates

Jonathan Pryor jonpryor@vt.edu
18 Apr 2002 23:06:30 -0400


The Common Language Runtime has its own form of "name mangling," as C++
calls it.  However, "name mangling" under the CLR must be human
readable, so that languages that don't have a concept of operator
overloading can still invoke the functions.  For example, given the C#
declaration:

        public static foo operator+ (foo a, foo b);

The "mangled name" would be "op_Addition".  So, in C# we can do:

        foo a, b; // initialize a & b
        foo f = a + b

while in VB.NET we would instead do:

        Dim a, b, c as foo
        ' initialize a & b
        c = foo.op_Addition (a, b);

(My VB.Net example may be wrong, as I don't really know VB.Net, but the
above is the basic idea.)

A full list of the mappings between C# operators and their "language
exportable" equivalents can be found in ECMA-335 Partition I, pg, 60-65.
(ECMA-335-Part-I-IV.pdf pg. 70.)

So, what's "Item"?  It's the "language exportable" name for indexed
properties, i.e. operator[].  Thus, C#'s:

        public object this [int index] {
                get {return null;}
                set {/* ignore */}
        }

is seen from other (non-operator-overloading) languages as an "Item"
property.

So, you make the function in the way that the documentation states: as
an indexer.

 - Jon

On Thu, 2002-04-18 at 19:00, Daniel Carrera wrote:
> 
> I'm confused by the documentation.  The documentation says:
> 
> Public Properties:
> Item
> 
> When I click on 'Item' I get:
> 
> 
> [C#] public DataGridTableStyle this[int] {get;}
> [C#] public DataGridTableStyle this[string] {get;}
> 
> 
> How should I make the template?  Should it be this?:
> 
>       public DataGridTableStyle Item
>       {
>               get { trhow ... }
>       }
> 
> 
> 
> Daniel.
> 
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list