Few languages contains feature known as while ... else.
It's very useful for special treatment of empty iterators.
In JS following code :
while (expr) {
/* code */
} else {
/* other code */
}
can be equivalent to :
let temp = expr ;
if (temp) {
while (temp) {
/* code */
temp = expr;
}
} else {
/* other code */
}
This implementation slightly differs from Python's while-else (in Python
else block is always executed, except for break statement) but I consider
it more logical.
Pure functions
pure square(x){
return Math.pow(x,2);
}
Pure functions are allowed to call only other pure functions. Pure
functions cannot reference any variable (but they can reference primitive
consts). Pure function always have undefined this, eval is forbidden. Every
Math, Object, Array or similar references always resolve to their
global value.
Calling nonpure function in any way should throw an exception.
Implementations are encouraged to parallelize these function calls whenever
it's possible (ie. .map on array).
Few languages contains feature known as while ... else.
It's very useful for special treatment of empty iterators.
In JS following code :
while (expr) {
/* code */
} else {
/* other code */
}
can be equivalent to :
let temp = expr ;
if (temp) {
while (temp) {
/* code */
temp = expr;
}
} else {
/* other code */
}
This implementation slightly differs from Python's while-else (in Python
else block is always executed, except for break statement) but I consider
it more logical.
Pure functions
pure square(x){
return Math.pow(x,2);
}
Pure functions are allowed to call only other pure functions. Pure
functions cannot reference any variable (but they can reference primitive
consts). Pure function always have undefined this, eval is forbidden. Every
`Math`, `Object`, `Array` or similar references always resolve to their
global value.
Calling nonpure function in any way should throw an exception.
Implementations are encouraged to parallelize these function calls whenever
it's possible (ie. `.map` on array).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141219/80cfae77/attachment.html>
Few languages contains feature known as while ... else.
It's very useful for special treatment of empty iterators.
In JS following code : while (expr) {
} else {
}
can be equivalent to : let temp = expr ; if (temp) { while (temp) { /* code */ temp = expr; } } else {
This implementation slightly differs from Python's while-else (in Python else block is always executed, except for break statement) but I consider it more logical.
Pure functions
pure square(x){
}
Pure functions are allowed to call only other pure functions. Pure functions cannot reference any variable (but they can reference primitive consts). Pure function always have undefined this, eval is forbidden. Every
Math
,Object
,Array
or similar references always resolve to their global value.Calling nonpure function in any way should throw an exception.
Implementations are encouraged to parallelize these function calls whenever it's possible (ie.
.map
on array).