trying to integrate with moby's vectors

This commit is contained in:
Danny Yoo 2011-06-07 16:48:56 -04:00
parent cfdcd215be
commit 9050882d4d
9 changed files with 329 additions and 311 deletions

10
NOTES
View File

@ -691,11 +691,11 @@ Working out the type mappings between values in Racket and values in JavaScript
Racket JavaScript
Racket JavaScript Switched over?
number jsnums.SchemeNumber
immutable strings JavaScript strings
number jsnums.SchemeNumber yes
immutable strings JavaScript string
mutable strings types.Str
vector
@ -710,8 +710,8 @@ Working out the type mappings between values in Racket and values in JavaScript
symbol
keyword
pair
empty
pair yes
empty yes
eq-hashtable
equal-hashtable

View File

@ -101,7 +101,7 @@
(cond [(symbol? val)
(format "~s" (symbol->string val))]
[(pair? val)
(format "[~a, ~a]"
(format "RUNTIME.makePair(~a, ~a)"
(loop (car val))
(loop (cdr val)))]
[(boolean? val)
@ -122,7 +122,7 @@
[(empty? vals)
"RUNTIME.NULL"]
[else
(format "[~a, ~a]" (first vals) (loop (rest vals)))])))
(format "RUNTIME.makePair(~a, ~a)" (first vals) (loop (rest vals)))])))

View File

@ -68,26 +68,21 @@
[(>=)
(assemble-boolean-chain "jsnums.greaterThanOrEqual" checked-operands)]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[(cons)
(format "[~a, ~a]" (first checked-operands) (second checked-operands))]
(format "RUNTIME.makePair(~a, ~a)"
(first checked-operands)
(second checked-operands))]
[(car)
(format "(~a)[0]" (first checked-operands))]
(format "(~a).first" (first checked-operands))]
[(cdr)
(format "(~a)[1]" (first checked-operands))]
(format "(~a).rest" (first checked-operands))]
[(list)
(let loop ([checked-operands checked-operands])
(cond
[(empty? checked-operands)
"RUNTIME.NULL"]
[else
(format "[~a,~a]" (first checked-operands) (loop (rest checked-operands)))]))]
(assemble-listof-assembled-values checked-operands))]
[(null?)
(format "(~a === RUNTIME.NULL)" (first checked-operands))]
@ -151,17 +146,15 @@
(let: ([test-string : String
(case domain
[(number)
(format "(jsnums.isSchemeNumber(~a))"
(format "jsnums.isSchemeNumber(~a)"
operand-string)]
[(string)
(format "(typeof(~a) === 'string')"
operand-string)]
[(list)
(format "(~a === [] || (typeof(~a) === 'object' && (~a).length === 2))"
operand-string operand-string operand-string)]
(format "RUNTIME.isList(~a)" operand-string)]
[(pair)
(format "(typeof(~a) === 'object' && (~a).length === 2)"
operand-string operand-string)]
(format "RUNTIME.isPair(~a)" operand-string)]
[(box)
(format "(typeof(~a) === 'object' && (~a).length === 1)"
operand-string operand-string)])])

View File

