I've implemented some simplest Python functions and very simple "class" macro (which doesn't and wouldn't support inheritance). https://github.com/Yardanico/nimpylib - check example2.nim for classes.
Yeah, code isn't the best - this is mainly due to the nature of Python (dynamic-typing), for example:
"range(5)" - here 5 is a position where range stops
"range(1, 5)" - 1 here is a position where range starts
Simplest example of class macro usage:
import pylib
type HelloWorld = ref object
name: string
class HelloWorld(object):
def init(self, name):
self.name = name
def greet(self):
print("Hello,", self.name, sep = "\n")
let c = newHelloWorld("Daniil")
c.greet()
Thanks to you I noticed there are finally proper AST nodes for doc-comments (one of the great features in Rust I hated Nim doesn't have). Yay!
Back to your module. I have mixed feelings...
Also, you used BiggestFloat and BiggestInt in parsing but int and float in //... Additionally, Python's integers are actually bigints so I'm not sure if this choice won't lead to some nasty bugs or inconveniences...
Do you plan to support some equivalences of magical methods (that's apropos of bool converter)?
Udiknedormin: I've fixed modulo (If I'm not mistaken), added a couple of tests. About range - I plan to make it an object, so it would be lazy too (as in python 3).
Yeah, I can't write print as an simple procedure because Nim doesn't have keyword-only arguments
Thanks to you I noticed there are finally proper AST nodes for doc-comments
I'm fairly sure we had AST nodes for doc comments since forever.
I can't write print as an simple procedure because Nim doesn't have keyword-only arguments
Not quite, you can't write it because you cannot mix varargs and keyword-only arguments in Nim.