-
Notifications
You must be signed in to change notification settings - Fork 28
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 code generation for bbml #245
The head ref may contain hidden characters: "bbml-codegen\u{1F9C3}"
Conversation
Which functions are you talking about? They should all be in this repo and so the migration should be easy. Perhaps we could just use a naming scheme. Functions called fun get_x() = _x
fun set_x(value) = set _x = value BTW I noticed that in JS fun (get) x() = _x
fun (set) x(value) = set _x = value (it looks a bit weird) Anyway, this should be done in a separate PR. |
What's the rationale for adding a competing Predef for BbML? Can't we use the existing one, and add all functionality needed by BbML in some separate BbPredef module? |
So far only |
Ah you mean that the current Predef doesn't type check. Then I guess this design is fine for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, but please see my comment.
Also, we should really now look into using Scope
to generate proper TV names without a counter. Currently, the counter makes diffs like this one very noisy.
I just realized we must forbid getters from being defined in non-module and non-function scopes. Indeed, they cannot be used correctly if we don't know their symbol. fun foo(f) =
f.oops
class Foo(x) with
fun oops = x
foo(Foo(42))
//│ = [Function: oops]
foo(Foo(42))()
//│ FAILURE: Unexpected runtime error
//│ ═══[RUNTIME ERROR] TypeError: Cannot read properties of undefined (reading 'x')
//│ at oops (REPL25:1:176)
//│ at REPL27:1:80
//│ at ContextifyScript.runInThisContext (node:vm:136:12)
//│ at REPLServer.defaultEval (node:repl:598:22)
//│ at bound (node:domain:432:15)
//│ at REPLServer.runBound [as eval] (node:domain:443:12)
//│ at REPLServer.onLine (node:repl:927:10)
//│ at REPLServer.emit (node:events:520:28)
//│ at REPLServer.emit (node:domain:488:12)
//│ at [_onLine] [as _onLine] (node:internal/readline/interface:416:12) Note that a property of module methods is that we always know their symbol when calling them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, sorry that the getter implementation is unexpectedly blocking this PR. It would have been better to make it in a separate PR. Anyway, let's fix it now.
There are also still problems with your hack around globalThis
. I still don't know what it achieves/what it's for.
Co-authored-by: Lionel Parreaux <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great changes, thanks! Please fix the few remaining issues and I'll make the merge.
In this PR:
However, I'm not sure if we still need to makeget
a keyword. There are already some functions usingget
as the name and it seems hard to repick names for them.