glassesneo / oolib Goto Github PK
View Code? Open in Web Editor NEWA nimble package for object-oriented programming
License: Do What The F*ck You Want To Public License
A nimble package for object-oriented programming
License: Do What The F*ck You Want To Public License
classes.nimble
error when member variables is marked with *
{.compileTime.}
to procs only used at compile timetuple
class pub SomeTuple(tuple):
var a: int
var b: string
proc f(num: int) =
discard
This will be converted to below
type SomeTuple* = tuple
a: int
b: string
proc f(self: SomeTuple, num: int) =
discard
let
member variables via getter or dotOperatorinstallDirs
new
that has generic paramspub
, of
)proc
, method
)self
as a first argument to procOption
Option
protocol
proc
, func
{.pProtocol.}
Pick
macro like Type Script's Pick
super
keyword for method
{.open.}
is used with of
nimble install OOlib
したところ、以下のWarningが表示されました。
Warning: Package 'oolib' has an incorrect structure. It should contain a single directory hierarchy for source files, named 'oolib', but file 'tmpl.nim' is in a directory named 'oolibpkg' instead. This will be an error in the future.
Hint: If 'oolibpkg' contains source files for building 'oolib', rename it to 'oolib'. Otherwise, prevent its installation by addingskipDirs = @["oolibpkg"]
to the .nimble file.
警告:パッケージ 'oolib'の構造が正しくありません。 'oolib'という名前のソースファイル用の単一のディレクトリ階層が含まれている必要がありますが、ファイル 'tmpl.nim'は代わりに 'oolibpkg'という名前のディレクトリにあります。これは将来エラーになります。
ヒント:「oolibpkg」に「oolib」をビルドするためのソースファイルが含まれている場合は、名前を「oolib」に変更します。それ以外の場合は、.nimbleファイルにskipDirs = @ ["oolibpkg"]を追加して、インストールを防止します。
これは oolib の内部用モジュールが oolibpkg ディレクトリ配下に存在するため表示されています。
通常、Nimのパッケージは library として提供する場合、プロジェクト構造を以下のようにします
参考: Project structure - nim-lang/nimble
パッケージ名pkg といった命名にするのは、Hybridなパッケージとして公開する場合に必要なアプローチでしたが、現在は解消していると思われます
pub
pClass
to have class info(e.g. ClassKind
, isPub
)template
==
template for data class like Kotlin's dataclassgit tag v0.2.2
を打ってほしいgit tag vX.X.X
を打つようにしてほしい※ 今より古いコミットについて、その当時のバージョンに合わせて git tag
を打つまではしなくてよいと思います
バージョン番号指定で nimble install
ができないため
⟩ nimble install '[email protected]'
Downloading https://github.com/Glasses-Neo/OOlib using git
Warning: Package 'oolib' has an incorrect structure. It should contain a single directory hierarchy for source files, named 'oolib', but file 'tmpl.nim' is in a directory named 'oolibpkg' instead. This will be an error in the future.
Hint: If 'oolibpkg' contains source files for building 'oolib', rename it to 'oolib'. Otherwise, prevent its installation by adding `skipDirs = @["oolibpkg"]` to the .nimble file.
Tip: 2 messages have been suppressed, use --verbose to show them.
Error: Downloaded package's version does not satisfy requested version range: wanted 0.2.1 got 0.2.2.
正常にインストールできる場合は、以下のように出力されます。
⟩ nimble install '[email protected]'
Downloading https://github.com/c-blake/cligen.git using git
Verifying dependencies for [email protected]
Installing [email protected]
Success: cligen installed successfully.
nimble でパッケージをバージョン指定してインストールする場合、バージョン情報はGitリポジトリのタグに基づいて判別されます。nimbleファイルのバージョン番号のみでは不足しています。
参考: Versions - nim-lang/nimble
このリポジトリはタグが振られていないため、最新版のインストールしかできない状態です。
他の nimble パッケージでバージョン番号運用をしているパッケージを紹介します
Many people use interface as a design tool.
perhaps it is possible to use Nim's when compiles(...) feature
to expand something like checkImpl(myClass, ISomeInterface)
where ISomeInterface will be scanned (typetraits perhaps) for the public procs and fields, and then for each it will be checked in the (hidden by template) when compiles block. then we get a compiler error message, that this proc was not yet implemented.
What do you think of this idea? btw, very cool lib. just came across it!
Type.new(args)
class
head (e.g. pub
, of
, distinct
)proc
, func
, iterator
, converter
method
template
I would like to be able to store data per class.
import oolib
class A {.open.}:
const className = "A"
const speed = 10.0f
class B of A:
const className = "B"
const speed = 15.0f
var a = newA()
var b = newB()
check A.className == "A"
check B.className == "B"
check a.className == "A"
check b.className == "B"
check b.speed > a.speed
{.oolibExperimental.}
pragmaprotocol
protocol
for class
{.class.}
to classisClass()
Make constructor stricter.
{.final.}
as default{.open.}
to allow inheritanceclass
and protocol
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.