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 variable to module #649

Open
shelllet opened this issue Nov 19, 2019 · 2 comments
Open

Add variable to module #649

shelllet opened this issue Nov 19, 2019 · 2 comments

Comments

@shelllet
Copy link

how to add variable?
i use v8 before and then i want to change to rust from c++.
i look for all doc and find way to add function by module.add or module.add_str, but i can't find how to add variable.
dyon support this?

@shelllet shelllet changed the title Add enum type Add variable to module Nov 19, 2019
@bvssvni
Copy link
Member

bvssvni commented Nov 19, 2019

Dyon does not have global variables, but instead uses current objects:

fn main() {
    ~ a := 2
    foo()
}

fn foo() ~ a: f64 {
    // `a` is available in this scope
}

@shelllet
Copy link
Author

thanks for your reply, i felt frustrated because i wan't to manipulate rust variable from Dyon.
like v8

  v8::Local<v8::ObjectTemplate> hkey = v8::ObjectTemplate::New(isolate);
    hkey->SetLazyDataProperty(V8_NEW_STRING(isolate, HKEY_CLASSES_ROOT), [](v8::Local<v8::Name> /*property*/,
        const v8::PropertyCallbackInfo<v8::Value> & info) {
            info.GetReturnValue().Set(v8::External::New(info.GetIsolate(), HKEY_CLASSES_ROOT));
        });

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

No branches or pull requests

2 participants