@ -4,6 +4,7 @@
"quote-cdata.rkt"
"../make.rkt"
"../make-structs.rkt"
"../parameters.rkt"
(planet dyoo/closure-compile:1:1)
(prefix-in runtime: "get-runtime.rkt")
(prefix-in racket: racket/base))
@ -114,12 +115,19 @@
(make (list only-bootstrapped-code) packaging-configuration)
(fprintf op "})(plt.runtime.currentMachine,\nfunction(){ plt.runtime.setReadyTrue(); },\nfunction(){},\n{});\n")))
(define (compress x)
(if (current-compress-javascript?)
(closure-compile x)
x))
(define *the-runtime*
(let ([buffer (open-output-string)])
(write-runtime buffer)
(closure-compile
(compress
(get-output-string buffer))))
@ -152,7 +160,7 @@ EOF
(package source-code
#:should-follow? (lambda (src p) #t)
#:output-port buffer)
(closure-compile
(compress
(get-output-string buffer))))
@ -161,7 +169,7 @@ EOF
(define (get-standalone-code source-code)
(let ([buffer (open-output-string)])
(write-standalone-code source-code buffer)
(closure-compile
(compress
(get-output-string buffer))))

View File

@ -777,16 +777,49 @@ if (! this['plt']) { this['plt'] = {}; }
// rationalToDomNode: rational -> dom-node
var rationalToDomNode = function(n) {
var node = document.createElement("span");
var repeatingDecimalNode = document.createElement("span");
var chunks = jsnums.toRepeatingDecimal(jsnums.numerator(n),
jsnums.denominator(n));
node.appendChild(document.createTextNode(chunks[0] + '.'))
node.appendChild(document.createTextNode(chunks[1]));
var overlineSpan = document.createElement("span");
overlineSpan.style.textDecoration = 'overline';
overlineSpan.appendChild(document.createTextNode(chunks[2]));
node.appendChild(overlineSpan);
return node;
jsnums.denominator(n),
{limit: 25});
repeatingDecimalNode.appendChild(document.createTextNode(chunks[0] + '.'))
repeatingDecimalNode.appendChild(document.createTextNode(chunks[1]));
if (chunks[2] === '...') {
repeatingDecimalNode.appendChild(
document.createTextNode(chunks[2]));
} else if (chunks[2] !== '0') {
var overlineSpan = document.createElement("span");
overlineSpan.style.textDecoration = 'overline';
overlineSpan.appendChild(document.createTextNode(chunks[2]));
repeatingDecimalNode.appendChild(overlineSpan);
}
var fractionalNode = document.createElement("span");
var numeratorNode = document.createElement("sup");
numeratorNode.appendChild(document.createTextNode(String(jsnums.numerator(n))));
var denominatorNode = document.createElement("sub");
denominatorNode.appendChild(document.createTextNode(String(jsnums.denominator(n))));
fractionalNode.appendChild(numeratorNode);
fractionalNode.appendChild(document.createTextNode("/"));
fractionalNode.appendChild(denominatorNode);
var numberNode = document.createElement("span");
numberNode.appendChild(repeatingDecimalNode);
numberNode.appendChild(fractionalNode);
fractionalNode.style['display'] = 'none';
var showingRepeating = true;
numberNode.onclick = function(e) {
showingRepeating = !showingRepeating;
repeatingDecimalNode.style['display'] =
(showingRepeating ? 'inline' : 'none')
fractionalNode.style['display'] =
(!showingRepeating ? 'inline' : 'none')
};
numberNode.style['cursor'] = 'pointer';
return numberNode;
}

View File

@ -195,7 +195,7 @@ That way, we can do a simple grep.
var length = function(lst) {
checkList(lst, 'length', 1, [lst]);
var ret = 0;
for (; !lst.isEmpty(); lst = lst.rest()) {
for (; !lst.isEmpty(); lst = lst.rest) {
ret = ret+1;
}
return ret;
@ -224,8 +224,8 @@ That way, we can do a simple grep.
var fArgs = [];
var argsRest = [];
for (var i = 0; i < args.length; i++) {
fArgs.push(args[i].first());
argsRest.push(args[i].rest());
fArgs.push(args[i].first);
argsRest.push(args[i].rest);
}
fArgs.push(acc);
return CALL(f, fArgs,
@ -246,20 +246,20 @@ That way, we can do a simple grep.
}
var compYes = new PrimProc('compYes', 1, false, false,
function(x) { return CALL(comp, [x, lst.first()], id); });
function(x) { return CALL(comp, [x, lst.first], id); });
var compNo = new PrimProc('compNo', 1, false, false,
function(x) { return CALL(comp, [x, lst.first()],
function(x) { return CALL(comp, [x, lst.first],
function(res) { return !res; });
});
return CALL(PRIMITIVES['filter'],
[compYes, lst.rest()],
[compYes, lst.rest],
quicksortHelp(function(sorted1) {
return CALL(PRIMITIVES['filter'],
[compNo, lst.rest()],
[compNo, lst.rest],
quicksortHelp(function(sorted2) {
return k( append([sorted1,
types.list([lst.first()]),
types.list([lst.first]),
sorted2]) );
}));
}));
@ -487,7 +487,7 @@ That way, we can do a simple grep.
var isAssocList = function(x) {
return isPair(x) && isPair(x.rest()) && isEmpty(x.rest().rest());
return isPair(x) && isPair(x.rest) && isEmpty(x.rest.rest);
};
@ -725,8 +725,8 @@ That way, we can do a simple grep.
var argsFirst = [];
var argsRest = [];
for (var i = 0; i < args.length; i++) {
argsFirst.push(args[i].first());
argsRest.push(args[i].rest());
argsFirst.push(args[i].first);
argsRest.push(args[i].rest);
}
return CALL(f, argsFirst,
@ -1109,11 +1109,11 @@ That way, we can do a simple grep.
return CALL(new PrimProc('', 1, false, false,
function(args) {
return callWithValues(fList.first(), args);
return callWithValues(fList.first, args);
}),
[x],
function(result) {
return composeHelp(result, fList.rest());
return composeHelp(result, fList.rest);
});
}
return new PrimProc('', 0, true, false,
@ -2032,9 +2032,9 @@ That way, we can do a simple grep.
var nextResult = parse(child);
if (isString(nextResult) &&
!result.isEmpty() &&
isString(result.first())) {
result = types.cons(result.first() + nextResult,
result.rest());
isString(result.first)) {
result = types.cons(result.first + nextResult,
result.rest);
} else {
result = types.cons(nextResult, result);
}
@ -2219,7 +2219,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, isPair, 'car', 'pair', 1);
return lst.first();
return lst.first;
});
PRIMITIVES['cdr'] =
@ -2228,7 +2228,7 @@ That way, we can do a simple grep.
false, false,
function (lst) {
check(lst, isPair, 'cdr', 'pair', 1);
return lst.rest();
return lst.rest;
});
PRIMITIVES['caar'] =
@ -2236,9 +2236,9 @@ That way, we can do a simple grep.
1,
false, false,
function(lst) {
check(lst, function(x) { return (isPair(x) && isPair(x.first())); },
check(lst, function(x) { return (isPair(x) && isPair(x.first)); },
'caar', 'caarable value', 1);
return lst.first().first();
return lst.first.first;
});
PRIMITIVES['cadr'] =
@ -2246,9 +2246,9 @@ That way, we can do a simple grep.
1,
false, false,
function(lst) {
check(lst, function(x) { return isPair(x) && isPair(x.rest()); },
check(lst, function(x) { return isPair(x) && isPair(x.rest); },
'cadr', 'cadrable value', 1);
return lst.rest().first();
return lst.rest.first;
});
PRIMITIVES['cdar'] =
@ -2256,9 +2256,9 @@ That way, we can do a simple grep.
1,
false, false,
function(lst) {
check(lst, function(x) { return isPair(x) && isPair(x.first()); },
check(lst, function(x) { return isPair(x) && isPair(x.first); },
'cdar', 'cdarable value', 1);
return lst.first().rest();
return lst.first.rest;
});
PRIMITIVES['cddr'] =
@ -2266,9 +2266,9 @@ That way, we can do a simple grep.
1,
false, false,
function(lst) {
check(lst, function(x) { return isPair(x) && isPair(x.rest()); },
check(lst, function(x) { return isPair(x) && isPair(x.rest); },
'cddr', 'cddrable value', 1);
return lst.rest().rest();
return lst.rest.rest;
});
PRIMITIVES['caaar'] =
@ -2277,10 +2277,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.first()) &&
isPair(x.first().first()) ); },
isPair(x.first) &&
isPair(x.first.first) ); },
'caaar', 'caaarable value', 1);
return lst.first().first().first();
return lst.first.first.first;
});
PRIMITIVES['caadr'] =
@ -2289,10 +2289,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.rest()) &&
isPair(x.rest().first()) ); },
isPair(x.rest) &&
isPair(x.rest.first) ); },
'caadr', 'caadrable value', 1);
return lst.rest().first().first();
return lst.rest.first.first;
});
PRIMITIVES['cadar'] =
@ -2301,10 +2301,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.first()) &&
isPair(x.first().rest()) ); },
isPair(x.first) &&
isPair(x.first.rest) ); },
'cadar', 'cadarable value', 1);
return lst.first().rest().first();
return lst.first.rest.first;
});
PRIMITIVES['cdaar'] =
@ -2313,10 +2313,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.first()) &&
isPair(x.first().first()) ); },
isPair(x.first) &&
isPair(x.first.first) ); },
'cdaar', 'cdaarable value', 1);
return lst.first().first().rest();
return lst.first.first.rest;
});
PRIMITIVES['cdadr'] =
@ -2325,10 +2325,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.rest()) &&
isPair(x.rest().first()) ); },
isPair(x.rest) &&
isPair(x.rest.first) ); },
'cdadr', 'cdadrable value', 1);
return lst.rest().first().rest();
return lst.rest.first.rest;
});
PRIMITIVES['cddar'] =
@ -2337,10 +2337,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.first()) &&
isPair(x.first().rest()) ); },
isPair(x.first) &&
isPair(x.first.rest) ); },
'cddar', 'cddarable value', 1);
return lst.first().rest().rest();
return lst.first.rest.rest;
});
PRIMITIVES['caddr'] =
@ -2349,10 +2349,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.rest()) &&
isPair(x.rest().rest()) ); },
isPair(x.rest) &&
isPair(x.rest.rest) ); },
'caddr', 'caddrable value', 1);
return lst.rest().rest().first();
return lst.rest.rest.first;
});
PRIMITIVES['cdddr'] =
@ -2361,10 +2361,10 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.rest()) &&
isPair(x.rest().rest()) ); },
isPair(x.rest) &&
isPair(x.rest.rest) ); },
'cdddr', 'cdddrable value', 1);
return lst.rest().rest().rest();
return lst.rest.rest.rest;
});
PRIMITIVES['cadddr'] =
@ -2373,11 +2373,11 @@ That way, we can do a simple grep.
false, false,
function(lst) {
check(lst, function(x) { return ( isPair(x) &&
isPair(x.rest()) &&
isPair(x.rest().rest()) &&
isPair(x.rest().rest().rest()) ); },
isPair(x.rest) &&
isPair(x.rest.rest) &&
isPair(x.rest.rest.rest) ); },
'cadddr', 'cadddrable value', 1);
return lst.rest().rest().rest().first();
return lst.rest.rest.rest.first;
});
@ -2388,7 +2388,7 @@ That way, we can do a simple grep.
function(lst) {
check(lst, function(x) { return isList(x) && !isEmpty(x); },
'rest', 'non-empty list', 1);
return lst.rest();
return lst.rest;
});
PRIMITIVES['first'] =
@ -2398,7 +2398,7 @@ That way, we can do a simple grep.
function(lst) {
check(lst, function(x) { return isList(x) && !isEmpty(x); },
'first', 'non-empty list', 1);
return lst.first();
return lst.first;
});
PRIMITIVES['second'] =
@ -2407,7 +2407,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
checkListOfLength(lst, 2, 'second', 1);
return lst.rest().first();
return lst.rest.first;
});
PRIMITIVES['third'] =
@ -2416,7 +2416,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
checkListOfLength(lst, 3, 'third', 1);
return lst.rest().rest().first();
return lst.rest.rest.first;
});
PRIMITIVES['fourth'] =
@ -2425,7 +2425,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
checkListOfLength(lst, 4, 'fourth', 1);
return lst.rest().rest().rest().first();
return lst.rest.rest.rest.first;
});
PRIMITIVES['fifth'] =
@ -2434,7 +2434,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
checkListOfLength(lst, 5, 'fifth', 1);
return lst.rest().rest().rest().rest().first();
return lst.rest.rest.rest.rest.first;
});
PRIMITIVES['sixth'] =
@ -2443,7 +2443,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
checkListOfLength(lst, 6, 'sixth', 1);
return lst.rest().rest().rest().rest().rest().first();
return lst.rest.rest.rest.rest.rest.first;
});
PRIMITIVES['seventh'] =
@ -2453,7 +2453,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
checkListOfLength(lst, 7, 'seventh', 1);
return lst.rest().rest().rest().rest().rest().rest().first();
return lst.rest.rest.rest.rest.rest.rest.first;
});
PRIMITIVES['eighth'] =
@ -2462,7 +2462,7 @@ That way, we can do a simple grep.
false, false,
function(lst) {
checkListOfLength(lst, 8, 'eighth', 1);
return lst.rest().rest().rest().rest().rest().rest().rest().first();
return lst.rest.rest.rest.rest.rest.rest.rest.first;
});
@ -2536,7 +2536,7 @@ That way, we can do a simple grep.
helpers.toDisplayedString(origList));
raise( types.incompleteExn(types.exnFailContract, msg, []) );
}
lst = lst.rest();
lst = lst.rest;
}
@ -2548,7 +2548,7 @@ That way, we can do a simple grep.
msg,
[]) );
}
return lst.first();
return lst.first;
});
PRIMITIVES['list-tail'] =
@ -2578,7 +2578,7 @@ That way, we can do a simple grep.
helpers.toDisplayedString(origList));
raise( types.incompleteExn(types.exnFailContract, msg, []) );
}
lst = lst.rest();
lst = lst.rest;
}
return lst;
});
@ -2622,8 +2622,8 @@ That way, we can do a simple grep.
var argsFirst = [];
var argsRest = [];
for (var i = 0; i < args.length; i++) {
argsFirst.push(args[i].first());
argsRest.push(args[i].rest());
argsFirst.push(args[i].first);
argsRest.push(args[i].rest);
}
var result = CALL(f, argsFirst,
function(result) {
@ -2658,8 +2658,8 @@ That way, we can do a simple grep.
var argsFirst = [];
var argsRest = [];
for (var i = 0; i < args.length; i++) {
argsFirst.push(args[i].first());
argsRest.push(args[i].rest());
argsFirst.push(args[i].first);
argsRest.push(args[i].rest);
}
return CALL(f, argsFirst,
@ -2699,8 +2699,8 @@ That way, we can do a simple grep.
var argsFirst = [];
var argsRest = [];
for (var i = 0; i < args.length; i++) {
argsFirst.push(args[i].first());
argsRest.push(args[i].rest());
argsFirst.push(args[i].first);
argsRest.push(args[i].rest);
}
return CALL(f, argsFirst,
@ -2734,10 +2734,10 @@ That way, we can do a simple grep.
}
while ( !lst.isEmpty() ) {
if ( isEq(item, lst.first()) ) {
if ( isEq(item, lst.first) ) {
return lst;
}
lst = lst.rest();
lst = lst.rest;
if (! isPair(lst) && lst !== types.EMPTY) {
var msg = ('memq: not a proper list: ' +
helpers.toDisplayedString(origList));
@ -2764,10 +2764,10 @@ That way, we can do a simple grep.
[]) );
}
while ( !lst.isEmpty() ) {
if ( isEqv(item, lst.first()) ) {
if ( isEqv(item, lst.first) ) {
return lst;
}
lst = lst.rest();
lst = lst.rest;
if (! isPair(lst) && lst !== types.EMPTY) {
var msg = ('memv: not a proper list: ' +
helpers.toDisplayedString(origList));
@ -2795,10 +2795,10 @@ That way, we can do a simple grep.
[]) );
}
while ( !lst.isEmpty() ) {
if ( isEqual(item, lst.first()) ) {
if ( isEqual(item, lst.first) ) {
return lst;
}
lst = lst.rest();
lst = lst.rest;
if (! isPair(lst) && lst !== types.EMPTY) {
var msg = ('member: not a proper list: ' +
@ -2825,12 +2825,12 @@ That way, we can do a simple grep.
return false;
}
return CALL(f, [lst.first()],
return CALL(f, [lst.first],
function(result) {
if (result) {
return lst;
}
return memfHelp(lst.rest());
return memfHelp(lst.rest);
});
}
return memfHelp(initList);
@ -2852,18 +2852,18 @@ That way, we can do a simple grep.
[]) );
}
while ( !lst.isEmpty() ) {
if (! isPair(lst.first())) {
if (! isPair(lst.first)) {
var msg = ('assq: non-pair found in list: ' +
helpers.toDisplayedString(lst.first()) +' in ' +
helpers.toDisplayedString(lst.first) +' in ' +
helpers.toDisplayedString(origList));
raise( types.incompleteExn(types.exnFailContract,
msg,
[]) );
}
if ( isEq(item, lst.first().first()) ) {
return lst.first();
if ( isEq(item, lst.first.first) ) {
return lst.first;
}
lst = lst.rest();
lst = lst.rest;
if (! isPair(lst) && lst !== types.EMPTY) {
var msg = ('assq: not a proper list: ' +
@ -2892,18 +2892,18 @@ That way, we can do a simple grep.
[]) );
}
while ( !lst.isEmpty() ) {
if (! isPair(lst.first())) {
if (! isPair(lst.first)) {
var msg = ('assv: non-pair found in list: ' +
helpers.toDisplayedString(lst.first()) +' in ' +
helpers.toDisplayedString(lst.first) +' in ' +
helpers.toDisplayedString(origList));
raise( types.incompleteExn(types.exnFailContract,
msg,
[]) );
}
if ( isEqv(item, lst.first().first()) ) {
return lst.first();
if ( isEqv(item, lst.first.first) ) {
return lst.first;
}
lst = lst.rest();
lst = lst.rest;
if (! isPair(lst) && lst !== types.EMPTY) {
var msg = ('assv: not a proper list: ' +
helpers.toDisplayedString(origList));
@ -2931,18 +2931,18 @@ That way, we can do a simple grep.
[]) );
}
while ( !lst.isEmpty() ) {
if (! isPair(lst.first())) {
if (! isPair(lst.first)) {
var msg = ('assoc: non-pair found in list: ' +
helpers.toDisplayedString(lst.first()) +' in ' +
helpers.toDisplayedString(lst.first) +' in ' +
helpers.toDisplayedString(origList));
raise( types.incompleteExn(types.exnFailContract,
msg,
[]) );
}
if ( isEqual(item, lst.first().first()) ) {
return lst.first();
if ( isEqual(item, lst.first.first) ) {
return lst.first;
}
lst = lst.rest();
lst = lst.rest;
if (! isPair(lst) && lst !== types.EMPTY) {
var msg = ('assoc: not a proper list: ' +
@ -2965,11 +2965,11 @@ That way, we can do a simple grep.
var originalLst = lst;
var result = types.EMPTY;
while ( !lst.isEmpty() ) {
if ( isEqual(item, lst.first()) ) {
return append([result.reverse(), lst.rest()]);
if ( isEqual(item, lst.first) ) {
return append([result.reverse(), lst.rest]);
} else {
result = types.cons(lst.first(), result);
lst = lst.rest();
result = types.cons(lst.first, result);
lst = lst.rest;
}
}
return originalLst;
@ -2989,14 +2989,14 @@ That way, we can do a simple grep.
return acc.reverse();
}
return CALL(f, [lst.first()],
return CALL(f, [lst.first],
function(result) {
if (result) {
return filterHelp(f, lst.rest(),
types.cons(lst.first(), acc));
return filterHelp(f, lst.rest,
types.cons(lst.first, acc));
}
else {
return filterHelp(f, lst.rest(), acc);
return filterHelp(f, lst.rest, acc);
}
});
}
@ -3055,22 +3055,22 @@ That way, we can do a simple grep.
return curMaxElt;
}
return CALL(f, [lst.first()],
return CALL(f, [lst.first],
function(result) {
check(result, isReal, 'argmax',
'procedure that returns real numbers', 1, args);
if (jsnums.greaterThan(result, curMaxVal)) {
return argmaxHelp(lst.rest(), result, lst.first());
return argmaxHelp(lst.rest, result, lst.first);
}
else {
return argmaxHelp(lst.rest(), curMaxVal, curMaxElt);
return argmaxHelp(lst.rest, curMaxVal, curMaxElt);
}
});
}
return CALL(f, [initList.first()],
return CALL(f, [initList.first],
function(result) {
check(result, isReal, 'argmax', 'procedure that returns real numbers', 1, args);
return argmaxHelp(initList.rest(), result, initList.first());
return argmaxHelp(initList.rest, result, initList.first);
});
});
@ -3089,22 +3089,22 @@ That way, we can do a simple grep.
return curMaxElt;
}
return CALL(f, [lst.first()],
return CALL(f, [lst.first],
function(result) {
check(result, isReal, 'argmin',
'procedure that returns real numbers', 1, args);
if (jsnums.lessThan(result, curMaxVal)) {
return argminHelp(lst.rest(), result, lst.first());
return argminHelp(lst.rest, result, lst.first);
}
else {
return argminHelp(lst.rest(), curMaxVal, curMaxElt);
return argminHelp(lst.rest, curMaxVal, curMaxElt);
}
});
}
return CALL(f, [initList.first()],
return CALL(f, [initList.first],
function(result) {
check(result, isReal, 'argmin', 'procedure that returns real numbers', 1, args);
return argminHelp(initList.rest(), result, initList.first());
return argminHelp(initList.rest, result, initList.first);
});
});
@ -3614,8 +3614,8 @@ That way, we can do a simple grep.
var ret = [];
while( !lst.isEmpty() ) {
ret.push(lst.first().val);
lst = lst.rest();
ret.push(lst.first.val);
lst = lst.rest;
}
return types.string(ret);
});
@ -3728,8 +3728,8 @@ That way, we can do a simple grep.
'implode', 'list of 1-letter strings', 1);
var ret = [];
while ( !lst.isEmpty() ) {
ret.push( lst.first().toString() );
lst = lst.rest();
ret.push( lst.first.toString() );
lst = lst.rest;
}
return types.string(ret);
});
@ -4139,8 +4139,8 @@ That way, we can do a simple grep.
var ret = [];
while ( !lst.isEmpty() ) {
ret.push(lst.first());
lst = lst.rest();
ret.push(lst.first);
lst = lst.rest;
}
return types.bytes(ret, true);
});

