TheToolsmiths / ddl

Data Definition Language for Game Development Tools
MIT License
4 stars 3 forks source link

Support explicit references ownership #10

Open flaxed opened 5 years ago

flaxed commented 5 years ago

If we support references in #3 it can be useful to know who owns the reference. If the data instance, or something else.

This could be implemented with a dedicated keyword, owns as an example, (placeholder syntax):

def data Car {
    engine: owns &Engine,
}

or alternatively with an attribute, owns_ref as an example, (placeholder syntax):

def data Car {
    engine: &Engine [ owns_ref, editable ],
}

As with any new features, it can bring added complexity, and in this case I expect even further complexity when dealing with collections of references. In the attribute based alternative we could use a new attribute, owns_item_ref, example (placeholder syntax):

def data Car {
    engine: Vec<&Engine> [ owns_item_ref ],
}

With the keyword approach it would end up with (placeholder syntax):

def data Car {
    engine: Vec<owns &Engine>,
}