Self type

Brendan Eich brendan at
Tue Aug 14 10:46:15 PDT 2007

On Aug 14, 2007, at 10:10 AM, liorean wrote:

>> Peter Hall wrote:
>>> type B = {b:Self};
> On 14/08/07, Cormac Flanagan <cormac at> wrote:
>> Yes, I think this should be fine.
> I'm all for allowing recursive structural types e.g. for use as binary
> trees or linked lists.
>     type BinTree = {sin:Self, dx:Self, value:*};

We've decided *not* to specify recursive structural types in general.  
The subtype relation is O(exp(n)) for the simpler algorithm [1], and O 
(n^2) for a fairly complex successor algorithm [1]. In the interest  
of simplicity and to minimize costs to small-device implementations,  
we are leaving out recursive structural types of ES4. They could be  
added later; for now, if you need trees and the like, use nominal types.

Dave Herman's analysis is on the wiki, but for some reason I'm  
getting an error trying to access the relevant page [3].

Self-references may be good enough for common "recursive" cases  
(iterator::get, clone, equals, etc.).



More information about the Es4-discuss mailing list