Skip to content

Commit

Permalink
doc: update readme and lang docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kthompson committed Jul 15, 2024
1 parent cfeb817 commit 0d136c5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 38 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Panther is a general-purpose, multi-paradigm programming language encompassing s
def main() = {
var guess = -1
var guessCount = 0
var answer = rnd()
var answer = rnd(100)

while (guess != answer) {
println("Guess the answer:")
guess = int(read())
guess = int(readLine())
guessCount = guessCount + 1

if (guess > answer) {
Expand All @@ -31,6 +31,24 @@ def main() = {
}
```

# Current language support

- [x] Variables
- [x] Functions
- Control flow
- [x] if
- [x] while
- [x] for
- [ ] pattern matching
- Builtin Data Types
- [x] Int
- [x] Char
- [x] String
- [x] Boolean
- Algebraic Data Types
- [x] Product Types
- [ ] Sum Types

# Road map

- complete basics in order to start writing code in Panther
Expand Down
45 changes: 9 additions & 36 deletions docs/LANG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@
* Unsigned ints u8, u16, u32, u64, usize (TODO)
* Signed ints i8, i16, i32, i64, isize (TODO)
* Floats: f32, f64 (TODO)
* char (TODO)
* char
* bool
* string

# expressions

```
if (x == 12) {
...
} else {
...
}
```


```
val result = if (x == 12) ... else ...

```
structs are value types? or should a trait decide if something is a value type like `Clone` in rust

```
struct Age(u8)
struct Person(name: String, age: Age)
struct Animal(feet: u16) {
Expand All @@ -38,44 +42,13 @@ val Person(name, Age(age)) = michael
println(name)
println(age)

# discriminated union
```
enum List<T> {
case Cons(head: T, tail: List),
case Nil
}
```

OR

# discriminated union
```
sum List<T> {
type List<T> {
Cons(head: T, tail: List),
Nil
}
```

# traits

trait Speak {
def speak(): String
}

instance Speak for Person {
def speak(): String = $"My name is {this.name}"
}

# lowered features



# sugar that can be lowered

expression(a, b, c) -> expression.Invoke(a, b, c)

lock -> try finally

for comprehension -> flapMap + map chain

val Person(name, Age(age)) = michael

0 comments on commit 0d136c5

Please sign in to comment.