OOlib is currently work in progress🔥
OOlib is a nimble package for object oriented programming.
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 = newPerson("Tony")
let p2 = newPerson("Steve", 100)
- Member variables with default values
- Class data constants
- Definition of
proc
,method
,func
, etc... (the only exception beingmacro
) - Auto inserting
self
as first argument - Auto definition of constructor (high performance!)
- Assistance with constructor definition
pub
modifier instead of*
- Inheritance with
of
modifier - Creating distinct type with
distinct
modifier {.final.}
by default{.open.}
to allow inheritancesuper
keyword formethod
- Alias class
Pick
like TypeScript'sPick
let
member variablesstruct
protocol
See CHANGELOG
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.