Skip to content

Instantly share code, notes, and snippets.

View eernstg's full-sized avatar

Erik Ernst eernstg

  • Google
  • Aarhus, Denmark
View GitHub Profile
@eernstg
eernstg / assert_expression.md
Last active August 29, 2016 08:18
Informal specification of assert statements with general expressions.

Feature: General expressions in assert

The language specification (Aug 19, 2015) states that an assert statement contains a parenthesized conditionalExpression. This feature changes assert to use a plain expression instead.

The motivation for having a conditionalExpression rather than a general expression in this syntactic location is not discussed in the specification, but it is likely to be a kind of safety device: A conditionalExpression covers only a subset of all expressions, and in particular it does not include assignments. An example which is often mentioned is that assert(x = 1) will be prevented syntactically, and the programmer may then note the error and change it to the more likely assert(x == 1).

However, the language specification takes different approaches in other, similar situations: An if statement, while statement, and do .. while statement all accept a general expression as the condition, whereas an argument to logical operators such as && and || must be

@eernstg
eernstg / initializing_formal_access.md
Last active November 29, 2016 11:33
Informal specification of initializing formal parameter access.

Feature: Access to Initializing Formals

This document is an informal specification of the support for access to initializing formal parameters which has been implemented in dart2js with option --initializing-formal-access, starting with commit 442fc5. In SDK 1.21 this feature is enabled by default (that is, also without the option) in all tools.

The motivation for having this feature is that it enables less verbose and less repetitive code, and it is a feature that users have frequently requested.

Recall that an initializing formal parameter is a parameter to a generative constructor whose declaration is on the form this.x for some identifier x (possibly with a type annotation as in int this.x or bool this.x(int y)). At call sites this kind of parameter is passed just like other parameters, but its name (here: x) must be the name of a field, and that field is implicitly initialized to the

@eernstg
eernstg / voidness.v
Last active March 9, 2017 08:49
Coq source for model of voidness preservation criteria
Require Import Coq.Program.Basics.
Require Import List.
Inductive Name : Set := Object | A | B | Iterable | List.
Inductive DartType : Set :=
| dt_void : DartType
| dt_dynamic : DartType
| dt_class : list (Name * list DartType) -> DartType (* Incl. all supertypes *)
| dt_function : DartType -> list DartType -> DartType
@eernstg
eernstg / test.v
Created March 9, 2017 08:51
Coq source for verifying example cases for voidness preservation criteria
Require Import List.
Require Import voidness.
(* ---------- Dart types ---------- *)
(* Object *)
Definition ct_Object : ClassTypes := (Object, nil) :: nil.
Definition dt_Object := dt_class ct_Object.
(* A<Object> *)
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
grammar Dart;
@parser::header{
import java.util.Stack;
}
@eernstg
eernstg / optional-new.md
Last active August 17, 2017 12:44
Informal specification of the optional new feature.

This document is now obsolete, please refer to the current version.

Optional new

Author: eernst@.

Version: 0.1 (2017-08-15)

Status: Under discussion

@eernstg
eernstg / optional-const.md
Last active August 17, 2017 12:44
Informal specification of the optional const feature.

This document is now obsolete, please refer to the current version.

Optional const

Author: eernst@.

Version: 0.1 (2017-08-10)

Status: Under discussion

@eernstg
eernstg / generalized-void.md
Last active August 17, 2017 13:16
Informal specification of generalized void

This document is now obsolete, please refer to the current version.

Feature: Generalized Void

Author: eernst@

Status: Under implementation.

This document is an informal specification of the generalized support in

@eernstg
eernstg / AnonymousExtensionMethods.md
Last active August 27, 2017 13:46
Informal specification: Anonymous extension methods

Anonymous Extension Methods

Author: eernst@

Status: Under discussion.

This document is an informal specification of the anonymous extension method feature in Dart. This feature allows for writing a function in an expression whose semantics makes it similar to an instance method on the result of an

@eernstg
eernstg / DispatchingParameters.md
Created August 27, 2017 13:46
Informal specification: Dispatching parameters.

Dispatching Parameters

Author: eernst@

Status: Under discussion.

This document is an informal specification of the dispatching parameter feature in Dart. That feature allows a function parameter to implicitly serve as the receiver for member accesses (e.g., calling instance methods) in the body of the function, similar to the ability of the object denoted by