Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dot notation for resolving objects #684

Open
SanderMertens opened this issue Jun 14, 2018 · 0 comments
Open

Support dot notation for resolving objects #684

SanderMertens opened this issue Jun 14, 2018 · 0 comments

Comments

@SanderMertens
Copy link
Member

SanderMertens commented Jun 14, 2018

Currently, the / character is used as scope operator to indicate parent-child relationships in object identifiers (foo/bar). The dot operator '.' is used to address fields inside an object (p.x).

In some cases, the practical difference between a field and a child object is small. One example is when using leaf objects in containers:

container Drone {
    leaf on_off: type:bool
}

The on_off object will be created as a child object for every instance of Drone, and thus can now only be referred to as my_drone/on_off. Conceptually however, it is similar to a member in that the lifecycle of the leaf is coupled to its parent.

To enable applications to abstract away from the difference between fields and child objects, the dot operator should be made available as a "more capable" scope operator. An example of an object expression that uses dot notation:

foo.bar

The semantics of the dot operator shall be to first lookup bar as a field of foo. If the type of foo does not contain a member bar, bar shall be resolved in the scope of foo, if it is a named object.

In cases where an object both has a member called foo and a child object called foo, the dot operator shall resolve the member. To force corto to resolve the object, the regular / operator can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant