[e-lang] Capabilities and value types - a conclusion?

Sandro Magi naasking at higherlogics.com
Thu Nov 2 07:59:39 CST 2006

Sandro Magi wrote:
> Also, structs have methods just like classes, which means they can
> encapsulate permissions too, just like capabilities.

A final example:

public struct FileStreamWrapper {
  FileStream output;
  public void Write(byte[] bytes) {

This struct encapsulates the permission to write to the file stream.
Every time this struct is passed, a new copy is allocated on the stack;
the FileStream is shared between all copies of the struct since it's a
reference type, but there is no way to access the underlying FileStream
except via the struct's methods (not like tuples).

So it behaves like an object, but also like a tuple. Hence my tentative
conclusion that it's a pass-by-copy object with mutable state.

Given this, perhaps the "capabilities == object reference" should be
generalized to "capability == language variable".

Every variable declared and assigned is thus a capability (and the
reference/value semantics are dictated by the type of the variable).
This seems closest to reality.


More information about the e-lang mailing list