This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fast_fib_module(stdlib, foreign, heap) { | |
"use asm"; | |
function fib(n) { | |
n = n|0; | |
if (n >>> 0 < 3) { | |
return 1|0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default f(1, 2, 3); // anonymous export | |
export let foo = 5; // named declaration export | |
export foo // named export of existing identifier | |
export foo, bar; // named export of multiple existing identifiers | |
export foo as f; // named aliasing export | |
export foo as f, bar; // you get the idea | |
import default glob from "glob"; // anonymous import | |
import sync from "glob"; // named import | |
import sync as s from "glob"; // named aliasing import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isIndex(n) { | |
// This isn't right, but pretend that this checks if n is an index in the | |
// way that SpiderMonkey checks in js_IdIsIndex. | |
return Number(n) % 1 == 0; | |
} | |
function indices(obj) { | |
var result = []; | |
for (var i = 0; i < obj.length; i++) | |
result.push(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.math.{PI, sqrt}; | |
struct Body { | |
x: f64; | |
y: f64; | |
z: f64; | |
vx: f64; | |
vy: f64; | |
vz: f64; | |
mass: f64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Examples using something closer to my original "minimal classes" proposal. | |
// There are several benefits to this approach. | |
// First, it uses a familiar approach to separating prototype properties from | |
// instance properties: methods are on the prototype, and static declarations | |
// are prototype data properties. Otherwise, instance properties are only | |
// declared in the constructor body. | |
// Second, instead of object literal syntax, it uses a property declaration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Demonstrating @jashkenas's examples in an even-more-minimalist version of | |
// classes that only allow object-literal syntax for the class body. | |
// Basic usage; unchanged. | |
class Color { | |
constructor: function(hex) { | |
... | |
}, |