Skip to content

Instantly share code, notes, and snippets.

View seaneagan's full-sized avatar

Sean Eagan seaneagan

View GitHub Profile
@seaneagan
seaneagan / proxyInternalStateAPI.js
Created April 19, 2011 18:30
Proxy internal state API
Proxy.ForwardingHandler.prototype = {
create: function(target) {return {target: target}},
getPrototypeOf: function (proxy, state) {
return Object.getPrototypeOf(state.target);
}
// all other traps take state argument
};
// ... //
@seaneagan
seaneagan / sealFreezeSingleProperty.js
Created April 21, 2011 20:38
seal/freeze single object properties and detect
Object.sealProperty = function(object, property) {
var pd = Object.getPropertyDescriptor(object, property) || {value: undefined};
pd.configurable = false;
return Object.defineProperty(object, property, pd);
};
Object.freezeProperty = function(object, property) {
var pd = Object.getPropertyDescriptor(object, property) || {value: undefined};
pd.configurable = false;
pd.writable = false;
@seaneagan
seaneagan / Object.extend.js
Created May 25, 2011 16:45
Adds Object.extend which copies property definitions from one object to another
Object.defineProperty(Object, "extend", {
"configurable": true,
"enumerable": false,
"value": function (object, extension) {
// throw if either is not an object
if(object !== Object(object)) {throw new TypeError;}
if(extension !== Object(extension)) {throw new TypeError;}
@seaneagan
seaneagan / super.markdown
Created June 20, 2011 18:18
Orthogonalized super keyword

Orthogonalized super keyword

There are two active proposals for what to do with the reserved word "super", [object initialiser super][] and [classes][]. Both proposals limit the context in which "super" can appear. This proposal attempts to allow "super" anywhere by basing it's behavior on ThisBindings.

Details

Execution contexts are updated to have a SuperBinding similar to the existing ThisBinding. The keyword "super" by itself evaluates to the value of the SuperBinding of the current execution context. Direct function calls, e.g. f() or f.call(this, arg), result in a SuperBinding of the [[Prototype]] internal property of the passed ThisBinding or undefined it the ThisBinding is not an object. Method calls, e.g. o.m(), and accessor property access, e.g. o.p where "p" is an accessor property somewhere in o's property lookup chain (own properties plus prototype chain), result in a SuperBinding which is the [[Prototype]] internal property of the object in o's property lookup chain on whic

@seaneagan
seaneagan / gist:1320447
Created October 27, 2011 18:48
Dart core lib changes
/**
* Proposal: Refactoring Dart collections
*
* Move accessors from Map, List, and Set into ReadableMap, ReadableList, and ReadableSet interfaces which Map, List, and Set extend
*
* "const " prefixed map and list literals produce ReadableMap and ReadableList instances
*
* Let ReadableMap<K, V> extend Collection<K>
*
* Let List extend Queue
@seaneagan
seaneagan / Dart-iterable-methods.dart
Created November 7, 2011 18:48
Dart-iterable-methods
// mixin instead of a class ?
class CollectionImpl<E> implements Collection<E> {
Iterable _wrapped;
CollectionImpl(Iterable other) {
this._wrapped = other;
}
Iterator<E> iterator() => _wrapped.iterator();
@seaneagan
seaneagan / dart_collection_changes_implications.dart
Created November 15, 2011 15:04
Dart Collection changes implications
/** Strings are ReadableLists of chars */
interface String extends ReadableList<char>, Pattern {
String(Iterable<int> other);
// Accessors
String toLowerCase ( );
String toUpperCase ( );
String trim ( );
String getRange (Range range ); // replaces subString
@seaneagan
seaneagan / dartReflect.dart
Created November 27, 2011 22:51
Dart reflection
interface IsolateMirror {
final LibraryMirror rootLibrary;
StackMirror stack();
MirrorGroup<LibraryMirror> imports;
MirrorGroup<ReceivePort> ports; // not sure what is used as the name of a port
}
// invocation
interface InvocationMirror {
/**instance of Library*/
interface Isolate {
final LibraryMirror library;
}
interface LibraryMirror extends ScopeMirror {
final LinkedHashMap<Import> imports;
final LinkedHashMap<Source> sources;
final Map <Dynamic> topLevels;
}
a::b
a::b=
a::+
a::[]=

a->b
a->b=
a->+
a-&gt;[]=