nimpylib / pylib

"Write Python in Nim!" Python builtins/standard-Lib functions ported to Nim
https://nimpylib.github.io/pylib/
MIT License
9 stars 0 forks source link

Change how class init is handled #14

Open litlighilit opened 4 months ago

litlighilit commented 4 months ago

The class macro, derived from the old pylib, still rewrite the init function in a class definition block to a proc starting with "new".

But in Python, there is actually a __new__ method of each class, which is responsible to return a new instance. Thus this issue introduces the new function in a class being supported, and when new is defined, leave init only to init on the new-ed instance, and returns nothing.