2005-06-19 · in Ideas · 309 words

One of my recurring daydreams is of a version of occam where all data types are mobile, or at least where the semantics for references are simpler than the current occam-pi. I think that it'd be clearest to simply have two different "assignment" operators, one which assigns values and one which moves references; this would mean that you could write code like this:

int a, b:
ref int c, d:
chan int x:
chan ref int y:
-- you can't have a "ref ref sometype" -- if you want nested refs, then you
-- need another type in the middle.
-- refs are like mobiles, in that only one thing can hold the reference.  seq
  a := 3
  b := a

  -- c, d undefined
  c := a
  -- c defined, d undefined
  d <- c
  -- d defined, c undefined
  c := d
  -- c, d defined

  x ! d    -- x takes values, so sends the value
  -- d defined
  y ! d    -- y takes references, so sends the reference
  -- d undefined

Honeysuckle follows much the same lines as this. Of course, you also need different operators for sending values and references down channels -- which makes doing separate compilation harder (although, as I've said before, I think it's somewhat overrated in the modern world -- you can always ship source or an AST, then "compile" on demand). Ideally we'd just have everything be a "ref", then optimise the code to use non-reference types where it's safe to do so.

We should also think about having all code being effectively mobile, so that you can easily ship processes between nodes in a cluster.

We also need to rethink how channels are specified so that they can all be mobile: when you say CHAN INT x, you're actually declaring two channel ends. It's possible we should make this explicit, so that you can move the ends around separately (as you can currently do for mobile channel bundles).