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

Added support for defer init for dyn_var #58

Merged

Conversation

AjayBrahmakshatriya
Copy link
Collaborator

Usually when dyn_var are instantiated, they are immediately initialized. This means they can be declared only inside builder contexts (or should use as_global or with_name).

This is restrictive when the user wants to create objects outside the context that have dyn_var members. Currently this requires the user to push the creation of the entire object inside the context. It creates issues with expensive computations being run multiple times. To get around this, we add a new constructor helper builder::defer_init and a member function deferred_init.

The constructor helper allows declaring dyn_var(s) without actually doing anything. The member function deferred_init, then does the job of the constructor and should be called inside the context.

Added sample53 to demonstrate/test this.

@AjayBrahmakshatriya AjayBrahmakshatriya merged commit 5d2ffd2 into BuildIt-lang:master Dec 8, 2023
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

Successfully merging this pull request may close these issues.

1 participant