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

Proposal: allow member access operator to accept a Struct?, Object?, or Pair? on the LHS #684

Open
peterhuene opened this issue Sep 18, 2024 · 1 comment

Comments

@peterhuene
Copy link
Contributor

peterhuene commented Sep 18, 2024

Currently the member access operator accepts Struct, Object, calls, and, as mentioned elsewhere in the spec, Pair.

However, it does not accept a Struct?, Object?, or Pair? and a type coercion from T? -> T rightfully does not exist.

As a result of this limitation, the spec and ecosystem tooling suggest calling the select_first function passing an array literal containing only the optional value e.g. select_first([x]). If x is None, then a runtime error is generated by the engine as defined in the spec for the select_first function.

To me, the select_first workaround seems overly verbose and incurs the overhead of a naive array value allocation and function call when x is not None just to access its members.

While I'm relatively new to WDL and I lack the historical context for the design of the member access operator, it seems like it could explicitly accept T? (where T is a type that is otherwise accepted for the member access operator) on the left hand side of the expression and raise a runtime error if the value is None. This would lead to better readability of WDL source too: x.y instead of select_first([x]).y, which would effectively have the same semantics.

@patmagee
Copy link
Member

related to #551

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

No branches or pull requests

2 participants