Small changes

master
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, Spades,
} }
let suit = Suit::Hearts val suit = Suit::Hearts
``` ```

View File

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

View File

@ -91,7 +91,7 @@ fun greet(
print("Hello {name} from {city}!") 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 ```thp
val mut x = 20 var x = 20
val f = fun() { val f = fun() {
print(x) print(x)
@ -44,7 +44,7 @@ fun(parameters) clone(variables) {
``` ```
```thp ```thp
val mut x = 20 var x = 20
val f = fun() clone(x) { val f = fun() clone(x) {
print(x) print(x)

View File

@ -16,20 +16,21 @@ If you want to learn the language, go to the learn section.
## Goals ## 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. that isn't a primitive type.
- Avoid automatic type conversion. - Generics & ADTs
- Avoid implicit type conversion.
- Remove the inconsistencies in the language. - Remove the inconsistencies in the language.
- Organize the stdlib. - Organize the stdlib into modules.
- Differentiate between Arrays, Tuples, Maps and Sets. - Differentiate between Arrays, Tuples, Maps and Sets.
- Create a **consistent** language. - 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). - 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?). - Ship a fast, native binary (written in Rust) (why use PHP when we can go **_blazingly fast_**?).
- Sub 10ms watch mode.
- Support in-place compilation. - Support in-place compilation.
- Emit readable PHP code. - (Try to) emit readable PHP.
- Implement a LSP server. - Implement an LSP server.
- Implement a formatter.
## Not goals ## Not goals

View File

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