Coming from C++, Ruby background I think it would be great to have some syntactic sugar for class method declarations, following unified call syntax, so following:
type
Test = object
v : int
proc bump(self : var Test) : int =
self.v += 1
result = self.v
var t = Test(v:1); echo t.bump, t.bump, t.bump
Could be rewritten as:
type
Test = object
v : int
proc var Test.bump : int =
self.v += 1 # self variable is implicitly introduced
result = self.v
var t = Test(v:1); echo t.bump, t.bump, t.bump
This would/could IMHO improve readability when declaring lot of class methods, as human reader tends to parse test left-to-right, having class name first clearly states it is class method. WDYT?
@def Awesome! I understand that however all method declared methods will be made public, right, so no way to declare private methods such way? Anyway very handy notation. Still having:
method Dog.vocalize*: string = "woof"
Out of class block would be useful as well. I think both could be part of some oop standard Nim module?