Some cosmetic fixes...
This commit is contained in:
parent
25fe9ad610
commit
5d2c6e89aa
1 changed files with 22 additions and 11 deletions
|
|
@ -1,16 +1,27 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
// Classes demo: fields, methods (with explicit 'this'), and usage.
|
||||
//
|
||||
// Notes:
|
||||
// - Define a class with `class Name`
|
||||
// - Fields are initialized with simple assignments inside the class body.
|
||||
// - Methods are written as `fun method(this, ...) { ... }` with 'this' required as the first parameter.
|
||||
// - Instantiation: p = Name()
|
||||
// - Method calls: load the method function from the instance into a variable, then call it with the instance as the first argument.
|
||||
// Example:
|
||||
// move_fn = p["move"]
|
||||
// move_fn(p, dx, dy)
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://hanez.org/project/fun/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the ISC license.
|
||||
* https://opensource.org/license/isc-license-txt
|
||||
*/
|
||||
|
||||
/*
|
||||
* Classes demo: fields, methods (with explicit 'this'), and usage.
|
||||
*
|
||||
* Notes:
|
||||
* - Define a class with `class Name`
|
||||
* - Fields are initialized with simple assignments inside the class body.
|
||||
* - Methods are written as `fun method(this, ...) { ... }` with 'this' required as the first parameter.
|
||||
* - Instantiation: p = Name()
|
||||
* - Method calls: load the method function from the instance into a variable, then call it with the instance as the first argument.
|
||||
* Example:
|
||||
* move_fn = p["move"]
|
||||
* move_fn(p, dx, dy)
|
||||
*/
|
||||
|
||||
class Point
|
||||
x = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue