OOlib
所属分类:编程语言基础
开发工具:Nim
文件大小:0KB
下载次数:0
上传日期:2023-08-27 13:32:20
上 传 者:
sh-1993
说明: 面向对象编程的灵活包,
(A nimble package for object-oriented programming,)
文件列表:
CHANGELOG.md (5969, 2023-10-21)
COPYING (484, 2023-10-21)
oolib.nimble (373, 2023-10-21)
src/ (0, 2023-10-21)
src/oolib.nim (4198, 2023-10-21)
src/oolib/ (0, 2023-10-21)
src/oolib/classes/ (0, 2023-10-21)
src/oolib/classes/class_util.nim (3394, 2023-10-21)
src/oolib/classes/constructor_pragma.nim (2424, 2023-10-21)
src/oolib/classes/distinct_class.nim (2290, 2023-10-21)
src/oolib/classes/implement_class.nim (6835, 2023-10-21)
src/oolib/classes/named_tuple_class.nim (1588, 2023-10-21)
src/oolib/classes/normal_class.nim (4209, 2023-10-21)
src/oolib/protocols/ (0, 2023-10-21)
src/oolib/protocols/protocol_core.nim (1740, 2023-10-21)
src/oolib/protocols/protocol_util.nim (1334, 2023-10-21)
tests/ (0, 2023-10-21)
tests/classes.nim (220, 2023-10-21)
tests/config.nims (36, 2023-10-21)
tests/constructor.nim (764, 2023-10-21)
tests/implementation.nim (745, 2023-10-21)
# OOlib
![license](https://img.shields.io/github/license/Glasses-Neo/OOlib?color=blueviolet)
[![test](https://github.com/Glasses-Neo/OOlib/actions/workflows/test.yml/badge.svg)](https://github.com/Glasses-Neo/OOlib/actions/workflows/test.yml)
![contributors](https://img.shields.io/github/contributors/Glasses-Neo/OOlib?color=important)
![stars](https://img.shields.io/github/stars/Glasses-Neo/OOlib?style=social)
**OOlib is currently work in progress**
## Overview
OOlib is a nimble package for object oriented programming.
## Usage
### class
```nim
import oolib
class Person:
var
name: string
age = 0
let steve = Person.new(name = "Steve")
let tony = Person.new(name = "Tony", age = 30)
```
### protocol
```nim
import oolib
protocol Readable:
var text: string
protocol Writable:
var text: string
proc `text=`(value: string)
protocol Product:
var price: int
protocol pub Writer:
proc write(text: string)
class Book impl (Readable, Product):
var
text: string = ""
price: int
class Diary impl (Readable, Writable, Product):
var text {.initial.}: string = ""
var price: int
proc `text=`(value: string) =
self.text = value
class HTMLWriter impl Writer:
var writable: Writable
proc write(text: string) =
self.writable.text = text
```
## Features
- `class` macro
- Automatic generation of constructor
- `self` inserted in procedures
- all routines (e.g., method, converter, template) with the only exception of macro
- `protocol` macro
- Provide an Kotlin-like interface
- defining setter/getter
## Changelog
See [CHANGELOG](https://github.com/Glasses-Neo/OOlib/blob/develop/CHANGELOG.md)
## Author
[![Twitter](https://img.shields.io/twitter/follow/Glassesman10.svg?style=social&label=@Glassesman10)](https://twitter.com/Glassesman10)
## License
Copyright 2021 Neo meganeo.programmer@gmail.com
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.
近期下载者:
相关文件:
收藏者: