30-01-2013, 04:41 PM
Dart Programming Language Specication
1Dart Programming.pdf (Size: 557.81 KB / Downloads: 54)
Overview
Dart is a class-based, single-inheritance, pure object-oriented programming language.
Dart is optionally typed (15) and supports reied generics. The run-time
type of every object is represented as an instance of class Type which can be
obtained by calling the getter runtimeType declared in class Object, the root of
the Dart class hierarchy.
Dart programs may be statically checked. The static checker will report
some violations of the type rules, but such violations do not abort compilation
or preclude execution.
Dart programs may be executed in one of two modes: production mode
or checked mode. In production mode, static type annotations (15.1) have
absolutely no eect on execution. In checked mode, assignments are dynamically
checked, and certain violations of the type system raise exceptions at run time.
Privacy
Dart supports two levels of privacy: public and private. A declaration is private
i its name begins with an underscore (the character) otherwise it is public.
A declaration m is accessible to library L if m is declared in L or if m is public.
This means private declarations may only be accessed within the library in which
they are declared.
Privacy is, at this point, a static notion tied to a particular piece of code
(a library). It is designed to support software engineering concerns rather than
security concerns. Untrusted code should always run in an another isolate. It is
possible that libraries will become rst class objects and privacy will be a dynamic
notion tied to a library instance.
Privacy is indicated by the name of a declaration - hence privacy and naming
are not orthogonal. This has the advantage that both humans and machines can
recognize access to private declarations at the point of use without knowledge of
the context from which the declaration is derived.
Errors and Warnings
This specication distinguishes between several kinds of errors.
Compile-time errors are errors that preclude execution. A compile-time error
must be reported by a Dart compiler before the erroneous code is executed.
A Dart implementation has considerable freedom as to when compilation
takes place. Modern programming language implementations often interleave
compilation and execution, so that compilation of a method may be delayed,
e.g., until it is rst invoked. Consequently, compile-time errors in a method m
may be reported as late as the time of m's rst invocation.
As a web language, Dart is often loaded directly from source, with no inter-
mediate binary representation. In the interests of rapid loading, Dart implemen-
tations may choose to avoid full parsing of method bodies, for example. This can
be done by tokenizing the input and checking for balanced curly braces on method
body entry. In such an implementation, even syntax errors will be detected only
when the method needs to be executed, at which time it will be compiled (JITed).
In a development environment a compiler should of course report compilation
errors eagerly so as to best serve the programmer.
If a compile-time error occurs within the code of a running isolate A, A is
immediately suspended.