Browse Source

More changes to the README because yes

master
Mattia Giambirtone 1 month ago
parent
commit
096bfaf662
  1. 25
      README.md
  2. 29
      docs/manual.md

25
README.md

@ -80,7 +80,30 @@ Misc:
- method-like call syntax without actual methods (dispatched at compile-time) [ ]
- ... More?
## Features
Aside from the obvious basics like exceptions, a true import system with namespaces and a standard library (duh), here's a
random list of high-level features I plan peon to have and that I think are kinda neat:
- References not being nullable by default (must use `#pragma[nullable]`)
- Easy C/Nim interop via FFI
- C/C++ backend
- Nim backend (maybe)
- Structured concurrency
- Capability-based programming (i.e. functions are passed objects to act on the real world)
- Parametric Polymorphism (with untagged typed unions and maybe interfaces)
- Simple OOP (with multiple dispatch!)
- RTTI, with methods that dispatch at runtime based on the true type of a value (maybe)
- Limited compile-time evaluation (embed the Peon VM in the C/C++/Nim backend and use that to execute peon code at compile time)
## The name
The name for peon comes from my and [Productive2's](https://git.nocturn9x.space/prod2) genius and is a result of shortening
the name of the fastest animal on earth: the **Pe**regrine Falc**on**. I guess I wanted this to mean peon will be blazing fast
the name of the fastest animal on earth: the **Pe**regrine Falc**on**. I guess I wanted this to mean peon will be blazing fast
# Peon needs you.
No, but really. I need help. This project is huge and (IMHO) awesome, but there's a lot of non-trivial work to do and doing
it with other people is just plain more fun and rewarding. If you want to get involved, definitely try [contacting](https://nocturn9x.space/contact) me
or open an issue/PR!

29
docs/manual.md

@ -44,11 +44,14 @@ For somewhat updated tests, check the [tests](../tests/) directory.
### Variable declarations
```
var x = 5; # Inferred type is int64
var y = 3'u16; # Type is specified as uint16
x = 6; # Works: type matches
x = 3.0; # Cannot assign float64 to x
var x = 3.14; # Cannot re-declare x
var x = 5; # Inferred type is int64
var y = 3'u16; # Type is specified as uint16
x = 6; # Works: type matches
x = 3.0; # Error: Cannot assign float64 to x
var x = 3.14; # Error: Cannot re-declare x
const z = 6.28; # Constant declaration
let a = "hi!"; # Cannot be reassigned/mutated
var b: int32 = 5; # Explicit type declaration
```
__Note__: Peon supports [name stropping](https://en.wikipedia.org/wiki/Stropping_(syntax)), meaning
@ -108,7 +111,7 @@ __Note__: Code the likes of `a.b()` is desugared to `b(a)` if there exists a fun
which case the attribute resolution takes precedence)
### Generic declarations
### Generics
```
fn genericSum[T: Number](a, b: T): T { # Note: "a, b: T" means that both a and b are of type T
@ -122,7 +125,7 @@ genericSum(3.14, 0.1);
genericSum(1'u8, 250'u8);
```
#### Multiple generics
#### More generics!
```
fn genericSth[T: someInterface, K: someInterface2](a: T, b: K) { # Note: no return type == void function!
@ -132,6 +135,18 @@ fn genericSth[T: someInterface, K: someInterface2](a: T, b: K) { # Note: no ret
genericSth(1, 3.0);
```
#### Even more generics?
```
type Box*[T: SomeNumber] = object {
num: T;
}
var boxFloat = Box[float](1.0);
var boxInt = Box[int](1);
```
__Note__: The `*` modifier to make a name visible outside the current module must be put
__before__ generics declarations, so only `fn foo*[T](a: T) {}` is the correct syntax

Loading…
Cancel
Save