omni icon indicating copy to clipboard operation
omni copied to clipboard

Remove need of calling constructor on complex structs

Open vitreo12 opened this issue 4 years ago • 3 comments

struct A:
    a

struct B:
    a A

init:
    b = B()  #this should be enough, instead of B(A())

vitreo12 avatar May 11 '20 20:05 vitreo12

This perhaps requires removing the objects as ptr to something, and instead letting them be just normal nim's object types. They could be inheriting from a common OmniStruct object that would help when parsing def arguments, in order to still allow this:

struct A:
    a

def set_value(a A, val):
    a.a = val

init:
   a A = A()
   a.set_value(0.5) 

vitreo12 avatar May 11 '20 20:05 vitreo12

What about Data though?

vitreo12 avatar May 11 '20 21:05 vitreo12

Should Data look at all the entries of each struct recursively and call the standard constructor, initializing all Datas along the way? What size should those Datas have though? Perhaps I can come up with a way of using this syntax ONLY for top-level Datas, meaning: Datas that do not contain structwith other Datas

vitreo12 avatar May 16 '20 12:05 vitreo12