Skip to content

Commit

Permalink
mention classes in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Jan 11, 2025
1 parent 5ffe1e0 commit b29aa31
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ def main() -> int:
return 0
```

Jou has classes. They can have methods, but that's about it:
otherwise Jou classes are just like structs in C.

```python
import "stdlib/io.jou"


class Greeting:
target: byte*

def show(self) -> None:
printf("Hello %s\n", self->target)


def main() -> int:
g = Greeting{target="World"}
g.show() # Output: Hello World
```

See the [examples](./examples/) and [tests](./tests/) directories for more example programs
or read [the Jou tutorial](./doc/tutorial.md).

Expand Down
6 changes: 3 additions & 3 deletions doctest.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env bash
#
# This file runs code snippets in doc/*.md files.
# This file runs code snippets in markdown files.

set -e -o pipefail

for arg in "$@"; do
if [[ "$arg" =~ ^- ]]; then
echo "Usage: $0 [doc/file1.md doc/file2.md ...]" >&2
echo "Usage: $0 [file1.md file2.md ...]" >&2
exit 2
fi
done

if [ $# == 0 ]; then
files=(doc/*.md)
files=(README.md doc/*.md)
else
files=("$@")
fi
Expand Down

0 comments on commit b29aa31

Please sign in to comment.