[e-lang] Capabilities and value types?

David Wagner daw at cs.berkeley.edu
Wed Nov 1 22:26:03 CST 2006

Sandro Magi <naasking at higherlogics.com> writes:
>public struct /*class*/ Test {
>  bool enabled = true;
>  public static void Main(string[] args) {
>    Test capToTest = new Test();
>    Test newCopy = capToTest; //capability copy copies the object
>    newCopy.enabled = false;
>    Console.WriteLine(capToTest.enabled); //prints "true"
>    Console.WriteLine(newTest.enabled); //prints "false"
>  }

I don't know C# very well, but it sounds to me like C#'s structs (value
types) are just syntactic sugar for a tuple of values.  As such, they
don't introduce anything new to the notion of object capabilities.

Just imagine expanding all stack-allocated structs into a set of variables
(and do the obvious transformation to deal with the case where a struct
is promoted to a heap object by boxing).  The resulting program is C# but
without structs (value types).  This transformation doesn't really change
anything essential about the object capability model or introduce any new
difficulties that I can see.

More information about the e-lang mailing list