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

Abstract vm.print away #9

Open
srijan-paul opened this issue Jul 17, 2021 · 4 comments
Open

Abstract vm.print away #9

srijan-paul opened this issue Jul 17, 2021 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@srijan-paul
Copy link
Owner

It'd be better to rename the print member variable to print_fn, and have vm.print call that, if it's not nullptr.
This way we can easily embed vyse in apps that do not have consoles enabled.

@srijan-paul srijan-paul added enhancement New feature or request good first issue Good for newcomers labels Jul 17, 2021
@svenkat19
Copy link

Could you specify under which directory I must do the changes?

@srijan-paul
Copy link
Owner Author

srijan-paul commented Jul 18, 2021

Could you specify under which directory I must do the changes?

Hi Shashank,
Currently when the vyse programmer calls the print function, on the C++ side of things, vm.print function is called along with the string that was passed to print. However, not all applications have a console to log stuff to, or perhaps sometimes it makes more sense to render to a screen instead (like browser's console.log). So what we ideally want is:

  • Rename vm.print to vm.print_fn.
  • Add a new vm.print method instead that first checks if vm.print_fn is nullptr, if so then it won't do anything and return.
  • If the VM does have a print function to use (print_fn is not nullptr) , then it will call that.

I expect the changes will mainly go in the header and implementation file of the VM.
So lang/src/vm.cpp and lang/include/vyse/vm.hpp.

EDIT: If you'd like to contribute You'll have an easier time working on this once I merge the stdlib branch in.
So my suggestion would be create a branch off of the stdlib branch and then create a PR from your_branch to stdlib. The main branch is the stable version and is outdated by a couple of months.

@svenkat19
Copy link

Am I missing something , because I couldn't find the vm.print function in any of the mentioned files

@srijan-paul
Copy link
Owner Author

srijan-paul commented Jul 19, 2021

Am I missing something , because I couldn't find the vm.print function in any of the mentioned files

It's here, in the stdlib branch. The main branch is for stable builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants