functionalscript 0.0.310 → 0.0.311
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.
- package/LANGUAGE.md +6 -6
- package/package.json +1 -1
package/LANGUAGE.md
CHANGED
|
@@ -13,7 +13,7 @@ const result = thirdPartyModule.someFunction('hello')
|
|
|
13
13
|
## 2. Packages
|
|
14
14
|
|
|
15
15
|
FunctionalScript uses a `package.json` file to define a package. This file is compatible with [Node.js `package.json`](https://nodejs.org/en/knowledge/getting-started/npm/what-is-the-file-package-json/).
|
|
16
|
-
The
|
|
16
|
+
The preferred way to reference dependencies is to use a GitHub URL. These dependencies in a `package.json` file could look like this,
|
|
17
17
|
|
|
18
18
|
```json
|
|
19
19
|
{
|
|
@@ -33,7 +33,7 @@ npm install -S github:functionalscript/functionalscript
|
|
|
33
33
|
|
|
34
34
|
## 3. Module Structure
|
|
35
35
|
|
|
36
|
-
A module is a file with the `.js`
|
|
36
|
+
A module is a file with the `.js` extension. It contains three parts: references to other modules, definitions, and exports. For example
|
|
37
37
|
|
|
38
38
|
`./first.js`
|
|
39
39
|
```js
|
|
@@ -81,7 +81,7 @@ const localFile = require('../some-directory/some-file.js')
|
|
|
81
81
|
|
|
82
82
|
## 5. Definitions
|
|
83
83
|
|
|
84
|
-
The format of
|
|
84
|
+
The format of definitions is `const NAME = EXPRESSION`, where the `EXPRESSION` is a subset of [JavaScript expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators).
|
|
85
85
|
|
|
86
86
|
```js
|
|
87
87
|
const myConst = 42
|
|
@@ -139,7 +139,7 @@ Expressions could fall under these categories:
|
|
|
139
139
|
- Relations Operators: `in`, `instanceof`.
|
|
140
140
|
- Member Operators: `.`, `[]`.
|
|
141
141
|
|
|
142
|
-
Note: the `.` member operator has
|
|
142
|
+
Note: the `.` member operator has prohibited property names, such as `constructor` and `push`. To access such properties, it's recommended to use the [Object.getOwnPropertyDescriptor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor) function.
|
|
143
143
|
|
|
144
144
|
## 8. Arrow Functions
|
|
145
145
|
|
|
@@ -167,7 +167,7 @@ const f = x => {
|
|
|
167
167
|
|
|
168
168
|
## 9. Statements
|
|
169
169
|
|
|
170
|
-
`{ A_LIST_OF_STATEMENTS }` is one or many statements
|
|
170
|
+
`{ A_LIST_OF_STATEMENTS }` is one or many statements separated by the newline control character. One of these statements mentioned earlier was [definition](#5-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.
|
|
171
171
|
|
|
172
172
|
### 9.1. Let
|
|
173
173
|
|
|
@@ -197,7 +197,7 @@ const f = () => x // < invalid
|
|
|
197
197
|
|
|
198
198
|
### 9.5. Throw
|
|
199
199
|
|
|
200
|
-
[Throw](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw). FunctionalScript allows to throw exceptions but
|
|
200
|
+
[Throw](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw). FunctionalScript allows to throw exceptions, but the language has no ability to catch them. You should only be using Statement throw in non-recoverable situations. Throwing an exception could be compared to [panic in Rust](https://doc.rust-lang.org/std/macro.panic.html).
|
|
201
201
|
|
|
202
202
|
### 9.6. While
|
|
203
203
|
|