From 0e0b6c9f2161dd393db0946804fa5a82fc911702 Mon Sep 17 00:00:00 2001 From: Emil Valeev Date: Sat, 23 Nov 2024 17:37:23 +0500 Subject: [PATCH] feat(docs:tutorial:dataflow): ports section added --- README.md | 2 +- docs/book/interfaces.md | 2 +- docs/tutorial.md | 200 ++++++++++++++-------------------------- 3 files changed, 71 insertions(+), 133 deletions(-) diff --git a/README.md b/README.md index 492563e3..959a9b3a 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ If you open `my_awesome_project/src/main.neva` with your favorite IDE you'll see import { fmt } def Main(start any) (stop any) { - println fmt.Println + println fmt.Println --- :start -> 'Hello, World!' -> println -> :stop } diff --git a/docs/book/interfaces.md b/docs/book/interfaces.md index ca2eaab5..cb853743 100644 --- a/docs/book/interfaces.md +++ b/docs/book/interfaces.md @@ -97,7 +97,7 @@ This allows code like this 1 -> switch:case[0] -> dst1 2 -> switch:case[1] -> dst2 3 -> switch:case[2] -> dst3 -switch:else -> { '!?' -> println } +switch:else -> '!?' -> println ``` Array-ports combine data from different sources. They are static, requiring the number of ports to be known at compile time for channel generation. This can always be determined from the source code. Limitations of array-ports will be discussed on the network page. diff --git a/docs/tutorial.md b/docs/tutorial.md index db9952a2..baf7ca3c 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -13,6 +13,8 @@ Welcome to a tour of the Nevalang programming language. This tutorial will intro - [Constants](#constants) - [Modules and Packages](#modules-and-packages) - [Imports and Visibility](#imports-and-visibility) +3. [Dataflow](#dataflow) + - [Ports](#ports) ## Welcome @@ -98,7 +100,7 @@ If you open `my_awesome_project/src/main.neva` with your favorite IDE, you'll se import { fmt } def Main(start any) (stop any) { - println fmt.Println + println fmt.Println --- :start -> 'Hello, World!' -> println -> :stop } @@ -152,7 +154,7 @@ Most components do more interesting work by using nodes to process data: import { fmt } def Main(start any) (stop any) { - println fmt.Println + println fmt.Println --- :start -> println -> :stop } @@ -177,7 +179,7 @@ Back to hello world: import { fmt } def Main(start any) (stop any) { - println fmt.Println + println fmt.Println --- :start -> 'Hello, World!' -> println -> :stop } @@ -223,7 +225,7 @@ Use `$` to prefix a constant in a network: const greeting string = 'Hello!' def Main(start any) (stop any) { - println fmt.Println + println fmt.Println --- :start -> $greeting -> println -> :stop } @@ -260,7 +262,7 @@ A package is a directory with `.neva` files. In our Hello World example, the `sr import { fmt } def Main(start any) (stop any) { - println fmt.Println + println fmt.Println --- :start -> 'Hello, World!' -> println -> :stop } @@ -292,12 +294,12 @@ pub def Greet(data string) (res string) { // new component // src/main.neva import { fmt - @:/utils // new import + @:utils // new import } def Main(start any) (stop any) { greet utils.Greet // new node - println fmt.Println + println fmt.Println --- :start -> 'World' -> greet -> println -> :stop // new connection } @@ -306,7 +308,7 @@ def Main(start any) (stop any) { Notice how we can have multiple imports: - `fmt` from the standard library for printing -- `@:/utils` from our local module (`@` is module name, `:` separates module/package) +- `@:utils` from our local module (`@` is module name, `:` separates module/package) This modular structure keeps your code organized and reusable as your projects grow. @@ -348,13 +350,13 @@ We can use `Greet` (import needed) and `AddExclamation` (no import needed) in ou ```neva import { fmt - @:/utils + @:utils } def Main(start any) (stop any) { greet utils.Greet exclaim AddExclamation // same package, no import needed - println fmt.Println + println fmt.Println --- :start -> 'World' -> greet -> exclaim -> println -> :stop } @@ -366,187 +368,123 @@ Output: Hello, World!!! ``` - - - - - +- Component (self) inports must all be used +- Component (self) outports must all be used +- Node inports must all be used +- Node outports can be partially used