Hell's bells, world, how you doin?
for (var i = 0, n = a.length; i < n; i++) {
console.log(a[i]);
}
Object.prototype.copy = function () { | |
let o = {} | |
for (let i in this) | |
o[i] = this[i] | |
return o | |
} | |
// Containment testing for arrays and strings that should be coherent with their __iterator__. | |
Array.prototype.contains = String.prototype.contains = function (e) { | |
return this.indexOf(e) != -1 |
let Tree = new StructType({ | |
key: int32, | |
val: float32; | |
left: int32, | |
right: int32 | |
}); | |
Tree.prototype[iterator] = function() { | |
// allocate the "pointer" object | |
let p = new StructView(Tree); |
var IPAddress = new ArrayType(uint8, 4); | |
var P_IPAddress = new PointerType(IPAddress); | |
var Packet = new StructType({ addr: IPAddress, ... }); | |
var P_Packet = new PointerType(Packet); | |
var PacketArray = new ArrayType(Packet); | |
var lotsOfPackets = new PacketArray(LOTS); | |
for (let p of lotsOfPackets.cursor("addr")) { |
var IPAddress = new StructType({ | |
f0: uint8, | |
f1: uint8, | |
f2: uint8, | |
f3: uint8 | |
}); | |
var Packet = new StructType({ addr: IPAddress, ... }); | |
var PacketArray = new ArrayType(Packet); |
var dict = Object.create(null); | |
dict.__proto__ // null | |
"__proto__" in dict // true | |
dict["__proto__"] = Math; | |
"sin" in dict // true |
Looking at the preceding token when the lexer points to a '/' | |
character is insufficient to determine which context it's in. In | |
fact, you need to look at an arbitrary number of preceding tokens | |
to figure it out. This example demonstrates a case where we can | |
pump up the number of preceding tokens to an arbitrary size | |
before you can disambiguate your syntactic context. |
// EXAMPLE: a compound iterator with sequencing | |
// Python style | |
function cat() { | |
let is = arguments; | |
return { | |
next: { | |
let length; | |
while ((length = is.length) > 0) { | |
try { |
The System
loader.
var capitalize = System.get('libs/string').capitalize;
var app = System.get('app').app;
Custom loader:
// { | |
// next: () -> { done: false, value: any } | |
// | { done: true[, value: any] } | |
// } | |
var i1 = (function *f() { | |
return; | |
})(); | |
'value' in i1.next(); |