[Grace-core] Brands

Timothy Jones tim at ecs.vuw.ac.nz
Mon Mar 3 21:30:21 PST 2014


On 03/03, Andrew P Black wrote:
> If two types that are different (e.g., have different methods) are given the
> same brand, what does that mean?   Presumably they don't suddenly become
> subtypes of each other.

Types aren't given brands, type names are marked as branded. So two types can't
have the same brand. If I write this:

  type A is brand = ...
  type B is brand = ...

Then A and B are distinct types, even if the types they declare on the right are
the same.

You can mark a class as branded with multiple brands, though. The class must
satisfy the interfaces of all of the types, and will have a generated method
added to it for each brand.

  class c.new -> C is branded(A, B)

The type of the new object is A & B & C (where C is some ordinary type).

-- 
Tim


More information about the Grace-core mailing list