What about a closure in the param list that refers to a param later in the list?
function foo(bar = function() { return x; }, x = 1) {
return bar();
}
foo(); // throws or 1?
I'm inclined to think that's fine because it's equivalent to:
function cons (a, b) { | |
return function (sel) { | |
return sel(a, b) | |
} | |
} | |
function car (l) { | |
return l(function (a, b) { | |
return a | |
}) |
(function () { | |
var debounce = function (fn, d) { | |
var t; | |
return function () { | |
if (t) clearTimeout(t); | |
t = setTimeout(fn, d); | |
}; | |
}; | |
var giffy = function () { | |
[].slice.apply(document.querySelectorAll('a')).filter(function (a) { |
#lang racket | |
(require 2htdp/image | |
2htdp/universe) | |
; Cell object. | |
(define make-cell | |
(lambda (x y) | |
(list (list x y) #f))) |
What about a closure in the param list that refers to a param later in the list?
function foo(bar = function() { return x; }, x = 1) {
return bar();
}
foo(); // throws or 1?
I'm inclined to think that's fine because it's equivalent to:
/* @flow */ | |
// This works: | |
class Foo { | |
test(n: ?number): boolean { | |
if (n == null) { | |
return false; | |
} else { | |
return n > 10; | |
} |
/* @flow */ | |
class Foo { | |
n: ?number; | |
test(): boolean { | |
var n = this.n; | |
if (n == null) { | |
return false; | |
} else { |
var spawn = require('child_process').spawn; | |
var csp = require('js-csp'); | |
class Math { | |
constructor(readyCallback) { | |
this._readyCallback = readyCallback; | |
this._worker = spawn('6to5-node', ['worker.js']); | |
this._worker.stderr.pipe(process.stderr); | |
this._reqChan = csp.chan(); |
function foo() { | |
var a = []; | |
for (var i = 0; i < 20000000; i++) { | |
a.push({}); | |
} | |
} | |
function repeat() { | |
printMem('before alloc'); | |
foo(); |
console.log('pid', process.pid); | |
var babel = require('babel-core'); | |
var bigFile = require('fs').readFileSync( | |
require.resolve('babel-core/browser'), | |
'utf8' | |
); | |
babel.transform(bigFile); | |
console.log('before gc'); |
document.write('<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist/embed-e75a8866f2a8f51e8bbbf8ca746676f1e7cacb08f4b1d9b52ea62524b333cc6d.css">') | |
document.write('<div id=\"gist28246440\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-clowtown\" class=\"file\">\n \n\n <div class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-clowtown-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-clowtown-LC1\" class=\"blob-code blob-code-inner js-file-line\">clowntown<\/td>\n <\/tr>\n<\/table>\n\n <\/div>\n\n <\/div>\n \n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/amasad/dbbfee7b9aa8dfb55bd4/raw/e6503803eedad49fe9bb0490a4ff6f1c81060947/clowtown\" style= |