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

Value of this is window #27

Open
a10k opened this issue Apr 9, 2021 · 6 comments
Open

Value of this is window #27

a10k opened this issue Apr 9, 2021 · 6 comments

Comments

@a10k
Copy link

a10k commented Apr 9, 2021

when defining a cell, the value of 'this' is set as window, while for the compiled output of the same code it will be undefined by default.

@asg017
Copy link
Owner

asg017 commented Apr 10, 2021

Thanks for the report!

You're, right, this isn't defined correctly for .module() and .cell(), but seems to work correctly for .moduleToESModule(). This notebook goes into the problem a little deeper.

Pretty sure it's got to do with how we use f = new Function(...), seems like there's a few Function methods like .call or .bind that we may to need use, will try to debug further...

@bryangingechen
Copy link
Contributor

@asg017 I can look into this later too if you need a hand!

@Srabutdotcom
Copy link

I see in your example in readme file is wrong -> new Interpreter({module: module, observer: observer}).

This Interpreter are much more flexible and functionality. However i just wonder how to deal with built in variables i.e. md, html etc. I mean how to delete or change existing one using this Interpreter?

@asg017
Copy link
Owner

asg017 commented Apr 20, 2021

Hey @Srabutdotcom , for changing which builtin cells are used in your implementation, that's the job of the runtime, not the interpreter. The interpreter takes in a runtime module as an input, where that module already has the builtin cells included. Using this example from the runtime readme, you can do something like:

const runtime = new Runtime({color: "red"});

This creates a new runtime with different builtin cells (in this case, a cell called color that has a value of "red"). Then, you create a module with that runtime and pass it into the Interpreter like so:

const main = runtime.module();
const interpret = new Interpreter();
const observer = () => true

await interpret.cell(" example = `The value of color is ${color}` ", main, observer);
await main.value("example") // "The value of color is red"

Also, feel free to ask more questions in #29 , which is about the new Interpreter/Compiler API, or create a new issue (since this issue is about another problem)

@Srabutdotcom
Copy link

Hai @asg017 ,

Sorry, i mean standard library. lets for example we have 3 md in 3 different cells.
md 1st md
md second
md third md

how do we change or update md second for example?

@asg017
Copy link
Owner

asg017 commented Apr 20, 2021

@Srabutdotcom please file a new issue with details on what youre trying to do, and whatever code you have. Also see #29 for example of the new Interpreter.

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

4 participants