View File

@ -9,8 +9,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
scope['runtime'] = runtime;
var helpers = plt.helpers;
var types = plt.types;
var heir = helpers.heir;
// Consumes a class and creates a predicate that recognizes subclasses.
@ -19,27 +19,32 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
};
var isNumber = jsnums.isSchemeNumber;
var isNatural = function(x) { return (jsnums.isInteger(x) &&
jsnums.greaterThanOrEqual(x, 0)); }
var isPair = function(x) { return (typeof(x) == 'object' &&
x.length === 2 &&
x.type !== 'vector') };
var isList = function(x) {
while (x !== NULL) {
if (typeof(x) == 'object' && x.length === 2) {
x = x[1];
} else {
return false;
}
}
return true;
};
var isVector = function(x) { return (typeof(x) == 'object' &&
x.type === 'vector') };
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// We try to isolate the effect of external modules: all the identifiers we
// pull from external modules should be listed here, and should otherwise not
// show up outside this section!
var isNumber = types.isNumber;
var isNatural = types.isNatural;
var isPair = types.isPair;
var isList = types.isList;
var isVector = types.isVector;
var NULL = types.EMPTY;
var makeVector = types.vector;
var makeList = types.list;
var makePair = types.pair;
var heir = helpers.heir;
var toDomNode = helpers.toDomNode;
//////////////////////////////////////////////////////////////////////]
// This value will be dynamically determined.
@ -77,7 +82,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
'currentSuccessHandler': function(MACHINE) {},
'currentErrorHandler': function(MACHINE, exn) {
MACHINE.params.currentErrorDisplayer(
helpers.toDomNode(exn.message, 'print'));
toDomNode(exn.message, 'print'));
},
'currentNamespace': {},
@ -105,8 +110,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
var outputPort =
MACHINE.params.currentOutputPort;
if (elt !== undefined) {
outputPort.writeDomNode(MACHINE, helpers.toDomNode(elt, 'print'));
outputPort.writeDomNode(MACHINE, helpers.toDomNode("\n", 'print'));
outputPort.writeDomNode(MACHINE, toDomNode(elt, 'print'));
outputPort.writeDomNode(MACHINE, toDomNode("\n", 'print'));
}
var frame = MACHINE.control.pop();
return frame.label(MACHINE);
@ -314,7 +319,6 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
new ContinuationPromptTag("default-continuation-prompt-tag");
var NULL = [];
var raise = function(MACHINE, e) {
@ -452,8 +456,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
var lst = MACHINE.env[MACHINE.env.length - 1 - depth];
var vals = [];
while(lst !== NULL) {
vals.push(lst[0]);
lst = lst[1];
vals.push(lst.first);
lst = lst.rest;
}
vals.reverse();
MACHINE.env.splice.apply(MACHINE.env,
@ -466,7 +470,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
var lst = NULL;
var i;
for (i = 0; i < length; i++) {
lst = [MACHINE.env[MACHINE.env.length - depth - length + i], lst];
lst = makePair(MACHINE.env[MACHINE.env.length - depth - length + i],
lst);
}
MACHINE.env.splice(MACHINE.env.length - depth - length,
length,
@ -492,12 +497,12 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
return n >= arity.value;
} else {
while (arity !== NULL) {
if (typeof(arity[0]) === 'number') {
if (arity[0] === n) { return true; }
if (typeof(arity.first) === 'number') {
if (arity.first === n) { return true; }
} else if (arity instanceof ArityAtLeast) {
if (n >= arity[0].value) { return true; }
if (n >= arity.first.value) { return true; }
}
arity = arity[1];
arity = arity.rest;
}
return false;
}
@ -524,9 +529,9 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
'display');
outputPort = MACHINE.env[MACHINE.env.length-2];
}
outputPort.writeDomNode(MACHINE, helpers.toDomNode(firstArg, 'display'));
outputPort.writeDomNode(MACHINE, toDomNode(firstArg, 'display'));
};
Primitives['display'].arity = [1, [2, NULL]];
Primitives['display'].arity = makeList(1, 2);
Primitives['display'].displayName = 'display';
@ -541,9 +546,9 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
'newline');
outputPort = MACHINE.env[MACHINE.env.length-1];
}
outputPort.writeDomNode(MACHINE, helpers.toDomNode("\n", 'display'));
outputPort.writeDomNode(MACHINE, toDomNode("\n", 'display'));
};
Primitives['newline'].arity = [0, [1, NULL]];
Primitives['newline'].arity = makeList(0, 1);
Primitives['newline'].displayName = 'newline';
@ -559,10 +564,10 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
'displayln');
outputPort = MACHINE.env[MACHINE.env.length-2];
}
outputPort.writeDomNode(MACHINE, helpers.toDomNode(firstArg, 'display'));
outputPort.writeDomNode(MACHINE, helpers.toDomNode("\n", 'display'));
outputPort.writeDomNode(MACHINE, toDomNode(firstArg, 'display'));
outputPort.writeDomNode(MACHINE, toDomNode("\n", 'display'));
};
Primitives['displayln'].arity = [1, [2, NULL]];
Primitives['displayln'].arity = makeList(1, 2);
Primitives['displayln'].displayName = 'displayln';
@ -570,7 +575,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
Primitives['current-print'] = function(MACHINE) {
return MACHINE.params['current-print'];
};
Primitives['current-print'].arity = [0, [1, NULL]];
Primitives['current-print'].arity = makeList(0, 1);
Primitives['current-print'].displayName = "current-print";
Primitives['pi'] = jsnums.pi;
@ -811,7 +816,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
Primitives['cons'] = function(MACHINE) {
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = MACHINE.env[MACHINE.env.length-2];
return [firstArg, secondArg];
return makePair(firstArg, secondArg);
};
Primitives['cons'].arity = 2;
Primitives['cons'].displayName = 'cons';
@ -820,8 +825,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
Primitives['list'] = function(MACHINE) {
var result = NULL;
for (var i = 0; i < MACHINE.argcount; i++) {
result = [MACHINE.env[MACHINE.env.length - (MACHINE.argcount - i)],
result];
result = makePair(MACHINE.env[MACHINE.env.length - (MACHINE.argcount - i)],
result);
}
return result;
};
@ -836,7 +841,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
0,
'car');
var firstArg = MACHINE.env[MACHINE.env.length-1];
return firstArg[0];
return firstArg.first;
};
Primitives['car'].arity = 1;
Primitives['car'].displayName = 'car';
@ -849,7 +854,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
0,
'cdr');
var firstArg = MACHINE.env[MACHINE.env.length-1];
return firstArg[1];
return firstArg.rest;
};
Primitives['cdr'].arity = 1;
Primitives['cdr'].displayName = 'cdr';
@ -870,7 +875,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
'set-car!');
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = MACHINE.env[MACHINE.env.length-2];
firstArg[0] = secondArg;
firstArg.first = secondArg;
};
Primitives['set-car!'].arity = 2;
Primitives['set-car!'].displayName = 'set-car!';
@ -884,7 +889,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
'set-cdr!');
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = MACHINE.env[MACHINE.env.length-2];
firstArg[1] = secondArg;
firstArg.rest = secondArg;
};
Primitives['set-cdr!'].arity = 2;
Primitives['set-cdr!'].displayName = 'set-cdr!';
@ -912,7 +917,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
result.push(MACHINE.env[MACHINE.env.length-1-i]);
}
result.type = 'vector';
return result;
return makeVector.apply(null, result);
};
Primitives['vector'].arity = new ArityAtLeast(0);
Primitives['vector'].displayName = 'vector';
@ -924,11 +929,11 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
MACHINE.env[MACHINE.env.length - 1],
0,
'vector->list');
var firstArg = MACHINE.env[MACHINE.env.length-1];
var elts = MACHINE.env[MACHINE.env.length-1].elts;
var i;
var result = NULL;
for (i = 0; i < firstArg.length; i++) {
result = [firstArg[firstArg.length - 1 - i], result];
for (i = 0; i < elts.length; i++) {
result = makePair(elts[elts.length - 1 - i], result);
}
return result;
};
@ -939,11 +944,10 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
var firstArg = MACHINE.env[MACHINE.env.length-1];
var result = [];
while (firstArg !== NULL) {
result.push(firstArg[0]);
firstArg = firstArg[1];
result.push(firstArg.first);
firstArg = firstArg.rest;
}
result.type='vector';
return result;
return makeVector.apply(null, result);
};
Primitives['list->vector'].arity = 1;
Primitives['list->vector'].displayName = 'list->vector';
@ -955,9 +959,9 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
MACHINE.env[MACHINE.env.length - 1],
0,
'vector-ref');
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = MACHINE.env[MACHINE.env.length-2];
return firstArg[secondArg];
var elts = MACHINE.env[MACHINE.env.length-1].elts;
var index = MACHINE.env[MACHINE.env.length-2];
return elts[index];
};
Primitives['vector-ref'].arity = 2;
Primitives['vector-ref'].displayName = 'vector-ref';
@ -969,10 +973,10 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
MACHINE.env[MACHINE.env.length - 1],
0,
'vector-set!');
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = jsnums.toFixnum(MACHINE.env[MACHINE.env.length-2]);
var thirdArg = MACHINE.env[MACHINE.env.length-3];
firstArg[secondArg] = thirdArg;
var elts = MACHINE.env[MACHINE.env.length-1].elts;
var index = jsnums.toFixnum(MACHINE.env[MACHINE.env.length-2]);
var val = MACHINE.env[MACHINE.env.length-3];
elts[index] = val;
return null;
};
Primitives['vector-set!'].arity = 3;
@ -986,7 +990,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
MACHINE.env[MACHINE.env.length - 1],
0,
'vector-length');
var firstArg = MACHINE.env[jsnums.toFixnum(MACHINE.env.length-1)];
var firstArg = MACHINE.env[MACHINE.env.length-1].elts;
return firstArg.length;
};
Primitives['vector-length'].arity = 1;
@ -1009,10 +1013,9 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
for(var i = 0; i < length; i++) {
arr[i] = value;
}
arr.type='vector';
return arr;
return makeVector.apply(null, arr);
};
Primitives['make-vector'].arity = [1, [2, NULL]];
Primitives['make-vector'].arity = makeList(1, 2);
Primitives['make-vector'].displayName = 'make-vector';
@ -1098,27 +1101,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
Primitives['equal?'].displayName = 'equal?';
var isEqual = function(firstArg, secondArg) {
var lset = [firstArg], rset = [secondArg];
while (lset.length !== 0 && rset.length !== 0) {
var lhs = lset.pop();
var rhs = rset.pop();
if (lhs === rhs) {
continue;
} else if (typeof(lhs) === 'object' &&
typeof(rhs) === 'object' &&
typeof(lhs.length) === 'number' &&
typeof(rhs.length) === 'number' &&
lhs.length === rhs.length) {
lset.push.apply(lset, lhs);
rset.push.apply(rset, rhs);
} else {
return false;
}
}
return true;
};
var isEqual = types.isEqual;
Primitives['member'] = function(MACHINE) {
@ -1134,10 +1117,10 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
if (lst === NULL) {
return false;
}
if (isEqual(x, (lst[0]))) {
if (isEqual(x, (lst.first))) {
return lst;
}
lst = lst[1];
lst = lst.rest;
}
};
Primitives['member'].arity = 2;
@ -1151,8 +1134,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
while(lst !== NULL) {
testArgument(MACHINE,
'pair', isPair, lst, 0, 'reverse');
rev = [lst[0], rev];
lst = lst[1];
rev = makePair(lst.first, rev);
lst = lst.rest;
}
return rev;
};
@ -1389,6 +1372,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
exports['unspliceRestFromStack'] = unspliceRestFromStack;
// Type predicates
exports['isNumber'] = isNumber;
exports['isNatural'] = isNatural;
exports['isPair'] = isPair;
@ -1398,6 +1382,12 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
exports['isOutputStringPort'] = isOutputStringPort;
exports['isEqual'] = isEqual;
// Type constructors
exports['makeList'] = makeList;
exports['makePair'] = makePair;
exports['ArityAtLeast'] = ArityAtLeast;
exports['isArityMatching'] = isArityMatching;

