functionalscript 0.0.290 → 0.0.291

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +53 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -184,3 +184,56 @@ const f = x => {
184
184
  return r
185
185
  }
186
186
  ```
187
+
188
+ ## 5. Statements
189
+
190
+ `{ A_LIST_OF_STATEMENTS }` is one or many statements seperated by the newline control character. One of these statements mentioned earlier was [definition](#25-Definitions), also known as a [const](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const) statement. The other statements are described below.
191
+
192
+ ### 5.1 Let
193
+
194
+ [Let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) declares a local mutable alias for immutable objects. For example
195
+
196
+ ```js
197
+ let x = [5]
198
+ // you can assign another immutable object to the alias at any time.
199
+ x = [3, 4]
200
+ //but you can't change the properties of the immutable object.
201
+ x[0] = 3 // < invalid
202
+ //let aliases can not be referenced from another arrow function.
203
+ const f = () => x // < invalid
204
+ ```
205
+
206
+
207
+
208
+ This mutable object cannot be used in [closures](https://en.wikipedia.org/wiki/Closure_(computer_programming)) or nested functions.
209
+
210
+ An example of incorrect code would look like this:
211
+
212
+ ```js
213
+ let x = 5
214
+ const f = () => x
215
+ ```
216
+
217
+ ### 5.2 Return
218
+
219
+ [Return](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return)
220
+
221
+ ### 5.3 If...Else
222
+
223
+ [If...Else](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)
224
+
225
+ ### 5.4 Switch
226
+
227
+ [Switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)
228
+
229
+ ### 5.5 Throw
230
+
231
+ [Throw](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw). FunctionalScript allows to throw exceptions but it doesn't catch them. You should only be using Statement throw in non-recoverable situations. It could be compared to [panic in Rust](https://doc.rust-lang.org/std/macro.panic.html).
232
+
233
+ ### 5.6 While
234
+
235
+ [While](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while)
236
+
237
+ ### 5.7 Block
238
+
239
+ [Block](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.290",
3
+ "version": "0.0.291",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "index.js",
6
6
  "scripts": {