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

Allow a query-expr to construct a stream #443

Closed
jclark opened this issue Feb 29, 2020 · 0 comments
Closed

Allow a query-expr to construct a stream #443

jclark opened this issue Feb 29, 2020 · 0 comments
Assignees
Labels
Area/Lang Relates to the Ballerina language specification Type/Improvement Enhancement to language design

Comments

@jclark
Copy link
Collaborator

jclark commented Feb 29, 2020

This works lazily: the stream has a closure that returns the next result when the closure is called. Errors are also returned lazily through the stream's iterator's termination value: this includes errors in the source iterator or from check expressions in the where and select clauses.

Because of the above difference in semantics, queries returning streams are prefixed with the stream keyword.

stream-query-expr := "stream" query-expr

Example

function myMap(string) returns int|Error1;

function foo(string[] source) returns int[]|Error1
{
   return from s in source select check myMap(s);
}

function foo(stream<string,Error2> source)
   returns stream<int,Error1|Error2>
{
   return stream from s in source select check myMap(s);
}
@jclark jclark added Type/Improvement Enhancement to language design Area/Lang Relates to the Ballerina language specification labels Feb 29, 2020
@jclark jclark added this to the 2020R2 milestone Feb 29, 2020
@jclark jclark self-assigned this Feb 29, 2020
@grainier grainier reopened this Mar 20, 2020
@jclark jclark closed this as completed in 7c41662 Apr 11, 2020
@jclark jclark modified the milestones: 2020R3, 2020R2 Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Lang Relates to the Ballerina language specification Type/Improvement Enhancement to language design
Projects
None yet
Development

No branches or pull requests

2 participants