Skip to content

Support dot notation for resolving objects #684

@SanderMertens

Description

@SanderMertens

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions