GitBook: [alpha] 27 pages modified

This commit is contained in:
Dmitry Kurinskiy 2021-09-08 11:29:52 +00:00 committed by gitbook-bot
parent 7b404f36d8
commit f827d194a0
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF
5 changed files with 38 additions and 19 deletions

View File

@ -7,6 +7,15 @@ Aqua compiler's versioning scheme is the following: `0.BREAKING.ENHANCING.RELEAS
* `ENHANCING` part is incremented for every syntax addition
* `RELEASE` is the release number, shows internal compiler changes, bugfixes that keep the language untouched
### [0.3.0](https://github.com/fluencelabs/aqua/releases/tag/0.3.0) September 8, 2021
* TypeScript output of the compiler now targets a completely rewritten [TypeScript SDK](https://doc.fluence.dev/docs/js-sdk) \([\#251](https://github.com/fluencelabs/aqua/pull/251)\)
* Constants are now `UPPER_CASED`, including always-available `HOST_PEER_ID` and `INIT_PEER_ID` \([\#260](https://github.com/fluencelabs/aqua/pull/260)\)
* The compiler is now distributed as [@fluencelabs/aqua](https://www.npmjs.com/package/@fluencelabs/aqua) package \(was `aqua-cli`\) \([\#278](https://github.com/fluencelabs/aqua/pull/278)\)
* `aqua` is the name of the compiler CLI command now \(was `aqua-cli`\) \([\#278](https://github.com/fluencelabs/aqua/pull/278)\)
* JVM version of the compiler is now available with `aqua-j` command; JS build is called by default so no more need to have JVM installed \([\#278](https://github.com/fluencelabs/aqua/pull/278)\)
* Now you can have a file that contains only a header with imports, uses, declares, and exports, and no new definitions \([\#274](https://github.com/fluencelabs/aqua/pull/274)\)
### [0.2.1](https://github.com/fluencelabs/aqua/releases/tag/0.2.1) August 31, 2021
* Javascript build of the compiler is now distributed via NPM: to run without Java, use `aqua-js` command \([\#256](https://github.com/fluencelabs/aqua/pull/256)\)

View File

@ -16,9 +16,9 @@ module ModuleName declares *
`ModuleName` can be used as the module's name when this file is `use`d. In this case, only what is enumerated in `declares` section will be available. `declares *` allows you to declare everything in the file as the module interface.
```text
module ModuleName declares constname, ServiceName, MyType, fn
module ModuleName declares CONSTNAME, ServiceName, MyType, fn
const constname = "smth"
const CONSTNAME = "smth"
service ServiceName:
do_smth()
@ -27,7 +27,7 @@ data MyType:
result: i32
function fn() -> string:
<- constname
<- CONSTNAME
```
## Import Expression

View File

@ -31,17 +31,17 @@ on myPeer:
`on` does not add network hops on its own: if there are no service calls inside the `on` scope, the node will not be reached. Use `via` to affect the topology without service calls.
{% endhint %}
## `%init_peer_id%`
## `INIT_PEER_ID`
There is one custom peer ID that is always in scope: `%init_peer_id%`. It points to the peer that initiated this request.
There is one custom peer ID that is always in scope: `INIT_PEER_ID`. It points to the peer that initiated this request.
{% hint style="warning" %}
Using `on %init_peer_id%` is an anti-pattern: There is no way to ensure that init peer is accessible from the currently used part of the network.
Using `on INIT_PEER_ID` is an anti-pattern: There is no way to ensure that init peer is accessible from the currently used part of the network.
{% endhint %}
## `host_peer_id`
## `HOST_PEER_ID`
This constant is resolved on compilation time to point on the relay \(the host the client is connected to\) if Aqua is compiled to be used behind the relay \(default mode, targets web browsers and other devices that needs a relay to receive incoming connections\), and on `%init_peer_id%` otherwise.
This constant is resolved on compilation time to point on the relay \(the host the client is connected to\) if Aqua is compiled to be used behind the relay \(default mode, targets web browsers and other devices that needs a relay to receive incoming connections\), and on `INIT_PEER_ID` otherwise.
## More complex scenarios
@ -73,7 +73,7 @@ Take a minute to think about:
Declarative topology definition always works the same way.
* `do_foo` is executed on "peer foo", always.
* `bar(1)` is executed on the same node where `baz` was running. If `baz` is the first called function, then it's `init peer id`.
* `bar(1)` is executed on the same node where `baz` was running. If `baz` is the first called function, then it's `INIT_PEER_ID`.
* `bar(2)` is executed on `"peer baz"`, despite the fact that foo does topologic transition. `bar(2)` is in the scope of `on "peer baz"`, so it will be executed there
* `bar(3)` is executed where `bar(1)` was: in the root scope of `baz`, wherever it was called from

View File

@ -10,7 +10,7 @@ Scalar types follow the Wasm IT notation.
* Boolean: `bool`
* String: `string`
* Records \(product type\): see below
* Arrays: see Collection Types below
* Arrays: see [Collection Types](types.md#collection-types) below
## Literals
@ -158,7 +158,7 @@ The file is a product of all defined constants and functions \(treated as arrows
func foo(arg: string) -> bool:
...
const flag ?= true
const FLAG ?= true
-- type of MyFile.aqua
data MyServiceType:
@ -166,5 +166,7 @@ data MyServiceType:
flag: bool
```
See [Imports and Exports](header.md#module) for module declarations.
{% embed url="https://github.com/fluencelabs/aqua/blob/main/types/src/main/scala/aqua/types/Type.scala" caption="See the types system implementation" %}

View File

@ -79,7 +79,7 @@ func otherFunc():
## Literals
Aqua supports just a few literals: numbers, quoted strings, booleans. You [cannot init a structure](https://github.com/fluencelabs/aqua/issues/167) in Aqua, only obtain it as a result of a function call.
Aqua supports just a few literals: numbers, quoted strings, booleans, and `nil`. You [cannot init a structure](https://github.com/fluencelabs/aqua/issues/167) in Aqua, only obtain it as a result of a function call.
```haskell
-- String literals cannot contain double quotes
@ -99,6 +99,12 @@ bar(-1)
-- Float:
bar(-0.2)
func takesMaybe(arg: ?string): ...
-- nil can be passed in every place
-- where a read-only collection fits
takesMaybe(nil)
```
## Getters
@ -156,18 +162,20 @@ Constants are like assignments but in the root scope. They can be used in all fu
You can change the compilation results by overriding a constant but the override needs to be of the same type or subtype.
```haskell
-- This flag is always true
const flag = true
Constants are always `UPPER_CASE`.
-- This setting can be overwritten via CLI flag
const setting ?= "value"
```haskell
-- This FLAG is always true
const FLAG = true
-- This SETTING can be overwritten via CLI flag
const SETTING ?= "value"
func foo(arg: string): ...
func bar():
-- Type of setting is string
foo(setting)
-- Type of SETTING is string
foo(SETTING)
```
## Visibility scopes