plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


41e0859Peter John 2026-08-09T21:12:47+05:30
docs: update methods section for nested-only method declaration syntax
Files changed (1) hide show
  1. README.md +5 -5
README.md CHANGED
@@ -272,18 +272,18 @@ Full example: [`examples/closures.plum`](examples/closures.plum).
272
272
 
273
273
  ### `self`, field access, and methods
274
274
 
275
- A function declared as `name<Receiver>(...)` is a method on `Receiver`, with an implicit `self: Receiver`:
275
+ A `fun` declared indented directly inside a `type`/`enum` body is a method on that type, with an implicit `self`:
276
276
 
277
277
  ```plum
278
278
  type Cat =
279
279
  name: Str
280
280
  age: Int
281
281
 
282
- fun getAge<Cat>() -> Int =
282
+ fun getAge(self) -> Int =
283
- self.age
283
+ self.age
284
284
 
285
- fun birthday<Cat>() -> Int =
285
+ fun birthday(self) -> Int =
286
- self.age + 1
286
+ self.age + 1
287
287
 
288
288
  fun main() -> Int =
289
289
  c = Cat(name: "Whiskers", age: 3)