functionalscript 0.0.309 → 0.0.313
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/.github/workflows/node.js.yml +1 -1
- package/LANGUAGE.md +6 -6
- package/README.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
|
|
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 syntax to catch them. Developers should only use the 'throw' statement 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
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# FunctionalScript
|
|
2
2
|
|
|
3
|
-
FunctionalScript is a
|
|
3
|
+
FunctionalScript is a purely functional programming language and a strict subset of
|
|
4
4
|
[ECMAScript](https://en.wikipedia.org/wiki/ECMAScript)/[JavaScript](https://en.wikipedia.org/wiki/JavaScript). It's inspired by
|
|
5
5
|
|
|
6
6
|
- [JSON](https://en.wikipedia.org/wiki/JSON) as a subset of JavaScript. JSON is also a subset of FunctionalScript.
|
|
@@ -16,14 +16,14 @@ Create a new FunctionalScript repository on GitHub [here](https://github.com/fun
|
|
|
16
16
|
In FunctionalScript:
|
|
17
17
|
|
|
18
18
|
- Any module is a valid JavaScript module. No additional build steps are required.
|
|
19
|
-
- Code should not have [side-effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)). Any JavaScript statement, expression, or function which has a side effect is not allowed in FunctionalScript. There are no exceptions to this rule, such as `unsafe` code which can be found in Rust, C#, and other languages.
|
|
20
|
-
- A module can't depend on non FunctionalScript module.
|
|
21
|
-
- It also has no standard library
|
|
19
|
+
- Code should not have [side-effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)). Any JavaScript statement, expression, or function which has a side effect is not allowed in FunctionalScript. There are no exceptions to this rule, such as `unsafe` code, which can be found in Rust, C#, and other languages.
|
|
20
|
+
- A module can't depend on a non FunctionalScript module.
|
|
21
|
+
- It also has no standard library. Only a safe subset of standard JavaScript API can be used without referencing other modules.
|
|
22
22
|
|
|
23
23
|
## Applications
|
|
24
24
|
|
|
25
|
-
FunctionalScript code can be used
|
|
25
|
+
FunctionalScript code can be used
|
|
26
26
|
|
|
27
27
|
- in any JavaScript/TypeScript application,
|
|
28
28
|
- as a JSON with expressions,
|
|
29
|
-
- as a query language.
|
|
29
|
+
- as a query language.
|