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

Add query-action #403

Closed
jclark opened this issue Jan 23, 2020 · 0 comments
Closed

Add query-action #403

jclark opened this issue Jan 23, 2020 · 0 comments
Assignees
Labels
enhancement Enhancement to language design lang Relates to the Ballerina language specification
Milestone

Comments

@jclark
Copy link
Collaborator

jclark commented Jan 23, 2020

A query-action provides a convenient syntax for iteration that handles errors (see #402).

query-action := query-pipeline do-clause
do-clause := "do" block-statement

Like a query-expr, a query-action can be used with a value iterable with any error type. The result of the query-action is the termination value of the iterator. Thus if the source type is infallibly iterable, the result will be () and can be ignored.

The do-clause is executed as follows:

  • for each input frame f:
    • execute block statement with f in scope

Variables bound by the clauses of the query expression should be treated as final (as with foreach) so cannot be modified by assignments in the block statement.

This is part of #340.

@jclark jclark added enhancement Enhancement to language design lang Relates to the Ballerina language specification labels Jan 23, 2020
@jclark jclark added this to the 2020R1 milestone Jan 23, 2020
@jclark jclark self-assigned this Jan 23, 2020
@jclark jclark added this to Query related features for 1.2 in Language Design for jBallerina 1.2 Jan 23, 2020
@jclark jclark closed this as completed in 112d601 Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to language design lang Relates to the Ballerina language specification
Projects
No open projects
Language Design for jBallerina 1.2
Query related features for 1.2
Development

No branches or pull requests

1 participant