View File

@ -83,7 +83,7 @@ if (! this['plt']) { this['plt'] = {}; }
//////////////////////////////////////////////////////////////////////
StructType = function(name, type, numberOfArgs, numberOfFields, firstField,
var StructType = function(name, type, numberOfArgs, numberOfFields, firstField,
applyGuard, constructor, predicate, accessor, mutator) {
this.name = name;
this.type = type;
@ -696,17 +696,24 @@ if (! this['plt']) { this['plt'] = {}; }
return b;
};
Cons = function(f, r) {
this.f = f;
this.r = r;
//////////////////////////////////////////////////////////////////////
// Cons Pairs
var Cons = function(f, r) {
this.first = f;
this.rest = r;
};
Cons.prototype.reverse = function() {
var lst = this;
var ret = Empty.EMPTY;
while (!lst.isEmpty()){
ret = Cons.makeInstance(lst.first(), ret);
lst = lst.rest();
ret = Cons.makeInstance(lst.first, ret);
lst = lst.rest;
}
return ret;
};
@ -715,28 +722,21 @@ if (! this['plt']) { this['plt'] = {}; }
return new Cons(f, r);
};
// FIXME: can we reduce the recursion on this?
Cons.prototype.isEqual = function(other, aUnionFind) {
if (! (other instanceof Cons)) {
return Logic.FALSE;
}
return (isEqual(this.first(), other.first(), aUnionFind) &&
isEqual(this.rest(), other.rest(), aUnionFind));
};
Cons.prototype.first = function() {
return this.f;
};
Cons.prototype.rest = function() {
return this.r;
return (isEqual(this.first, other.first, aUnionFind) &&
isEqual(this.rest, other.rest, aUnionFind));
};
Cons.prototype.isEmpty = function() {
return false;
};
// Cons.append: (listof X) -> (listof X)
Cons.prototype.append = function(b){
if (b === Empty.EMPTY)
@ -744,8 +744,8 @@ if (! this['plt']) { this['plt'] = {}; }
var ret = b;
var lst = this.reverse();
while ( !lst.isEmpty() ) {
ret = Cons.makeInstance(lst.first(), ret);
lst = lst.rest();
ret = Cons.makeInstance(lst.first, ret);
lst = lst.rest;
}
return ret;
@ -757,8 +757,8 @@ if (! this['plt']) { this['plt'] = {}; }
var texts = [];
var p = this;
while ( p instanceof Cons ) {
texts.push(toWrittenString(p.first(), cache));
p = p.rest();
texts.push(toWrittenString(p.first, cache));
p = p.rest;
if (typeof(p) === 'object' && cache.containsKey(p)) {
break;
}
@ -777,8 +777,8 @@ if (! this['plt']) { this['plt'] = {}; }
var texts = [];
var p = this;
while ( p instanceof Cons ) {
texts.push(toDisplayedString(p.first(), cache));
p = p.rest();
texts.push(toDisplayedString(p.first, cache));
p = p.rest;
if (typeof(p) === 'object' && cache.containsKey(p)) {
break;
}
@ -787,17 +787,6 @@ if (! this['plt']) { this['plt'] = {}; }
texts.push('.');
texts.push(toDisplayedString(p, cache));
}
// while (true) {
// if ((!(p instanceof Cons)) && (!(p instanceof Empty))) {
// texts.push(".");
// texts.push(toDisplayedString(p, cache));
// break;
// }
// if (p.isEmpty())
// break;
// texts.push(toDisplayedString(p.first(), cache));
// p = p.rest();
// }
return "(" + texts.join(" ") + ")";
};
@ -809,8 +798,8 @@ if (! this['plt']) { this['plt'] = {}; }
node.appendChild(document.createTextNode("("));
var p = this;
while ( p instanceof Cons ) {
appendChild(node, toDomNode(p.first(), cache));
p = p.rest();
appendChild(node, toDomNode(p.first, cache));
p = p.rest;
if ( p !== Empty.EMPTY ) {
appendChild(node, document.createTextNode(" "));
}
@ -823,27 +812,27 @@ if (! this['plt']) { this['plt'] = {}; }
appendChild(node, document.createTextNode(" "));
appendChild(node, toDomNode(p, cache));
}
// while (true) {
// if ((!(p instanceof Cons)) && (!(p instanceof Empty))) {
// appendChild(node, document.createTextNode(" "));
// appendChild(node, document.createTextNode("."));
// appendChild(node, document.createTextNode(" "));
// appendChild(node, toDomNode(p, cache));
// break;
// }
// if (p.isEmpty())
// break;
// appendChild(node, toDomNode(p.first(), cache));
// p = p.rest();
// if (! p.isEmpty()) {
// appendChild(node, document.createTextNode(" "));
// }
// }
node.appendChild(document.createTextNode(")"));
return node;
};
// isList: Any -> Boolean
// Returns true if x is a list (a chain of pairs terminated by EMPTY).
var isList = function(x) {
while (x !== Empty.EMPTY) {
if (x instanceof Cons){
x = x.rest;
} else {
return false;
}
}
return true;
};
//////////////////////////////////////////////////////////////////////
@ -1953,22 +1942,22 @@ String.prototype.toDisplayedString = function(cache) {
var makeList = function(args) {
var makeList = function() {
var result = Empty.EMPTY;
for(var i = args.length-1; i >= 0; i--) {
result = Cons.makeInstance(args[i], result);
for(var i = arguments.length-1; i >= 0; i--) {
result = Cons.makeInstance(arguments[i], result);
}
return result;
};
var makeVector = function(args) {
return Vector.makeInstance(args.length, args);
var makeVector = function(arguments) {
return Vector.makeInstance(arguments.length, arguments);
};
var makeVectorImmutable = function(args) {
var v = Vector.makeInstance(args.length, args);
var makeVectorImmutable = function(arguments) {
var v = Vector.makeInstance(arguments.length, arguments);
v.mutable = false;
return v;
};
@ -2000,8 +1989,8 @@ String.prototype.toDisplayedString = function(cache) {
var makeHashEq = function(lst) {
var newHash = new EqHashTable();
while ( !lst.isEmpty() ) {
newHash.hash.put(lst.first().first(), lst.first().rest());
lst = lst.rest();
newHash.hash.put(lst.first.first, lst.first.rest);
lst = lst.rest;
}
return newHash;
}
@ -2010,8 +1999,8 @@ String.prototype.toDisplayedString = function(cache) {
var makeHashEqual = function(lst) {
var newHash = new EqualHashTable();
while ( !lst.isEmpty() ) {
newHash.hash.put(lst.first().first(), lst.first().rest());
lst = lst.rest();
newHash.hash.put(lst.first.first, lst.first.rest);
lst = lst.rest;
}
return newHash;
}
@ -2040,10 +2029,10 @@ String.prototype.toDisplayedString = function(cache) {
}
if (types.isPair(x)) {
var consPair = types.cons(x.first(), x.rest());
var consPair = types.cons(x.first, x.rest);
objectHash.put(x, consPair);
consPair.f = readerGraph(x.first(), objectHash, n+1);
consPair.r = readerGraph(x.rest(), objectHash, n+1);
consPair.f = readerGraph(x.first, objectHash, n+1);
consPair.r = readerGraph(x.rest, objectHash, n+1);
return consPair;
}
@ -2152,6 +2141,7 @@ String.prototype.toDisplayedString = function(cache) {
types.isChar = function(x) { return x instanceof Char; };
types.isString = isString;
types.isPair = function(x) { return x instanceof Cons; };
types.isList = isList;
types.isEmpty = function(x) { return x === Empty.EMPTY; };
types.isVector = function(x) { return x instanceof Vector; };
types.isBox = function(x) { return x instanceof Box; };

View File

@ -11,7 +11,8 @@
current-root-path
current-warn-unimplemented-kernel-primitive
current-seen-unimplemented-kernel-primitives
current-kernel-module-locator?)
current-kernel-module-locator?
current-compress-javascript?)
@ -47,6 +48,9 @@
(: current-compress-javascript? (Parameterof Boolean))
(define current-compress-javascript? (make-parameter #f))