These are chat archives for ramda/ramda

4th
Apr 2015
Scott Christopher
@scott-christopher
Apr 04 2015 00:20

i wonder if there could be a mechanism for importing all without bad consequences

If we ignore the "without bad consequences" part:

with (require('ramda')) {
  console.log(add(1)(2));
}
Walle Cyril
@GrosSacASac
Apr 04 2015 01:52
can you explain the bad consequences @scott-christopher
Scott Christopher
@scott-christopher
Apr 04 2015 02:26
Use of with is prohibited in strict mode for one. MDN has some more info regarding the concerns of with: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
Walle Cyril
@GrosSacASac
Apr 04 2015 02:58
when writing normal js there is an implicit with (window) ?
Scott Christopher
@scott-christopher
Apr 04 2015 03:38
Sure, that's one way to think of it.
JS (well the ecmascript definition) has the notion of Object Environment Records, which are used to look-up variables not defined in the current lexical scope, such as all the global variables attached to the window object in the context of a browser.
The with statement adds a new Object Environment Record in front of the existing one for any code defined inside the with block. So any references to variables that aren't defined in the with block will first check the properties of the object passed to the with statement, then check the outer Object Environment Record and so on until it reaches the root (global).