dhh1128 / intent

the intent formal language
https://intentlang.org
2 stars 1 forks source link

support groups in addition to interfaces and inheritance/substructure #98

Open dhh1128 opened 9 years ago

dhh1128 commented 9 years ago

Traditional namespacing and scoping behaviors in familiar programming languages gives a nice way to disambiguate. Also, if a named scope is identified as an interface (abstract base class), it can be implemented or inherited.

However, such approaches have some drawbacks:

I'd like to be able to cluster members (data members or methods) into a group (imagine the "appearance" group for a "car" object consisting of "paint", "cladding", "window tinting"), where the same item can be a member of more than one group ("paint" could also be a part of "manufacturer options", "window tinting" could also be a part of "after-market mods"). Putting an item into a group would provide an optional namespace (car->appearance->paint and car->paint and car->manufacturer_options->paint all refer to the same thing). Groups might be layer-able (after-market mods hides any same-named items that were part of the original car from the manufacturer). Additional semantics could attach to groups (you could inherit them or include them [reuse without forced hierarchical name containment], implement them or hide them or make them read-only or mark them in other ways).

Consider the idea of aliasing (separate issue, but related) to rename a data member that's been inherited.

Also, is there a way to selectively inherit (we assume you can override base class virtual methods, but what about dropping useless data members (would have to prove that no method needs them anymore). Would we basically create a union between new member in derived class and unused member in base class?