hkust-taco / mlscript

The MLscript programming language. Functional and object-oriented; structurally typed and sound; with powerful type inference. Soon to have full interop with TypeScript!
https://hkust-taco.github.io/mlscript
MIT License
175 stars 27 forks source link

Add code generation for bbml #245

Open NeilKleistGao opened 2 days ago

NeilKleistGao commented 2 days ago

In this PR:

However, I'm not sure if we still need to make get a keyword. There are already some functions using get as the name and it seems hard to repick names for them.

LPTK commented 22 hours ago

There are already some functions using get as the name and it seems hard to repick names for them.

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 get_XXX generate a getter for XXX and similarly for set_XXX.

fun get_x() = _x
fun set_x(value) = set _x = value

BTW I noticed that in JS get is not actually a keyword. So yet another alternative approach in a similar spirit as 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.

LPTK commented 22 hours ago

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?

NeilKleistGao commented 7 hours ago

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 checkArgs in the predef is required. I added a new implementation that can be type checked in Bbml (even though the type-checking for importing is still not done). Or do we plan to use the untyped predef everywhere?

LPTK commented 4 hours ago

Ah you mean that the current Predef doesn't type check. Then I guess this design is fine for now.