Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ This release brings a lot of useful tools to write buzz code: LSP, formatter and

## Changed

- buzz binary now uses subcommands rather than options
- `buzz <script.buzz>` becomes `buzz run-script <script.buzz>`
- buzz binary now uses subcommands for tools and direct paths for execution
- `buzz <script.buzz>` runs a standalone script
- `buzz -t <script.buzz>` becomes `buzz test <script.buzz>`
- `buzz -f <script.buzz>` becomes `buzz format <script.buzz>`
- `buzz run` runs `src/main.buzz` from the current package
- `buzz <directory>` runs `src/main.buzz` from a buzz package directory
- `buzz run` and `buzz run-script` were removed
- `buzz init` and `buzz fetch` manage package scaffolding and dependencies
- `buzz` will start the REPL
- Extern libraries now must expose only one function which will be called by the compiler to lookup the functions of the library
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ A small/lightweight statically typed scripting language written in Zig
3. Build it `zig build -Doptimize=ReleaseSafe`
4. Have fun (with `BUZZ_PATH=./zig-out`)
- `buzz` launches the REPL
- `buzz run-script` to run a lone script
- `buzz <script.buzz>` to run a lone script
- `buzz <directory>` to run a buzz package
- `buzz init` to start a buzz package

### Install
Expand All @@ -62,4 +63,4 @@ sudo zig build -Doptimize=ReleaseSafe install -p /usr/local

If you're usage if performance critical (game dev for example), you can build using `-Doptimize=ReleaseFast`.

Remember to modify PATH to include the `bin` directory where it is installed. For example, `export PATH=PATH:/home/xxx/.local/bin`. You can then run buzz with `buzz <myscript.buzz>`. Or you can simply run `buzz` to start the REPL.
Remember to modify PATH to include the `bin` directory where it is installed. For example, `export PATH=PATH:/home/xxx/.local/bin`. You can then run buzz with `buzz <myscript.buzz>` or `buzz <directory>`. Or you can simply run `buzz` to start the REPL.
40 changes: 40 additions & 0 deletions examples/showcase.buzz
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import "buzz:std";

enum State {
todo,
doing,
done,
}

object Task {
title: str,
points: int?,
state: State = .todo,

fun score() => match (this.state) {
.done -> this.points ?? 0,
.doing, .todo -> 0
};
}

fun scores(tasks: [Task]) > str *> int? {
foreach (task in tasks) {
_ = yield task.score();
}
return "scored {tasks.len()} tasks";
}

fun main() > void {
final tasks: [Task] = [
.{ title = "parser", points = 8, state = .done },
.{ title = "lsp", points = 5, state = .doing },
.{ title = "docs", points = 3 },
];

var total = 0;
foreach (score in &scores(tasks)) {
total += score ?? 0;
}

std\print("completed points: {total}");
}
Loading
Loading