[e-lang] Capabilities and value types?

Kevin Reid kpreid at mac.com
Wed Nov 1 21:59:00 CST 2006


On Nov 1, 2006, at 22:29, Sandro Magi wrote:
> Kevin Reid wrote:
>> * an unum, where the newly constructed object ('presence') takes
>> measures to keep its state synchronized with the original object.
>
> This sounds similar to a proxy. Would the semantics be similar to a
> checked out source repository that must merge changes from and submit
> changes to a central repository?

Yes, exactly. I'd never noticed that before, but they do seem to have  
the the same kind of structure and possible variations.

>>> Given value semantics, I would conclude that a variable bound to a
>>> struct either:
>> 3. is a reference to an object which the inter-thread communication
>> system chooses to treat specially
>
> C# ValueType semantics are not related to threading, it's purely the
> semantics of value types (as in #2). An even simpler example:
>
> 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"
>   }
> }
> If Test were a class, they would both print false.

Ah, I see. This then has no correspondence with anything in the E  
model, outside of global code transformations inserting copying.

> Given your explanation above, the .NET semantics for ValueTypes are
> pass-by-copy with mutable state, correct?

No. In E, a pass-by-copy object *must not* incorporate mutable state  
(but may reference it, therefore not including it in the copy). All  
copies of such an object are considered the same reference, and  
allowing them to diverge would make sameness inconsistent.

Pass-by-construction objects have no such restriction, but their  
copies are not in any way considered the same object.

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list