2015-07-31 06:31:03 +03:00
|
|
|
export function new_env(outer={}, binds=[], exprs=[]) {
|
2015-08-05 06:20:58 +03:00
|
|
|
var e = Object.setPrototypeOf({}, outer)
|
2015-07-31 06:31:03 +03:00
|
|
|
// Bind symbols in binds to values in exprs
|
|
|
|
for (var i=0; i<binds.length; i++) {
|
2015-08-05 06:20:58 +03:00
|
|
|
if (Symbol.keyFor(binds[i]) === "&") {
|
|
|
|
e[binds[i+1]] = exprs.slice(i) // variable length arguments
|
|
|
|
break
|
2015-07-31 06:31:03 +03:00
|
|
|
}
|
ES6: more use of ES6, simplifications, newer babel.
- Use Vector class derived from Array
- Use Array/Vector.from for initializing/cloning of Array/Vector
- Remove most semi-colon line endings
- More use of arrow functions
- Use Object.assign to copy properties in _malfunc and function
cloning.
- Remove or inline a bunch of types.js functions that don't really
need to be separate functions: _obj_type, _sequential_Q, _symbol,
_symbol_Q, _vector, _vector_Q, _hash_map, _hash_map_Q
- Simplify dependency list in Makefile
- Remove some separate core.js functions by moving them into the
core_ns declaration: _nth, keys, vals, with_meta.
With node 7, babel is mostly just used for translating imports into
CommonJS requires for node.
2017-02-11 07:06:09 +03:00
|
|
|
e[binds[i]] = exprs[i]
|
2015-07-31 06:31:03 +03:00
|
|
|
}
|
2015-08-05 06:20:58 +03:00
|
|
|
return e
|
2015-07-31 06:31:03 +03:00
|
|
|
}
|
2015-08-05 06:20:58 +03:00
|
|
|
export const env_get = (env, sym) => {
|
ES6: more use of ES6, simplifications, newer babel.
- Use Vector class derived from Array
- Use Array/Vector.from for initializing/cloning of Array/Vector
- Remove most semi-colon line endings
- More use of arrow functions
- Use Object.assign to copy properties in _malfunc and function
cloning.
- Remove or inline a bunch of types.js functions that don't really
need to be separate functions: _obj_type, _sequential_Q, _symbol,
_symbol_Q, _vector, _vector_Q, _hash_map, _hash_map_Q
- Simplify dependency list in Makefile
- Remove some separate core.js functions by moving them into the
core_ns declaration: _nth, keys, vals, with_meta.
With node 7, babel is mostly just used for translating imports into
CommonJS requires for node.
2017-02-11 07:06:09 +03:00
|
|
|
if (sym in env) { return env[sym] }
|
|
|
|
throw Error(`'${Symbol.keyFor(sym)}' not found`)
|
2015-07-31 07:57:45 +03:00
|
|
|
}
|
2015-08-05 06:20:58 +03:00
|
|
|
export const env_set = (env, sym, val) => env[sym] = val
|