Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Seggan committed Nov 2, 2023
1 parent 85c86ac commit 518704f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions docs/lang/index.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ end
add(1, 2) // 1, 2, 0
```

If the first argument is named `self`, then that function is considered a @i {self function}. When getting
a self function from a table, the table is passed as the first argument:

@metis ```
let x = { "a" = 1, "b" = 2 }

fn x.get_a(self)
return self.a
end

print(x.get_a()) // 1
```

@h2 { Anonymous Functions }

The syntax above is actually syntax sugar for assigning an anonymous function to a variable. Anonymous
Expand Down Expand Up @@ -304,10 +317,9 @@ Coroutines can be run with `coroutine.run`:

Metis has a set of operators that may or may not be overloaded. They are listed in order of decreasing precedence:

`[]`, `()`, `.`, and `:`; these are used to index tables and call callables. There is no way to overload
calling, but as `.` and `:` are various forms of syntax sugar for `[]`, they can be overloaded using
the metamethod `__index__`. `a:b(c)` is syntax sugar for `a.b(a, c)`, and `a.b` is syntax sugar for
`a["b"]`.
`[]`, `()`, and `.`; these are used to index tables and call callables. There is no way to overload
calling, but as `.` is syntax sugar for `[]`, they can be overloaded using
the metamethod `__index__`.

`not` and unary `-`; these are used to negate booleans and numbers. Only `-` can be overloaded using
`__neg__`.
Expand Down

0 comments on commit 518704f

Please sign in to comment.