An interactive scripting language where you can read and modify code comments as if they were regular strings. Add and view text-based visualizations and debugging information inside your source code file.
The experience is better locally though, read on!
Since this is an interactive editor, the best examples are moving use cases.
Make sure you have the Cargo package manager with a recent nightly Rust, and from inside this directory:
cargo install --path .
As an example, open examples/hello.zac in your editor. Then, run (preferably through your editor)
zac examples/hello.zac
(or if you're a Rust coder)
cargo build --release
target/release/zac examples/hello.zac
If you're using Vim, there's a syntax file in the repo. Put this in your ~/.vim/syntax
directory, or ~/.config/nvim/syntax
if you're using Neovim, and follow the instructions at the top of the file.
It's highly recommended that you save the file from inside of your editor instead of changing windows. Zac is meant to be used like Gofmt or Rustfmt, run every time you save your file.
In Vim, you can use the following command to save your file:
:map \t :w\|:!zac %<CR>:e<CR><CR>
You'll have a better time getting a feel of how the language works from looking at and running examples than from reading detailed documentation. Other than comment modification, Zac is a familiar-looking scripting language.
Comments come in two flavors, anonymous and named.
// This is an anonymous comment because it doesn't have a #identifier as
// the first line.
//
// This cannot be referenced or modified from within the code.
let #changeme = // some string
// #changeme
// This is a comment with the name #changeme.
//
// In this program, it is modified twice, once above and once below
// using the `let` expression.
//
// After running this program, this comment will instead contain:
// // some string another string
let another_string = // another string
let #changeme = cat(#changeme, chr(32), another_string)
// Named comments can be changed before and/or after they appear in the source code. Zac will throw
// an error if there are two comments in a program with the same name.
As of now, there is no specific syntax for string literals, if you need a string literal, you can make a comment.
This is a proof-of-concept I made in the first Lang Jam, a 2-day competition to design a programming language around the theme first-class comments
.
Submitted to the contest under the team name SOLDIER.