Opened 6 years ago

Closed 6 years ago

#260 closed change (fixed)

[Typed objects] Implement type inheritance

Reported by: trev Assignee: trev
Priority: P2 Milestone:
Module: Core Keywords:
Cc: Blocked By:
Blocking: #145 Platform:
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):

http://codereview.adblockplus.org/5656302898380800/

Description (last modified by trev)

Background

See #145. The ECMAScript Harmony proposal doesn't include any type inheritance mechanism but we'll need it.

What to change

An API like the following should work:

const Point2D = new ObjectType({x: uint32, y: uint32});
const Point3D = Point2D.extend({z: uint32});

It should be possible to use the subclass wherever its superclass is required (especially for typed properties). One implication is that property overriding cannot be supported - a property with given name should have the same type both in the subclass and its superclass.

It probably makes sense to have a predefined ObjectBase type as a common ancestor of all objects, so new ObjectType(...) would be equivalent to ObjectBase.extend(...). That type can be used for "untyped" references that can store objects of any time. It can also define properties that will be common to all types like .equals().

Change History (4)

comment:1 Changed 6 years ago by trev

  • Description modified (diff)

comment:2 Changed 6 years ago by trev

  • Description modified (diff)
  • Owner set to trev
  • Status changed from new to assigned

comment:3 Changed 6 years ago by trev

  • Review URL(s) modified (diff)
  • Status changed from assigned to reviewing

comment:4 Changed 6 years ago by trev

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.