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

Explicit initialization function for modules #101

Closed
sameerajayasoma opened this issue May 8, 2019 · 4 comments
Closed

Explicit initialization function for modules #101

sameerajayasoma opened this issue May 8, 2019 · 4 comments
Assignees
Labels
Area/Lang Relates to the Ballerina language specification status/pending Design is agreed and waiting to be added Type/Improvement Enhancement to language design
Milestone

Comments

@sameerajayasoma
Copy link
Contributor

Should we allow developers to declare an explicit module init function? The module init function can be used to initialize module-level variables. Sometimes it is hard to initialize them in the initializer expression. Another use case would be to initialize the final variables conditionally.

@jclark jclark added Area/Lang Relates to the Ballerina language specification Type/Improvement Enhancement to language design labels May 8, 2019
@jclark jclark added this to the 2019Rn milestone May 8, 2019
@jclark
Copy link
Collaborator

jclark commented May 8, 2019

I think this would be a useful feature to add a some point. Is the function called init like main or __init like an object initializer?

@jclark jclark changed the title Explicit Init function for modules Explicit initialization function for modules May 8, 2019
@sameerajayasoma
Copy link
Contributor Author

I think we should make this __int, because it is similar to the object initializer. It is a function with module-level visibility which cannot be called by the module code.

@sanjiva
Copy link
Contributor

sanjiva commented May 30, 2019

+1.

@jclark
Copy link
Collaborator

jclark commented Jun 20, 2019

Return value would need to be subtype of error? like __init on objects. Must not have public visibility

@jclark jclark modified the milestones: 2019Rn, 2019R2 Jun 20, 2019
@jclark jclark self-assigned this Jun 20, 2019
@jclark jclark added the status/pending Design is agreed and waiting to be added label Jun 25, 2019
@jclark jclark closed this as completed in 181b801 Jun 25, 2019
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 status/pending Design is agreed and waiting to be added Type/Improvement Enhancement to language design
Projects
None yet
Development

No branches or pull requests

3 participants