Small changes

This commit is contained in:
Araozu 2024-02-20 05:53:38 -05:00
parent 46f162620b
commit 49a04fa5ac
6 changed files with 21 additions and 21 deletions

View File

@ -11,7 +11,7 @@ enum Suit
Spades,
}
let suit = Suit::Hearts
val suit = Suit::Hearts
```

View File

@ -8,7 +8,7 @@ Basically kotlin syntax.
`new` not required, in fact, forbidden.
```thp
let dog = Dog()
val dog = Dog()
```
## Simple class
@ -18,7 +18,7 @@ Why'd you do this tho?
```thp
class SimpleClass
let instance = SimpleClass()
val instance = SimpleClass()
```
## Properties & methods
@ -89,14 +89,13 @@ print(michifu.get_name())
With kotlin's `init` block.
```thp
class Dog(pub String name)
class Dog(val String name)
{
Int name_length
Int name_length = name.length()
init
{
print("Dog has been instantiated")
$name_length = name.length()
}
}
```

View File

@ -91,7 +91,7 @@ fun greet(
print("Hello {name} from {city}!")
}
greet(name: "John", from: "LA")
greet("John", from: "LA")
```

View File

@ -22,7 +22,7 @@ By default closures **always** capture variables as **references**.
```thp
val mut x = 20
var x = 20
val f = fun() {
print(x)
@ -44,7 +44,7 @@ fun(parameters) clone(variables) {
```
```thp
val mut x = 20
var x = 20
val f = fun() clone(x) {
print(x)

View File

@ -16,20 +16,21 @@ If you want to learn the language, go to the learn section.
## Goals
- Bring static typing to PHP: Not just type hints, not use `mixed` for everything
- Bring static typing to PHP: Not just type hints, not just `mixed` for everything
that isn't a primitive type.
- Avoid automatic type conversion.
- Generics & ADTs
- Avoid implicit type conversion.
- Remove the inconsistencies in the language.
- Organize the stdlib.
- Organize the stdlib into modules.
- Differentiate between Arrays, Tuples, Maps and Sets.
- Create a **consistent** language.
- Create typings for popular libraries (like TS's `.d.ts`).
- Have typings for popular libraries (like TS's `.d.ts`).
- Have a simple instalation and configuration (requiring just Composer).
- Ship a fast, native binary (written in Rust) (why use PHP when we can go native?).
- Sub 10ms watch mode.
- Ship a fast, native binary (written in Rust) (why use PHP when we can go **_blazingly fast_**?).
- Support in-place compilation.
- Emit readable PHP code.
- Implement a LSP server.
- (Try to) emit readable PHP.
- Implement an LSP server.
- Implement a formatter.
## Not goals

View File

@ -62,17 +62,17 @@
<pre style="padding: 0 !important;">
<code class="language-thp">
fun find_person(Str person_id) -> Result[Str] {
let person_id = try person_id.parse[Int]()
val person_id = try person_id.parse[Int]()
try Person::find_by_id(person_id)
}
let id = POST::get("person_id") ?: die
let person = find_person(person_id: id) ?: die
val id = POST::get("person_id") ?: die
val person = find_person(person_id: id) ?: die
print(
&lt;a href="/person/reports/{person.id}"&gt;
Hello {person.name}
&lt;/div&gt;
&lt;/a&gt;
)
</code>
</pre>