👑 OOlib
OOlib is currently work in progress
🗺 Overview
OOlib is a nimble package for object oriented programming.
📜 Usage
import strformat
import oolib
# add `pub` prefix to export class
class pub Person:
var
name*: string
age* = 0
# auto insert `self` as first argument
proc `$`*: string = fmt"<Person> name: {self.name}"
proc happyBirthday* =
inc self.age
# auto define constructor
let p1 = Person.new("Tony")
let p2 = Person.new("Steve", 100)
✨ Features
- Member variables with default values
- Class data constants
- Definition of
proc
,method
,func
, etc... (the only exception beingmacro
) - Auto definition of constructor
- Support for inheritance, distinct, alias
super
keyword formethod
{.final.}
by defaultprotocol
that provides interfaces forclass
details
See Wiki
💭 Planned
struct
- setter / getter
dataclass
like Kotlin'sdata class
Changelog
See CHANGELOG
🥷 Author
License
Copyright © 2021 Neo [email protected] This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.