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

Preliminary Implementation: Metaprogramming with Quasiquote #164

Closed kkdlau closed 1 year ago

kkdlau commented 1 year ago

Description

This pull request introduces a preliminary implementation of metaprogramming using the quasiquote concept.

Changes

Here's a brief summary of the changes:

Testing

Unit tests have been added to ensure the correct functionality of the quasiquote operations. These tests cover both basic use cases and edge cases. All the test cases can be found at shared/src/test/diff/quasiquote/.

Example

Here are some examples of using the new quasiquote feature.

Define a quasiquote:

code"1"

Define a quasiquote with a string inside:

code""" "github" """ // works without putting the space between """ and ", but we formatted for better readability

Define a quasiquote with a free variable:

code"a" // error - free variable is not allowed in this version

Execute a quasiquote:

code"1 + 1"
run(res) // res: 2
LPTK commented 1 year ago

The CI does not pass as the code has many warnings...

Question: what happened to the "context-tracking" part of this branch called kkdlau:quasiquote/context-tracking?

LPTK commented 1 year ago

Ok so when the CI does not pass you just remove the CI? Great job!

Let's revisit these changes later on. We'll probably selectively import what we need in a clean way.

Thanks for your work on this project anyway!

kkdlau commented 1 year ago

Ok so when the CI does not pass you just remove the CI? Great job!

Let's revisit these changes later on. We'll probably selectively import what we need in a clean way.

Thanks for your work on this project anyway!

For the clarification, I didn't remove the CI, instead as the CI runs only if I push something to branch mlscript / make a pull request on branch mlscript, I update the trigger condition to every push so everytime I push to my repo, I can see if the CI passes or not.

This also can help me understand why the CI by running it on my repo and get the full report of it. We will make sure the CI file is aligned with the parent repo

LPTK commented 1 year ago

I see, thanks for the clarification.