capy-language / capy

🍊 A statically typed, compiled programming language, largely inspired by Jai, Odin, and Zig.
Apache License 2.0
64 stars 4 forks source link

Command-line arguments #33

Closed NotAFlyingGoose closed 4 months ago

NotAFlyingGoose commented 4 months ago

Problem

It's currently impossible to access command line arguments. This is definitely needed before 0.1.0 on crates.io

Proposed Solution

argc and argv are currently taken in as parameters in the codegen crate, but codegen doesn't do anything with these values.

What should be done is there should be a builtin slice in core called args or smth (maybe figure out a better name for this). At runtime in the cmain function just before the actual main function is called, codegen should create the slice using argc and argv and store it into this builtin global.

boom! command-line arguments

Notes

The builtin should be similar to other builtins, so it only gets generated if it actually gets used

NotAFlyingGoose commented 4 months ago

I'm gonna start working on this