-
Notifications
You must be signed in to change notification settings - Fork 8
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
Why do so many examples use {}s? #21
Comments
Yep, that's exactly the case: it has to do with how we deal with nesting: how do you make some block params to be connected to each other (i.e. in this example, To a larger extent, this is really large question that is being raised in many forms (example). @erights's suggestion (which I thinking I'm coming to terms with) is to require a explicit sigil (e.g. ::) to connect these things. In this formulation, instead of the let data = survey("TC39 Meeting Schedule") {
::question("Where should we host the European meeting?") {
::option("Paris");
::option("Barcelona");
::option("London");
}
} Would be transpiled to: let data = survey("TC39 Meeting Schedule", (__parent__) => {
__parent__.question("Where should we host the European meeting?", (__parent__) => {
__parent__.option("Paris");
__parent__.option("Barcelona");
__parent__.option("London");
})
}) Which would give function survey(name, block) {
let survey = {question: []};
block({
question(name, inner) {
let q = {name: name, options: []};
survey.questions.push(q);
inner({
option(name) {
let opt = {name: name};
q.options.push(opt);
}
})
}
})
return survey;
} WDYT? |
That seems reasonable, although it's becoming a bit syntactically heavy. |
E.g.
why doesn't this just use statements for the options, e.g. as in
?
This probably has to do with some of the restrictions on the contents of the blocks, which are not really spelled out (or maybe I skimmed over them too fast).
The text was updated successfully, but these errors were encountered: