Skip to content

Commit f54ad8d

Browse files
authored
Merge pull request #1941 from xushiwei/q
How Go+ simplifies Go's expressions
2 parents aa7b0e0 + f9ba0a8 commit f54ad8d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ For more details, see [Quick Start](doc/docs.md).
4646

4747
## Key Features of Go+
4848

49-
* Approaching natural language expression and intuitive (see [Command Style Code](#command-style-code)).
49+
* Approaching natural language expression and intuitive (see [How Go+ simplifies Go's expressions](#how-go-simplifies-gos-expressions)).
5050
* Fully compatible with [Go](https://github.com/golang/go) and can mix Go/Go+ code in the same package (see [Go/Go+ Hybrid Programming](doc/docs.md#gogo-hybrid-programming)).
5151
* Integrating with the C ecosystem including Python and providing limitless possibilities based on [LLGo](https://github.com/goplus/llgo) (see [Support for C/C++ and Python](#support-for-cc-and-python)).
5252
* Does not support DSL (Domain-Specific Languages), but supports SDF (Specific Domain Friendliness) (see [Go+ Classfiles](#go-classfiles)).
5353

5454

55-
## Command Style Code
55+
## How Go+ simplifies Go's expressions
5656

5757
Different from the function call style of most languages, Go+ recommends command style code:
5858

@@ -68,6 +68,17 @@ echo "Hello world"
6868

6969
For more discussion on coding style, see https://tutorial.goplus.org/hello-world.
7070

71+
Code style is just the first step. We have made many efforts to make the code more intuitive and closer to natural language expression. These include:
72+
73+
| Go code | Go+ code | Note |
74+
| ---- | ---- | ---- |
75+
| package main<br><br>import "fmt"<br><br>func main() {<br>&nbsp;&nbsp;&nbsp;&nbsp;fmt.Println("Hello world")<br>} | import "fmt"<br><br>fmt.Println("Hello world")<br> | Program Structure: Go+ allows omitting `package main` and `func main`. The contents of the main function can be written directly at the end of a Go+ file. |
76+
| fmt.Println("Hello world") | echo("Hello world") | Go+ provides more builtin functions to simplify the expression of the most common tasks. |
77+
| fmt.Println("Hello world") | echo "Hello world" | Go+ encourages writing code in a command-line style. It reduces the number of parentheses in the code as much as possible, making it closer to natural language. |
78+
| a := []int{1, 2, 3} | a := [1, 2, 3] | List literals |
79+
| a := map[string]int{<br>&nbsp;&nbsp;&nbsp;&nbsp;"Monday": 1,<br>&nbsp;&nbsp;&nbsp;&nbsp;"Tuesday": 2,<br>} | a := {<br>&nbsp;&nbsp;&nbsp;&nbsp;"Monday": 1,<br>&nbsp;&nbsp;&nbsp;&nbsp;"Tuesday": 2,<br>} | Mapping literals |
80+
| OnStart(func() {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>}) | onStart => {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>} | Lambda expressions |
81+
7182

7283
## Support for C/C++ and Python
7384

0 commit comments

Comments
 (0)