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

Compile Time Functions #58

Open
VincentRPS opened this issue Nov 15, 2024 · 3 comments
Open

Compile Time Functions #58

VincentRPS opened this issue Nov 15, 2024 · 3 comments
Milestone

Comments

@VincentRPS
Copy link
Contributor

VincentRPS commented Nov 15, 2024

Add support for functions running at compile time. i.e.:

@macro(comptime)
def print_hello(): str {
    print("Hello from the compiler!");
    return "A";
}

def main() {
    // is run in compile time and
    // a will always be the value "A"
    // returned in `print_hello`
    let a = print_hello();
}
@VincentRPS VincentRPS added this to the 0.1 milestone Nov 15, 2024
@elenakrittik
Copy link
Contributor

Considering that the language will have a REPL and therefore an interpreter, i think making all expressions evaluate-able at comptime will be effortless

@VincentRPS
Copy link
Contributor Author

Considering that the language will have a REPL and therefore an interpreter, i think making all expressions evaluate-able at comptime will be effortless

The interpreter (and comptime) can most likely just be built on top of LLVM's JIT APIs, which should make it even easier since we can leverage metal-llvm's codegen. We could also probably explore using Cranelift for the repl too if we really want fast build times.

@elenakrittik
Copy link
Contributor

Considering that the language will have a REPL and therefore an interpreter, i think making all expressions evaluate-able at comptime will be effortless

The interpreter (and comptime) can most likely just be built on top of LLVM's JIT APIs, which should make it even easier since we can leverage metal-llvm's codegen. We could also probably explore using Cranelift for the repl too if we really want fast build times.

WASM as well! Plenty of options

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

2 participants