Interfaces working?

This commit is contained in:
nub31
2025-08-13 00:41:28 +02:00
parent fc5b08e5c6
commit c8f913dc23
5 changed files with 119 additions and 58 deletions

View File

@@ -1,27 +1,32 @@
extern func puts(fmt: cstring)
interface Printable
{
func print()
}
struct Human : Printable {
struct Human : Printable
{
name: cstring
func print_name()
{
puts(this^.name)
}
func print()
{
puts("example")
puts(this^.name)
}
}
func main(args: []cstring): i64
{
let human: Human = alloc Human {
let human = alloc Human {
name = "oliver"
}
human.print()
print_printable(human)
return 0
}
func print_printable(printable: Printable)
{
printable.print()
}