Style for "to" attribute of capability routing

9 views
Skip to first unread message

Justin Mattson

unread,
Jun 23, 2021, 8:05:20 PM6/23/21
to component-framework-dev
When "to" has a single entry should it still be written as an array? We're inconsistent about this. What should we do?

1) Array, things should be as uniform as sanity allows
2) Not array, like, bytes aren't free you know
3) Consistency is irrelevant, all capabilities will be routed

Cheers,
Justin

Aaron Wood

unread,
Jun 23, 2021, 8:59:13 PM6/23/21
to Justin Mattson, component-framework-dev
I vote for an array of 1, for consistency.

--
All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
---
You received this message because you are subscribed to the Google Groups "component-framework-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to component-framewo...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/component-framework-dev/CA%2BX8dX_wBmnb60avuZonZ95k6x3nEnyhawRQ%3Ds0%2BH0bQQ_jp%3Dg%40mail.gmail.com.

Gabe Schine

unread,
Jun 24, 2021, 12:09:18 PM6/24/21
to Aaron Wood, Justin Mattson, component-framework-dev
+1 for 1. Consistency & clarity: people who see an array of 1 know it can grow to 2 without reading documentation.



--
Gabe Schine
Software Engineer / Manager

Yegor Pomortsev

unread,
Jun 24, 2021, 2:21:17 PM6/24/21
to Gabe Schine, Aaron Wood, Justin Mattson, component-framework-dev

Rich Kadel

unread,
Jun 24, 2021, 3:17:49 PM6/24/21
to Yegor Pomortsev, Gabe Schine, Aaron Wood, Justin Mattson, component-framework-dev
The final resolution for CTP-035 was to allow for array or non-array syntax if a string array property has a single string value:

> ... any CML property that supports multiple string values, but has only one entry, can use either Array of String syntax or simple String syntax. So, for example, `to: [ "#startup" ]` and `to: "#startup"` are both valid.

There were advocates for enforcing the array syntax (that's also my personal preference), but there were also advocates for the flexibility, which was the final call for that CTP.

Note, since the current schema allows both, choosing to allow both for CTP-035 was really choosing to NOT change that part of the current CML schema. But Gary has always been open to feedback, and potentially making a change if there is sufficient support for it. (Some CTP-035 decisions were, in essence, deferred, or "wait and see" as I think Gary put it.)

So, I count 3 advocates for sure, in this email (Aaron, Gabe, and me), and from the thread Yegor linked, it looks like Hunter also advocated for enforcing array syntax for array values (correct me if I'm wrong).

I'm not sure (from these threads) of Yegor's or Justin's stance?

Are there other advocates for making this a requirement (which I could implement in CTP-035, if approved)?

Rich



Hunter Freyer

unread,
Jun 24, 2021, 3:34:57 PM6/24/21
to Rich Kadel, Yegor Pomortsev, Gabe Schine, Aaron Wood, Justin Mattson, component-framework-dev
On Thu, Jun 24, 2021 at 3:17 PM 'Rich Kadel' via component-framework-dev <component-f...@fuchsia.dev> wrote:
The final resolution for CTP-035 was to allow for array or non-array syntax if a string array property has a single string value:

> ... any CML property that supports multiple string values, but has only one entry, can use either Array of String syntax or simple String syntax. So, for example, `to: [ "#startup" ]` and `to: "#startup"` are both valid.

There were advocates for enforcing the array syntax (that's also my personal preference), but there were also advocates for the flexibility, which was the final call for that CTP.

Note, since the current schema allows both, choosing to allow both for CTP-035 was really choosing to NOT change that part of the current CML schema. But Gary has always been open to feedback, and potentially making a change if there is sufficient support for it. (Some CTP-035 decisions were, in essence, deferred, or "wait and see" as I think Gary put it.)

So, I count 3 advocates for sure, in this email (Aaron, Gabe, and me), and from the thread Yegor linked, it looks like Hunter also advocated for enforcing array syntax for array values (correct me if I'm wrong).

Yup, I agree with the arguments for enforcing the array.
 

Justin Mattson

unread,
Jun 24, 2021, 3:44:32 PM6/24/21
to Hunter Freyer, Rich Kadel, Yegor Pomortsev, Gabe Schine, Aaron Wood, component-framework-dev
My question is not to go as far as enforcing array syntax so much as a style convention. I leave it to the would-be enforcers if we want to make that change, I'll be leaving style comments on CLs going forward and see about updating some of the more central manifests in the system.

Gary Bressler

unread,
Jul 7, 2021, 4:50:15 PM7/7/21
to Justin Mattson, Hunter Freyer, Rich Kadel, Yegor Pomortsev, Gabe Schine, Aaron Wood, component-framework-dev
If we want to enforce array syntax, I think we should do it everywhere for consistency. The problem we found with doing this is that for certain types of declarations, a singleton is far more common. For example, when you declare a directory capability you set the rights and path, which are capability specific. For protocols, on the other hand, it's useful to group multiple declarations together because they usually don't vary apart from the name. Having each type support either singleton-only or array-only is also a possibility, but that has its own issues (how is the user to know which is allowed for a given type?).

For a long time only arrays were supported in 'to' syntax, so this is historical debt that we could clean up.

Gary Bressler

unread,
Jul 9, 2021, 5:19:20 PM7/9/21
to Justin Mattson, Hunter Freyer, Rich Kadel, Yegor Pomortsev, Gabe Schine, Aaron Wood, component-framework-dev
Justin, I realize I kind of missed your original point about style, which is my bad. Indeed, the style we promote need not match the rules we enforce. I don't think we've decided on any style guidelines (apart from those enforced by json5format), so I'm open to discussing further. As for my personal preference, 95% of `to` fields seem to be singleton arrays, and I like the elegance of just having a string. 

Gabe Schine

unread,
Jul 12, 2021, 7:25:58 PM7/12/21
to Gary Bressler, Justin Mattson, Hunter Freyer, Rich Kadel, Yegor Pomortsev, Aaron Wood, component-framework-dev
Justin, I realize I kind of missed your original point about style, which is my bad. Indeed, the style we promote need not match the rules we enforce. I don't think we've decided on any style guidelines (apart from those enforced by json5format), so I'm open to discussing further. As for my personal preference, 95% of `to` fields seem to be singleton arrays, and I like the elegance of just having a string. 

A single string can easily lead a developer to assume the value cannot grow into an array. If elegance is all we get, I personally don't think it's worth it relative to the decrease in understandability. My 2c.
Reply all
Reply to author
Forward
0 new messages