Added Go implementation

This commit is contained in:
Luxferre
2026-07-03 16:12:25 +03:00
parent 7f236d97b3
commit eabb972834
7 changed files with 553 additions and 10 deletions
+41 -1
View File
@@ -50,6 +50,31 @@ sh dist-python.sh /path/to/mounted/volume/app/clyx
```
This will install Clyx as a T-DeckARD applet.
### Reference Go implementation installation
To install the Go-based Clyx implementation directly from Git, run:
```sh
go install codeberg.org/luxferre/clyx@latest
```
For maximum performance, you can pass optimization flags to build a stripped binary without debug symbols, bounds checks, or inlining:
```sh
go install -a -trimpath -gcflags=all="-l -B -e" -ldflags "-s -w" codeberg.org/luxferre/clyx@latest
```
This will install the executable as `clyx` into your `$GOPATH/bin` directory. To upgrade to the latest version at any time, simply run the same command again.
Alternatively, to compile and build it locally, navigate to the `clyx-go` directory and run:
```sh
cd clyx-go
make
```
This will build the `clyx` executable.
## Usage
Note: this section describes how to run the interpreter itself. For the language manual, refer to [Clyx Reference Manual](clyx_manual.md).
@@ -71,6 +96,20 @@ clyx.repl()
```
To run a Clyx source file directly, issue `clyx.clyx('path/to/file.clx')` instead.
### Running the Go implementation
To run the REPL, execute the compiled `clyx` binary without arguments:
```sh
./clyx
```
To run a program directly, pass the path to the `.clx` file as an argument:
```sh
./clyx path/to/program.clx
```
Caveats:
1. The entire operation is rather slow (which is expected for an interpreted runtime on top of CircuitPython on this class of machines) and may sometimes overflow the allocated (native) Python stack. As such, it's not recommended to `src` files from the REPL if you can run them directly instead.
@@ -79,6 +118,7 @@ Caveats:
## Implementations
- [Reference implementation in Python](clyx-python/clyx/clyx.py) (compatible with MicroPython and T-DeckARD on CircuitPython)
- [Reference implementation in Go](clyx-go/clyx.go)
## FAQ
@@ -108,7 +148,7 @@ Apart from that, your implementation needs to be able to load `lib.clx` (standar
### Doesn't `hseval` primitive make Clyx programs non-portable across different implementations?
Yes, it does, because it works differently across different host languages (and Clyx implementations are allowed to not support it at all), so it must only be used as a last resort when any other attempts to interact with the outside world are unsuccessful. Additionally, using `hseval` introduces extra security risks. Nevertheless, this primitive had been added in order to enable some host-specific interoperability that would otherwise be impossible or very cumbersome to implement, such as browser-based deployments.
Yes, it does, because it works differently across different host languages (and Clyx implementations like `clyx-go` are allowed to not support it at all), so it must only be used as a last resort when any other attempts to interact with the outside world are unsuccessful. Additionally, using `hseval` introduces extra security risks. Nevertheless, this primitive had been added in order to enable some host-specific interoperability that would otherwise be impossible or very cumbersome to implement, such as browser-based deployments.
In other words, `hseval` is sometimes very useful in very specific cases, but please avoid using it unless you have a really good reason to use it.