Crosscut

Daily Thought - 2025-03-02

Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!

If modules can be functions that are executed at compile time, that would be pretty neat. It would re-use a concept that already needs to be in the language anyway. And it would introduce compile-time code execution, which is a powerful tool that can be useful in many scenarios.

As I said yesterday, I haven't worked out all the details yet. But here's how that could look like, maybe:

module {
    # Insert some code here; calculate some constant values, for example.

    # At the end of the module, we return what we want to export.
    {
        TheThing: # insert some data type here
        read_from_the_thing: # insert a function here
        write_to_the_thing: # another function goes here
    }
}

Probably more than anything, this is inspired by old-school JavaScript, before modules where supported in the language. Back then, we could build our own module systems, based on functions that returned objects of things they wanted to export. (Well, we still can. It just makes less sense these days.)

Maybe this is the wrong inspiration for a language that is supposed to be statically typed and compiled, at some point. But right now, I can't see why it wouldn't work. We'll see!

Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email every time I post a new one.