Skip to main content


Showing posts from June, 2012

Proposal for First-class Types in Dart

Posted by Gilad Bracha

First-class Types in Dart
Currently Dart does not provide any access to types as objects at the base level.  We propose to provide a getter on class Object:

@native Type get type;

which returns a reified representation of the class of an object.  Note that the method type can be overridden in subclasses (for example, to implement a remote proxy that hides its implementation).

The declaration of class Type is

class Type {
 @native String toString();
 String descriptor(){...} // return the simple name of the type

In other words, Type does not add any API to Object, other than the ability to get its name.  One can use toString() to obtain a description of the type (such as its name), one can test types for equality or identity, one can hash them (assuming we move forward on making all objects hashable) and that is all. The main use of these reified types is to serve as keys to the mirror system. Instances of Type are canonicalized.

An identifier that denotes a type in Dar…

Proposal to eliminate interface declarations from Dart

Posted by Gilad Bracha

Eliminating Interface Declarations from Dart

This document motivates the planned phase-out of interface declarations from the Dart language, and details the required specification changes.

In Dart, every class engenders an implicit interface.  Now that this feature is implemented, it is possible to actually eliminate interface declarations from the language. Interface declarations are replaced by purely abstract classes.

Almost every existing interface declaration can already be mapped into an abstract class declaration with no impact whatsoever on other code, by following this formula:

interface I<T> extends J, K  default F<T>{
set p=(R x);
 R get p;
 U f1;
final V f2;
 T0 m(T1 a1, ..., Tn An);
 I(S1 p1, ..., Sk pk);

maps to

abstractclass I’<T> implements J, K {
abstractset p=(R x);
abstract R get p;
abstractset f1=(U _);